1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Add scrollbar_h/v_separation theme properties to ScrollContainer

This commit is contained in:
fish
2025-10-23 16:26:15 -07:00
parent 084d5d407e
commit 1a72f4c3ba
3 changed files with 14 additions and 2 deletions

View File

@@ -110,6 +110,12 @@
</constant>
</constants>
<theme_items>
<theme_item name="scrollbar_h_separation" data_type="constant" type="int" default="0">
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.
</theme_item>
<theme_item name="scrollbar_v_separation" data_type="constant" type="int" default="0">
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.
</theme_item>
<theme_item name="focus" data_type="style" type="StyleBox">
The focus border [StyleBox] of the [ScrollContainer]. Only used if [member draw_focus_border] is [code]true[/code].
</theme_item>

View File

@@ -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");

View File

@@ -78,6 +78,9 @@ private:
struct ThemeCache {
Ref<StyleBox> panel_style;
Ref<StyleBox> focus_style;
int scrollbar_h_separation = 0;
int scrollbar_v_separation = 0;
} theme_cache;
void _cancel_drag();