Skip to content

Commit 24d442d

Browse files
committed
Add icons to certain menu bar items
1 parent f9a8302 commit 24d442d

3 files changed

Lines changed: 71 additions & 34 deletions

File tree

editor/editor_node.cpp

Lines changed: 65 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,45 @@ void EditorNode::_propagate_translation_notification() {
684684
scene_root->propagate_notification(NOTIFICATION_TRANSLATION_CHANGED);
685685
}
686686

687+
void EditorNode::_update_system_menu_icons(bool dark_mode) {
688+
file_menu->set_item_icon(file_menu->get_item_index(SCENE_NEW_SCENE), get_editor_theme_native_menu_icon(SNAME("CreateNewSceneFrom"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
689+
file_menu->set_item_icon(file_menu->get_item_index(SCENE_OPEN_SCENE), get_editor_theme_native_menu_icon(SNAME("PackedScene"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
690+
file_menu->set_item_icon(file_menu->get_item_index(SCENE_SAVE_SCENE), get_editor_theme_native_menu_icon(SNAME("Save"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
691+
file_menu->set_item_icon(file_menu->get_item_index(SCENE_QUICK_OPEN), get_editor_theme_native_menu_icon(SNAME("Load"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
692+
file_menu->set_item_icon(file_menu->get_item_index(SCENE_UNDO), get_editor_theme_native_menu_icon(SNAME("RotateLeft"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
693+
file_menu->set_item_icon(file_menu->get_item_index(SCENE_CLOSE), get_editor_theme_native_menu_icon(SNAME("CloseScene"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
694+
#ifdef MACOS_ENABLED
695+
if (menu_type != MENU_TYPE_GLOBAL) {
696+
file_menu->set_item_icon(file_menu->get_item_index(SCENE_QUIT), get_editor_theme_native_menu_icon(SNAME("Close"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
697+
}
698+
#else
699+
file_menu->set_item_icon(file_menu->get_item_index(SCENE_QUIT), get_editor_theme_native_menu_icon(SNAME("Close"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
700+
#endif
701+
702+
project_menu->set_item_icon(project_menu->get_item_index(PROJECT_OPEN_SETTINGS), get_editor_theme_native_menu_icon(SNAME("ClassList"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
703+
project_menu->set_item_icon(project_menu->get_item_index(PROJECT_EXPORT), get_editor_theme_native_menu_icon(SNAME("ResourcePreloader"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
704+
project_menu->set_item_icon(project_menu->get_item_index(PROJECT_QUIT_TO_PROJECT_MANAGER), get_editor_theme_native_menu_icon(SNAME("Close"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
705+
706+
#ifdef MACOS_ENABLED
707+
if (menu_type != MENU_TYPE_GLOBAL) {
708+
settings_menu->set_item_icon(settings_menu->get_item_index(EDITOR_OPEN_SETTINGS), get_editor_theme_native_menu_icon(SNAME("Tools"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
709+
}
710+
#else
711+
settings_menu->set_item_icon(settings_menu->get_item_index(EDITOR_OPEN_SETTINGS), get_editor_theme_native_menu_icon(SNAME("Tools"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
712+
#endif
713+
714+
help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), get_editor_theme_native_menu_icon(SNAME("HelpSearch"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
715+
help_menu->set_item_icon(help_menu->get_item_index(HELP_COPY_SYSTEM_INFO), get_editor_theme_native_menu_icon(SNAME("ActionCopy"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
716+
#ifdef MACOS_ENABLED
717+
if (menu_type != MENU_TYPE_GLOBAL) {
718+
help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), get_editor_theme_native_menu_icon(SNAME("Godot"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
719+
}
720+
#else
721+
help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), get_editor_theme_native_menu_icon(SNAME("Godot"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
722+
#endif
723+
help_menu->set_item_icon(help_menu->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), get_editor_theme_native_menu_icon(SNAME("Heart"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
724+
}
725+
687726
void EditorNode::_update_theme(bool p_skip_creation) {
688727
if (!p_skip_creation) {
689728
theme = EditorThemeManager::generate_theme(theme);
@@ -740,10 +779,7 @@ void EditorNode::_update_theme(bool p_skip_creation) {
740779
distraction_free->set_button_icon(theme->get_icon(SNAME("DistractionFree"), EditorStringName(EditorIcons)));
741780
update_distraction_free_button_theme();
742781

743-
help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), get_editor_theme_native_menu_icon(SNAME("HelpSearch"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
744-
help_menu->set_item_icon(help_menu->get_item_index(HELP_COPY_SYSTEM_INFO), get_editor_theme_native_menu_icon(SNAME("ActionCopy"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
745-
help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), get_editor_theme_native_menu_icon(SNAME("Godot"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
746-
help_menu->set_item_icon(help_menu->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), get_editor_theme_native_menu_icon(SNAME("Heart"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
782+
_update_system_menu_icons(dark_mode);
747783

748784
_update_renderer_color();
749785
}
@@ -4019,10 +4055,8 @@ void EditorNode::_check_system_theme_changed() {
40194055
// Update system menus.
40204056
bool dark_mode = DisplayServer::get_singleton()->is_dark_mode();
40214057

4022-
help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), get_editor_theme_native_menu_icon(SNAME("HelpSearch"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
4023-
help_menu->set_item_icon(help_menu->get_item_index(HELP_COPY_SYSTEM_INFO), get_editor_theme_native_menu_icon(SNAME("ActionCopy"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
4024-
help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), get_editor_theme_native_menu_icon(SNAME("Godot"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
4025-
help_menu->set_item_icon(help_menu->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), get_editor_theme_native_menu_icon(SNAME("Heart"), menu_type == MENU_TYPE_GLOBAL, dark_mode));
4058+
_update_system_menu_icons(dark_mode);
4059+
40264060
editor_dock_manager->update_docks_menu();
40274061
}
40284062
}
@@ -7898,15 +7932,15 @@ void EditorNode::set_unfocused_low_processor_usage_mode_enabled(bool p_enabled)
78987932
unfocused_low_processor_usage_mode_enabled = p_enabled;
78997933
}
79007934

7901-
void EditorNode::_build_file_menu() {
7935+
void EditorNode::_build_file_menu(bool dark_mode) {
79027936
if (!file_menu) {
79037937
return;
79047938
}
79057939
file_menu->clear(false);
79067940

7907-
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/new_scene"), SCENE_NEW_SCENE);
7941+
file_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("CreateNewSceneFrom"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/new_scene"), SCENE_NEW_SCENE);
79087942
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/new_inherited_scene"), SCENE_NEW_INHERITED_SCENE);
7909-
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/open_scene"), SCENE_OPEN_SCENE);
7943+
file_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("PackedScene"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/open_scene"), SCENE_OPEN_SCENE);
79107944
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/reopen_closed_scene"), SCENE_OPEN_PREV);
79117945
if (!recent_scenes) {
79127946
recent_scenes = memnew(PopupMenu);
@@ -7916,12 +7950,12 @@ void EditorNode::_build_file_menu() {
79167950
file_menu->add_submenu_node_item(TTRC("Open Recent"), recent_scenes, SCENE_OPEN_RECENT);
79177951
file_menu->add_separator();
79187952

7919-
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/save_scene"), SCENE_SAVE_SCENE);
7953+
file_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("Save"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/save_scene"), SCENE_SAVE_SCENE);
79207954
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/save_scene_as"), SCENE_SAVE_AS_SCENE);
79217955
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/save_all_scenes"), SCENE_SAVE_ALL_SCENES);
79227956
file_menu->add_separator();
79237957

7924-
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/quick_open"), SCENE_QUICK_OPEN);
7958+
file_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("Load"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/quick_open"), SCENE_QUICK_OPEN);
79257959
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/quick_open_scene"), SCENE_QUICK_OPEN_SCENE);
79267960
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/quick_open_script"), SCENE_QUICK_OPEN_SCRIPT);
79277961
file_menu->add_separator();
@@ -7934,32 +7968,32 @@ void EditorNode::_build_file_menu() {
79347968
file_menu->add_submenu_node_item(TTRC("Export As..."), export_as_menu, SCENE_EXPORT_AS);
79357969
file_menu->add_separator();
79367970

7937-
file_menu->add_shortcut(ED_GET_SHORTCUT("ui_undo"), SCENE_UNDO, false, true);
7971+
file_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("RotateLeft"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("ui_undo"), SCENE_UNDO, false, true);
79387972
file_menu->add_shortcut(ED_GET_SHORTCUT("ui_redo"), SCENE_REDO, false, true);
79397973
file_menu->add_separator();
79407974

79417975
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/reload_saved_scene"), SCENE_RELOAD_SAVED_SCENE);
7942-
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/close_scene"), SCENE_CLOSE);
7976+
file_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("CloseScene"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/close_scene"), SCENE_CLOSE);
79437977
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/close_all_scenes"), SCENE_CLOSE_ALL);
79447978
#ifdef MACOS_ENABLED
79457979
if (menu_type != MENU_TYPE_GLOBAL) {
79467980
// On macOS "Quit" option is in the "app" menu.
79477981
file_menu->add_separator();
7948-
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/file_quit"), SCENE_QUIT, true);
7982+
file_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("Close"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/file_quit"), SCENE_QUIT, true);
79497983
}
79507984
#else
79517985
file_menu->add_separator();
7952-
file_menu->add_shortcut(ED_GET_SHORTCUT("editor/file_quit"), SCENE_QUIT, true);
7986+
file_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("Close"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/file_quit"), SCENE_QUIT, true);
79537987
#endif
79547988
}
79557989

7956-
void EditorNode::_build_project_menu() {
7990+
void EditorNode::_build_project_menu(bool dark_mode) {
79577991
if (!project_menu) {
79587992
return;
79597993
}
79607994
project_menu->clear(false);
79617995

7962-
project_menu->add_shortcut(ED_GET_SHORTCUT("editor/project_settings"), PROJECT_OPEN_SETTINGS);
7996+
project_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("ClassList"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/project_settings"), PROJECT_OPEN_SETTINGS);
79637997
project_menu->add_shortcut(ED_GET_SHORTCUT("editor/find_in_files"), PROJECT_FIND_IN_FILES);
79647998
project_menu->add_separator();
79657999

@@ -7973,7 +8007,7 @@ void EditorNode::_build_project_menu() {
79738007
project_menu->set_item_submenu_node(project_menu->get_item_index(PROJECT_VERSION_CONTROL), vcs_actions_menu);
79748008

79758009
project_menu->add_separator();
7976-
project_menu->add_shortcut(ED_GET_SHORTCUT("editor/export"), PROJECT_EXPORT);
8010+
project_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("ResourcePreloader"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/export"), PROJECT_EXPORT);
79778011
project_menu->add_item(TTRC("Pack Project as ZIP..."), PROJECT_PACK_AS_ZIP);
79788012
project_menu->add_item(TTRC("Install Android Build Template..."), PROJECT_INSTALL_ANDROID_SOURCE);
79798013
#ifndef ANDROID_ENABLED
@@ -7992,10 +8026,10 @@ void EditorNode::_build_project_menu() {
79928026

79938027
project_menu->add_separator();
79948028
project_menu->add_shortcut(ED_GET_SHORTCUT("editor/reload_current_project"), PROJECT_RELOAD_CURRENT_PROJECT);
7995-
project_menu->add_shortcut(ED_GET_SHORTCUT("editor/quit_to_project_list"), PROJECT_QUIT_TO_PROJECT_MANAGER, true);
8029+
project_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("Close"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/quit_to_project_list"), PROJECT_QUIT_TO_PROJECT_MANAGER, true);
79968030
}
79978031

7998-
void EditorNode::_build_settings_menu() {
8032+
void EditorNode::_build_settings_menu(bool dark_mode) {
79998033
if (!settings_menu) {
80008034
return;
80018035
}
@@ -8004,10 +8038,10 @@ void EditorNode::_build_settings_menu() {
80048038
#ifdef MACOS_ENABLED
80058039
if (menu_type != MENU_TYPE_GLOBAL) {
80068040
// On macOS "Settings" option is in the "app" menu.
8007-
settings_menu->add_shortcut(ED_GET_SHORTCUT("editor/editor_settings"), EDITOR_OPEN_SETTINGS);
8041+
settings_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("Tools"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/editor_settings"), EDITOR_OPEN_SETTINGS);
80088042
}
80098043
#else
8010-
settings_menu->add_shortcut(ED_GET_SHORTCUT("editor/editor_settings"), EDITOR_OPEN_SETTINGS);
8044+
settings_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("Tools"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/editor_settings"), EDITOR_OPEN_SETTINGS);
80118045
#endif
80128046
settings_menu->add_shortcut(ED_GET_SHORTCUT("editor/command_palette"), EDITOR_COMMAND_PALETTE);
80138047
settings_menu->add_separator();
@@ -8046,7 +8080,7 @@ void EditorNode::_build_settings_menu() {
80468080
#endif
80478081
}
80488082

8049-
void EditorNode::_build_help_menu() {
8083+
void EditorNode::_build_help_menu(bool dark_mode) {
80508084
if (!help_menu) {
80518085
return;
80528086
}
@@ -8057,7 +8091,7 @@ void EditorNode::_build_help_menu() {
80578091
} else {
80588092
help_menu->set_system_menu(NativeMenu::INVALID_MENU_ID);
80598093
}
8060-
bool dark_mode = DisplayServer::get_singleton()->is_dark_mode_supported() && DisplayServer::get_singleton()->is_dark_mode();
8094+
80618095
help_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("HelpSearch"), menu_type == MENU_TYPE_GLOBAL, dark_mode), ED_GET_SHORTCUT("editor/editor_help"), HELP_SEARCH);
80628096
help_menu->add_separator();
80638097
help_menu->add_shortcut(ED_GET_SHORTCUT("editor/online_docs"), HELP_DOCS);
@@ -8105,10 +8139,11 @@ void EditorNode::_update_main_menu_type() {
81058139
menu_type = new_menu_type;
81068140

81078141
// Update menu items.
8108-
_build_file_menu();
8109-
_build_project_menu();
8110-
_build_settings_menu();
8111-
_build_help_menu();
8142+
bool dark_mode = DisplayServer::get_singleton()->is_dark_mode_supported() && DisplayServer::get_singleton()->is_dark_mode();
8143+
_build_file_menu(dark_mode);
8144+
_build_project_menu(dark_mode);
8145+
_build_settings_menu(dark_mode);
8146+
_build_help_menu(dark_mode);
81128147

81138148
// Delete all menu.
81148149
if (main_menu_bar) {

editor/editor_node.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ class EditorNode : public Node {
525525
static void _resource_saved(Ref<Resource> p_resource, const String &p_path);
526526
static void _resource_loaded(Ref<Resource> p_resource, const String &p_path);
527527

528+
void _update_system_menu_icons(bool dark_mode);
528529
void _update_theme(bool p_skip_creation = false);
529530
void _build_icon_type_cache();
530531
void _enable_pending_addons();
@@ -715,10 +716,10 @@ class EditorNode : public Node {
715716
MenuType menu_type = MENU_TYPE_NONE;
716717
Vector<PopupMenu *> main_menu_items;
717718

718-
void _build_file_menu();
719-
void _build_project_menu();
720-
void _build_settings_menu();
721-
void _build_help_menu();
719+
void _build_file_menu(bool dark_mode);
720+
void _build_project_menu(bool dark_mode);
721+
void _build_settings_menu(bool dark_mode);
722+
void _build_help_menu(bool dark_mode);
722723

723724
void _update_main_menu_type();
724725
void _add_to_main_menu(const String &p_name, PopupMenu *p_menu);

editor/icons/CloseScene.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)