Skip to content

Commit

Permalink
Add hover highlight to main editor buttons
Browse files Browse the repository at this point in the history
Updates styling of the editor run bar, plugin, bottom panel, icon buttons, and main menu buttons for accessibility.
  • Loading branch information
RobProductions committed Jan 30, 2024
1 parent 313f623 commit e6b0220
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 26 deletions.
26 changes: 21 additions & 5 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ void EditorNode::_update_theme(bool p_skip_creation) {
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)));
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)));
Expand All @@ -521,10 +522,21 @@ void EditorNode::_update_theme(bool p_skip_creation) {
help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), theme->get_icon(SNAME("Godot"), EditorStringName(EditorIcons)));
help_menu->set_item_icon(help_menu->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), theme->get_icon(SNAME("Heart"), EditorStringName(EditorIcons)));

for (int i = 0; i < main_editor_buttons.size(); i++) {
main_editor_buttons.write[i]->add_theme_style_override("normal", theme->get_stylebox(SNAME("MenuTransparent"), EditorStringName(EditorStyles)));
main_editor_buttons.write[i]->add_theme_style_override("pressed", theme->get_stylebox(SNAME("MenuTransparent"), EditorStringName(EditorStyles)));
main_editor_buttons.write[i]->add_theme_style_override("hover_pressed", theme->get_stylebox(SNAME("MenuHover"), EditorStringName(EditorStyles)));
}

if (EditorDebuggerNode::get_singleton()->is_visible()) {
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];
Expand Down Expand Up @@ -3275,7 +3287,7 @@ 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_flat(false);
tb->set_toggle_mode(true);
tb->set_theme_type_variation("MainScreenButton");
tb->set_name(p_editor->get_name());
Expand Down Expand Up @@ -5176,7 +5188,8 @@ class EditorBottomDockButton : public Button {

Button *EditorNode::add_bottom_panel_item(String p_text, Control *p_item, bool p_at_front) {
Button *tb = memnew(EditorBottomDockButton);
tb->set_flat(true);
tb->set_flat(false);
tb->set_theme_type_variation("FlatMenuButton");
tb->connect("toggled", callable_mp(this, &EditorNode::_bottom_panel_switch_by_control).bind(p_item));
tb->connect("dropping", callable_mp(this, &EditorNode::_bottom_panel_switch_by_control).bind(true, p_item));
tb->set_text(p_text);
Expand Down Expand Up @@ -6643,7 +6656,8 @@ 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_flat(false);
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"));
Expand Down Expand Up @@ -6684,8 +6698,9 @@ EditorNode::EditorNode() {
main_menu = memnew(MenuBar);
title_bar->add_child(main_menu);

main_menu->add_theme_style_override("normal", theme->get_stylebox(SNAME("MenuTransparent"), EditorStringName(EditorStyles)));
main_menu->add_theme_style_override("pressed", theme->get_stylebox(SNAME("MenuTransparent"), EditorStringName(EditorStyles)));
main_menu->add_theme_style_override("hover", theme->get_stylebox(SNAME("MenuHover"), EditorStringName(EditorStyles)));
main_menu->set_flat(true);
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);
Expand Down Expand Up @@ -7151,7 +7166,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));
Expand Down
3 changes: 3 additions & 0 deletions editor/editor_run_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ void EditorRunNative::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
remote_debug->set_icon(get_editor_theme_icon(SNAME("PlayRemote")));
remote_debug->add_theme_style_override("disabled", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
remote_debug->add_theme_style_override("pressed", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
} break;

case NOTIFICATION_PROCESS: {
Expand Down Expand Up @@ -157,6 +159,7 @@ bool EditorRunNative::is_deploy_debug_remote_enabled() const {

EditorRunNative::EditorRunNative() {
remote_debug = memnew(MenuButton);
remote_debug->set_flat(false);
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);
Expand Down
6 changes: 4 additions & 2 deletions editor/filesystem_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3603,7 +3603,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();
Expand Down Expand Up @@ -3817,7 +3818,8 @@ 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_flat(false);
button_toggle_display_mode->set_theme_type_variation("FlatMenuButton");
toolbar_hbc->add_child(button_toggle_display_mode);

button_dock_placement = memnew(Button);
Expand Down
24 changes: 18 additions & 6 deletions editor/gui/editor_run_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,20 @@ void EditorRunBar::_notification(int p_what) {

case NOTIFICATION_THEME_CHANGED: {
_update_play_buttons();
play_button->add_theme_style_override("disabled", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
play_button->add_theme_style_override("pressed", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
pause_button->set_icon(get_editor_theme_icon(SNAME("Pause")));
pause_button->add_theme_style_override("disabled", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
pause_button->add_theme_style_override("pressed", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
stop_button->set_icon(get_editor_theme_icon(SNAME("Stop")));
stop_button->add_theme_style_override("disabled", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
stop_button->add_theme_style_override("pressed", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
play_scene_button->add_theme_style_override("disabled", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
play_scene_button->add_theme_style_override("pressed", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
play_custom_scene_button->add_theme_style_override("disabled", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
play_custom_scene_button->add_theme_style_override("pressed", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
write_movie_button->add_theme_style_override("disabled", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));
write_movie_button->add_theme_style_override("pressed", get_theme_stylebox(SNAME("normal"), "FlatMenuButton"));

if (is_movie_maker_enabled()) {
main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadMovieMode"), EditorStringName(EditorStyles)));
Expand Down Expand Up @@ -372,7 +384,7 @@ EditorRunBar::EditorRunBar() {

play_button = memnew(Button);
main_hbox->add_child(play_button);
play_button->set_flat(true);
play_button->set_flat(false);
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."));
Expand All @@ -384,7 +396,7 @@ EditorRunBar::EditorRunBar() {

pause_button = memnew(Button);
main_hbox->add_child(pause_button);
pause_button->set_flat(true);
pause_button->set_flat(false);
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."));
Expand All @@ -396,7 +408,7 @@ EditorRunBar::EditorRunBar() {

stop_button = memnew(Button);
main_hbox->add_child(stop_button);
stop_button->set_flat(true);
stop_button->set_flat(false);
stop_button->set_focus_mode(Control::FOCUS_NONE);
stop_button->set_tooltip_text(TTR("Stop the currently running project."));
stop_button->set_disabled(true);
Expand All @@ -412,7 +424,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_flat(false);
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."));
Expand All @@ -424,7 +436,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_flat(false);
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."));
Expand All @@ -439,7 +451,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_flat(false);
write_movie_button->set_toggle_mode(true);
write_movie_button->set_pressed(false);
write_movie_button->set_focus_mode(Control::FOCUS_NONE);
Expand Down
3 changes: 2 additions & 1 deletion editor/gui/editor_toaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ 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_flat(false);
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));
Expand Down
17 changes: 14 additions & 3 deletions editor/inspector_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,20 +646,24 @@ 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_flat(false);
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_flat(false);
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);
Expand All @@ -669,6 +673,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));
Expand Down Expand Up @@ -698,6 +704,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));
Expand All @@ -710,7 +718,8 @@ 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_flat(false);
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")));
Expand All @@ -732,6 +741,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."));
Expand Down
2 changes: 2 additions & 0 deletions editor/plugins/animation_player_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 11 additions & 5 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4140,14 +4140,16 @@ 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_flat(false);
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_flat(false);
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"));
Expand All @@ -4167,27 +4169,31 @@ 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_flat(false);
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"));
filter_hbc->add_child(button_create_script);
button_create_script->hide();

button_detach_script = memnew(Button);
button_detach_script->set_flat(true);
button_detach_script->set_flat(false);
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"));
filter_hbc->add_child(button_detach_script);
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);
Expand Down
Loading

0 comments on commit e6b0220

Please sign in to comment.