From c35addb82dc268a1b7c3db3f3621f5629d21d788 Mon Sep 17 00:00:00 2001 From: Lars Schmertmann Date: Fri, 12 Oct 2018 21:18:36 +0200 Subject: [PATCH 1/3] Improved the position of the directory labels. * 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. --- src/dirnode.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/dirnode.cpp b/src/dirnode.cpp index 150165cc..8e3c6ae5 100644 --- a/src/dirnode.cpp +++ b/src/dirnode.cpp @@ -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; + if (gGourceSettings.dir_name_position > 0.5f) { + const vec2 dirVec = glm::abs(parent->getProjectedPos() - projected_pos); + if (dirVec.x > dirVec.y) { + 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) { From 17540b791014926b9946b1bf5a91317f16bc9095 Mon Sep 17 00:00:00 2001 From: Lars Schmertmann Date: Sat, 10 Nov 2018 17:58:17 +0100 Subject: [PATCH 2/3] Increased the distance of the dir label to the line. --- src/dirnode.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dirnode.cpp b/src/dirnode.cpp index 8e3c6ae5..2975e59a 100644 --- a/src/dirnode.cpp +++ b/src/dirnode.cpp @@ -901,19 +901,22 @@ void RDirNode::calcEdges() { void RDirNode::updateLabelOffset(float dt) { if (!parent) return; - vec2 new_offset(0.0f); + const vec2 topLeft_align(-0.25f * label_size.y); + const vec2 bottomRight_align = label_size - topLeft_align; + + vec2 new_offset(topLeft_align); if (parent->getProjectedPos().x > projected_pos.x) { - new_offset.x = label_size.x; + new_offset.x = bottomRight_align.x; } if (parent->getProjectedPos().y < projected_pos.y) { - new_offset.y = label_size.y; + new_offset.y = bottomRight_align.y; } if (gGourceSettings.dir_name_position > 0.5f) { const vec2 dirVec = glm::abs(parent->getProjectedPos() - projected_pos); if (dirVec.x > dirVec.y) { - 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); + new_offset.x = (new_offset.x == topLeft_align.x ? bottomRight_align.x : topLeft_align.x); + new_offset.y = (new_offset.y == topLeft_align.y ? bottomRight_align.y : topLeft_align.y); } } From e2b3f3e2ffa831be80f874cb91badf7345f80af4 Mon Sep 17 00:00:00 2001 From: Lars Schmertmann Date: Thu, 30 May 2019 10:44:02 +0200 Subject: [PATCH 3/3] Center the position of the label if dir-name-position is 0.5 --- src/dirnode.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/dirnode.cpp b/src/dirnode.cpp index 2975e59a..87335f3f 100644 --- a/src/dirnode.cpp +++ b/src/dirnode.cpp @@ -901,22 +901,24 @@ void RDirNode::calcEdges() { void RDirNode::updateLabelOffset(float dt) { if (!parent) return; - const vec2 topLeft_align(-0.25f * label_size.y); - const vec2 bottomRight_align = label_size - topLeft_align; - - vec2 new_offset(topLeft_align); - if (parent->getProjectedPos().x > projected_pos.x) { - new_offset.x = bottomRight_align.x; - } - if (parent->getProjectedPos().y < projected_pos.y) { - new_offset.y = bottomRight_align.y; - } - - if (gGourceSettings.dir_name_position > 0.5f) { - const vec2 dirVec = glm::abs(parent->getProjectedPos() - projected_pos); - if (dirVec.x > dirVec.y) { - new_offset.x = (new_offset.x == topLeft_align.x ? bottomRight_align.x : topLeft_align.x); - new_offset.y = (new_offset.y == topLeft_align.y ? bottomRight_align.y : topLeft_align.y); + vec2 new_offset; + if (gGourceSettings.dir_name_position == 0.5f) { + //center the label + new_offset = label_size / vec2(2.0f); + } else { + const vec2 topLeft_align(-0.25f * label_size.y); + const vec2 bottomRight_align = label_size - topLeft_align; + + new_offset.x = (parent->getProjectedPos().x > projected_pos.x ? bottomRight_align.x : topLeft_align.x); + new_offset.y = (parent->getProjectedPos().y < projected_pos.y ? bottomRight_align.y : topLeft_align.y); + + //invert the alignment if dir_name_position > 0.5 and the angle is flat + if (gGourceSettings.dir_name_position > 0.5f) { + const vec2 dirVec = glm::abs(parent->getProjectedPos() - projected_pos); + if (dirVec.x > dirVec.y) { + new_offset.x = (new_offset.x == topLeft_align.x ? bottomRight_align.x : topLeft_align.x); + new_offset.y = (new_offset.y == topLeft_align.y ? bottomRight_align.y : topLeft_align.y); + } } }