diff options
| author | Jordyfel <jord_id@abv.bg> | 2024-08-30 02:08:54 +0300 |
|---|---|---|
| committer | Jordyfel <jord_id@abv.bg> | 2024-09-10 17:25:34 +0300 |
| commit | 6d516a2609d2a869ffd3a0cd92163809da7bc13f (patch) | |
| tree | c9056973968da860997f2515c76313e4a453b062 | |
| parent | fd7239cfab228c50777cd54a8bf6eb279a02ef81 (diff) | |
| download | redot-engine-6d516a2609d2a869ffd3a0cd92163809da7bc13f.tar.gz | |
Fix scroll container min size calculation
| -rw-r--r-- | scene/gui/scroll_container.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index d96809b67a..f1902bade4 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -35,8 +35,6 @@ #include "scene/theme/theme_db.h" Size2 ScrollContainer::get_minimum_size() const { - Size2 min_size; - // Calculated in this function, as it needs to traverse all child controls once to calculate; // and needs to be calculated before being used by update_scrollbars(). largest_child_min_size = Size2(); @@ -55,21 +53,23 @@ Size2 ScrollContainer::get_minimum_size() const { largest_child_min_size = largest_child_min_size.max(child_min_size); } + Size2 min_size; + const Size2 size = get_size(); + if (horizontal_scroll_mode == SCROLL_MODE_DISABLED) { - min_size.x = MAX(min_size.x, largest_child_min_size.x); - } - if (vertical_scroll_mode == SCROLL_MODE_DISABLED) { - min_size.y = MAX(min_size.y, largest_child_min_size.y); + min_size.x = largest_child_min_size.x; + bool v_scroll_show = vertical_scroll_mode == SCROLL_MODE_SHOW_ALWAYS || (vertical_scroll_mode == SCROLL_MODE_AUTO && largest_child_min_size.y > size.y); + if (v_scroll_show && v_scroll->get_parent() == this) { + min_size.x += v_scroll->get_minimum_size().x; + } } - bool h_scroll_show = horizontal_scroll_mode == SCROLL_MODE_SHOW_ALWAYS || (horizontal_scroll_mode == SCROLL_MODE_AUTO && largest_child_min_size.x > min_size.x); - bool v_scroll_show = vertical_scroll_mode == SCROLL_MODE_SHOW_ALWAYS || (vertical_scroll_mode == SCROLL_MODE_AUTO && largest_child_min_size.y > min_size.y); - - if (h_scroll_show && h_scroll->get_parent() == this) { - min_size.y += h_scroll->get_minimum_size().y; - } - if (v_scroll_show && v_scroll->get_parent() == this) { - min_size.x += v_scroll->get_minimum_size().x; + if (vertical_scroll_mode == SCROLL_MODE_DISABLED) { + min_size.y = largest_child_min_size.y; + bool h_scroll_show = horizontal_scroll_mode == SCROLL_MODE_SHOW_ALWAYS || (horizontal_scroll_mode == SCROLL_MODE_AUTO && largest_child_min_size.x > size.x); + if (h_scroll_show && h_scroll->get_parent() == this) { + min_size.y += h_scroll->get_minimum_size().y; + } } min_size += theme_cache.panel_style->get_minimum_size(); |
