From 034942557e6c7fb597c70976b677bda5284ea2f5 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Mon, 10 Nov 2025 15:32:43 -0300 Subject: [PATCH] Fix issues with property height in the inspector --- editor/gui/editor_spin_slider.cpp | 13 +-- editor/gui/editor_spin_slider.h | 1 - editor/inspector/editor_inspector.cpp | 55 ++++++----- editor/inspector/editor_inspector.h | 3 +- editor/inspector/editor_properties.cpp | 26 +++-- editor/inspector/editor_properties.h | 1 - .../editor_properties_array_dict.cpp | 20 +++- editor/inspector/editor_resource_picker.cpp | 6 +- editor/scene/3d/node_3d_editor_plugin.cpp | 6 +- editor/scene/gui/theme_editor_preview.cpp | 2 +- editor/themes/editor_theme_manager.cpp | 7 +- editor/themes/editor_theme_manager.h | 4 +- editor/themes/theme_classic.cpp | 24 +++-- editor/themes/theme_modern.cpp | 96 ++++++++++++++----- 14 files changed, 171 insertions(+), 93 deletions(-) diff --git a/editor/gui/editor_spin_slider.cpp b/editor/gui/editor_spin_slider.cpp index 3b34db4210d..c389dcfdf74 100644 --- a/editor/gui/editor_spin_slider.cpp +++ b/editor/gui/editor_spin_slider.cpp @@ -34,6 +34,7 @@ #include "core/math/expression.h" #include "core/os/keyboard.h" #include "core/string/translation_server.h" +#include "editor/editor_string_names.h" #include "editor/settings/editor_settings.h" #include "editor/themes/editor_scale.h" #include "scene/theme/theme_db.h" @@ -464,6 +465,7 @@ void EditorSpinSlider::_notification(int p_what) { case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_THEME_CHANGED: { + set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("inspector_property_height"), EditorStringName(Editor)))); _update_value_input_stylebox(); } break; @@ -516,17 +518,6 @@ LineEdit *EditorSpinSlider::get_line_edit() { return value_input; } -Size2 EditorSpinSlider::get_minimum_size() const { - Ref sb = get_theme_stylebox(CoreStringName(normal), SNAME("LineEdit")); - Ref font = get_theme_font(SceneStringName(font), SNAME("LineEdit")); - int font_size = get_theme_font_size(SceneStringName(font_size), SNAME("LineEdit")); - - Size2 ms = sb->get_minimum_size(); - ms.height += font->get_height(font_size); - - return ms; -} - void EditorSpinSlider::set_control_state(ControlState p_state) { control_state = p_state; queue_redraw(); diff --git a/editor/gui/editor_spin_slider.h b/editor/gui/editor_spin_slider.h index a72b5001950..b21e5fc433c 100644 --- a/editor/gui/editor_spin_slider.h +++ b/editor/gui/editor_spin_slider.h @@ -141,7 +141,6 @@ public: void setup_and_show() { _focus_entered(); } LineEdit *get_line_edit(); - virtual Size2 get_minimum_size() const override; EditorSpinSlider(); }; diff --git a/editor/inspector/editor_inspector.cpp b/editor/inspector/editor_inspector.cpp index c24a0a3c9db..94d07d291f5 100644 --- a/editor/inspector/editor_inspector.cpp +++ b/editor/inspector/editor_inspector.cpp @@ -219,10 +219,7 @@ Size2 EditorProperty::get_minimum_size() const { return Vector2(); } - Size2 ms; - int separation = 4 * EDSCALE; - ms.height = label.is_empty() ? 0 : theme_cache.font->get_height(theme_cache.font_size) + separation; - + Size2 ms = Size2(0, theme_cache.inspector_property_height); for (int i = 0; i < get_child_count(); i++) { Control *c = as_sortable_control(get_child(i)); if (!c) { @@ -316,7 +313,7 @@ void EditorProperty::_notification(int p_what) { { int child_room = size.width * (1.0 - split_ratio); int separation = 4 * EDSCALE; - int height = label.is_empty() ? 0 : theme_cache.font->get_height(theme_cache.font_size) + separation; + int height = theme_cache.inspector_property_height; int half_padding = theme_cache.padding / 2; bool no_children = true; @@ -1982,8 +1979,6 @@ void EditorInspectorSection::_notification(int p_what) { bg_color = theme_cache.prop_subsection; bg_color.a /= level; - - vbox->add_theme_constant_override("separation", theme_cache.vertical_separation); } break; case NOTIFICATION_SORT_CHILDREN: { @@ -2546,6 +2541,7 @@ EditorInspectorSection::EditorInspectorSection() { set_focus_mode(FOCUS_ACCESSIBILITY); vbox = memnew(VBoxContainer); + vbox->set_theme_type_variation(SNAME("EditorPropertyContainer")); dropping_unfold_timer = memnew(Timer); dropping_unfold_timer->set_wait_time(EDITOR_GET("interface/editor/dragging_hover_wait_seconds")); @@ -3557,7 +3553,7 @@ void EditorInspector::initialize_section_theme(EditorInspectorSection::ThemeCach } p_cache.horizontal_separation = p_control->get_theme_constant(SNAME("h_separation"), SNAME("EditorInspectorSection")); - p_cache.vertical_separation = p_control->get_theme_constant(SNAME("v_separation"), SNAME("EditorInspector")); + p_cache.vertical_separation = p_control->get_theme_constant(SNAME("separation"), SNAME("EditorPropertyContainer")); p_cache.inspector_margin = p_control->get_theme_constant(SNAME("inspector_margin"), EditorStringName(Editor)); p_cache.indent_size = p_control->get_theme_constant(SNAME("indent_size"), SNAME("EditorInspectorSection")); p_cache.key_padding_size = int(EDITOR_GET("interface/theme/base_spacing")) * 2; @@ -3596,7 +3592,7 @@ void EditorInspector::initialize_category_theme(EditorInspectorCategory::ThemeCa } p_cache.horizontal_separation = p_control->get_theme_constant(SNAME("h_separation"), SNAME("Tree")); - p_cache.vertical_separation = p_control->get_theme_constant(SNAME("v_separation"), SNAME("EditorInspector")); + p_cache.vertical_separation = p_control->get_theme_constant(SNAME("separation"), SNAME("EditorPropertyContainer")); p_cache.class_icon_size = p_control->get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)); p_cache.font_color = p_control->get_theme_color(SceneStringName(font_color), SNAME("Tree")); @@ -3644,8 +3640,9 @@ void EditorInspector::initialize_property_theme(EditorProperty::ThemeCache &p_ca p_cache.font_size = p_control->get_theme_font_size(SceneStringName(font_size), SNAME("Tree")); p_cache.font_offset = p_control->get_theme_constant(SNAME("font_offset"), SNAME("EditorProperty")); p_cache.horizontal_separation = p_control->get_theme_constant(SNAME("h_separation"), SNAME("Tree")); - p_cache.vertical_separation = p_control->get_theme_constant(SNAME("v_separation"), SNAME("EditorProperty")); + p_cache.vertical_separation = p_control->get_theme_constant(SNAME("separation"), SNAME("EditorPropertyContainer")); p_cache.padding = int(EDITOR_GET("interface/theme/base_spacing")) * 2; + p_cache.inspector_property_height = p_control->get_theme_constant(SNAME("inspector_property_height"), EditorStringName(Editor)); p_cache.property_color = p_control->get_theme_color(SNAME("property_color"), SNAME("EditorProperty")); p_cache.readonly_property_color = p_control->get_theme_color(SNAME("readonly_color"), SNAME("EditorProperty")); @@ -3807,7 +3804,7 @@ bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName } void EditorInspector::_add_section_in_tree(EditorInspectorSection *p_section, VBoxContainer *p_current_vbox) { - // Place adjacent sections in their own vbox with 0 separation + // Place adjacent sections in their own vbox with a theme-specific separation. VBoxContainer *container = nullptr; if (p_current_vbox->get_child_count() > 0) { Node *last_child = p_current_vbox->get_child(-1); @@ -3815,7 +3812,7 @@ void EditorInspector::_add_section_in_tree(EditorInspectorSection *p_section, VB } if (!container) { container = memnew(VBoxContainer); - container->add_theme_constant_override("separation", theme_cache.vertical_separation); + container->set_theme_type_variation(SNAME("EditorInspectorContainer")); p_current_vbox->add_child(container); } container->add_child(p_section); @@ -3919,13 +3916,15 @@ void EditorInspector::update_tree() { bool sub_inspectors_enabled = EDITOR_GET("interface/inspector/open_resources_in_current_inspector"); if (!valid_plugins.is_empty()) { - begin_vbox->show(); - - // Get the lists of editors to add the beginning. for (Ref &ped : valid_plugins) { ped->parse_begin(object); _parse_added_editors(begin_vbox, nullptr, ped); } + + // Show if any of the editors were added to the beginning. + if (begin_vbox->get_child_count() > 0) { + begin_vbox->show(); + } } StringName doc_name; @@ -4217,7 +4216,7 @@ void EditorInspector::update_tree() { // Recreate the category vbox if it was reset. if (category_vbox == nullptr) { category_vbox = memnew(VBoxContainer); - category_vbox->add_theme_constant_override("separation", theme_cache.vertical_separation); + category_vbox->set_theme_type_variation(SNAME("EditorPropertyContainer")); category_vbox->hide(); main_vbox->add_child(category_vbox); } @@ -4684,6 +4683,8 @@ void EditorInspector::update_tree() { String tooltip; VBoxContainer *parent_vbox = favorites_vbox; if (!section_name.is_empty()) { + favorites_groups_vbox->show(); + if (is_localized) { label = EditorPropertyNameProcessor::get_singleton()->translate_group_name(section_name); tooltip = section_name; @@ -4785,6 +4786,10 @@ void EditorInspector::update_tree() { } } } + + if (favorites_vbox->get_child_count() > 0) { + favorites_vbox->show(); + } } // Show a separator if there's no category to clearly divide the properties. @@ -4863,9 +4868,11 @@ void EditorInspector::_clear(bool p_hide_plugins) { } favorites_section->hide(); + favorites_vbox->hide(); while (favorites_vbox->get_child_count()) { memdelete(favorites_vbox->get_child(0)); } + favorites_groups_vbox->hide(); while (favorites_groups_vbox->get_child_count()) { memdelete(favorites_groups_vbox->get_child(0)); } @@ -5648,19 +5655,11 @@ void EditorInspector::_notification(int p_what) { break; } - theme_cache.vertical_separation = get_theme_constant(SNAME("v_separation"), SNAME("EditorInspector")); theme_cache.prop_subsection = get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor)); - theme_cache.icon_add = get_editor_theme_icon(SNAME("Add")); initialize_section_theme(section_theme_cache, this); initialize_category_theme(category_theme_cache, this); initialize_property_theme(property_theme_cache, this); - - base_vbox->add_theme_constant_override("separation", theme_cache.vertical_separation); - begin_vbox->add_theme_constant_override("separation", theme_cache.vertical_separation); - favorites_section->add_theme_constant_override("separation", theme_cache.vertical_separation); - favorites_groups_vbox->add_theme_constant_override("separation", theme_cache.vertical_separation); - main_vbox->add_theme_constant_override("separation", theme_cache.vertical_separation); } break; case NOTIFICATION_READY: { @@ -5893,14 +5892,17 @@ EditorInspector::EditorInspector() { object = nullptr; base_vbox = memnew(VBoxContainer); + base_vbox->set_theme_type_variation(SNAME("EditorInspectorContainer")); base_vbox->set_h_size_flags(SIZE_EXPAND_FILL); add_child(base_vbox); begin_vbox = memnew(VBoxContainer); + begin_vbox->set_theme_type_variation(SNAME("EditorInspectorContainer")); base_vbox->add_child(begin_vbox); begin_vbox->hide(); favorites_section = memnew(VBoxContainer); + favorites_section->set_theme_type_variation(SNAME("EditorInspectorContainer")); base_vbox->add_child(favorites_section); favorites_section->hide(); @@ -5910,15 +5912,20 @@ EditorInspector::EditorInspector() { favorites_section->add_child(favorites_category); favorites_vbox = memnew(VBoxContainer); + favorites_vbox->set_theme_type_variation(SNAME("EditorPropertyContainer")); favorites_section->add_child(favorites_vbox); + favorites_vbox->hide(); favorites_groups_vbox = memnew(VBoxContainer); + favorites_groups_vbox->set_theme_type_variation(SNAME("EditorInspectorContainer")); favorites_section->add_child(favorites_groups_vbox); + favorites_groups_vbox->hide(); favorites_separator = memnew(HSeparator); favorites_section->add_child(favorites_separator); favorites_separator->hide(); main_vbox = memnew(VBoxContainer); + main_vbox->set_theme_type_variation(SNAME("EditorInspectorContainer")); base_vbox->add_child(main_vbox); set_horizontal_scroll_mode(SCROLL_MODE_DISABLED); diff --git a/editor/inspector/editor_inspector.h b/editor/inspector/editor_inspector.h index 6b9e1927501..bd5776a0e8a 100644 --- a/editor/inspector/editor_inspector.h +++ b/editor/inspector/editor_inspector.h @@ -102,6 +102,7 @@ class EditorProperty : public Container { int horizontal_separation = 0; int vertical_separation = 0; int padding = 0; + int inspector_property_height = 0; Color property_color; Color readonly_property_color; @@ -701,9 +702,7 @@ class EditorInspector : public ScrollContainer { static int inspector_plugin_count; struct ThemeCache { - int vertical_separation = 0; Color prop_subsection; - Ref icon_add; } theme_cache; EditorInspectorSection::ThemeCache section_theme_cache; diff --git a/editor/inspector/editor_properties.cpp b/editor/inspector/editor_properties.cpp index 5e996cbea73..9bd2543670a 100644 --- a/editor/inspector/editor_properties.cpp +++ b/editor/inspector/editor_properties.cpp @@ -150,6 +150,7 @@ EditorPropertyVariant::EditorPropertyVariant() { edit_button = memnew(Button); edit_button->set_flat(true); + edit_button->set_theme_type_variation(SNAME("EditorInspectorButton")); edit_button->set_accessibility_name(TTRC("Edit")); edit_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyVariant::_popup_edit_menu)); content->add_child(edit_button); @@ -333,6 +334,7 @@ EditorPropertyMultilineText::EditorPropertyMultilineText(bool p_expression) { open_big_text = memnew(Button); open_big_text->set_accessibility_name(TTRC("Open Text Edit Dialog")); open_big_text->set_flat(true); + open_big_text->set_theme_type_variation(SNAME("EditorInspectorButton")); open_big_text->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyMultilineText::_open_big_text)); hb->add_child(open_big_text); big_text_dialog = nullptr; @@ -482,6 +484,7 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() { option_button->set_h_size_flags(SIZE_EXPAND_FILL); option_button->set_clip_text(true); option_button->set_flat(true); + option_button->set_theme_type_variation(SNAME("EditorInspectorButton")); option_button->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); default_layout->add_child(option_button); option_button->connect(SceneStringName(item_selected), callable_mp(this, &EditorPropertyTextEnum::_option_selected)); @@ -489,6 +492,7 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() { edit_button = memnew(Button); edit_button->set_accessibility_name(TTRC("Edit")); edit_button->set_flat(true); + edit_button->set_theme_type_variation(SNAME("EditorInspectorButton")); edit_button->hide(); default_layout->add_child(edit_button); edit_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyTextEnum::_edit_custom_value)); @@ -502,12 +506,14 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() { accept_button = memnew(Button); accept_button->set_accessibility_name(TTRC("Accept Custom Value Edit")); accept_button->set_flat(true); + accept_button->set_theme_type_variation(SNAME("EditorInspectorButton")); edit_custom_layout->add_child(accept_button); accept_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyTextEnum::_custom_value_accepted)); cancel_button = memnew(Button); cancel_button->set_accessibility_name(TTRC("Cancel Custom Value Edit")); cancel_button->set_flat(true); + cancel_button->set_theme_type_variation(SNAME("EditorInspectorButton")); edit_custom_layout->add_child(cancel_button); cancel_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyTextEnum::_custom_value_canceled)); @@ -571,6 +577,7 @@ EditorPropertyLocale::EditorPropertyLocale() { locale_edit = memnew(Button); locale_edit->set_accessibility_name(TTRC("Edit")); locale_edit->set_clip_text(true); + locale_edit->set_theme_type_variation(SNAME("EditorInspectorButton")); locale_hb->add_child(locale_edit); add_focusable(locale); dialog = nullptr; @@ -742,11 +749,13 @@ EditorPropertyPath::EditorPropertyPath() { toggle_uid->set_accessibility_name(TTRC("Toggle Display UID")); toggle_uid->set_tooltip_text(TTRC("Toggles displaying between path and UID.\nThe UID is the actual value of this property.")); toggle_uid->set_pressed(false); + toggle_uid->set_theme_type_variation(SNAME("EditorInspectorButton")); path_hb->add_child(toggle_uid); add_focusable(toggle_uid); toggle_uid->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyPath::_toggle_uid_display)); path_edit = memnew(Button); + path_edit->set_theme_type_variation(SNAME("EditorInspectorButton")); path_edit->set_accessibility_name(TTRC("Edit")); path_hb->add_child(path_edit); add_focusable(path); @@ -785,6 +794,7 @@ void EditorPropertyClassName::_dialog_created() { EditorPropertyClassName::EditorPropertyClassName() { property = memnew(Button); property->set_clip_text(true); + property->set_theme_type_variation(SNAME("EditorInspectorButton")); add_child(property); add_focusable(property); property->set_text(selected_type); @@ -879,6 +889,7 @@ EditorPropertyEnum::EditorPropertyEnum() { options = memnew(OptionButton); options->set_clip_text(true); options->set_flat(true); + options->set_theme_type_variation(SNAME("EditorInspectorButton")); options->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); add_child(options); add_focusable(options); @@ -1546,6 +1557,7 @@ void EditorPropertyObjectID::setup(const String &p_base_type) { EditorPropertyObjectID::EditorPropertyObjectID() { edit = memnew(Button); + edit->set_theme_type_variation(SNAME("EditorInspectorButton")); edit->set_accessibility_name(TTRC("Edit")); add_child(edit); add_focusable(edit); @@ -1572,6 +1584,7 @@ void EditorPropertySignal::update_property() { EditorPropertySignal::EditorPropertySignal() { edit = memnew(Button); + edit->set_theme_type_variation(SNAME("EditorInspectorButton")); edit->set_accessibility_name(TTRC("Edit")); add_child(edit); add_focusable(edit); @@ -1592,6 +1605,7 @@ void EditorPropertyCallable::update_property() { EditorPropertyCallable::EditorPropertyCallable() { edit = memnew(Button); + edit->set_theme_type_variation(SNAME("EditorInspectorButton")); edit->set_accessibility_name(TTRC("Edit")); add_child(edit); add_focusable(edit); @@ -2314,6 +2328,7 @@ EditorPropertyQuaternion::EditorPropertyQuaternion() { warning = memnew(Button); warning->set_text(TTR("Temporary Euler may be changed implicitly!")); warning->set_clip_text(true); + warning->set_theme_type_variation(SNAME("EditorInspectorButton")); warning->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyQuaternion::_warning_pressed)); warning_dialog = memnew(AcceptDialog); add_child(warning_dialog); @@ -2343,6 +2358,7 @@ EditorPropertyQuaternion::EditorPropertyQuaternion() { edit_button->set_accessibility_name(TTRC("Edit")); edit_button->set_flat(true); edit_button->set_toggle_mode(true); + edit_button->set_theme_type_variation(SNAME("EditorInspectorButton")); default_layout->add_child(edit_button); edit_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyQuaternion::_edit_custom_value)); @@ -2821,14 +2837,6 @@ void EditorPropertyColor::_popup_closed() { } } -void EditorPropertyColor::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_THEME_CHANGED: { - picker->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor)))); - } break; - } -} - void EditorPropertyColor::update_property() { picker->set_pick_color(get_edited_property_display_value()); const Color color = picker->get_pick_color(); @@ -2862,6 +2870,7 @@ EditorPropertyColor::EditorPropertyColor() { picker = memnew(ColorPickerButton); add_child(picker); picker->set_flat(true); + picker->set_theme_type_variation(SNAME("EditorInspectorButton")); picker->connect("color_changed", callable_mp(this, &EditorPropertyColor::_color_changed)); picker->connect("picker_created", callable_mp(this, &EditorPropertyColor::_picker_created), CONNECT_ONE_SHOT); } @@ -3170,6 +3179,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() { assign = memnew(Button); assign->set_accessibility_name(TTRC("Assign Node")); assign->set_flat(true); + assign->set_theme_type_variation(SNAME("EditorInspectorButton")); assign->set_h_size_flags(SIZE_EXPAND_FILL); assign->set_clip_text(true); assign->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); diff --git a/editor/inspector/editor_properties.h b/editor/inspector/editor_properties.h index 494723728eb..e281f14a5ea 100644 --- a/editor/inspector/editor_properties.h +++ b/editor/inspector/editor_properties.h @@ -652,7 +652,6 @@ class EditorPropertyColor : public EditorProperty { protected: virtual void _set_read_only(bool p_read_only) override; - void _notification(int p_what); public: virtual void update_property() override; diff --git a/editor/inspector/editor_properties_array_dict.cpp b/editor/inspector/editor_properties_array_dict.cpp index 66ffe4671c8..b746c040dcf 100644 --- a/editor/inspector/editor_properties_array_dict.cpp +++ b/editor/inspector/editor_properties_array_dict.cpp @@ -316,7 +316,7 @@ void EditorPropertyArray::_create_new_property_slot() { reorder_button->set_button_icon(get_editor_theme_icon(SNAME("TripleBar"))); reorder_button->set_default_cursor_shape(Control::CURSOR_MOVE); reorder_button->set_disabled(is_read_only()); - reorder_button->set_theme_type_variation(SceneStringName(FlatButton)); + reorder_button->set_theme_type_variation(SNAME("EditorInspectorFlatButton")); reorder_button->connect(SceneStringName(gui_input), callable_mp(this, &EditorPropertyArray::_reorder_button_gui_input)); reorder_button->connect(SNAME("button_up"), callable_mp(this, &EditorPropertyArray::_reorder_button_up)); reorder_button->connect(SNAME("button_down"), callable_mp(this, &EditorPropertyArray::_reorder_button_down).bind(idx)); @@ -332,14 +332,14 @@ void EditorPropertyArray::_create_new_property_slot() { edit_btn->set_accessibility_name(TTRC("Edit")); edit_btn->set_button_icon(get_editor_theme_icon(SNAME("Edit"))); edit_btn->set_disabled(is_read_only()); - edit_btn->set_theme_type_variation(SceneStringName(FlatButton)); + edit_btn->set_theme_type_variation(SNAME("EditorInspectorFlatButton")); edit_btn->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyArray::_change_type).bind(edit_btn, idx)); } else { remove_btn = memnew(Button); remove_btn->set_accessibility_name(TTRC("Remove")); remove_btn->set_button_icon(get_editor_theme_icon(SNAME("Remove"))); remove_btn->set_disabled(is_read_only()); - remove_btn->set_theme_type_variation(SceneStringName(FlatButton)); + remove_btn->set_theme_type_variation(SNAME("EditorInspectorFlatButton")); remove_btn->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyArray::_remove_pressed).bind(idx)); } property_vbox->add_child(hbox); @@ -442,6 +442,7 @@ void EditorPropertyArray::update_property() { set_bottom_editor(container); VBoxContainer *vbox = memnew(VBoxContainer); + vbox->set_theme_type_variation(SNAME("EditorPropertyContainer")); container->add_child(vbox); HBoxContainer *hbox = memnew(HBoxContainer); @@ -462,6 +463,7 @@ void EditorPropertyArray::update_property() { hbox->add_child(size_slider); property_vbox = memnew(VBoxContainer); + property_vbox->set_theme_type_variation(SNAME("EditorPropertyContainer")); property_vbox->set_h_size_flags(SIZE_EXPAND_FILL); vbox->add_child(property_vbox); @@ -974,6 +976,7 @@ EditorPropertyArray::EditorPropertyArray() { edit->set_accessibility_name(TTRC("Edit")); edit->set_h_size_flags(SIZE_EXPAND_FILL); edit->set_clip_text(true); + edit->set_theme_type_variation(SNAME("EditorInspectorButton")); edit->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyArray::_edit_pressed)); edit->set_toggle_mode(true); SET_DRAG_FORWARDING_CD(edit, EditorPropertyArray); @@ -1089,14 +1092,14 @@ void EditorPropertyDictionary::_create_new_property_slot(int p_idx) { edit_btn->set_accessibility_name(TTRC("Edit")); edit_btn->set_button_icon(get_editor_theme_icon(SNAME("Edit"))); edit_btn->set_disabled(is_read_only()); - edit_btn->set_theme_type_variation(SceneStringName(FlatButton)); + edit_btn->set_theme_type_variation(SNAME("EditorInspectorFlatButton")); edit_btn->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyDictionary::_change_type).bind(edit_btn, slots.size())); } else if (p_idx >= 0) { remove_btn = memnew(Button); remove_btn->set_accessibility_name(TTRC("Remove")); remove_btn->set_button_icon(get_editor_theme_icon(SNAME("Remove"))); remove_btn->set_disabled(is_read_only()); - remove_btn->set_theme_type_variation(SceneStringName(FlatButton)); + remove_btn->set_theme_type_variation(SNAME("EditorInspectorFlatButton")); remove_btn->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyDictionary::_remove_pressed).bind(slots.size())); } @@ -1301,9 +1304,11 @@ void EditorPropertyDictionary::update_property() { set_bottom_editor(container); VBoxContainer *vbox = memnew(VBoxContainer); + vbox->set_theme_type_variation(SNAME("EditorPropertyContainer")); container->add_child(vbox); property_vbox = memnew(VBoxContainer); + property_vbox->set_theme_type_variation(SNAME("EditorPropertyContainer")); property_vbox->set_h_size_flags(SIZE_EXPAND_FILL); vbox->add_child(property_vbox); @@ -1319,6 +1324,7 @@ void EditorPropertyDictionary::update_property() { property_vbox->add_child(add_panel); add_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("DictionaryAddItem"))); VBoxContainer *add_vbox = memnew(VBoxContainer); + add_vbox->set_theme_type_variation(SNAME("EditorPropertyContainer")); add_panel->add_child(add_vbox); _create_new_property_slot(EditorPropertyDictionaryObject::NEW_KEY_INDEX); @@ -1539,6 +1545,7 @@ EditorPropertyDictionary::EditorPropertyDictionary() { edit->set_accessibility_name(TTRC("Edit")); edit->set_h_size_flags(SIZE_EXPAND_FILL); edit->set_clip_text(true); + edit->set_theme_type_variation(SNAME("EditorInspectorButton")); edit->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyDictionary::_edit_pressed)); edit->set_toggle_mode(true); add_child(edit); @@ -1636,9 +1643,11 @@ void EditorPropertyLocalizableString::update_property() { set_bottom_editor(container); VBoxContainer *vbox = memnew(VBoxContainer); + vbox->set_theme_type_variation(SNAME("EditorPropertyContainer")); container->add_child(vbox); property_vbox = memnew(VBoxContainer); + property_vbox->set_theme_type_variation(SNAME("EditorPropertyContainer")); property_vbox->set_h_size_flags(SIZE_EXPAND_FILL); vbox->add_child(property_vbox); @@ -1750,6 +1759,7 @@ EditorPropertyLocalizableString::EditorPropertyLocalizableString() { edit->set_accessibility_name(TTRC("Edit")); edit->set_h_size_flags(SIZE_EXPAND_FILL); edit->set_clip_text(true); + edit->set_theme_type_variation(SNAME("EditorInspectorButton")); edit->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyLocalizableString::_edit_pressed)); edit->set_toggle_mode(true); add_child(edit); diff --git a/editor/inspector/editor_resource_picker.cpp b/editor/inspector/editor_resource_picker.cpp index ea1752852e2..e527b8f598f 100644 --- a/editor/inspector/editor_resource_picker.cpp +++ b/editor/inspector/editor_resource_picker.cpp @@ -1434,6 +1434,7 @@ EditorResourcePicker::EditorResourcePicker(bool p_hide_assign_button_controls) { make_unique_button->set_tooltip_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); make_unique_button->set_button_mask(MouseButtonMask::LEFT | MouseButtonMask::RIGHT); make_unique_button->set_action_mode(BaseButton::ACTION_MODE_BUTTON_PRESS); + make_unique_button->set_theme_type_variation(SNAME("EditorInspectorButton")); add_child(make_unique_button); make_unique_button->connect(SceneStringName(pressed), callable_mp(this, &EditorResourcePicker::_on_unique_button_pressed)); @@ -1443,6 +1444,7 @@ EditorResourcePicker::EditorResourcePicker(bool p_hide_assign_button_controls) { assign_button->set_accessibility_name(TTRC("Assign Resource")); assign_button->set_expand_icon(true); assign_button->set_clip_text(true); + assign_button->set_theme_type_variation(SNAME("EditorInspectorButton")); assign_button->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); SET_DRAG_FORWARDING_GCD(assign_button, EditorResourcePicker); add_child(assign_button); @@ -1462,13 +1464,13 @@ EditorResourcePicker::EditorResourcePicker(bool p_hide_assign_button_controls) { } quick_load_button = memnew(Button); - quick_load_button->set_theme_type_variation(SceneStringName(FlatButton)); + quick_load_button->set_theme_type_variation(SNAME("EditorInspectorFlatButton")); quick_load_button->set_tooltip_text(TTRC("Quick Load")); add_child(quick_load_button); quick_load_button->connect(SceneStringName(pressed), callable_mp(this, &EditorResourcePicker::_edit_menu_cbk).bind(OBJ_MENU_QUICKLOAD)); edit_button = memnew(Button); - edit_button->set_theme_type_variation(SceneStringName(FlatButton)); + edit_button->set_theme_type_variation(SNAME("EditorInspectorFlatButton")); edit_button->set_toggle_mode(true); edit_button->set_action_mode(BaseButton::ACTION_MODE_BUTTON_PRESS); edit_button->set_accessibility_name(TTRC("Edit")); diff --git a/editor/scene/3d/node_3d_editor_plugin.cpp b/editor/scene/3d/node_3d_editor_plugin.cpp index bd31d8dd846..520ff83dad1 100644 --- a/editor/scene/3d/node_3d_editor_plugin.cpp +++ b/editor/scene/3d/node_3d_editor_plugin.cpp @@ -8888,9 +8888,9 @@ void Node3DEditor::_update_theme() { sun_title->add_theme_font_override(SceneStringName(font), get_theme_font(SNAME("title_font"), SNAME("Window"))); environ_title->add_theme_font_override(SceneStringName(font), get_theme_font(SNAME("title_font"), SNAME("Window"))); - sun_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor)))); - environ_sky_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor)))); - environ_ground_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor)))); + sun_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("inspector_property_height"), EditorStringName(Editor)))); + environ_sky_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("inspector_property_height"), EditorStringName(Editor)))); + environ_ground_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("inspector_property_height"), EditorStringName(Editor)))); context_toolbar_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("ContextualToolbar"), EditorStringName(EditorStyles))); } diff --git a/editor/scene/gui/theme_editor_preview.cpp b/editor/scene/gui/theme_editor_preview.cpp index 3bf3e78e511..fabebc269d0 100644 --- a/editor/scene/gui/theme_editor_preview.cpp +++ b/editor/scene/gui/theme_editor_preview.cpp @@ -293,7 +293,7 @@ ThemeEditorPreview::ThemeEditorPreview() { void DefaultThemeEditorPreview::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - test_color_picker_button->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor)))); + test_color_picker_button->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("inspector_property_height"), EditorStringName(Editor)))); } break; } } diff --git a/editor/themes/editor_theme_manager.cpp b/editor/themes/editor_theme_manager.cpp index b1ef0e98cec..caf55b418fd 100644 --- a/editor/themes/editor_theme_manager.cpp +++ b/editor/themes/editor_theme_manager.cpp @@ -78,7 +78,7 @@ uint32_t EditorThemeManager::ThemeConfiguration::hash() { hash = hash_murmur3_one_32(class_icon_size, hash); hash = hash_murmur3_one_32((int)enable_touch_optimizations, hash); hash = hash_murmur3_one_float(gizmo_handle_scale, hash); - hash = hash_murmur3_one_32(color_picker_button_height, hash); + hash = hash_murmur3_one_32(inspector_property_height, hash); hash = hash_murmur3_one_float(subresource_hue_tint, hash); hash = hash_murmur3_one_float(default_contrast, hash); @@ -168,7 +168,7 @@ Ref EditorThemeManager::_create_base_theme(const Ref & OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Create Base Theme"); Ref theme = memnew(EditorTheme); - ThemeConfiguration config = _create_theme_config(theme); + ThemeConfiguration config = _create_theme_config(); theme->set_generated_hash(config.hash()); theme->set_generated_fonts_hash(config.hash_fonts()); theme->set_generated_icons_hash(config.hash_icons()); @@ -235,7 +235,7 @@ Ref EditorThemeManager::_create_base_theme(const Ref & return theme; } -EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(const Ref &p_theme) { +EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config() { ThemeConfiguration config; // Basic properties. @@ -264,7 +264,6 @@ EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config( config.class_icon_size = 16 * EDSCALE; config.enable_touch_optimizations = EDITOR_GET("interface/touchscreen/enable_touch_optimizations"); config.gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles"); - config.color_picker_button_height = 28 * EDSCALE; config.subresource_hue_tint = EDITOR_GET("docks/property_editor/subresource_hue_tint"); config.dragging_hover_wait_msec = (float)EDITOR_GET("interface/editor/dragging_hover_wait_seconds") * 1000; diff --git a/editor/themes/editor_theme_manager.h b/editor/themes/editor_theme_manager.h index bdbe05f18c5..200bf597856 100644 --- a/editor/themes/editor_theme_manager.h +++ b/editor/themes/editor_theme_manager.h @@ -77,7 +77,7 @@ public: int class_icon_size = 16; bool enable_touch_optimizations = false; float gizmo_handle_scale = 1.0; - int color_picker_button_height = 28; + int inspector_property_height = 28; float subresource_hue_tint = 0.0; float dragging_hover_wait_msec = 0; @@ -204,7 +204,7 @@ public: private: static Ref _create_base_theme(const Ref &p_old_theme = nullptr); - static ThemeConfiguration _create_theme_config(const Ref &p_theme); + static ThemeConfiguration _create_theme_config(); static void _populate_text_editor_styles(const Ref &p_theme, ThemeConfiguration &p_config); static void _populate_visual_shader_styles(const Ref &p_theme, ThemeConfiguration &p_config); diff --git a/editor/themes/theme_classic.cpp b/editor/themes/theme_classic.cpp index 738c06b7524..06b2029edbf 100644 --- a/editor/themes/theme_classic.cpp +++ b/editor/themes/theme_classic.cpp @@ -224,7 +224,6 @@ void ThemeClassic::populate_shared_styles(const Ref &p_theme, Edito p_theme->set_constant("thumb_size", EditorStringName(Editor), p_config.thumb_size); p_theme->set_constant("class_icon_size", EditorStringName(Editor), p_config.class_icon_size); - p_theme->set_constant("color_picker_button_height", EditorStringName(Editor), p_config.color_picker_button_height); p_theme->set_constant("gizmo_handle_scale", EditorStringName(Editor), p_config.gizmo_handle_scale); p_theme->set_constant("base_margin", EditorStringName(Editor), p_config.base_margin); @@ -1988,8 +1987,13 @@ void ThemeClassic::populate_editor_styles(const Ref &p_theme, Edito editor_inspector_panel->set_content_margin_all(0); p_theme->set_stylebox(SceneStringName(panel), "EditorInspector", editor_inspector_panel); - // Vertical separation between inspector categories and sections. - p_theme->set_constant("v_separation", "EditorInspector", 0); + // Vertical separation between inspector areas. + p_theme->set_type_variation("EditorInspectorContainer", "VBoxContainer"); + p_theme->set_constant("separation", "EditorInspectorContainer", 0); + + // Vertical separation between inspector properties. + p_theme->set_type_variation("EditorPropertyContainer", "VBoxContainer"); + p_theme->set_constant("separation", "EditorPropertyContainer", p_config.increased_margin * EDSCALE); // EditorProperty. @@ -2005,7 +2009,6 @@ void ThemeClassic::populate_editor_styles(const Ref &p_theme, Edito p_theme->set_stylebox("bg_selected", "EditorProperty", style_property_bg); p_theme->set_stylebox("child_bg", "EditorProperty", style_property_child_bg); p_theme->set_constant("font_offset", "EditorProperty", 8 * EDSCALE); - p_theme->set_constant("v_separation", "EditorProperty", p_config.increased_margin * EDSCALE); const Color property_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.5); const Color readonly_color = property_color.lerp(p_config.dark_icon_and_font ? Color(0, 0, 0) : Color(1, 1, 1), 0.25); @@ -2022,6 +2025,13 @@ void ThemeClassic::populate_editor_styles(const Ref &p_theme, Edito style_property_group_note->set_bg_color(property_group_note_color); p_theme->set_stylebox("bg_group_note", "EditorProperty", style_property_group_note); + // Make the height for properties uniform. + Ref inspector_button_style = p_theme->get_stylebox(CoreStringName(normal), SNAME("Button")); + Ref font = p_theme->get_font(SceneStringName(font), SNAME("LineEdit")); + int font_size = p_theme->get_font_size(SceneStringName(font_size), SNAME("LineEdit")); + p_config.inspector_property_height = inspector_button_style->get_minimum_size().height + font->get_height(font_size); + p_theme->set_constant("inspector_property_height", EditorStringName(Editor), p_config.inspector_property_height); + // EditorInspectorSection. Color inspector_section_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.35); @@ -2382,8 +2392,8 @@ void ThemeClassic::populate_editor_styles(const Ref &p_theme, Edito p_theme->set_color("playback_color", "GraphStateMachine", p_config.font_color); p_theme->set_color("playback_background_color", "GraphStateMachine", p_config.font_color * Color(1, 1, 1, 0.3)); } - - // TileSet editor. - p_theme->set_stylebox("expand_panel", "TileSetEditor", p_config.tree_panel_style); } + + // TileSet editor. + p_theme->set_stylebox("expand_panel", "TileSetEditor", p_config.tree_panel_style); } diff --git a/editor/themes/theme_modern.cpp b/editor/themes/theme_modern.cpp index daa03826c2d..8c31b2cfe8e 100644 --- a/editor/themes/theme_modern.cpp +++ b/editor/themes/theme_modern.cpp @@ -247,7 +247,6 @@ void ThemeModern::populate_shared_styles(const Ref &p_theme, Editor p_theme->set_constant("thumb_size", EditorStringName(Editor), p_config.thumb_size); p_theme->set_constant("class_icon_size", EditorStringName(Editor), p_config.class_icon_size); - p_theme->set_constant("color_picker_button_height", EditorStringName(Editor), p_config.color_picker_button_height); p_theme->set_constant("gizmo_handle_scale", EditorStringName(Editor), p_config.gizmo_handle_scale); p_theme->set_constant("base_margin", EditorStringName(Editor), p_config.base_margin); @@ -548,8 +547,8 @@ void ThemeModern::populate_standard_styles(const Ref &p_theme, Edit // CheckBox. { Ref checkbox_style = p_config.panel_container_style->duplicate(); - Ref checkbox_style_normal = p_config.base_style->duplicate(); - checkbox_style_normal->set_content_margin_individual(p_config.base_margin * 1.5 * EDSCALE, p_config.base_margin * 0.5 * EDSCALE, p_config.base_margin * 1.5 * EDSCALE, p_config.base_margin * 0.5 * EDSCALE); + checkbox_style->set_content_margin_individual(p_config.base_margin * 1.5 * EDSCALE, p_config.base_margin * 0.75 * EDSCALE, p_config.base_margin * 1.5 * EDSCALE, p_config.base_margin * 0.75 * EDSCALE); + Ref checkbox_style_normal = checkbox_style->duplicate(); checkbox_style_normal->set_draw_center(false); p_theme->set_stylebox(CoreStringName(normal), "CheckBox", checkbox_style_normal); @@ -838,7 +837,7 @@ void ThemeModern::populate_standard_styles(const Ref &p_theme, Edit { Ref text_editor_style = p_config.base_style->duplicate(); text_editor_style->set_bg_color(p_config.surface_lower_color); - text_editor_style->set_content_margin_individual(p_config.base_margin * 2 * EDSCALE, p_config.base_margin * 0.75 * EDSCALE, p_config.base_margin * 2 * EDSCALE, p_config.base_margin * 0.75 * EDSCALE); + text_editor_style->set_content_margin_individual(p_config.base_margin * 2 * EDSCALE, ((p_config.base_margin * 0.75) + 1) * EDSCALE, p_config.base_margin * 2 * EDSCALE, ((p_config.base_margin * 0.75) + 1) * EDSCALE); if (p_config.draw_extra_borders) { text_editor_style->set_border_width_all(Math::round(EDSCALE)); text_editor_style->set_border_color(p_config.extra_border_color_1); @@ -1858,14 +1857,6 @@ void ThemeModern::populate_editor_styles(const Ref &p_theme, Editor p_theme->set_stylebox(SceneStringName(panel), "EditorAbout", p_config.window_complex_style); p_theme->set_stylebox(SceneStringName(panel), "ThemeItemEditorDialog", p_config.window_complex_style); - // InspectorActionButton. - p_theme->set_type_variation("InspectorActionButton", "Button"); - p_theme->set_constant("h_separation", "InspectorActionButton", p_config.base_margin * 2 * EDSCALE); - p_theme->set_stylebox(CoreStringName(normal), "InspectorActionButton", p_config.button_style); - p_theme->set_stylebox(SceneStringName(hover), "InspectorActionButton", p_config.button_style_hover); - p_theme->set_stylebox(SceneStringName(pressed), "InspectorActionButton", p_config.button_style_pressed); - p_theme->set_stylebox("disabled", "InspectorActionButton", p_config.button_style_disabled); - // Buttons in material previews. { const Color dim_light_color = p_config.icon_normal_color.darkened(0.24); @@ -1945,8 +1936,13 @@ void ThemeModern::populate_editor_styles(const Ref &p_theme, Editor editor_inspector_panel->set_content_margin_all(p_config.base_margin * 2 * EDSCALE); p_theme->set_stylebox(SceneStringName(panel), "EditorInspector", editor_inspector_panel); - // Vertical separation between inspector categories and sections. - p_theme->set_constant("v_separation", "EditorInspector", Math::ceil(p_config.base_margin * 0.5 * EDSCALE)); + // Vertical separation between inspector areas. + p_theme->set_type_variation("EditorInspectorContainer", "VBoxContainer"); + p_theme->set_constant("separation", "EditorInspectorContainer", Math::ceil(p_config.base_margin * 0.5 * EDSCALE)); + + // Vertical separation between inspector properties. + p_theme->set_type_variation("EditorPropertyContainer", "VBoxContainer"); + p_theme->set_constant("separation", "EditorPropertyContainer", p_config.base_margin * 0.5 * EDSCALE); // EditorProperty. @@ -1965,7 +1961,6 @@ void ThemeModern::populate_editor_styles(const Ref &p_theme, Editor p_theme->set_stylebox("bg_selected", "EditorProperty", style_property_bg_selected); p_theme->set_stylebox("child_bg", "EditorProperty", style_property_child_bg); p_theme->set_constant("font_offset", "EditorProperty", 8 * EDSCALE); - p_theme->set_constant("v_separation", "EditorProperty", p_config.increased_margin * EDSCALE); const Color property_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.5); const Color readonly_color = property_color.lerp(p_config.dark_icon_and_font ? Color(0, 0, 0) : Color(1, 1, 1), 0.25); @@ -2105,6 +2100,63 @@ void ThemeModern::populate_editor_styles(const Ref &p_theme, Editor p_theme->set_type_variation("ObjectSelectorMargin", "MarginContainer"); p_theme->set_constant("margin_left", "ObjectSelectorMargin", p_config.base_margin * 2 * EDSCALE); p_theme->set_constant("margin_right", "ObjectSelectorMargin", p_config.base_margin * 2.5 * EDSCALE); + + // EditorInspectorButton. + + p_theme->set_type_variation("EditorInspectorButton", "Button"); + Ref style_line = p_theme->get_stylebox(CoreStringName(normal), SNAME("LineEdit")); + float vertical_margin = style_line->get_content_margin(SIDE_TOP); + + Ref style_inspector_button = p_config.button_style->duplicate(); + style_inspector_button->set_content_margin(SIDE_TOP, vertical_margin); + style_inspector_button->set_content_margin(SIDE_BOTTOM, vertical_margin); + + Ref style_inspector_button_hover = p_config.button_style_hover->duplicate(); + style_inspector_button_hover->set_content_margin(SIDE_TOP, vertical_margin); + style_inspector_button_hover->set_content_margin(SIDE_BOTTOM, vertical_margin); + + Ref style_inspector_button_pressed = p_config.button_style_pressed->duplicate(); + style_inspector_button_pressed->set_content_margin(SIDE_TOP, vertical_margin); + style_inspector_button_pressed->set_content_margin(SIDE_BOTTOM, vertical_margin); + + Ref style_inspector_button_disabled = p_config.button_style_disabled->duplicate(); + style_inspector_button_disabled->set_content_margin(SIDE_TOP, vertical_margin); + style_inspector_button_disabled->set_content_margin(SIDE_BOTTOM, vertical_margin); + + p_theme->set_stylebox(CoreStringName(normal), "EditorInspectorButton", style_inspector_button); + p_theme->set_stylebox(SceneStringName(hover), "EditorInspectorButton", style_inspector_button_hover); + p_theme->set_stylebox(SceneStringName(pressed), "EditorInspectorButton", style_inspector_button_pressed); + p_theme->set_stylebox("hover_pressed", "EditorInspectorButton", style_inspector_button_pressed); + p_theme->set_stylebox("disabled", "EditorInspectorButton", style_inspector_button_disabled); + + // Make the height for properties uniform. + Ref inspector_button_style = p_theme->get_stylebox(CoreStringName(normal), SNAME("EditorInspectorButton")); + Ref font = p_theme->get_font(SceneStringName(font), SNAME("LineEdit")); + int font_size = p_theme->get_font_size(SceneStringName(font_size), SNAME("LineEdit")); + p_config.inspector_property_height = inspector_button_style->get_minimum_size().height + font->get_height(font_size); + p_theme->set_constant("inspector_property_height", EditorStringName(Editor), p_config.inspector_property_height); + + // EditorInspectorFlatButton. + + p_theme->set_type_variation("EditorInspectorFlatButton", "FlatButton"); + + Ref inspector_flat_button_hover = p_config.flat_button_hover->duplicate(); + inspector_flat_button_hover->set_content_margin(SIDE_TOP, vertical_margin); + inspector_flat_button_hover->set_content_margin(SIDE_BOTTOM, vertical_margin); + + Ref inspector_flat_button_pressed = p_config.flat_button_pressed->duplicate(); + inspector_flat_button_pressed->set_content_margin(SIDE_TOP, vertical_margin); + inspector_flat_button_pressed->set_content_margin(SIDE_BOTTOM, vertical_margin); + + p_theme->set_stylebox(CoreStringName(normal), "EditorInspectorFlatButton", p_config.base_empty_wide_style); + p_theme->set_stylebox(SceneStringName(hover), "EditorInspectorFlatButton", p_config.flat_button_hover); + p_theme->set_stylebox(SceneStringName(pressed), "EditorInspectorFlatButton", p_config.flat_button_pressed); + p_theme->set_stylebox("hover_pressed", "EditorInspectorFlatButton", p_config.flat_button_pressed); + p_theme->set_stylebox("disabled", "EditorInspectorFlatButton", p_config.base_empty_wide_style); + + // InspectorActionButton. + p_theme->set_type_variation("InspectorActionButton", "Button"); + p_theme->set_constant("h_separation", "InspectorActionButton", p_config.base_margin * 2 * EDSCALE); } // Animation Editor. @@ -2363,12 +2415,12 @@ void ThemeModern::populate_editor_styles(const Ref &p_theme, Editor p_theme->set_color("playback_color", "GraphStateMachine", p_config.font_color); p_theme->set_color("playback_background_color", "GraphStateMachine", p_config.font_color * Color(1, 1, 1, 0.3)); } - - // TileSet editor. - // This editor is using Tree panel for the panel container of expanded view, while the theme - // needs trees to be transparent, so it needs to have its own style. - Ref tile_expand_style = p_config.base_style->duplicate(); - tile_expand_style->set_corner_radius_all(0); - p_theme->set_stylebox("expand_panel", "TileSetEditor", tile_expand_style); } + + // TileSet editor. + // This editor is using Tree panel for the panel container of expanded view, while the theme + // needs trees to be transparent, so it needs to have its own style. + Ref tile_expand_style = p_config.base_style->duplicate(); + tile_expand_style->set_corner_radius_all(0); + p_theme->set_stylebox("expand_panel", "TileSetEditor", tile_expand_style); }