Fix Tree items ignoring inner margins
This commit is contained in:
parent
76dda5c6c5
commit
62d0392131
1 changed files with 13 additions and 5 deletions
|
|
@ -1703,6 +1703,7 @@ Size2 TreeItem::get_minimum_size(int p_column) {
|
|||
Size2 size = Size2(
|
||||
parent_tree->theme_cache.inner_item_margin_left + parent_tree->theme_cache.inner_item_margin_right,
|
||||
parent_tree->theme_cache.inner_item_margin_top + parent_tree->theme_cache.inner_item_margin_bottom);
|
||||
int content_height = size.height;
|
||||
|
||||
// Text.
|
||||
if (!cell.text.is_empty()) {
|
||||
|
|
@ -1713,19 +1714,24 @@ Size2 TreeItem::get_minimum_size(int p_column) {
|
|||
if (get_text_overrun_behavior(p_column) == TextServer::OVERRUN_NO_TRIMMING) {
|
||||
size.width += text_size.width;
|
||||
}
|
||||
size.height = MAX(size.height, text_size.height);
|
||||
content_height = MAX(content_height, text_size.height);
|
||||
}
|
||||
|
||||
// Icon.
|
||||
if (cell.mode == CELL_MODE_CHECK) {
|
||||
Size2i check_size = parent_tree->theme_cache.checked->get_size();
|
||||
size.width += check_size.width + parent_tree->theme_cache.h_separation;
|
||||
size.height = MAX(size.height, check_size.height);
|
||||
content_height = MAX(content_height, check_size.height);
|
||||
} else if (cell.mode == CELL_MODE_RANGE) {
|
||||
Ref<Texture2D> icon = cell.text.is_empty() ? parent_tree->theme_cache.updown : parent_tree->theme_cache.select_arrow;
|
||||
Size2i icon_size = icon->get_size();
|
||||
size.width += icon_size.width + parent_tree->theme_cache.h_separation;
|
||||
content_height = MAX(content_height, icon_size.height);
|
||||
}
|
||||
if (cell.icon.is_valid()) {
|
||||
Size2i icon_size = parent_tree->_get_cell_icon_size(cell);
|
||||
size.width += icon_size.width + parent_tree->theme_cache.h_separation;
|
||||
size.height = MAX(size.height, icon_size.height);
|
||||
content_height = MAX(content_height, icon_size.height);
|
||||
}
|
||||
|
||||
// Buttons.
|
||||
|
|
@ -1735,10 +1741,11 @@ Size2 TreeItem::get_minimum_size(int p_column) {
|
|||
Size2 button_size = texture->get_size();
|
||||
button_size.width += parent_tree->theme_cache.button_pressed->get_minimum_size().width;
|
||||
size.width += button_size.width + parent_tree->theme_cache.button_margin;
|
||||
size.height = MAX(size.height, button_size.height);
|
||||
content_height = MAX(content_height, button_size.height);
|
||||
}
|
||||
}
|
||||
|
||||
size.height += content_height;
|
||||
cells.write[p_column].cached_minimum_size = size;
|
||||
cells.write[p_column].cached_minimum_size_dirty = false;
|
||||
}
|
||||
|
|
@ -2070,7 +2077,7 @@ Rect2i Tree::convert_rtl_rect(const Rect2i &rect) const {
|
|||
void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color, int p_ol_size, const Color &p_ol_color) const {
|
||||
ERR_FAIL_COND(theme_cache.font.is_null());
|
||||
|
||||
Rect2i rect = p_rect.grow_individual(-theme_cache.inner_item_margin_left, -theme_cache.inner_item_margin_top, -theme_cache.inner_item_margin_right, -theme_cache.inner_item_margin_bottom);
|
||||
Rect2i rect = p_rect;
|
||||
Size2 ts = p_cell.text_buf->get_size();
|
||||
bool rtl = is_layout_rtl();
|
||||
|
||||
|
|
@ -2502,6 +2509,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
|||
}
|
||||
|
||||
item_rect = convert_rtl_rect(item_rect);
|
||||
item_rect = item_rect.grow_individual(-theme_cache.inner_item_margin_left, -theme_cache.inner_item_margin_top, -theme_cache.inner_item_margin_right, -theme_cache.inner_item_margin_bottom);
|
||||
|
||||
Point2i text_pos = item_rect.position;
|
||||
text_pos.y += Math::floor((item_rect.size.y - p_item->cells[i].text_buf->get_size().y) * 0.5);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue