From f75cffcd46b72434effb5febc8cfa9d582bc761c Mon Sep 17 00:00:00 2001 From: Matt Enad Date: Wed, 21 Feb 2024 21:36:48 -0500 Subject: [PATCH] Fix hover style margin with extra borders enabled The content margins for FlatMenuButton and RunBarButton are now handled correctly when the "Draw Extra Borders" user option is enabled --- editor/themes/editor_theme_manager.cpp | 19 +++++++++++++------ .../GodotTools/GodotTools/GodotSharpEditor.cs | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/editor/themes/editor_theme_manager.cpp b/editor/themes/editor_theme_manager.cpp index 052b19478c7..9ffe80661bf 100644 --- a/editor/themes/editor_theme_manager.cpp +++ b/editor/themes/editor_theme_manager.cpp @@ -1683,10 +1683,14 @@ void EditorThemeManager::_populate_editor_styles(const Ref &p_theme Ref menu_transparent_style = p_config.button_style->duplicate(); menu_transparent_style->set_bg_color(Color(1, 1, 1, 0)); menu_transparent_style->set_border_width_all(0); + Ref main_screen_button_transparent = menu_transparent_style->duplicate(); + for (int i = 0; i < 4; i++) { + menu_transparent_style->set_content_margin((Side)i, p_config.button_style->get_margin((Side)i) + p_config.button_style->get_border_width((Side)i)); + } p_theme->set_stylebox("MenuTransparent", EditorStringName(EditorStyles), menu_transparent_style); p_theme->set_stylebox("MenuHover", EditorStringName(EditorStyles), p_config.button_style_hover); - p_theme->set_stylebox("normal", "MainScreenButton", menu_transparent_style); - p_theme->set_stylebox("pressed", "MainScreenButton", menu_transparent_style); + p_theme->set_stylebox("normal", "MainScreenButton", main_screen_button_transparent); + p_theme->set_stylebox("pressed", "MainScreenButton", main_screen_button_transparent); p_theme->set_stylebox("hover_pressed", "MainScreenButton", p_config.button_style_hover); // Run bar. @@ -1745,11 +1749,14 @@ void EditorThemeManager::_populate_editor_styles(const Ref &p_theme // Flat button variations. { Ref style_flat_button = make_empty_stylebox(); + Ref style_flat_button_hover = p_config.button_style_hover->duplicate(); + Ref style_flat_button_pressed = p_config.button_style_pressed->duplicate(); + for (int i = 0; i < 4; i++) { style_flat_button->set_content_margin((Side)i, p_config.button_style->get_margin((Side)i) + p_config.button_style->get_border_width((Side)i)); + style_flat_button_hover->set_content_margin((Side)i, p_config.button_style->get_margin((Side)i) + p_config.button_style->get_border_width((Side)i)); + style_flat_button_pressed->set_content_margin((Side)i, p_config.button_style->get_margin((Side)i) + p_config.button_style->get_border_width((Side)i)); } - - Ref style_flat_button_pressed = p_config.button_style_pressed->duplicate(); Color flat_pressed_color = p_config.dark_color_1.lightened(0.24).lerp(p_config.accent_color, 0.2) * Color(0.8, 0.8, 0.8, 0.85); if (p_config.dark_theme) { flat_pressed_color = p_config.dark_color_1.lerp(p_config.accent_color, 0.12) * Color(0.6, 0.6, 0.6, 0.85); @@ -1757,12 +1764,12 @@ void EditorThemeManager::_populate_editor_styles(const Ref &p_theme style_flat_button_pressed->set_bg_color(flat_pressed_color); p_theme->set_stylebox("normal", "FlatButton", style_flat_button); - p_theme->set_stylebox("hover", "FlatButton", p_config.button_style_hover); + p_theme->set_stylebox("hover", "FlatButton", style_flat_button_hover); p_theme->set_stylebox("pressed", "FlatButton", style_flat_button_pressed); p_theme->set_stylebox("disabled", "FlatButton", style_flat_button); p_theme->set_stylebox("normal", "FlatMenuButton", style_flat_button); - p_theme->set_stylebox("hover", "FlatMenuButton", p_config.button_style_hover); + p_theme->set_stylebox("hover", "FlatMenuButton", style_flat_button_hover); p_theme->set_stylebox("pressed", "FlatMenuButton", style_flat_button_pressed); p_theme->set_stylebox("disabled", "FlatMenuButton", style_flat_button); diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index b4adc94c642..bf6cab11c78 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -511,6 +511,7 @@ namespace GodotTools FocusMode = Control.FocusModeEnum.None, Shortcut = EditorDefShortcut("mono/build_solution", "Build Project".TTR(), (Key)KeyModifierMask.MaskAlt | Key.B), ShortcutInTooltip = true, + ThemeTypeVariation = "RunBarButton", }; EditorShortcutOverride("mono/build_solution", "macos", (Key)KeyModifierMask.MaskMeta | (Key)KeyModifierMask.MaskCtrl | Key.B);