From 5b5de0e1676bb96c34e4e3cd51f912ac159519a8 Mon Sep 17 00:00:00 2001 From: Matt Enad Date: Wed, 20 Dec 2023 19:52:20 -0500 Subject: [PATCH] Add hover highlight to main editor buttons Updates styling of the editor run bar, plugin, bottom panel, icon buttons, and main menu buttons for accessibility. --- editor/editor_node.cpp | 20 +++++++++++-------- editor/editor_run_native.cpp | 2 ++ editor/filesystem_dock.cpp | 5 +++-- editor/gui/editor_run_bar.cpp | 12 +++++------ editor/gui/editor_toaster.cpp | 2 +- editor/inspector_dock.cpp | 14 ++++++++++--- .../animation_player_editor_plugin.cpp | 2 ++ editor/scene_tree_dock.cpp | 12 ++++++----- editor/themes/editor_theme_manager.cpp | 17 ++++++++++++++-- .../GodotTools/GodotTools/GodotSharpEditor.cs | 2 +- 10 files changed, 60 insertions(+), 28 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 827e2c7bf68..75062e49334 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -511,8 +511,9 @@ void EditorNode::_update_theme(bool p_skip_creation) { scene_root_parent->add_theme_style_override("panel", theme->get_stylebox(SNAME("Content"), EditorStringName(EditorStyles))); bottom_panel->add_theme_style_override("panel", theme->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))); - main_menu->add_theme_style_override("hover", theme->get_stylebox(SNAME("MenuHover"), EditorStringName(EditorStyles))); + main_menu->add_theme_style_override("pressed", theme->get_stylebox(SNAME("MenuTransparent"), EditorStringName(EditorStyles))); distraction_free->set_icon(theme->get_icon(SNAME("DistractionFree"), EditorStringName(EditorIcons))); + distraction_free->add_theme_style_override("pressed", theme->get_stylebox(SNAME("MenuTransparent"), EditorStringName(EditorStyles))); bottom_panel_raise->set_icon(theme->get_icon(SNAME("ExpandBottomDock"), EditorStringName(EditorIcons))); help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), theme->get_icon(SNAME("HelpSearch"), EditorStringName(EditorIcons))); @@ -530,6 +531,11 @@ void EditorNode::_update_theme(bool p_skip_creation) { bottom_panel->add_theme_style_override("panel", theme->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))); } + for (int i = 0; i < bottom_panel_items.size(); i++) { + bottom_panel_items.write[i].button->add_theme_style_override("pressed", theme->get_stylebox(SNAME("MenuTransparent"), EditorStringName(EditorStyles))); + bottom_panel_items.write[i].button->add_theme_style_override("hover_pressed", theme->get_stylebox(SNAME("MenuHover"), EditorStringName(EditorStyles))); + } + for (int i = 0; i < main_editor_buttons.size(); i++) { Button *tb = main_editor_buttons[i]; EditorPlugin *p_editor = editor_table[i]; @@ -3293,7 +3299,6 @@ void EditorNode::select_editor_by_name(const String &p_name) { void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) { if (p_editor->has_main_screen()) { Button *tb = memnew(Button); - tb->set_flat(true); tb->set_toggle_mode(true); tb->set_theme_type_variation("MainScreenButton"); tb->set_name(p_editor->get_name()); @@ -5188,7 +5193,7 @@ void EditorNode::_scene_tab_closed(int p_tab) { Button *EditorNode::add_bottom_panel_item(String p_text, Control *p_item, bool p_at_front) { Button *tb = memnew(Button); - tb->set_flat(true); + tb->set_theme_type_variation("FlatMenuButton"); tb->connect("toggled", callable_mp(this, &EditorNode::_bottom_panel_switch_by_control).bind(p_item)); tb->set_drag_forwarding(Callable(), callable_mp(this, &EditorNode::_bottom_panel_drag_hover).bind(tb, p_item), Callable()); tb->set_text(p_text); @@ -6661,7 +6666,7 @@ EditorNode::EditorNode() { scene_tabs->connect("tab_closed", callable_mp(this, &EditorNode::_scene_tab_closed)); distraction_free = memnew(Button); - distraction_free->set_flat(true); + distraction_free->set_theme_type_variation("FlatMenuButton"); ED_SHORTCUT_AND_COMMAND("editor/distraction_free_mode", TTR("Distraction Free Mode"), KeyModifierMask::CTRL | KeyModifierMask::SHIFT | Key::F11); ED_SHORTCUT_OVERRIDE("editor/distraction_free_mode", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::D); distraction_free->set_shortcut(ED_GET_SHORTCUT("editor/distraction_free_mode")); @@ -6701,9 +6706,7 @@ EditorNode::EditorNode() { main_menu = memnew(MenuBar); title_bar->add_child(main_menu); - - main_menu->add_theme_style_override("hover", theme->get_stylebox(SNAME("MenuHover"), EditorStringName(EditorStyles))); - main_menu->set_flat(true); + main_menu->set_theme_type_variation("FlatMenuButton"); main_menu->set_start_index(0); // Main menu, add to the start of global menu. main_menu->set_prefer_global_menu(global_menu); main_menu->set_switch_on_hover(true); @@ -7169,7 +7172,8 @@ EditorNode::EditorNode() { bottom_panel_raise = memnew(Button); bottom_panel_hb->add_child(bottom_panel_raise); bottom_panel_raise->hide(); - bottom_panel_raise->set_flat(true); + bottom_panel_raise->set_flat(false); + bottom_panel_raise->set_theme_type_variation("FlatMenuButton"); bottom_panel_raise->set_toggle_mode(true); bottom_panel_raise->set_shortcut(ED_SHORTCUT_AND_COMMAND("editor/bottom_panel_expand", TTR("Expand Bottom Panel"), KeyModifierMask::SHIFT | Key::F12)); bottom_panel_raise->connect("toggled", callable_mp(this, &EditorNode::_bottom_panel_raise_toggled)); diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index fd6b083c120..a380ebd4ad4 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -157,6 +157,8 @@ bool EditorRunNative::is_deploy_debug_remote_enabled() const { EditorRunNative::EditorRunNative() { remote_debug = memnew(MenuButton); + remote_debug->set_flat(false); + remote_debug->set_theme_type_variation("RunBarButton"); remote_debug->get_popup()->connect("id_pressed", callable_mp(this, &EditorRunNative::start_run_native)); remote_debug->set_tooltip_text(TTR("Remote Debug")); remote_debug->set_disabled(true); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 02ae15b80d9..44e2cd8fcd6 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -3598,7 +3598,8 @@ Dictionary FileSystemDock::get_assigned_folder_colors() const { MenuButton *FileSystemDock::_create_file_menu_button() { MenuButton *button = memnew(MenuButton); - button->set_flat(true); + button->set_flat(false); + button->set_theme_type_variation("FlatMenuButton"); button->set_tooltip_text(TTR("Sort Files")); PopupMenu *p = button->get_popup(); @@ -3812,7 +3813,7 @@ FileSystemDock::FileSystemDock() { button_toggle_display_mode->connect("pressed", callable_mp(this, &FileSystemDock::_change_split_mode)); button_toggle_display_mode->set_focus_mode(FOCUS_NONE); button_toggle_display_mode->set_tooltip_text(TTR("Change Split Mode")); - button_toggle_display_mode->set_flat(true); + button_toggle_display_mode->set_theme_type_variation("FlatMenuButton"); toolbar_hbc->add_child(button_toggle_display_mode); button_dock_placement = memnew(Button); diff --git a/editor/gui/editor_run_bar.cpp b/editor/gui/editor_run_bar.cpp index a79dced69e7..a44dfc98589 100644 --- a/editor/gui/editor_run_bar.cpp +++ b/editor/gui/editor_run_bar.cpp @@ -372,7 +372,7 @@ EditorRunBar::EditorRunBar() { play_button = memnew(Button); main_hbox->add_child(play_button); - play_button->set_flat(true); + play_button->set_theme_type_variation("RunBarButton"); play_button->set_toggle_mode(true); play_button->set_focus_mode(Control::FOCUS_NONE); play_button->set_tooltip_text(TTR("Run the project's default scene.")); @@ -384,7 +384,7 @@ EditorRunBar::EditorRunBar() { pause_button = memnew(Button); main_hbox->add_child(pause_button); - pause_button->set_flat(true); + pause_button->set_theme_type_variation("RunBarButton"); pause_button->set_toggle_mode(true); pause_button->set_focus_mode(Control::FOCUS_NONE); pause_button->set_tooltip_text(TTR("Pause the running project's execution for debugging.")); @@ -396,7 +396,7 @@ EditorRunBar::EditorRunBar() { stop_button = memnew(Button); main_hbox->add_child(stop_button); - stop_button->set_flat(true); + stop_button->set_theme_type_variation("RunBarButton"); stop_button->set_focus_mode(Control::FOCUS_NONE); stop_button->set_tooltip_text(TTR("Stop the currently running project.")); stop_button->set_disabled(true); @@ -412,7 +412,7 @@ EditorRunBar::EditorRunBar() { play_scene_button = memnew(Button); main_hbox->add_child(play_scene_button); - play_scene_button->set_flat(true); + play_scene_button->set_theme_type_variation("RunBarButton"); play_scene_button->set_toggle_mode(true); play_scene_button->set_focus_mode(Control::FOCUS_NONE); play_scene_button->set_tooltip_text(TTR("Run the currently edited scene.")); @@ -424,7 +424,7 @@ EditorRunBar::EditorRunBar() { play_custom_scene_button = memnew(Button); main_hbox->add_child(play_custom_scene_button); - play_custom_scene_button->set_flat(true); + play_custom_scene_button->set_theme_type_variation("RunBarButton"); play_custom_scene_button->set_toggle_mode(true); play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE); play_custom_scene_button->set_tooltip_text(TTR("Run a specific scene.")); @@ -439,7 +439,7 @@ EditorRunBar::EditorRunBar() { write_movie_button = memnew(Button); write_movie_panel->add_child(write_movie_button); - write_movie_button->set_flat(true); + write_movie_button->set_theme_type_variation("RunBarButton"); write_movie_button->set_toggle_mode(true); write_movie_button->set_pressed(false); write_movie_button->set_focus_mode(Control::FOCUS_NONE); diff --git a/editor/gui/editor_toaster.cpp b/editor/gui/editor_toaster.cpp index 48e1c56e831..69a129e73ca 100644 --- a/editor/gui/editor_toaster.cpp +++ b/editor/gui/editor_toaster.cpp @@ -543,7 +543,7 @@ EditorToaster::EditorToaster() { main_button->set_tooltip_text(TTR("No notifications.")); main_button->set_modulate(Color(0.5, 0.5, 0.5)); main_button->set_disabled(true); - main_button->set_flat(true); + main_button->set_theme_type_variation("FlatMenuButton"); main_button->connect("pressed", callable_mp(this, &EditorToaster::_set_notifications_enabled).bind(true)); main_button->connect("pressed", callable_mp(this, &EditorToaster::_repop_old)); main_button->connect("draw", callable_mp(this, &EditorToaster::_draw_button)); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index d5be2bd5a97..8a7eb802815 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -646,20 +646,22 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) { add_child(general_options_hb); resource_new_button = memnew(Button); - resource_new_button->set_flat(true); + resource_new_button->set_theme_type_variation("FlatMenuButton"); resource_new_button->set_tooltip_text(TTR("Create a new resource in memory and edit it.")); general_options_hb->add_child(resource_new_button); resource_new_button->connect("pressed", callable_mp(this, &InspectorDock::_new_resource)); resource_new_button->set_focus_mode(Control::FOCUS_NONE); resource_load_button = memnew(Button); - resource_load_button->set_flat(true); + resource_load_button->set_theme_type_variation("FlatMenuButton"); resource_load_button->set_tooltip_text(TTR("Load an existing resource from disk and edit it.")); general_options_hb->add_child(resource_load_button); resource_load_button->connect("pressed", callable_mp(this, &InspectorDock::_open_resource_selector)); resource_load_button->set_focus_mode(Control::FOCUS_NONE); resource_save_button = memnew(MenuButton); + resource_save_button->set_flat(false); + resource_save_button->set_theme_type_variation("FlatMenuButton"); resource_save_button->set_tooltip_text(TTR("Save the currently edited resource.")); general_options_hb->add_child(resource_save_button); resource_save_button->get_popup()->add_item(TTR("Save"), RESOURCE_SAVE); @@ -669,6 +671,8 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) { resource_save_button->set_disabled(true); resource_extra_button = memnew(MenuButton); + resource_extra_button->set_flat(false); + resource_extra_button->set_theme_type_variation("FlatMenuButton"); resource_extra_button->set_tooltip_text(TTR("Extra resource options.")); general_options_hb->add_child(resource_extra_button); resource_extra_button->connect("about_to_popup", callable_mp(this, &InspectorDock::_prepare_resource_extra_popup)); @@ -698,6 +702,8 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) { forward_button->connect("pressed", callable_mp(this, &InspectorDock::_edit_forward)); history_menu = memnew(MenuButton); + history_menu->set_flat(false); + history_menu->set_theme_type_variation("FlatMenuButton"); history_menu->set_tooltip_text(TTR("History of recently edited objects.")); general_options_hb->add_child(history_menu); history_menu->connect("about_to_popup", callable_mp(this, &InspectorDock::_prepare_history)); @@ -710,7 +716,7 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) { subresource_hb->add_child(object_selector); open_docs_button = memnew(Button); - open_docs_button->set_flat(true); + open_docs_button->set_theme_type_variation("FlatMenuButton"); open_docs_button->set_disabled(true); open_docs_button->set_tooltip_text(TTR("Open documentation for this object.")); open_docs_button->set_shortcut(ED_SHORTCUT("property_editor/open_help", TTR("Open Documentation"))); @@ -732,6 +738,8 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) { property_tools_hb->add_child(search); object_menu = memnew(MenuButton); + object_menu->set_flat(false); + object_menu->set_theme_type_variation("FlatMenuButton"); object_menu->set_shortcut_context(this); property_tools_hb->add_child(object_menu); object_menu->set_tooltip_text(TTR("Manage object properties.")); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index b08d2e966d6..62bb3f3ff9b 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1908,6 +1908,8 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug hb->add_child(onion_toggle); onion_skinning = memnew(MenuButton); + onion_skinning->set_flat(false); + onion_skinning->set_theme_type_variation("FlatMenuButton"); onion_skinning->set_tooltip_text(TTR("Onion Skinning Options")); onion_skinning->get_popup()->add_separator(TTR("Directions")); // TRANSLATORS: Opposite of "Future", refers to a direction in animation onion skinning. diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 413281ad081..52a97bd11df 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -4135,14 +4135,14 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec ED_SHORTCUT("scene_tree/delete", TTR("Delete"), Key::KEY_DELETE); button_add = memnew(Button); - button_add->set_flat(true); + button_add->set_theme_type_variation("FlatMenuButton"); button_add->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(TOOL_NEW, false)); button_add->set_tooltip_text(TTR("Add/Create a New Node.")); button_add->set_shortcut(ED_GET_SHORTCUT("scene_tree/add_child_node")); filter_hbc->add_child(button_add); button_instance = memnew(Button); - button_instance->set_flat(true); + button_instance->set_theme_type_variation("FlatMenuButton"); button_instance->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(TOOL_INSTANTIATE, false)); button_instance->set_tooltip_text(TTR("Instantiate a scene file as a Node. Creates an inherited scene if no root node exists.")); button_instance->set_shortcut(ED_GET_SHORTCUT("scene_tree/instantiate_scene")); @@ -4162,11 +4162,12 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec _append_filter_options_to(filter->get_menu()); filter_quick_menu = memnew(PopupMenu); + filter_quick_menu->set_theme_type_variation("FlatMenuButton"); filter_quick_menu->connect("id_pressed", callable_mp(this, &SceneTreeDock::_filter_option_selected)); filter->add_child(filter_quick_menu); button_create_script = memnew(Button); - button_create_script->set_flat(true); + button_create_script->set_theme_type_variation("FlatMenuButton"); button_create_script->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(TOOL_ATTACH_SCRIPT, false)); button_create_script->set_tooltip_text(TTR("Attach a new or existing script to the selected node.")); button_create_script->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script")); @@ -4174,7 +4175,7 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec button_create_script->hide(); button_detach_script = memnew(Button); - button_detach_script->set_flat(true); + button_detach_script->set_theme_type_variation("FlatMenuButton"); button_detach_script->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(TOOL_DETACH_SCRIPT, false)); button_detach_script->set_tooltip_text(TTR("Detach the script from the selected node.")); button_detach_script->set_shortcut(ED_GET_SHORTCUT("scene_tree/detach_script")); @@ -4182,7 +4183,8 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec button_detach_script->hide(); button_tree_menu = memnew(MenuButton); - button_tree_menu->set_flat(true); + button_tree_menu->set_flat(false); + button_tree_menu->set_theme_type_variation("FlatMenuButton"); button_tree_menu->set_tooltip_text(TTR("Extra scene options.")); button_tree_menu->connect("about_to_popup", callable_mp(this, &SceneTreeDock::_update_tree_menu)); filter_hbc->add_child(button_tree_menu); diff --git a/editor/themes/editor_theme_manager.cpp b/editor/themes/editor_theme_manager.cpp index 479a3ebc87c..efff12c9f28 100644 --- a/editor/themes/editor_theme_manager.cpp +++ b/editor/themes/editor_theme_manager.cpp @@ -681,6 +681,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref &p_the p_theme->set_color("icon_normal_color", "Button", p_config.icon_normal_color); p_theme->set_color("icon_hover_color", "Button", p_config.icon_hover_color); p_theme->set_color("icon_focus_color", "Button", p_config.icon_focus_color); + p_theme->set_color("icon_hover_pressed_color", "Button", p_config.icon_pressed_color); p_theme->set_color("icon_pressed_color", "Button", p_config.icon_pressed_color); p_theme->set_color("icon_disabled_color", "Button", p_config.icon_disabled_color); @@ -1679,7 +1680,19 @@ void EditorThemeManager::_populate_editor_styles(const Ref &p_theme p_theme->set_stylebox("BottomPanel", EditorStringName(EditorStyles), style_bottom_panel); // Main menu. + 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); + 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("hover_pressed", "MainScreenButton", p_config.button_style_hover); + + // Run bar. + p_theme->set_type_variation("RunBarButton", "FlatMenuButton"); + p_theme->set_stylebox("disabled", "RunBarButton", menu_transparent_style); + p_theme->set_stylebox("pressed", "RunBarButton", menu_transparent_style); } // Editor GUI widgets. @@ -1744,12 +1757,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", style_flat_button); + p_theme->set_stylebox("hover", "FlatButton", p_config.button_style_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", style_flat_button); + p_theme->set_stylebox("hover", "FlatMenuButton", p_config.button_style_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 44422eb8628..6c8b9b099c3 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -509,7 +509,7 @@ namespace GodotTools _toolBarBuildButton = new Button { - Flat = true, + Flat = false, Icon = EditorInterface.Singleton.GetEditorTheme().GetIcon("BuildCSharp", "EditorIcons"), FocusMode = Control.FocusModeEnum.None, Shortcut = EditorDefShortcut("mono/build_solution", "Build Project".TTR(), (Key)KeyModifierMask.MaskAlt | Key.B),