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

Revert "Correctly display tooltips for buttons in Tree when they overlap cell content #90842

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
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
13 changes: 10 additions & 3 deletions scene/gui/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2459,7 +2459,6 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
if (rtl) {
button_ofs.x = get_size().width - button_ofs.x - button_texture->get_width();
}
p_item->cells.write[i].buttons.write[j].rect = Rect2i(button_ofs, button_size);
button_texture->draw(ci, button_ofs, p_item->cells[i].buttons[j].disabled ? Color(1, 1, 1, 0.5) : p_item->cells[i].buttons[j].color);
item_width_with_buttons -= button_size.width + theme_cache.button_margin;
}
Expand Down Expand Up @@ -5400,7 +5399,6 @@ String Tree::get_tooltip(const Point2 &p_pos) const {
return Control::get_tooltip(p_pos);
}

Point2 button_pos = pos;
if (h_scroll->is_visible_in_tree()) {
pos.x += h_scroll->get_value();
}
Expand All @@ -5413,13 +5411,22 @@ String Tree::get_tooltip(const Point2 &p_pos) const {

if (it) {
const TreeItem::Cell &c = it->cells[col];
int col_width = get_column_width(col);

for (int i = 0; i < col; i++) {
pos.x -= get_column_width(i);
}

for (int j = c.buttons.size() - 1; j >= 0; j--) {
if (c.buttons[j].rect.has_point(button_pos)) {
Ref<Texture2D> b = c.buttons[j].texture;
Size2 size = b->get_size() + theme_cache.button_pressed->get_minimum_size();
if (pos.x > col_width - size.width) {
String tooltip = c.buttons[j].tooltip;
if (!tooltip.is_empty()) {
return tooltip;
}
}
col_width -= size.width;
}
String ret;
if (it->get_tooltip_text(col) == "") {
Expand Down
1 change: 0 additions & 1 deletion scene/gui/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class TreeItem : public Object {
Ref<Texture2D> texture;
Color color = Color(1, 1, 1, 1);
String tooltip;
Rect2i rect;
};

Vector<Button> buttons;
Expand Down
Loading