Merge pull request #86378 from RobProductions/update-hover-styling

Add hover highlight to main editor buttons
This commit is contained in:
Rémi Verschelde 2024-02-20 19:34:40 +01:00
commit 9e9dcdbba4
No known key found for this signature in database
GPG key ID: C3336907360768E1
10 changed files with 60 additions and 28 deletions

View file

@ -515,8 +515,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)));
@ -528,6 +529,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];
@ -3346,7 +3352,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());
@ -5241,7 +5246,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);
@ -6686,7 +6691,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"));
@ -6726,9 +6731,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);
@ -7194,7 +7197,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));

View file

@ -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);

View file

@ -3607,7 +3607,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();
@ -3821,7 +3822,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);

View file

@ -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);

View file

@ -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));

View file

@ -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."));

View file

@ -1911,6 +1911,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.

View file

@ -4192,14 +4192,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"));
@ -4219,11 +4219,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"));
@ -4231,7 +4232,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"));
@ -4239,7 +4240,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);

View file

@ -681,6 +681,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &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<EditorTheme> &p_theme
p_theme->set_stylebox("BottomPanel", EditorStringName(EditorStyles), style_bottom_panel);
// Main menu.
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);
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<EditorTheme> &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);

View file

@ -505,7 +505,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),