Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved the position of the directory labels. #181

Open
wants to merge 3 commits into
base: symmetric-dir-names
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions src/dirnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,19 +899,27 @@ 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
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;
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);
}
}
}

if (label_offset != new_offset) {
Expand Down