Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix editor hover style margins when Draw Extra Borders is enabled #88652

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions editor/themes/editor_theme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,10 +1683,14 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
Ref<StyleBoxFlat> 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<StyleBoxFlat> 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.
Expand Down Expand Up @@ -1745,24 +1749,27 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
// Flat button variations.
{
Ref<StyleBoxEmpty> style_flat_button = make_empty_stylebox();
Ref<StyleBoxFlat> style_flat_button_hover = p_config.button_style_hover->duplicate();
Ref<StyleBoxFlat> 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<StyleBoxFlat> 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);
}
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ public override void _EnablePlugin()
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);

Expand Down
Loading