From 437b4d267aaf5411fb84858c0cd06081425773ab Mon Sep 17 00:00:00 2001 From: maidopi-usagi Date: Wed, 11 Sep 2024 13:54:02 +0800 Subject: [PATCH] replace computed height with cached item minimum size replace computed height with cached item minimum size --- scene/gui/tree.cpp | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 8871af23cbd7..888ecee328a5 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1825,41 +1825,7 @@ int Tree::compute_item_height(TreeItem *p_item) const { if (p_item->cells[i].dirty) { const_cast(this)->update_item_cell(p_item, i); } - height = MAX(height, p_item->cells[i].text_buf->get_size().y); - for (int j = 0; j < p_item->cells[i].buttons.size(); j++) { - Size2i s; // = cache.button_pressed->get_minimum_size(); - s += p_item->cells[i].buttons[j].texture->get_size(); - if (s.height > height) { - height = s.height; - } - } - - switch (p_item->cells[i].mode) { - case TreeItem::CELL_MODE_CHECK: { - int check_icon_h = theme_cache.checked->get_height(); - if (height < check_icon_h) { - height = check_icon_h; - } - [[fallthrough]]; - } - case TreeItem::CELL_MODE_STRING: - case TreeItem::CELL_MODE_CUSTOM: - case TreeItem::CELL_MODE_ICON: { - Ref icon = p_item->cells[i].icon; - if (!icon.is_null()) { - Size2i s = _get_cell_icon_size(p_item->cells[i]); - if (s.height > height) { - height = s.height; - } - } - if (p_item->cells[i].mode == TreeItem::CELL_MODE_CUSTOM && p_item->cells[i].custom_button) { - height += theme_cache.custom_button->get_minimum_size().height; - } - - } break; - default: { - } - } + height = MAX(height, p_item->get_minimum_size(i).y); } int item_min_height = MAX(theme_cache.font->get_height(theme_cache.font_size), p_item->get_custom_minimum_height()); if (height < item_min_height) { @@ -4488,6 +4454,7 @@ void Tree::item_edited(int p_column, TreeItem *p_item, MouseButton p_custom_mous edited_col = p_column; if (p_item != nullptr && p_column >= 0 && p_column < p_item->cells.size()) { edited_item->cells.write[p_column].dirty = true; + edited_item->cells.write[p_column].cached_minimum_size_dirty = true; } emit_signal(SNAME("item_edited")); if (p_custom_mouse_index != MouseButton::NONE) {