diff --git a/editor/docks/editor_dock_manager.cpp b/editor/docks/editor_dock_manager.cpp index dc094329fd0..31bd09ea718 100644 --- a/editor/docks/editor_dock_manager.cpp +++ b/editor/docks/editor_dock_manager.cpp @@ -333,7 +333,7 @@ void EditorDockManager::update_docks_menu() { // Add docks. docks_menu_docks.clear(); int id = 0; - const Callable icon_fetch = callable_mp((Window *)docks_menu, &Window::get_editor_theme_native_menu_icon).bind(global_menu, dark_mode); + const Callable icon_fetch = callable_mp(EditorNode::get_singleton(), &EditorNode::get_editor_theme_native_menu_icon).bind(global_menu, dark_mode); for (EditorDock *dock : all_docks) { if (!dock->enabled || !dock->global) { continue; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 96673b3dba7..ba875dd67ac 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -65,6 +65,7 @@ #include "scene/main/timer.h" #include "scene/main/window.h" #include "scene/property_utils.h" +#include "scene/resources/dpi_texture.h" #include "scene/resources/image_texture.h" #include "scene/resources/packed_scene.h" #include "scene/resources/portable_compressed_texture.h" @@ -166,6 +167,7 @@ #include "editor/settings/project_settings_editor.h" #include "editor/shader/editor_native_shader_source_visualizer.h" #include "editor/shader/visual_shader_editor_plugin.h" +#include "editor/themes/editor_color_map.h" #include "editor/themes/editor_scale.h" #include "editor/themes/editor_theme_manager.h" #include "editor/translations/editor_translation_parser.h" @@ -683,10 +685,10 @@ void EditorNode::_update_theme(bool p_skip_creation) { distraction_free->set_button_icon(theme->get_icon(SNAME("DistractionFree"), EditorStringName(EditorIcons))); update_distraction_free_button_theme(); - help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), _get_editor_theme_native_menu_icon(SNAME("HelpSearch"), global_menu, dark_mode)); - help_menu->set_item_icon(help_menu->get_item_index(HELP_COPY_SYSTEM_INFO), _get_editor_theme_native_menu_icon(SNAME("ActionCopy"), global_menu, dark_mode)); - help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), _get_editor_theme_native_menu_icon(SNAME("Godot"), global_menu, dark_mode)); - help_menu->set_item_icon(help_menu->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), _get_editor_theme_native_menu_icon(SNAME("Heart"), global_menu, dark_mode)); + help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), get_editor_theme_native_menu_icon(SNAME("HelpSearch"), global_menu, dark_mode)); + help_menu->set_item_icon(help_menu->get_item_index(HELP_COPY_SYSTEM_INFO), get_editor_theme_native_menu_icon(SNAME("ActionCopy"), global_menu, dark_mode)); + help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), get_editor_theme_native_menu_icon(SNAME("Godot"), global_menu, dark_mode)); + help_menu->set_item_icon(help_menu->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), get_editor_theme_native_menu_icon(SNAME("Heart"), global_menu, dark_mode)); _update_renderer_color(); } @@ -703,16 +705,27 @@ void EditorNode::_update_theme(bool p_skip_creation) { #endif } -Ref EditorNode::_get_editor_theme_native_menu_icon(const StringName &p_name, bool p_global_menu, bool p_dark_mode) const { - if (!p_global_menu) { - return theme->get_icon(p_name, SNAME("EditorIcons")); +Ref EditorNode::get_editor_theme_native_menu_icon(const StringName &p_name, bool p_global_menu, bool p_dark_mode) const { + Ref tx = theme->get_icon(p_name, SNAME("EditorIcons")); + if (!p_global_menu || p_dark_mode == EditorThemeManager::is_dark_icon_and_font()) { + return tx; } - if (p_dark_mode && theme->has_icon(String(p_name) + "Dark", SNAME("EditorIcons"))) { - return theme->get_icon(String(p_name) + "Dark", SNAME("EditorIcons")); - } else if (!p_dark_mode && theme->has_icon(String(p_name) + "Light", SNAME("EditorIcons"))) { - return theme->get_icon(String(p_name) + "Light", SNAME("EditorIcons")); + + Ref new_tx = tx; + if (new_tx.is_null()) { + return tx; } - return theme->get_icon(p_name, SNAME("EditorIcons")); + new_tx = new_tx->duplicate(); + + Dictionary color_conversion_map; + if (!p_dark_mode) { + for (KeyValue &E : EditorColorMap::get_color_conversion_map()) { + color_conversion_map[E.key] = E.value; + } + } + new_tx->set_color_map(color_conversion_map); + + return new_tx; } void EditorNode::update_preview_themes(int p_mode) { @@ -3905,10 +3918,10 @@ void EditorNode::_check_system_theme_changed() { // Update system menus. bool dark_mode = DisplayServer::get_singleton()->is_dark_mode(); - help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), _get_editor_theme_native_menu_icon(SNAME("HelpSearch"), global_menu, dark_mode)); - help_menu->set_item_icon(help_menu->get_item_index(HELP_COPY_SYSTEM_INFO), _get_editor_theme_native_menu_icon(SNAME("ActionCopy"), global_menu, dark_mode)); - help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), _get_editor_theme_native_menu_icon(SNAME("Godot"), global_menu, dark_mode)); - help_menu->set_item_icon(help_menu->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), _get_editor_theme_native_menu_icon(SNAME("Heart"), global_menu, dark_mode)); + help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), get_editor_theme_native_menu_icon(SNAME("HelpSearch"), global_menu, dark_mode)); + help_menu->set_item_icon(help_menu->get_item_index(HELP_COPY_SYSTEM_INFO), get_editor_theme_native_menu_icon(SNAME("ActionCopy"), global_menu, dark_mode)); + help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), get_editor_theme_native_menu_icon(SNAME("Godot"), global_menu, dark_mode)); + help_menu->set_item_icon(help_menu->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), get_editor_theme_native_menu_icon(SNAME("Heart"), global_menu, dark_mode)); editor_dock_manager->update_docks_menu(); } } @@ -8635,13 +8648,13 @@ EditorNode::EditorNode() { ED_SHORTCUT_AND_COMMAND("editor/editor_help", TTRC("Search Help..."), Key::F1); ED_SHORTCUT_OVERRIDE("editor/editor_help", "macos", KeyModifierMask::ALT | Key::SPACE); - help_menu->add_icon_shortcut(_get_editor_theme_native_menu_icon(SNAME("HelpSearch"), global_menu, dark_mode), ED_GET_SHORTCUT("editor/editor_help"), HELP_SEARCH); + help_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("HelpSearch"), global_menu, dark_mode), ED_GET_SHORTCUT("editor/editor_help"), HELP_SEARCH); help_menu->add_separator(); help_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/online_docs", TTRC("Online Documentation")), HELP_DOCS); help_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/forum", TTRC("Forum")), HELP_FORUM); help_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/community", TTRC("Community")), HELP_COMMUNITY); help_menu->add_separator(); - help_menu->add_icon_shortcut(_get_editor_theme_native_menu_icon(SNAME("ActionCopy"), global_menu, dark_mode), ED_SHORTCUT_AND_COMMAND("editor/copy_system_info", TTRC("Copy System Info")), HELP_COPY_SYSTEM_INFO); + help_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("ActionCopy"), global_menu, dark_mode), ED_SHORTCUT_AND_COMMAND("editor/copy_system_info", TTRC("Copy System Info")), HELP_COPY_SYSTEM_INFO); help_menu->set_item_tooltip(-1, TTR("Copies the system info as a single-line text into the clipboard.")); help_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/report_a_bug", TTRC("Report a Bug")), HELP_REPORT_A_BUG); help_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/suggest_a_feature", TTRC("Suggest a Feature")), HELP_SUGGEST_A_FEATURE); @@ -8649,9 +8662,9 @@ EditorNode::EditorNode() { help_menu->add_separator(); if (!global_menu || !OS::get_singleton()->has_feature("macos")) { // On macOS "Quit" and "About" options are in the "app" menu. - help_menu->add_icon_shortcut(_get_editor_theme_native_menu_icon(SNAME("Godot"), global_menu, dark_mode), ED_SHORTCUT_AND_COMMAND("editor/about", TTRC("About Godot...")), HELP_ABOUT); + help_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("Godot"), global_menu, dark_mode), ED_SHORTCUT_AND_COMMAND("editor/about", TTRC("About Godot...")), HELP_ABOUT); } - help_menu->add_icon_shortcut(_get_editor_theme_native_menu_icon(SNAME("Heart"), global_menu, dark_mode), ED_SHORTCUT_AND_COMMAND("editor/support_development", TTRC("Support Godot Development")), HELP_SUPPORT_GODOT_DEVELOPMENT); + help_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("Heart"), global_menu, dark_mode), ED_SHORTCUT_AND_COMMAND("editor/support_development", TTRC("Support Godot Development")), HELP_SUPPORT_GODOT_DEVELOPMENT); // Spacer to center 2D / 3D / Script buttons. right_spacer = memnew(Control); diff --git a/editor/editor_node.h b/editor/editor_node.h index 024fddf25cf..16f95d604db 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -698,7 +698,6 @@ private: bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class); Ref _get_class_or_script_icon(const String &p_class, const String &p_script_path, const String &p_fallback = "", bool p_fallback_script_to_theme = false, bool p_skip_fallback_virtual = false); - Ref _get_editor_theme_native_menu_icon(const StringName &p_name, bool p_global_menu, bool p_dark_mode) const; void _pick_main_scene_custom_action(const String &p_custom_action_name); @@ -787,6 +786,8 @@ public: static void cleanup(); + Ref get_editor_theme_native_menu_icon(const StringName &p_name, bool p_global_menu, bool p_dark_mode) const; + EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; } EditorPluginList *get_editor_plugins_force_over() { return editor_plugins_force_over; } EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; } diff --git a/editor/themes/editor_icons.cpp b/editor/themes/editor_icons.cpp index 0c2aca519ee..33ad89b9a9a 100644 --- a/editor/themes/editor_icons.cpp +++ b/editor/themes/editor_icons.cpp @@ -104,19 +104,6 @@ void editor_register_icons(const Ref &p_theme, bool p_dark_theme, float p Dictionary color_conversion_map = p_dark_theme ? color_conversion_map_dark : color_conversion_map_light; - // The names of the icons used in native menus. - HashSet native_menu_icons; - native_menu_icons.insert("HelpSearch"); - native_menu_icons.insert("ActionCopy"); - native_menu_icons.insert("Heart"); - native_menu_icons.insert("PackedScene"); - native_menu_icons.insert("FileAccess"); - native_menu_icons.insert("Folder"); - native_menu_icons.insert("AnimationTrackList"); - native_menu_icons.insert("Signals"); - native_menu_icons.insert("Groups"); - native_menu_icons.insert("History"); - // The names of the icons to exclude from the standard color conversion. HashSet conversion_exceptions = EditorColorMap::get_color_conversion_exceptions(); @@ -149,37 +136,23 @@ void editor_register_icons(const Ref &p_theme, bool p_dark_theme, float p { for (int i = 0; i < editor_icons_count; i++) { const String &editor_icon_name = editor_icons_names[i]; - if (native_menu_icons.has(editor_icon_name)) { + Ref icon; + if (accent_color_icons.has(editor_icon_name)) { + icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), 1.0, accent_color_map); + } else { float saturation = p_icon_saturation; if (saturation_exceptions.has(editor_icon_name)) { saturation = 1.0; } - Ref icon_dark = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_dark); - Ref icon_light = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_light); - - p_theme->set_icon(editor_icon_name + "Dark", EditorStringName(EditorIcons), icon_dark); - p_theme->set_icon(editor_icon_name + "Light", EditorStringName(EditorIcons), icon_light); - p_theme->set_icon(editor_icon_name, EditorStringName(EditorIcons), p_dark_theme ? icon_dark : icon_light); - } else { - Ref icon; - if (accent_color_icons.has(editor_icon_name)) { - icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), 1.0, accent_color_map); + if (conversion_exceptions.has(editor_icon_name)) { + icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation); } else { - float saturation = p_icon_saturation; - if (saturation_exceptions.has(editor_icon_name)) { - saturation = 1.0; - } - - if (conversion_exceptions.has(editor_icon_name)) { - icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation); - } else { - icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map); - } + icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map); } - - p_theme->set_icon(editor_icon_name, EditorStringName(EditorIcons), icon); } + + p_theme->set_icon(editor_icon_name, EditorStringName(EditorIcons), icon); } } diff --git a/scene/main/window.cpp b/scene/main/window.cpp index e0d6f674316..68bfb4513ac 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -2617,18 +2617,6 @@ Variant Window::get_theme_item(Theme::DataType p_data_type, const StringName &p_ Ref Window::get_editor_theme_icon(const StringName &p_name) const { return get_theme_icon(p_name, SNAME("EditorIcons")); } - -Ref Window::get_editor_theme_native_menu_icon(const StringName &p_name, bool p_global_menu, bool p_dark_mode) const { - if (!p_global_menu) { - return get_theme_icon(p_name, SNAME("EditorIcons")); - } - if (p_dark_mode && has_theme_icon(String(p_name) + "Dark", SNAME("EditorIcons"))) { - return get_theme_icon(String(p_name) + "Dark", SNAME("EditorIcons")); - } else if (!p_dark_mode && has_theme_icon(String(p_name) + "Light", SNAME("EditorIcons"))) { - return get_theme_icon(String(p_name) + "Light", SNAME("EditorIcons")); - } - return get_theme_icon(p_name, SNAME("EditorIcons")); -} #endif bool Window::has_theme_icon(const StringName &p_name, const StringName &p_theme_type) const { diff --git a/scene/main/window.h b/scene/main/window.h index c61684aed25..68ab3f842a2 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -495,7 +495,6 @@ public: Variant get_theme_item(Theme::DataType p_data_type, const StringName &p_name, const StringName &p_theme_type = StringName()) const; #ifdef TOOLS_ENABLED Ref get_editor_theme_icon(const StringName &p_name) const; - Ref get_editor_theme_native_menu_icon(const StringName &p_name, bool p_global_menu, bool p_dark_mode) const; #endif bool has_theme_icon_override(const StringName &p_name) const;