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

Add hover highlight to main editor buttons #86378

Merged
merged 1 commit into from
Feb 20, 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
20 changes: 12 additions & 8 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand All @@ -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];
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_run_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions editor/filesystem_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions editor/gui/editor_run_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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."));
Expand All @@ -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."));
Expand All @@ -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);
Expand All @@ -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."));
Expand All @@ -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."));
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion editor/gui/editor_toaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
14 changes: 11 additions & 3 deletions editor/inspector_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
Expand Down Expand Up @@ -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));
Expand All @@ -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")));
Expand All @@ -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."));
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
12 changes: 7 additions & 5 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -4162,27 +4162,29 @@ 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"));
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_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
17 changes: 15 additions & 2 deletions editor/themes/editor_theme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public override void _EnablePlugin()

_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),
Expand Down
Loading