Skip to content

Commit

Permalink
Improved the position of the directory labels.
Browse files Browse the repository at this point in the history
* Vertical and horizontal alignment always need to match
  to avoid overlapping of the label and the line.
* Inverting the alignment on dir_name_position > 0.5 is only
  meaningful on a flat angle (below 45 degree in relation to
  the x axis) to avoid moving names on top of each other.
  • Loading branch information
SmallLars committed Nov 6, 2018
1 parent 7743258 commit ae51589
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/dirnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,19 +899,22 @@ void RDirNode::calcEdges() {
}

void RDirNode::updateLabelOffset(float dt) {
if(!parent) return;
if (!parent) return;

vec2 new_offset(0.0f);

if (parent->getProjectedPos().y > projected_pos.y) {
// alignBottom
if (parent->getProjectedPos().x > projected_pos.x) {
new_offset.x = label_size.x;
}
if (parent->getProjectedPos().y < projected_pos.y) {
new_offset.y = label_size.y;
}

if ( (gGourceSettings.dir_name_position <= 0.5f && parent->getProjectedPos().x < projected_pos.x)
|| (gGourceSettings.dir_name_position > 0.5f && parent->getProjectedPos().x > projected_pos.x)) {
// alignRight
new_offset.x = label_size.x;
const vec2 dirVec = glm::abs(parent->getProjectedPos() - projected_pos);
const bool flat = dirVec.x > dirVec.y;
const bool invert = gGourceSettings.dir_name_position > 0.5f;
if (flat && invert) {
new_offset.x = (new_offset.x == 0.0 ? label_size.x : 0.0);
new_offset.y = (new_offset.y == 0.0 ? label_size.y : 0.0);
}

if (label_offset != new_offset) {
Expand Down

0 comments on commit ae51589

Please sign in to comment.