1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-31 18:41:20 +00:00

[Editor] Simplify native menu icon generation.

This commit is contained in:
Pāvels Nadtočajevs
2025-11-27 23:04:51 +02:00
parent 3a97723ff2
commit e68b2436ee
6 changed files with 45 additions and 71 deletions

View File

@@ -104,19 +104,6 @@ void editor_register_icons(const Ref<Theme> &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<StringName> 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<StringName> conversion_exceptions = EditorColorMap::get_color_conversion_exceptions();
@@ -149,37 +136,23 @@ void editor_register_icons(const Ref<Theme> &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<DPITexture> 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<DPITexture> icon_dark = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_dark);
Ref<DPITexture> 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<DPITexture> 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);
}
}