Skip to content

Commit decb559

Browse files
committed
Merge pull request #111975 from sockeye-d/scrollcontainer-separation
Add `h`/`v_separation` theme properties to ScrollContainer
2 parents 17ea264 + 1a72f4c commit decb559

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

doc/classes/ScrollContainer.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@
110110
</constant>
111111
</constants>
112112
<theme_items>
113+
<theme_item name="scrollbar_h_separation" data_type="constant" type="int" default="0">
114+
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.
115+
</theme_item>
116+
<theme_item name="scrollbar_v_separation" data_type="constant" type="int" default="0">
117+
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.
118+
</theme_item>
113119
<theme_item name="focus" data_type="style" type="StyleBox">
114120
The focus border [StyleBox] of the [ScrollContainer]. Only used if [member draw_focus_border] is [code]true[/code].
115121
</theme_item>

scene/gui/scroll_container.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,11 @@ void ScrollContainer::_reposition_children() {
353353
bool reserve_vscroll = _is_v_scroll_visible() || vertical_scroll_mode == SCROLL_MODE_RESERVE;
354354

355355
if (_is_h_scroll_visible() || horizontal_scroll_mode == SCROLL_MODE_RESERVE) {
356-
size.y -= h_scroll->get_minimum_size().y;
356+
size.y -= h_scroll->get_minimum_size().y + theme_cache.scrollbar_v_separation;
357357
}
358358

359359
if (reserve_vscroll) {
360-
size.x -= v_scroll->get_minimum_size().x;
360+
size.x -= v_scroll->get_minimum_size().x + theme_cache.scrollbar_h_separation;
361361
}
362362

363363
for (int i = 0; i < get_child_count(); i++) {
@@ -773,6 +773,9 @@ void ScrollContainer::_bind_methods() {
773773
BIND_ENUM_CONSTANT(SCROLL_MODE_SHOW_NEVER);
774774
BIND_ENUM_CONSTANT(SCROLL_MODE_RESERVE);
775775

776+
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, ScrollContainer, scrollbar_h_separation);
777+
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, ScrollContainer, scrollbar_v_separation);
778+
776779
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, ScrollContainer, panel_style, "panel");
777780
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, ScrollContainer, focus_style, "focus");
778781

scene/gui/scroll_container.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ class ScrollContainer : public Container {
7878
struct ThemeCache {
7979
Ref<StyleBox> panel_style;
8080
Ref<StyleBox> focus_style;
81+
82+
int scrollbar_h_separation = 0;
83+
int scrollbar_v_separation = 0;
8184
} theme_cache;
8285

8386
void _cancel_drag();

0 commit comments

Comments
 (0)