1
0
Fork 0

Merge pull request #113591 from YeldhamDev/tree_column_arrow_hide

Hide arrows when they go past the column titles on `Tree`s
This commit is contained in:
Thaddeus Crews 2025-12-08 11:53:51 -06:00
commit ebc5a9b1fb
No known key found for this signature in database
GPG Key ID: 8C6E5FEB5FC03CCC
1 changed files with 29 additions and 28 deletions

View File

@ -2708,41 +2708,42 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
}
// Draw the folding arrow.
if (!p_item->disable_folding && !hide_folding && p_item->first_child && p_item->get_visible_child_count() != 0) { // Has visible children, draw the guide box.
if (p_pos.y + label_h - theme_cache.offset.y >= 0) {
// Draw the folding arrow.
if (!p_item->disable_folding && !hide_folding && p_item->first_child && p_item->get_visible_child_count() != 0) { // Has visible children, draw the guide box.
Ref<Texture2D> arrow;
Ref<Texture2D> arrow;
if (p_item->collapsed) {
if (rtl) {
arrow = theme_cache.arrow_collapsed_mirrored;
if (p_item->collapsed) {
if (rtl) {
arrow = theme_cache.arrow_collapsed_mirrored;
} else {
arrow = theme_cache.arrow_collapsed;
}
} else {
arrow = theme_cache.arrow_collapsed;
arrow = theme_cache.arrow;
}
} else {
arrow = theme_cache.arrow;
}
Size2 arrow_full_size = arrow->get_size();
Size2 arrow_full_size = arrow->get_size();
Point2 apos = p_pos + Point2i(0, (label_h - arrow_full_size.height) / 2) - theme_cache.offset + p_draw_ofs;
apos.x += theme_cache.item_margin - arrow_full_size.width;
Point2 apos = p_pos + Point2i(0, (label_h - arrow_full_size.height) / 2) - theme_cache.offset + p_draw_ofs;
apos.x += theme_cache.item_margin - arrow_full_size.width;
Size2 arrow_draw_size = arrow_full_size;
int out_width = p_pos.x + theme_cache.item_margin - get_column_width(0);
if (out_width > 0) {
arrow_draw_size.width -= out_width;
}
if (arrow_draw_size.width > 0) {
apos = convert_rtl_position(apos, arrow_draw_size.width);
Point2 src_pos = Point2();
if (rtl) {
src_pos = Point2(arrow_full_size.width - arrow_draw_size.width, 0);
Size2 arrow_draw_size = arrow_full_size;
int out_width = p_pos.x + theme_cache.item_margin - get_column_width(0);
if (out_width > 0) {
arrow_draw_size.width -= out_width;
}
if (arrow_draw_size.width > 0) {
apos = convert_rtl_position(apos, arrow_draw_size.width);
Point2 src_pos = Point2();
if (rtl) {
src_pos = Point2(arrow_full_size.width - arrow_draw_size.width, 0);
}
Rect2 arrow_rect = Rect2(apos, arrow_draw_size);
Rect2 arrow_src_rect = Rect2(src_pos, arrow_draw_size);
arrow->draw_rect_region(ci, arrow_rect, arrow_src_rect);
}
Rect2 arrow_rect = Rect2(apos, arrow_draw_size);
Rect2 arrow_src_rect = Rect2(src_pos, arrow_draw_size);
arrow->draw_rect_region(ci, arrow_rect, arrow_src_rect);
}
}
}