|
@@ -31,7 +31,6 @@
|
|
|
#include "scroll_container.h"
|
|
|
|
|
|
#include "core/config/project_settings.h"
|
|
|
-#include "core/os/os.h"
|
|
|
#include "scene/main/window.h"
|
|
|
#include "scene/theme/theme_db.h"
|
|
|
|
|
@@ -250,18 +249,21 @@ void ScrollContainer::_update_scrollbar_position() {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- Size2 hmin = h_scroll->get_combined_minimum_size();
|
|
|
- Size2 vmin = v_scroll->get_combined_minimum_size();
|
|
|
+ Size2 hmin = h_scroll->is_visible() ? h_scroll->get_combined_minimum_size() : Size2();
|
|
|
+ Size2 vmin = v_scroll->is_visible() ? v_scroll->get_combined_minimum_size() : Size2();
|
|
|
+
|
|
|
+ int lmar = is_layout_rtl() ? theme_cache.panel_style->get_margin(SIDE_RIGHT) : theme_cache.panel_style->get_margin(SIDE_LEFT);
|
|
|
+ int rmar = is_layout_rtl() ? theme_cache.panel_style->get_margin(SIDE_LEFT) : theme_cache.panel_style->get_margin(SIDE_RIGHT);
|
|
|
|
|
|
- h_scroll->set_anchor_and_offset(SIDE_LEFT, ANCHOR_BEGIN, 0);
|
|
|
- h_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, 0);
|
|
|
- h_scroll->set_anchor_and_offset(SIDE_TOP, ANCHOR_END, -hmin.height);
|
|
|
- h_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, 0);
|
|
|
+ h_scroll->set_anchor_and_offset(SIDE_LEFT, ANCHOR_BEGIN, lmar);
|
|
|
+ h_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, -rmar - vmin.width);
|
|
|
+ h_scroll->set_anchor_and_offset(SIDE_TOP, ANCHOR_END, -hmin.height - theme_cache.panel_style->get_margin(SIDE_BOTTOM));
|
|
|
+ h_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, -theme_cache.panel_style->get_margin(SIDE_BOTTOM));
|
|
|
|
|
|
- v_scroll->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -vmin.width);
|
|
|
- v_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, 0);
|
|
|
- v_scroll->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, 0);
|
|
|
- v_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, 0);
|
|
|
+ v_scroll->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -vmin.width - rmar);
|
|
|
+ v_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, -rmar);
|
|
|
+ v_scroll->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, theme_cache.panel_style->get_margin(SIDE_TOP));
|
|
|
+ v_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, -hmin.height - theme_cache.panel_style->get_margin(SIDE_BOTTOM));
|
|
|
|
|
|
_updating_scrollbars = false;
|
|
|
}
|
|
@@ -339,7 +341,7 @@ void ScrollContainer::_notification(int p_what) {
|
|
|
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
|
|
|
case NOTIFICATION_TRANSLATION_CHANGED: {
|
|
|
_updating_scrollbars = true;
|
|
|
- callable_mp(this, &ScrollContainer::_update_scrollbar_position).call_deferred();
|
|
|
+ callable_mp(this, is_ready() ? &ScrollContainer::_reposition_children : &ScrollContainer::_update_scrollbar_position).call_deferred();
|
|
|
} break;
|
|
|
|
|
|
case NOTIFICATION_READY: {
|
|
@@ -444,8 +446,8 @@ void ScrollContainer::update_scrollbars() {
|
|
|
v_scroll->set_page((h_scroll->is_visible() && h_scroll->get_parent() == this) ? size.height - hmin.height : size.height);
|
|
|
|
|
|
// Avoid scrollbar overlapping.
|
|
|
- h_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, (v_scroll->is_visible() && v_scroll->get_parent() == this) ? -vmin.width : 0);
|
|
|
- v_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, (h_scroll->is_visible() && h_scroll->get_parent() == this) ? -hmin.height : 0);
|
|
|
+ _updating_scrollbars = true;
|
|
|
+ callable_mp(this, &ScrollContainer::_update_scrollbar_position).call_deferred();
|
|
|
}
|
|
|
|
|
|
void ScrollContainer::_scroll_moved(float) {
|