1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-31 18:41:20 +00:00

Merge pull request #112615 from YeldhamDev/inspector_props_size_fix

Fix issues with property height in the inspector
This commit is contained in:
Rémi Verschelde
2025-12-04 15:52:40 +01:00
14 changed files with 171 additions and 93 deletions

View File

@@ -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<EditorTheme> EditorThemeManager::_create_base_theme(const Ref<EditorTheme> &
OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Create Base Theme");
Ref<EditorTheme> 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<EditorTheme> EditorThemeManager::_create_base_theme(const Ref<EditorTheme> &
return theme;
}
EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(const Ref<EditorTheme> &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;

View File

@@ -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<EditorTheme> _create_base_theme(const Ref<EditorTheme> &p_old_theme = nullptr);
static ThemeConfiguration _create_theme_config(const Ref<EditorTheme> &p_theme);
static ThemeConfiguration _create_theme_config();
static void _populate_text_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config);
static void _populate_visual_shader_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config);

View File

@@ -225,7 +225,6 @@ void ThemeClassic::populate_shared_styles(const Ref<EditorTheme> &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);
@@ -1998,8 +1997,13 @@ void ThemeClassic::populate_editor_styles(const Ref<EditorTheme> &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.
@@ -2015,7 +2019,6 @@ void ThemeClassic::populate_editor_styles(const Ref<EditorTheme> &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);
@@ -2032,6 +2035,13 @@ void ThemeClassic::populate_editor_styles(const Ref<EditorTheme> &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<StyleBoxFlat> inspector_button_style = p_theme->get_stylebox(CoreStringName(normal), SNAME("Button"));
Ref<Font> 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);
@@ -2392,8 +2402,8 @@ void ThemeClassic::populate_editor_styles(const Ref<EditorTheme> &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);
}

View File

@@ -247,7 +247,6 @@ void ThemeModern::populate_shared_styles(const Ref<EditorTheme> &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<EditorTheme> &p_theme, Edit
// CheckBox.
{
Ref<StyleBoxFlat> checkbox_style = p_config.panel_container_style->duplicate();
Ref<StyleBoxFlat> 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<StyleBoxFlat> 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<EditorTheme> &p_theme, Edit
{
Ref<StyleBoxFlat> 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);
@@ -1860,14 +1859,6 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &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<EditorTheme> &p_theme, Editor
// Panel.
p_theme->set_stylebox(SceneStringName(panel), "EditorInspector", p_config.base_empty_style);
// 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<EditorTheme> &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<EditorTheme> &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<StyleBoxFlat> style_line = p_theme->get_stylebox(CoreStringName(normal), SNAME("LineEdit"));
float vertical_margin = style_line->get_content_margin(SIDE_TOP);
Ref<StyleBoxFlat> 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<StyleBoxFlat> 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<StyleBoxFlat> 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<StyleBoxFlat> 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<StyleBoxFlat> inspector_button_style = p_theme->get_stylebox(CoreStringName(normal), SNAME("EditorInspectorButton"));
Ref<Font> 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<StyleBoxFlat> 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<StyleBoxFlat> 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<EditorTheme> &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<StyleBoxFlat> 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<StyleBoxFlat> 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);
}