Godot Engine – Multi-platform 2D and 3D game engine
Added theme constant scroll_bar_h_seperation to fix incorrectly positioned VScrollBar of Script and Method ItemList
Lin Pyae13f4b9f74c44
diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xmlindex efef6fc98d5..706b3b59664 100644--- a/doc/classes/ItemList.xml+++ b/doc/classes/ItemList.xml@@ -572,6 +572,9 @@The size of the item text outline.[b]Note:[/b] If using a font with [member FontFile.multichannel_signed_distance_field] enabled, its [member FontFile.msdf_pixel_range] must be set to at least [i]twice[/i] the value of [theme_item outline_size] for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.</theme_item>+ <theme_item name="scroll_bar_h_separation" data_type="constant" type="int" default="4">+ The horizontal separation of items and the vertical scrollbar.+ </theme_item><theme_item name="v_separation" data_type="constant" type="int" default="4">The vertical spacing between items.</theme_item>diff --git a/editor/themes/theme_classic.cpp b/editor/themes/theme_classic.cppindex 300201c04f5..e653bfec8a5 100644--- a/editor/themes/theme_classic.cpp+++ b/editor/themes/theme_classic.cpp@@ -776,6 +776,7 @@ void ThemeClassic::populate_standard_styles(const Ref<EditorTheme> &p_theme, Edip_theme->set_color("guide_color", "ItemList", Color(1, 1, 1, 0));p_theme->set_constant("v_separation", "ItemList", p_config.forced_even_separation * EDSCALE);p_theme->set_constant("h_separation", "ItemList", (p_config.increased_margin + 2) * EDSCALE);+ p_theme->set_constant("scroll_bar_h_separation", "ItemList", p_config.separation_margin);p_theme->set_constant("icon_margin", "ItemList", (p_config.increased_margin + 2) * EDSCALE);p_theme->set_constant(SceneStringName(line_separation), "ItemList", p_config.separation_margin);p_theme->set_constant("outline_size", "ItemList", 0);diff --git a/editor/themes/theme_modern.cpp b/editor/themes/theme_modern.cppindex ca7ab4126e3..78e02573be3 100644--- a/editor/themes/theme_modern.cpp+++ b/editor/themes/theme_modern.cpp@@ -780,6 +780,7 @@ void ThemeModern::populate_standard_styles(const Ref<EditorTheme> &p_theme, Editp_theme->set_color("scroll_hint_color", "ItemList", Color(0, 0, 0, p_config.dark_theme ? 1.0 : 0.5));p_theme->set_constant("v_separation", "ItemList", p_config.base_margin * 1.5 * EDSCALE);p_theme->set_constant("h_separation", "ItemList", (p_config.increased_margin + 2) * EDSCALE);+ p_theme->set_constant("scroll_bar_h_separation", "ItemList", style_itemlist_bg->get_margin(SIDE_RIGHT));p_theme->set_constant("icon_margin", "ItemList", (p_config.increased_margin + 2) * EDSCALE);p_theme->set_constant(SceneStringName(line_separation), "ItemList", p_config.separation_margin);p_theme->set_constant("outline_size", "ItemList", 0);@@ -2240,6 +2241,7 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &p_theme, Editorp_theme->set_stylebox(SceneStringName(panel), "ScrollContainerSecondary", style_sidebar);p_theme->set_stylebox(SceneStringName(panel), "TreeSecondary", style_sidebar);p_theme->set_stylebox(SceneStringName(panel), "ItemListSecondary", style_sidebar);+ p_theme->set_constant("scroll_bar_h_separation", "ItemListSecondary", style_sidebar->get_margin(SIDE_RIGHT));// Use it for EditorDebuggerInspector in StackTrace to keep the default 3-column layout,// as the debugger inspector is too small to be considered a main area.p_theme->set_stylebox(SceneStringName(panel), "EditorDebuggerInspector", style_sidebar);diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cppindex 1809e5e260b..900d35ecfc7 100644--- a/scene/gui/item_list.cpp+++ b/scene/gui/item_list.cpp@@ -346,7 +346,7 @@ Rect2 ItemList::get_item_rect(int p_idx, bool p_expand) const {if (p_expand && p_idx % current_columns == current_columns - 1) {int width = get_size().width - theme_cache.panel_style->get_minimum_size().width;if (scroll_bar_v->is_visible()) {- width -= scroll_bar_v->get_bound_minimum_size().width;+ width -= scroll_bar_v->get_bound_minimum_size().width + theme_cache.scroll_bar_h_separation;}ret.size.width = width - ret.position.x;}@@ -1420,7 +1420,7 @@ void ItemList::_notification(int p_what) {Size2 size = get_size();int width = size.width - theme_cache.panel_style->get_minimum_size().width;if (scroll_bar_v->is_visible()) {- width -= scroll_bar_v_min.width;+ width -= scroll_bar_v_min.width + theme_cache.scroll_bar_h_separation;}draw_style_box(theme_cache.panel_style, Rect2(Point2(), size));@@ -2487,6 +2487,7 @@ void ItemList::_bind_methods() {BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, ItemList, h_separation);BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, ItemList, v_separation);+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, ItemList, scroll_bar_h_separation);BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, ItemList, panel_style, "panel");BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, ItemList, focus_style, "focus");diff --git a/scene/gui/item_list.h b/scene/gui/item_list.hindex d210135a7a0..52daf4bdabb 100644--- a/scene/gui/item_list.h+++ b/scene/gui/item_list.h@@ -163,6 +163,7 @@ protected:struct ThemeCache {int h_separation = 0;int v_separation = 0;+ int scroll_bar_h_separation = 0;Ref<StyleBox> panel_style;Ref<StyleBox> focus_style;diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cppindex 726a804ca2b..88f5953a3cf 100644--- a/scene/theme/default_theme.cpp+++ b/scene/theme/default_theme.cpp@@ -970,6 +970,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, consttheme->set_constant("v_separation", "ItemList", Math::round(4 * scale));theme->set_constant("icon_margin", "ItemList", Math::round(4 * scale));theme->set_constant(SceneStringName(line_separation), "ItemList", Math::round(2 * scale));+ theme->set_constant("scroll_bar_h_separation", "ItemList", Math::round(4 * scale));theme->set_font(SceneStringName(font), "ItemList", Ref<Font>());theme->set_font_size(SceneStringName(font_size), "ItemList", -1);