diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml index 317bcaa937f..057e6fef653 100644 --- a/doc/classes/ScrollContainer.xml +++ b/doc/classes/ScrollContainer.xml @@ -110,6 +110,12 @@ + + The space between the ScrollContainer's vertical scroll bar and its content, in pixels. No space will be added when the content's minimum size is larger than the ScrollContainer's size. + + + The space between the ScrollContainer's horizontal scroll bar and its content, in pixels. No space will be added when the content's minimum size is larger than the ScrollContainer's size. + The focus border [StyleBox] of the [ScrollContainer]. Only used if [member draw_focus_border] is [code]true[/code]. diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index e3bf63a89ad..8edd27ba12f 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -353,11 +353,11 @@ void ScrollContainer::_reposition_children() { bool reserve_vscroll = _is_v_scroll_visible() || vertical_scroll_mode == SCROLL_MODE_RESERVE; if (_is_h_scroll_visible() || horizontal_scroll_mode == SCROLL_MODE_RESERVE) { - size.y -= h_scroll->get_minimum_size().y; + size.y -= h_scroll->get_minimum_size().y + theme_cache.scrollbar_v_separation; } if (reserve_vscroll) { - size.x -= v_scroll->get_minimum_size().x; + size.x -= v_scroll->get_minimum_size().x + theme_cache.scrollbar_h_separation; } for (int i = 0; i < get_child_count(); i++) { @@ -773,6 +773,9 @@ void ScrollContainer::_bind_methods() { BIND_ENUM_CONSTANT(SCROLL_MODE_SHOW_NEVER); BIND_ENUM_CONSTANT(SCROLL_MODE_RESERVE); + BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, ScrollContainer, scrollbar_h_separation); + BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, ScrollContainer, scrollbar_v_separation); + BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, ScrollContainer, panel_style, "panel"); BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, ScrollContainer, focus_style, "focus"); diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h index 47b39daca7a..879969f0e9a 100644 --- a/scene/gui/scroll_container.h +++ b/scene/gui/scroll_container.h @@ -78,6 +78,9 @@ private: struct ThemeCache { Ref panel_style; Ref focus_style; + + int scrollbar_h_separation = 0; + int scrollbar_v_separation = 0; } theme_cache; void _cancel_drag();