Godot Engine – Multi-platform 2D and 3D game engine
Fix toolbars from not being centered on non-standard font sizes
Komariarii71f8f575de43
diff --git a/editor/gui/editor_toolbar_group.cpp b/editor/gui/editor_toolbar_group.cppindex 86051555c22..3dc5cf85f66 100644--- a/editor/gui/editor_toolbar_group.cpp+++ b/editor/gui/editor_toolbar_group.cpp@@ -35,7 +35,7 @@EditorToolbarGroup::EditorToolbarGroup() {set_theme_type_variation("PanelContainerButtonGroup");- set_custom_maximum_size(Size2(-1, 32 * EDSCALE));+ set_v_size_flags(Control::SizeFlags::SIZE_SHRINK_CENTER);hbox = memnew(HBoxContainer);hbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);@@ -48,3 +48,18 @@ HBoxContainer *EditorToolbarGroup::create(Control *p_parent) {return group->get_hbox();}++void EditorToolbarGroup::_notification(int p_what) {+ switch (p_what) {+ case NOTIFICATION_THEME_CHANGED: {+ // 32 roughly matches the height of the toolbars prior to the toolbar redesign.+ // The default font size of the editor is 14+ // thus adding 18 will give us the minimum of 32+ // which allows increased font sizes to scale the toolbar.+ const int font_size = get_theme_default_font_size();+ const int max_size = MAX(32, font_size + 18);+ set_custom_minimum_size(Size2(-1, max_size));+ set_custom_maximum_size(Size2(-1, max_size));+ } break;+ }+}diff --git a/editor/gui/editor_toolbar_group.h b/editor/gui/editor_toolbar_group.hindex ee1ae8cc570..f1c84ac003f 100644--- a/editor/gui/editor_toolbar_group.h+++ b/editor/gui/editor_toolbar_group.h@@ -45,4 +45,7 @@ public:static HBoxContainer *create(Control *p_parent);HBoxContainer *get_hbox() const { return hbox; }++protected:+ void _notification(int p_what);};