diff options
338 files changed, 5804 insertions, 4422 deletions
diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index afc73a462f..ea97ef023d 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -18,7 +18,7 @@ jobs: name: Template (target=template_release) steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Java 11 uses: actions/setup-java@v3 diff --git a/.github/workflows/godot_cpp_test.yml b/.github/workflows/godot_cpp_test.yml index 5384197f37..dccc853550 100644 --- a/.github/workflows/godot_cpp_test.yml +++ b/.github/workflows/godot_cpp_test.yml @@ -18,14 +18,14 @@ jobs: runs-on: "ubuntu-20.04" name: "Build and test Godot CPP" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup python and scons uses: ./.github/actions/godot-deps # Checkout godot-cpp - name: Checkout godot-cpp - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: godotengine/godot-cpp ref: ${{ env.GODOT_CPP_BRANCH }} diff --git a/.github/workflows/ios_builds.yml b/.github/workflows/ios_builds.yml index 63ecabd957..6557120d87 100644 --- a/.github/workflows/ios_builds.yml +++ b/.github/workflows/ios_builds.yml @@ -18,7 +18,7 @@ jobs: name: Template (target=template_release) steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Godot build cache uses: ./.github/actions/godot-cache diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index 01f2404866..fc0db1fbd6 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -85,7 +85,7 @@ jobs: artifact: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Need newer mesa for lavapipe to work properly. - name: Linux dependencies for tests @@ -111,7 +111,7 @@ jobs: uses: ./.github/actions/godot-deps - name: Set up .NET Sdk - uses: actions/setup-dotnet@v2 + uses: actions/setup-dotnet@v3 if: ${{ matrix.build-mono }} with: dotnet-version: '6.0.x' diff --git a/.github/workflows/macos_builds.yml b/.github/workflows/macos_builds.yml index ae6f452bc2..1e39aceeb8 100644 --- a/.github/workflows/macos_builds.yml +++ b/.github/workflows/macos_builds.yml @@ -33,7 +33,7 @@ jobs: sconsflags: debug_symbols=no steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Godot build cache uses: ./.github/actions/godot-cache diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index c096c63f9b..4b7f721a23 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 diff --git a/.github/workflows/web_builds.yml b/.github/workflows/web_builds.yml index 2ae238caa6..6de6eeaf2e 100644 --- a/.github/workflows/web_builds.yml +++ b/.github/workflows/web_builds.yml @@ -7,7 +7,7 @@ env: # Used for the cache key. Add version suffix to force clean build. GODOT_BASE_BRANCH: master SCONSFLAGS: verbose=yes warnings=extra werror=yes debug_symbols=no - EM_VERSION: 3.1.18 + EM_VERSION: 3.1.45 EM_CACHE_FOLDER: "emsdk-cache" concurrency: @@ -16,11 +16,11 @@ concurrency: jobs: web-template: - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" name: Template (target=template_release) steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Emscripten latest uses: mymindstorm/setup-emsdk@v12 diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index ab62dca5cb..14f2992848 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -38,7 +38,7 @@ jobs: sconsflags: debug_symbols=no steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Godot build cache uses: ./.github/actions/godot-cache diff --git a/SConstruct b/SConstruct index 7d4c8975e7..df750beae4 100644 --- a/SConstruct +++ b/SConstruct @@ -978,7 +978,7 @@ if selected_platform in platform_list: print("Error: The `vsproj` option is only usable on Windows with Visual Studio.") Exit(255) env["CPPPATH"] = [Dir(path) for path in env["CPPPATH"]] - methods.generate_vs_project(env, GetOption("num_jobs"), env["vsproj_name"]) + methods.generate_vs_project(env, ARGUMENTS, env["vsproj_name"]) methods.generate_cpp_hint_file("cpp.hint") # Check for the existence of headers diff --git a/core/extension/gdextension_interface.cpp b/core/extension/gdextension_interface.cpp index b6dfec33ed..a09b1f491e 100644 --- a/core/extension/gdextension_interface.cpp +++ b/core/extension/gdextension_interface.cpp @@ -1055,6 +1055,7 @@ static GDExtensionScriptInstancePtr gdextension_script_instance_create(const GDE info_2->get_method_list_func = p_info->get_method_list_func; info_2->free_method_list_func = p_info->free_method_list_func; info_2->get_property_type_func = p_info->get_property_type_func; + info_2->validate_property_func = nullptr; info_2->has_method_func = p_info->has_method_func; info_2->call_func = p_info->call_func; info_2->notification_func = nullptr; diff --git a/core/extension/gdextension_interface.h b/core/extension/gdextension_interface.h index 102220c0fc..4379e520b7 100644 --- a/core/extension/gdextension_interface.h +++ b/core/extension/gdextension_interface.h @@ -373,6 +373,7 @@ typedef GDExtensionBool (*GDExtensionScriptInstanceGet)(GDExtensionScriptInstanc typedef const GDExtensionPropertyInfo *(*GDExtensionScriptInstanceGetPropertyList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count); typedef void (*GDExtensionScriptInstanceFreePropertyList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list); typedef GDExtensionVariantType (*GDExtensionScriptInstanceGetPropertyType)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid); +typedef GDExtensionBool (*GDExtensionScriptInstanceValidateProperty)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionPropertyInfo *p_property); typedef GDExtensionBool (*GDExtensionScriptInstancePropertyCanRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name); typedef GDExtensionBool (*GDExtensionScriptInstancePropertyGetRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret); @@ -459,6 +460,7 @@ typedef struct { GDExtensionScriptInstanceGetMethodList get_method_list_func; GDExtensionScriptInstanceFreeMethodList free_method_list_func; GDExtensionScriptInstanceGetPropertyType get_property_type_func; + GDExtensionScriptInstanceValidateProperty validate_property_func; GDExtensionScriptInstanceHasMethod has_method_func; diff --git a/core/extension/gdextension_manager.cpp b/core/extension/gdextension_manager.cpp index 63e809bc7c..0f0e2fad41 100644 --- a/core/extension/gdextension_manager.cpp +++ b/core/extension/gdextension_manager.cpp @@ -143,6 +143,8 @@ void GDExtensionManager::load_extensions() { ERR_CONTINUE_MSG(err == LOAD_STATUS_FAILED, "Error loading extension: " + s); } } + + OS::get_singleton()->load_platform_gdextensions(); } GDExtensionManager *GDExtensionManager::get_singleton() { diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h index bf5ad3c107..c7218d99a6 100644 --- a/core/object/script_language_extension.h +++ b/core/object/script_language_extension.h @@ -688,7 +688,24 @@ public: return Variant::NIL; } virtual void validate_property(PropertyInfo &p_property) const override { - // TODO + if (native_info->validate_property_func) { + GDExtensionPropertyInfo gdext_prop = { + (GDExtensionVariantType)p_property.type, + &p_property.name, + &p_property.class_name, + (uint32_t)p_property.hint, + &p_property.hint_string, + p_property.usage, + }; + if (native_info->validate_property_func(instance, &gdext_prop)) { + p_property.type = (Variant::Type)gdext_prop.type; + p_property.name = *reinterpret_cast<StringName *>(gdext_prop.name); + p_property.class_name = *reinterpret_cast<StringName *>(gdext_prop.class_name); + p_property.hint = (PropertyHint)gdext_prop.hint; + p_property.hint_string = *reinterpret_cast<String *>(gdext_prop.hint_string); + p_property.usage = gdext_prop.usage; + } + } } virtual bool property_can_revert(const StringName &p_name) const override { diff --git a/core/os/os.h b/core/os/os.h index 965dc1f912..cc5ebe1bc8 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -328,6 +328,10 @@ public: virtual PreferredTextureFormat get_preferred_texture_format() const; + // Load GDExtensions specific to this platform. + // This is invoked by the GDExtensionManager after loading GDExtensions specified by the project. + virtual void load_platform_gdextensions() const {} + OS(); virtual ~OS(); }; diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 3f11459a1e..f6a17cf1a7 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -1493,9 +1493,9 @@ String String::num(double p_num, int p_decimals) { if (p_decimals < 0) { p_decimals = 14; - const double abs_num = ABS(p_num); + const double abs_num = Math::abs(p_num); if (abs_num > 10) { - // We want to align the digits to the above sane default, so we only + // We want to align the digits to the above reasonable default, so we only // need to subtract log10 for numbers with a positive power of ten. p_decimals -= (int)floor(log10(abs_num)); } @@ -4890,8 +4890,8 @@ String String::sprintf(const Array &values, bool *error) const { } double value = values[value_index]; - bool is_negative = (value < 0); - String str = String::num(ABS(value), min_decimals); + bool is_negative = signbit(value); + String str = String::num(Math::abs(value), min_decimals); const bool is_finite = Math::is_finite(value); // Pad decimals out. @@ -4953,7 +4953,7 @@ String String::sprintf(const Array &values, bool *error) const { String str = "("; for (int i = 0; i < count; i++) { double val = vec[i]; - String number_str = String::num(ABS(val), min_decimals); + String number_str = String::num(Math::abs(val), min_decimals); const bool is_finite = Math::is_finite(val); // Pad decimals out. diff --git a/doc/classes/BaseMaterial3D.xml b/doc/classes/BaseMaterial3D.xml index 1cc2976c81..2246e30817 100644 --- a/doc/classes/BaseMaterial3D.xml +++ b/doc/classes/BaseMaterial3D.xml @@ -176,6 +176,9 @@ <member name="disable_ambient_light" type="bool" setter="set_flag" getter="get_flag" default="false"> If [code]true[/code], the object receives no ambient light. </member> + <member name="disable_fog" type="bool" setter="set_flag" getter="get_flag" default="false"> + If [code]true[/code], the object will not be affected by fog (neither volumetric nor depth fog). This is useful for unshaded or transparent materials (e.g. particles), which without this setting will be affected even if fully transparent. + </member> <member name="disable_receive_shadows" type="bool" setter="set_flag" getter="get_flag" default="false"> If [code]true[/code], the object receives no shadow that would otherwise be cast onto it. </member> @@ -697,7 +700,10 @@ <constant name="FLAG_ALBEDO_TEXTURE_MSDF" value="20" enum="Flags"> Enables multichannel signed distance field rendering shader. </constant> - <constant name="FLAG_MAX" value="21" enum="Flags"> + <constant name="FLAG_DISABLE_FOG" value="21" enum="Flags"> + Disables receiving depth-based or volumetric fog. + </constant> + <constant name="FLAG_MAX" value="22" enum="Flags"> Represents the size of the [enum Flags] enum. </constant> <constant name="DIFFUSE_BURLEY" value="0" enum="DiffuseMode"> diff --git a/doc/classes/EditorResourceTooltipPlugin.xml b/doc/classes/EditorResourceTooltipPlugin.xml index 69c5f30f25..acfa881ab1 100644 --- a/doc/classes/EditorResourceTooltipPlugin.xml +++ b/doc/classes/EditorResourceTooltipPlugin.xml @@ -24,7 +24,7 @@ <param index="2" name="base" type="Control" /> <description> Create and return a tooltip that will be displayed when the user hovers a resource under the given [param path] in filesystem dock. - The [param metadata] dictionary is provided by preview generator (see method EditorResourcePreviewGenerator._generate]). + The [param metadata] dictionary is provided by preview generator (see [method EditorResourcePreviewGenerator._generate]). [param base] is the base default tooltip, which is a [VBoxContainer] with a file name, type and size labels. If another plugin handled the same file type, [param base] will be output from the previous plugin. For best result, make sure the base tooltip is part of the returned [Control]. [b]Note:[/b] It's unadvised to use [method ResourceLoader.load], especially with heavy resources like models or textures, because it will make the editor unresponsive when creating the tooltip. You can use [method request_thumbnail] if you want to display a preview in your tooltip. [b]Note:[/b] If you decide to discard the [param base], make sure to call [method Node.queue_free], because it's not freed automatically. diff --git a/doc/classes/SpringArm3D.xml b/doc/classes/SpringArm3D.xml index 6e12d9a613..99389fb78d 100644 --- a/doc/classes/SpringArm3D.xml +++ b/doc/classes/SpringArm3D.xml @@ -4,7 +4,7 @@ A 3D raycast that dynamically moves its children near the collision point. </brief_description> <description> - [SpringArm3D] casts a ray or a shape along its Z axis and moves all its direct children to the collision point, with an optional margin. This is useful for 3rd person cameras that move closer to the player when inside a tight space (you may need to exclude the player's collider from the [SpringArm3D]'s collision check. + [SpringArm3D] casts a ray or a shape along its Z axis and moves all its direct children to the collision point, with an optional margin. This is useful for 3rd person cameras that move closer to the player when inside a tight space (you may need to exclude the player's collider from the [SpringArm3D]'s collision check). </description> <tutorials> </tutorials> diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 7cba77be2f..8d3eabc55b 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -962,7 +962,9 @@ void main() { float clearcoat_roughness = 0.0; float anisotropy = 0.0; vec2 anisotropy_flow = vec2(1.0, 0.0); +#ifndef FOG_DISABLED vec4 fog = vec4(0.0); +#endif // !FOG_DISABLED #if defined(CUSTOM_RADIANCE_USED) vec4 custom_radiance = vec4(0.0); #endif @@ -1075,6 +1077,7 @@ void main() { #ifndef MODE_RENDER_DEPTH +#ifndef FOG_DISABLED #ifndef CUSTOM_FOG_USED #ifndef DISABLE_FOG // fog must be processed as early as possible and then packed. @@ -1088,6 +1091,7 @@ void main() { uint fog_rg = packHalf2x16(fog.rg); uint fog_ba = packHalf2x16(fog.ba); +#endif // !FOG_DISABLED // Convert colors to linear albedo = srgb_to_linear(albedo); @@ -1300,6 +1304,8 @@ void main() { frag_color.rgb += emission + ambient_light; #endif #endif //MODE_UNSHADED + +#ifndef FOG_DISABLED fog = vec4(unpackHalf2x16(fog_rg), unpackHalf2x16(fog_ba)); #ifndef DISABLE_FOG @@ -1310,7 +1316,8 @@ void main() { frag_color.rgb *= (1.0 - fog.a); #endif // BASE_PASS } -#endif +#endif // !DISABLE_FOG +#endif // !FOG_DISABLED // Tonemap before writing as we are writing to an sRGB framebuffer frag_color.rgb *= exposure; diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp index a36004209b..32b62ee605 100644 --- a/drivers/gles3/storage/material_storage.cpp +++ b/drivers/gles3/storage/material_storage.cpp @@ -1358,6 +1358,7 @@ MaterialStorage::MaterialStorage() { actions.render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n"; actions.render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n"; actions.render_mode_defines["unshaded"] = "#define MODE_UNSHADED\n"; + actions.render_mode_defines["fog_disabled"] = "#define FOG_DISABLED\n"; actions.default_filter = ShaderLanguage::FILTER_LINEAR_MIPMAP; actions.default_repeat = ShaderLanguage::REPEAT_ENABLE; diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 36b19198e6..d47b315c40 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -32,6 +32,7 @@ #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/event_listener_line_edit.h" #include "editor/input_event_configuration_dialog.h" #include "scene/gui/check_button.h" @@ -355,7 +356,7 @@ void ActionMapEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - action_list_search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + action_list_search->set_right_icon(get_editor_theme_icon(SNAME("Search"))); if (!actions_cache.is_empty()) { update_action_list(); } @@ -442,13 +443,13 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info bool events_eq = Shortcut::is_event_array_equal(action_info.action_initial["events"], action_info.action["events"]); bool action_eq = deadzone_eq && events_eq; action_item->set_meta("__action_initial", action_info.action_initial); - action_item->add_button(2, action_tree->get_theme_icon(SNAME("ReloadSmall"), SNAME("EditorIcons")), BUTTON_REVERT_ACTION, action_eq, action_eq ? TTR("Cannot Revert - Action is same as initial") : TTR("Revert Action")); + action_item->add_button(2, action_tree->get_editor_theme_icon(SNAME("ReloadSmall")), BUTTON_REVERT_ACTION, action_eq, action_eq ? TTR("Cannot Revert - Action is same as initial") : TTR("Revert Action")); } - action_item->add_button(2, action_tree->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), BUTTON_ADD_EVENT, false, TTR("Add Event")); - action_item->add_button(2, action_tree->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_ACTION, !action_info.editable, action_info.editable ? TTR("Remove Action") : TTR("Cannot Remove Action")); + action_item->add_button(2, action_tree->get_editor_theme_icon(SNAME("Add")), BUTTON_ADD_EVENT, false, TTR("Add Event")); + action_item->add_button(2, action_tree->get_editor_theme_icon(SNAME("Remove")), BUTTON_REMOVE_ACTION, !action_info.editable, action_info.editable ? TTR("Remove Action") : TTR("Cannot Remove Action")); - action_item->set_custom_bg_color(0, action_tree->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); - action_item->set_custom_bg_color(1, action_tree->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + action_item->set_custom_bg_color(0, action_tree->get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); + action_item->set_custom_bg_color(1, action_tree->get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); for (int evnt_idx = 0; evnt_idx < events.size(); evnt_idx++) { Ref<InputEvent> event = events[evnt_idx]; @@ -467,34 +468,34 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info Ref<InputEventKey> k = event; if (k.is_valid()) { if (k->get_physical_keycode() == Key::NONE && k->get_keycode() == Key::NONE && k->get_key_label() != Key::NONE) { - event_item->set_icon(0, action_tree->get_theme_icon(SNAME("KeyboardLabel"), SNAME("EditorIcons"))); + event_item->set_icon(0, action_tree->get_editor_theme_icon(SNAME("KeyboardLabel"))); } else if (k->get_keycode() != Key::NONE) { - event_item->set_icon(0, action_tree->get_theme_icon(SNAME("Keyboard"), SNAME("EditorIcons"))); + event_item->set_icon(0, action_tree->get_editor_theme_icon(SNAME("Keyboard"))); } else if (k->get_physical_keycode() != Key::NONE) { - event_item->set_icon(0, action_tree->get_theme_icon(SNAME("KeyboardPhysical"), SNAME("EditorIcons"))); + event_item->set_icon(0, action_tree->get_editor_theme_icon(SNAME("KeyboardPhysical"))); } else { - event_item->set_icon(0, action_tree->get_theme_icon(SNAME("KeyboardError"), SNAME("EditorIcons"))); + event_item->set_icon(0, action_tree->get_editor_theme_icon(SNAME("KeyboardError"))); } } Ref<InputEventMouseButton> mb = event; if (mb.is_valid()) { - event_item->set_icon(0, action_tree->get_theme_icon(SNAME("Mouse"), SNAME("EditorIcons"))); + event_item->set_icon(0, action_tree->get_editor_theme_icon(SNAME("Mouse"))); } Ref<InputEventJoypadButton> jb = event; if (jb.is_valid()) { - event_item->set_icon(0, action_tree->get_theme_icon(SNAME("JoyButton"), SNAME("EditorIcons"))); + event_item->set_icon(0, action_tree->get_editor_theme_icon(SNAME("JoyButton"))); } Ref<InputEventJoypadMotion> jm = event; if (jm.is_valid()) { - event_item->set_icon(0, action_tree->get_theme_icon(SNAME("JoyAxis"), SNAME("EditorIcons"))); + event_item->set_icon(0, action_tree->get_editor_theme_icon(SNAME("JoyAxis"))); } // Third Column - Buttons - event_item->add_button(2, action_tree->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), BUTTON_EDIT_EVENT, false, TTR("Edit Event")); - event_item->add_button(2, action_tree->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_EVENT, false, TTR("Remove Event")); + event_item->add_button(2, action_tree->get_editor_theme_icon(SNAME("Edit")), BUTTON_EDIT_EVENT, false, TTR("Edit Event")); + event_item->add_button(2, action_tree->get_editor_theme_icon(SNAME("Remove")), BUTTON_REMOVE_EVENT, false, TTR("Remove Event")); event_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); event_item->set_button_color(2, 1, Color(1, 1, 1, 0.75)); } diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 8defa04ada..23c1665cad 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -33,6 +33,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "scene/gui/view_panner.h" #include "scene/resources/text_line.h" @@ -220,9 +221,9 @@ void AnimationBezierTrackEdit::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - bezier_icon = get_theme_icon(SNAME("KeyBezierPoint"), SNAME("EditorIcons")); - bezier_handle_icon = get_theme_icon(SNAME("KeyBezierHandle"), SNAME("EditorIcons")); - selected_icon = get_theme_icon(SNAME("KeyBezierSelected"), SNAME("EditorIcons")); + bezier_icon = get_editor_theme_icon(SNAME("KeyBezierPoint")); + bezier_handle_icon = get_editor_theme_icon(SNAME("KeyBezierHandle")); + selected_icon = get_editor_theme_icon(SNAME("KeyBezierSelected")); } break; case NOTIFICATION_DRAW: { @@ -233,7 +234,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { int limit = timeline->get_name_limit(); if (has_focus()) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false, Math::round(EDSCALE)); } @@ -330,20 +331,20 @@ void AnimationBezierTrackEdit::_notification(int p_what) { } } - Color dc = get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")); + Color dc = get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor)); - Ref<Texture2D> remove = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); + Ref<Texture2D> remove = get_editor_theme_icon(SNAME("Remove")); float remove_hpos = limit - hsep - remove->get_width(); - Ref<Texture2D> lock = get_theme_icon(SNAME("Lock"), SNAME("EditorIcons")); - Ref<Texture2D> unlock = get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons")); + Ref<Texture2D> lock = get_editor_theme_icon(SNAME("Lock")); + Ref<Texture2D> unlock = get_editor_theme_icon(SNAME("Unlock")); float lock_hpos = remove_hpos - hsep - lock->get_width(); - Ref<Texture2D> visibility_visible = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")); - Ref<Texture2D> visibility_hidden = get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")); + Ref<Texture2D> visibility_visible = get_editor_theme_icon(SNAME("GuiVisibilityVisible")); + Ref<Texture2D> visibility_hidden = get_editor_theme_icon(SNAME("GuiVisibilityHidden")); float visibility_hpos = lock_hpos - hsep - visibility_visible->get_width(); - Ref<Texture2D> solo = get_theme_icon(SNAME("AudioBusSolo"), SNAME("EditorIcons")); + Ref<Texture2D> solo = get_editor_theme_icon(SNAME("AudioBusSolo")); float solo_hpos = visibility_hpos - hsep - solo->get_width(); float buttons_width = remove->get_width() + lock->get_width() + visibility_visible->get_width() + solo->get_width() + hsep * 3; @@ -391,7 +392,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { subtracks[current_track] = rect; } else { - Color ac = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color ac = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); ac.a = 0.5; draw_rect(rect, ac); if (locked_tracks.has(selected_track)) { @@ -441,7 +442,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { } } - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); { //guides float min_left_scale = font->get_height(font_size) + vsep; @@ -482,7 +483,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { { //draw OTHER curves float scale = timeline->get_zoom_scale(); - Ref<Texture2D> point = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")); + Ref<Texture2D> point = get_editor_theme_icon(SNAME("KeyValue")); for (const KeyValue<int, Color> &E : subtrack_colors) { if (hidden_tracks.has(E.key)) { continue; @@ -630,10 +631,10 @@ void AnimationBezierTrackEdit::_notification(int p_what) { } draw_rect( Rect2(bs_from, bs_to - bs_from), - get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); + get_theme_color(SNAME("box_selection_fill_color"), EditorStringName(Editor))); draw_rect( Rect2(bs_from, bs_to - bs_from), - get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")), + get_theme_color(SNAME("box_selection_stroke_color"), EditorStringName(Editor)), false, Math::round(EDSCALE)); } @@ -681,7 +682,7 @@ void AnimationBezierTrackEdit::_play_position_draw() { int px = (-timeline->get_value() + play_position_pos) * scale + limit; if (px >= limit && px < (get_size().width)) { - Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); } } @@ -945,17 +946,17 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { menu->add_icon_item(bezier_icon, TTR("Insert Key Here"), MENU_KEY_INSERT); if (selection.size()) { menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE); + menu->add_icon_item(get_editor_theme_icon(SNAME("Duplicate")), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE); menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE); + menu->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE); menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("BezierHandlesFree"), SNAME("EditorIcons")), TTR("Make Handles Free"), MENU_KEY_SET_HANDLE_FREE); - menu->add_icon_item(get_theme_icon(SNAME("BezierHandlesLinear"), SNAME("EditorIcons")), TTR("Make Handles Linear"), MENU_KEY_SET_HANDLE_LINEAR); - menu->add_icon_item(get_theme_icon(SNAME("BezierHandlesBalanced"), SNAME("EditorIcons")), TTR("Make Handles Balanced"), MENU_KEY_SET_HANDLE_BALANCED); - menu->add_icon_item(get_theme_icon(SNAME("BezierHandlesMirror"), SNAME("EditorIcons")), TTR("Make Handles Mirrored"), MENU_KEY_SET_HANDLE_MIRRORED); + menu->add_icon_item(get_editor_theme_icon(SNAME("BezierHandlesFree")), TTR("Make Handles Free"), MENU_KEY_SET_HANDLE_FREE); + menu->add_icon_item(get_editor_theme_icon(SNAME("BezierHandlesLinear")), TTR("Make Handles Linear"), MENU_KEY_SET_HANDLE_LINEAR); + menu->add_icon_item(get_editor_theme_icon(SNAME("BezierHandlesBalanced")), TTR("Make Handles Balanced"), MENU_KEY_SET_HANDLE_BALANCED); + menu->add_icon_item(get_editor_theme_icon(SNAME("BezierHandlesMirror")), TTR("Make Handles Mirrored"), MENU_KEY_SET_HANDLE_MIRRORED); menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("BezierHandlesBalanced"), SNAME("EditorIcons")), TTR("Make Handles Balanced (Auto Tangent)"), MENU_KEY_SET_HANDLE_AUTO_BALANCED); - menu->add_icon_item(get_theme_icon(SNAME("BezierHandlesMirror"), SNAME("EditorIcons")), TTR("Make Handles Mirrored (Auto Tangent)"), MENU_KEY_SET_HANDLE_AUTO_MIRRORED); + menu->add_icon_item(get_editor_theme_icon(SNAME("BezierHandlesBalanced")), TTR("Make Handles Balanced (Auto Tangent)"), MENU_KEY_SET_HANDLE_AUTO_BALANCED); + menu->add_icon_item(get_editor_theme_icon(SNAME("BezierHandlesMirror")), TTR("Make Handles Mirrored (Auto Tangent)"), MENU_KEY_SET_HANDLE_AUTO_MIRRORED); } if (menu->get_item_count()) { diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 3aa3aa567b..77ab709679 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -36,6 +36,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_spin_slider.h" #include "editor/gui/scene_tree_editor.h" @@ -1304,10 +1305,10 @@ void AnimationTimelineEdit::_anim_loop_pressed() { } int AnimationTimelineEdit::get_buttons_width() const { - Ref<Texture2D> interp_mode = get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")); - Ref<Texture2D> interp_type = get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")); - Ref<Texture2D> loop_type = get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")); - Ref<Texture2D> remove_icon = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); + Ref<Texture2D> interp_mode = get_editor_theme_icon(SNAME("TrackContinuous")); + Ref<Texture2D> interp_type = get_editor_theme_icon(SNAME("InterpRaw")); + Ref<Texture2D> loop_type = get_editor_theme_icon(SNAME("InterpWrapClamp")); + Ref<Texture2D> remove_icon = get_editor_theme_icon(SNAME("Remove")); Ref<Texture2D> down_icon = get_theme_icon(SNAME("select_arrow"), SNAME("Tree")); int total_w = interp_mode->get_width() + interp_type->get_width() + loop_type->get_width() + remove_icon->get_width(); @@ -1317,7 +1318,7 @@ int AnimationTimelineEdit::get_buttons_width() const { } int AnimationTimelineEdit::get_name_limit() const { - Ref<Texture2D> hsize_icon = get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons")); + Ref<Texture2D> hsize_icon = get_editor_theme_icon(SNAME("Hsize")); int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width()); @@ -1331,20 +1332,20 @@ void AnimationTimelineEdit::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning"))); - add_track->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons"))); - time_icon->set_texture(get_theme_icon(SNAME("Time"), SNAME("EditorIcons"))); + add_track->set_icon(get_editor_theme_icon(SNAME("Add"))); + loop->set_icon(get_editor_theme_icon(SNAME("Loop"))); + time_icon->set_texture(get_editor_theme_icon(SNAME("Time"))); add_track->get_popup()->clear(); - add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), TTR("Property Track")); - add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXPosition"), SNAME("EditorIcons")), TTR("3D Position Track")); - add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXRotation"), SNAME("EditorIcons")), TTR("3D Rotation Track")); - add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXScale"), SNAME("EditorIcons")), TTR("3D Scale Track")); - add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyBlendShape"), SNAME("EditorIcons")), TTR("Blend Shape Track")); - add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), TTR("Call Method Track")); - add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), TTR("Bezier Curve Track")); - add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), TTR("Audio Playback Track")); - add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")), TTR("Animation Playback Track")); + add_track->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("KeyValue")), TTR("Property Track")); + add_track->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("KeyXPosition")), TTR("3D Position Track")); + add_track->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("KeyXRotation")), TTR("3D Rotation Track")); + add_track->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("KeyXScale")), TTR("3D Scale Track")); + add_track->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("KeyBlendShape")), TTR("Blend Shape Track")); + add_track->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("KeyCall")), TTR("Call Method Track")); + add_track->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("KeyBezier")), TTR("Bezier Curve Track")); + add_track->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("KeyAudio")), TTR("Audio Playback Track")); + add_track->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("KeyAnimation")), TTR("Animation Playback Track")); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { @@ -1376,7 +1377,7 @@ void AnimationTimelineEdit::_notification(int p_what) { l = 0.0001; // Avoid crashor. } - Ref<Texture2D> hsize_icon = get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons")); + Ref<Texture2D> hsize_icon = get_editor_theme_icon(SNAME("Hsize")); hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height()); draw_texture(hsize_icon, hsize_rect.position); @@ -1417,7 +1418,7 @@ void AnimationTimelineEdit::_notification(int p_what) { int end_px = (l - get_value()) * scale; int begin_px = -get_value() * scale; - Color notimecol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); + Color notimecol = get_theme_color(SNAME("dark_color_2"), EditorStringName(Editor)); Color timecolor = color; timecolor.a = 0.2; Color linecolor = color; @@ -1553,7 +1554,7 @@ Size2 AnimationTimelineEdit::get_minimum_size() const { Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); ms.height = MAX(ms.height, font->get_height(font_size)); - ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons"))->get_width() + 2; + ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_editor_theme_icon(SNAME("Hsize"))->get_width() + 2; return ms; } @@ -1602,15 +1603,15 @@ void AnimationTimelineEdit::update_values() { switch (animation->get_loop_mode()) { case Animation::LOOP_NONE: { - loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons"))); + loop->set_icon(get_editor_theme_icon(SNAME("Loop"))); loop->set_pressed(false); } break; case Animation::LOOP_LINEAR: { - loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons"))); + loop->set_icon(get_editor_theme_icon(SNAME("Loop"))); loop->set_pressed(true); } break; case Animation::LOOP_PINGPONG: { - loop->set_icon(get_theme_icon(SNAME("PingPongLoop"), SNAME("EditorIcons"))); + loop->set_icon(get_editor_theme_icon(SNAME("PingPongLoop"))); loop->set_pressed(true); } break; default: @@ -1631,11 +1632,11 @@ void AnimationTimelineEdit::_play_position_draw() { int px = (-get_value() + play_position_pos) * scale + get_name_limit(); if (px >= get_name_limit() && px < (play_position->get_size().width - get_buttons_width())) { - Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); play_position->draw_texture( - get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons")), - Point2(px - get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons"))->get_width() * 0.5, 0), + get_editor_theme_icon(SNAME("TimelineIndicator")), + Point2(px - get_editor_theme_icon(SNAME("TimelineIndicator"))->get_width() * 0.5, 0), color); } } @@ -1813,7 +1814,7 @@ void AnimationTrackEdit::_notification(int p_what) { ERR_FAIL_INDEX(track, animation->get_track_count()); type_icon = _get_key_type_icon(); - selected_icon = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); + selected_icon = get_editor_theme_icon(SNAME("KeySelected")); } break; case NOTIFICATION_DRAW: { @@ -1835,10 +1836,10 @@ void AnimationTrackEdit::_notification(int p_what) { } if (has_focus()) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); accent.a *= 0.7; // Offside so the horizontal sides aren't cutoff. - draw_style_box(get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles")), Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0))); + draw_style_box(get_theme_stylebox(SNAME("Focus"), EditorStringName(EditorStyles)), Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0))); } Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); @@ -1848,7 +1849,7 @@ void AnimationTrackEdit::_notification(int p_what) { Color linecolor = color; linecolor.a = 0.2; - Color dc = get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")); + Color dc = get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor)); // NAMES AND ICONS // @@ -1874,7 +1875,7 @@ void AnimationTrackEdit::_notification(int p_what) { String text; Color text_color = color; if (node && EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) { - text_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + text_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); } if (in_group) { @@ -1949,24 +1950,24 @@ void AnimationTrackEdit::_notification(int p_what) { { Ref<Texture2D> wrap_icon[2] = { - get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), - get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), + get_editor_theme_icon(SNAME("InterpWrapClamp")), + get_editor_theme_icon(SNAME("InterpWrapLoop")), }; Ref<Texture2D> interp_icon[5] = { - get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), - get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), - get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")), - get_theme_icon(SNAME("InterpLinearAngle"), SNAME("EditorIcons")), - get_theme_icon(SNAME("InterpCubicAngle"), SNAME("EditorIcons")), + get_editor_theme_icon(SNAME("InterpRaw")), + get_editor_theme_icon(SNAME("InterpLinear")), + get_editor_theme_icon(SNAME("InterpCubic")), + get_editor_theme_icon(SNAME("InterpLinearAngle")), + get_editor_theme_icon(SNAME("InterpCubicAngle")), }; Ref<Texture2D> cont_icon[3] = { - get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), - get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), - get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")) + get_editor_theme_icon(SNAME("TrackContinuous")), + get_editor_theme_icon(SNAME("TrackDiscrete")), + get_editor_theme_icon(SNAME("TrackCapture")) }; Ref<Texture2D> blend_icon[2] = { - get_theme_icon(SNAME("UseBlendEnable"), SNAME("EditorIcons")), - get_theme_icon(SNAME("UseBlendDisable"), SNAME("EditorIcons")), + get_editor_theme_icon(SNAME("UseBlendEnable")), + get_editor_theme_icon(SNAME("UseBlendDisable")), }; int ofs = get_size().width - timeline->get_buttons_width(); @@ -2096,7 +2097,7 @@ void AnimationTrackEdit::_notification(int p_what) { { // Erase. - Ref<Texture2D> icon = get_theme_icon(animation->track_is_compressed(track) ? SNAME("Lock") : SNAME("Remove"), SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(animation->track_is_compressed(track) ? SNAME("Lock") : SNAME("Remove")); remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width()); remove_rect.position.y = int(get_size().height - icon->get_height()) / 2; @@ -2117,7 +2118,7 @@ void AnimationTrackEdit::_notification(int p_what) { } if (dropping_at != 0) { - Color drop_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color drop_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); if (dropping_at < 0) { draw_line(Vector2(0, 0), Vector2(get_size().width, 0), drop_color, Math::round(EDSCALE)); } else { @@ -2202,7 +2203,7 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool if (animation->track_get_type(track) == Animation::TYPE_VALUE && !Math::is_equal_approx(animation->track_get_key_transition(track, p_index), real_t(1.0))) { // Use a different icon for keys with non-linear easing. - icon_to_draw = get_theme_icon(p_selected ? SNAME("KeyEasedSelected") : SNAME("KeyValueEased"), SNAME("EditorIcons")); + icon_to_draw = get_editor_theme_icon(p_selected ? SNAME("KeyEasedSelected") : SNAME("KeyValueEased")); } // Override type icon for invalid value keys, unless selected. @@ -2210,7 +2211,7 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool const Variant &v = animation->track_get_key_value(track, p_index); Variant::Type valid_type = Variant::NIL; if (!_is_value_key_valid(v, valid_type)) { - icon_to_draw = get_theme_icon(SNAME("KeyInvalid"), SNAME("EditorIcons")); + icon_to_draw = get_editor_theme_icon(SNAME("KeyInvalid")); } } @@ -2333,7 +2334,7 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati node_path = animation->track_get_path(p_track); type_icon = _get_key_type_icon(); - selected_icon = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); + selected_icon = get_editor_theme_icon(SNAME("KeySelected")); } NodePath AnimationTrackEdit::get_path() const { @@ -2341,7 +2342,7 @@ NodePath AnimationTrackEdit::get_path() const { } Size2 AnimationTrackEdit::get_minimum_size() const { - Ref<Texture2D> texture = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); + Ref<Texture2D> texture = get_editor_theme_icon(SNAME("Object")); Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int separation = get_theme_constant(SNAME("v_separation"), SNAME("ItemList")); @@ -2374,7 +2375,7 @@ void AnimationTrackEdit::_play_position_draw() { int px = (-timeline->get_value() + play_position_pos) * scale + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); } } @@ -2432,15 +2433,15 @@ bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant Ref<Texture2D> AnimationTrackEdit::_get_key_type_icon() const { const Ref<Texture2D> type_icons[9] = { - get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackPosition"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackRotation"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackScale"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackBlendShape"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")) + get_editor_theme_icon(SNAME("KeyValue")), + get_editor_theme_icon(SNAME("KeyTrackPosition")), + get_editor_theme_icon(SNAME("KeyTrackRotation")), + get_editor_theme_icon(SNAME("KeyTrackScale")), + get_editor_theme_icon(SNAME("KeyTrackBlendShape")), + get_editor_theme_icon(SNAME("KeyCall")), + get_editor_theme_icon(SNAME("KeyBezier")), + get_editor_theme_icon(SNAME("KeyAudio")), + get_editor_theme_icon(SNAME("KeyAnimation")) }; return type_icons[animation->track_get_type(track)]; } @@ -2663,12 +2664,12 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } menu->clear(); if (animation->track_get_type(track) == Animation::TYPE_AUDIO) { - menu->add_icon_item(get_theme_icon(SNAME("UseBlendEnable"), SNAME("EditorIcons")), TTR("Use Blend"), MENU_USE_BLEND_ENABLED); - menu->add_icon_item(get_theme_icon(SNAME("UseBlendDisable"), SNAME("EditorIcons")), TTR("Don't Use Blend"), MENU_USE_BLEND_DISABLED); + menu->add_icon_item(get_editor_theme_icon(SNAME("UseBlendEnable")), TTR("Use Blend"), MENU_USE_BLEND_ENABLED); + menu->add_icon_item(get_editor_theme_icon(SNAME("UseBlendDisable")), TTR("Don't Use Blend"), MENU_USE_BLEND_DISABLED); } else { - menu->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); - menu->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); - menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE); + menu->add_icon_item(get_editor_theme_icon(SNAME("TrackContinuous")), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); + menu->add_icon_item(get_editor_theme_icon(SNAME("TrackDiscrete")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); + menu->add_icon_item(get_editor_theme_icon(SNAME("TrackCapture")), TTR("Capture"), MENU_CALL_MODE_CAPTURE); } menu->reset_size(); @@ -2685,9 +2686,9 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); - menu->add_icon_item(get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), TTR("Linear"), MENU_INTERPOLATION_LINEAR); - menu->add_icon_item(get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); + menu->add_icon_item(get_editor_theme_icon(SNAME("InterpRaw")), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); + menu->add_icon_item(get_editor_theme_icon(SNAME("InterpLinear")), TTR("Linear"), MENU_INTERPOLATION_LINEAR); + menu->add_icon_item(get_editor_theme_icon(SNAME("InterpCubic")), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); // Check whether it is angle property. AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton(); if (ape) { @@ -2700,8 +2701,8 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { ClassDB::get_property_info(nd->get_class(), prop, &prop_info); bool is_angle = prop_info.type == Variant::FLOAT && prop_info.hint_string.find("radians") != -1; if (is_angle) { - menu->add_icon_item(get_theme_icon(SNAME("InterpLinearAngle"), SNAME("EditorIcons")), TTR("Linear Angle"), MENU_INTERPOLATION_LINEAR_ANGLE); - menu->add_icon_item(get_theme_icon(SNAME("InterpCubicAngle"), SNAME("EditorIcons")), TTR("Cubic Angle"), MENU_INTERPOLATION_CUBIC_ANGLE); + menu->add_icon_item(get_editor_theme_icon(SNAME("InterpLinearAngle")), TTR("Linear Angle"), MENU_INTERPOLATION_LINEAR_ANGLE); + menu->add_icon_item(get_editor_theme_icon(SNAME("InterpCubicAngle")), TTR("Cubic Angle"), MENU_INTERPOLATION_CUBIC_ANGLE); } } } @@ -2720,8 +2721,8 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); - menu->add_icon_item(get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); + menu->add_icon_item(get_editor_theme_icon(SNAME("InterpWrapClamp")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); + menu->add_icon_item(get_editor_theme_icon(SNAME("InterpWrapLoop")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); menu->reset_size(); Vector2 popup_pos = get_screen_position() + loop_wrap_rect.position + Vector2(0, loop_wrap_rect.size.height); @@ -2818,18 +2819,18 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } menu->clear(); - menu->add_icon_item(get_theme_icon(SNAME("Key"), SNAME("EditorIcons")), TTR("Insert Key"), MENU_KEY_INSERT); + menu->add_icon_item(get_editor_theme_icon(SNAME("Key")), TTR("Insert Key"), MENU_KEY_INSERT); if (editor->is_selection_active()) { menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); + menu->add_icon_item(get_editor_theme_icon(SNAME("Duplicate")), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); AnimationPlayer *player = AnimationPlayerEditor::get_singleton()->get_player(); if (!player->has_animation(SceneStringNames::get_singleton()->RESET) || animation != player->get_animation(SceneStringNames::get_singleton()->RESET)) { - menu->add_icon_item(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), TTR("Add RESET Value(s)"), MENU_KEY_ADD_RESET); + menu->add_icon_item(get_editor_theme_icon(SNAME("Reload")), TTR("Add RESET Value(s)"), MENU_KEY_ADD_RESET); } menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Key(s)"), MENU_KEY_DELETE); + menu->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Delete Key(s)"), MENU_KEY_DELETE); } menu->reset_size(); @@ -3215,11 +3216,11 @@ void AnimationTrackEditGroup::_notification(int p_what) { if (root && root->has_node(node)) { Node *n = root->get_node(node); if (n && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) { - color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); } } - Color bgcol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); + Color bgcol = get_theme_color(SNAME("dark_color_2"), EditorStringName(Editor)); bgcol.a *= 0.6; draw_rect(Rect2(Point2(), get_size()), bgcol); Color linecolor = color; @@ -3237,7 +3238,7 @@ void AnimationTrackEditGroup::_notification(int p_what) { int px = (-timeline->get_value() + timeline->get_play_position()) * timeline->get_zoom_scale() + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_line(Point2(px, 0), Point2(px, get_size().height), accent, Math::round(2 * EDSCALE)); } } break; @@ -4434,7 +4435,7 @@ void AnimationTrackEditor::_update_tracks() { if (!group_sort.has(base_path)) { AnimationTrackEditGroup *g = memnew(AnimationTrackEditGroup); - Ref<Texture2D> icon = get_theme_icon(SNAME("Node"), SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(SNAME("Node")); String name = base_path; String tooltip; if (root && root->has_node(base_path)) { @@ -4615,14 +4616,14 @@ void AnimationTrackEditor::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - zoom_icon->set_texture(get_theme_icon(SNAME("Zoom"), SNAME("EditorIcons"))); - bezier_edit_icon->set_icon(get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons"))); - snap->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); - view_group->set_icon(get_theme_icon(view_group->is_pressed() ? SNAME("AnimationTrackList") : SNAME("AnimationTrackGroup"), SNAME("EditorIcons"))); - selected_filter->set_icon(get_theme_icon(SNAME("AnimationFilter"), SNAME("EditorIcons"))); - imported_anim_warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); + zoom_icon->set_texture(get_editor_theme_icon(SNAME("Zoom"))); + bezier_edit_icon->set_icon(get_editor_theme_icon(SNAME("EditBezier"))); + snap->set_icon(get_editor_theme_icon(SNAME("Snap"))); + view_group->set_icon(get_editor_theme_icon(view_group->is_pressed() ? SNAME("AnimationTrackList") : SNAME("AnimationTrackGroup"))); + selected_filter->set_icon(get_editor_theme_icon(SNAME("AnimationFilter"))); + imported_anim_warning->set_icon(get_editor_theme_icon(SNAME("NodeWarning"))); main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_editor_theme_icon(SNAME("Reload"))); } break; case NOTIFICATION_READY: { @@ -5312,8 +5313,8 @@ float AnimationTrackEditor::get_moving_selection_offset() const { void AnimationTrackEditor::_box_selection_draw() { const Rect2 selection_rect = Rect2(Point2(), box_selection->get_size()); - box_selection->draw_rect(selection_rect, get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); - box_selection->draw_rect(selection_rect, get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")), false, Math::round(EDSCALE)); + box_selection->draw_rect(selection_rect, get_theme_color(SNAME("box_selection_fill_color"), EditorStringName(Editor))); + box_selection->draw_rect(selection_rect, get_theme_color(SNAME("box_selection_stroke_color"), EditorStringName(Editor)), false, Math::round(EDSCALE)); } void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { @@ -5590,10 +5591,10 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } String text; - Ref<Texture2D> icon = get_theme_icon(SNAME("Node"), SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(SNAME("Node")); if (node) { - if (has_theme_icon(node->get_class(), SNAME("EditorIcons"))) { - icon = get_theme_icon(node->get_class(), SNAME("EditorIcons")); + if (has_theme_icon(node->get_class(), EditorStringName(EditorIcons))) { + icon = get_editor_theme_icon(node->get_class()); } text = node->get_name(); @@ -6249,7 +6250,7 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) { void AnimationTrackEditor::_view_group_toggle() { _update_tracks(); - view_group->set_icon(get_theme_icon(view_group->is_pressed() ? SNAME("AnimationTrackList") : SNAME("AnimationTrackGroup"), SNAME("EditorIcons"))); + view_group->set_icon(get_editor_theme_icon(view_group->is_pressed() ? SNAME("AnimationTrackList") : SNAME("AnimationTrackGroup"))); bezier_edit->set_filtered(selected_filter->is_pressed()); } diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 553f391a1d..91a0f213ec 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -33,6 +33,7 @@ #include "editor/audio_stream_preview.h" #include "editor/editor_resource_preview.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "scene/2d/animated_sprite_2d.h" #include "scene/2d/sprite_2d.h" @@ -73,7 +74,7 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, draw_texture(icon, ofs); if (p_selected) { - Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_rect_clipped(Rect2(ofs, icon->get_size()), color, false); } } @@ -180,7 +181,7 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x, draw_rect_clipped(rect, color); if (p_selected) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_rect_clipped(rect, accent, false); } } @@ -329,7 +330,7 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), points, colors); if (p_selected) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_rect(rect, accent, false); } } else { @@ -342,7 +343,7 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, draw_rect_clipped(rect, color); if (p_selected) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_rect_clipped(rect, accent, false); } } @@ -541,7 +542,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in return; } - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); Color bg = accent; bg.a = 0.15; @@ -700,7 +701,7 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ } if (p_selected) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_rect(rect, accent, false); } } else { @@ -713,7 +714,7 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ draw_rect_clipped(rect, color); if (p_selected) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_rect_clipped(rect, accent, false); } } @@ -726,12 +727,12 @@ void AnimationTrackEditSubAnim::set_node(Object *p_object) { //// VOLUME DB //// int AnimationTrackEditVolumeDB::get_key_height() const { - Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); + Ref<Texture2D> volume_texture = get_editor_theme_icon(SNAME("ColorTrackVu")); return volume_texture->get_height() * 1.2; } void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { - Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); + Ref<Texture2D> volume_texture = get_editor_theme_icon(SNAME("ColorTrackVu")); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; @@ -742,7 +743,7 @@ void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { } void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) { - Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); + Ref<Texture2D> volume_texture = get_editor_theme_icon(SNAME("ColorTrackVu")); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; int db0 = y_from + (24 / 80.0) * tex_h; @@ -777,7 +778,7 @@ void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec, to_x = p_clip_right; } - Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); + Ref<Texture2D> volume_texture = get_editor_theme_icon(SNAME("ColorTrackVu")); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; @@ -936,7 +937,7 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), points, colors); - Color cut_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color cut_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); cut_color.a = 0.7; if (start_ofs > 0 && pixel_begin > p_clip_left) { draw_rect(Rect2(pixel_begin, rect.position.y, 1, rect.size.y), cut_color); @@ -946,7 +947,7 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int } if (p_selected) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_rect(rect, accent, false); } } @@ -1307,7 +1308,7 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, } if (p_selected) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_rect(rect, accent, false); } } else { @@ -1320,7 +1321,7 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, draw_rect_clipped(rect, color); if (p_selected) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_rect_clipped(rect, accent, false); } } diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 2123e79475..876fef078b 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -36,6 +36,7 @@ #include "core/templates/pair.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/plugins/script_editor_plugin.h" #include "scene/resources/font.h" @@ -93,11 +94,11 @@ void FindReplaceBar::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); - find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); - hide_button->set_texture_normal(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); - hide_button->set_texture_hover(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); - hide_button->set_texture_pressed(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + find_prev->set_icon(get_editor_theme_icon(SNAME("MoveUp"))); + find_next->set_icon(get_editor_theme_icon(SNAME("MoveDown"))); + hide_button->set_texture_normal(get_editor_theme_icon(SNAME("Close"))); + hide_button->set_texture_hover(get_editor_theme_icon(SNAME("Close"))); + hide_button->set_texture_pressed(get_editor_theme_icon(SNAME("Close"))); hide_button->set_custom_minimum_size(hide_button->get_texture_normal()->get_size()); } break; @@ -106,7 +107,7 @@ void FindReplaceBar::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), EditorStringName(Editor))); } break; case NOTIFICATION_PREDELETE: { @@ -311,7 +312,7 @@ void FindReplaceBar::_replace_all() { } text_editor->set_v_scroll(vsval); - matches_label->add_theme_color_override("font_color", rc > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); + matches_label->add_theme_color_override("font_color", rc > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), EditorStringName(Editor))); matches_label->set_text(vformat(TTR("%d replaced."), rc)); text_editor->call_deferred(SNAME("connect"), "text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed)); @@ -407,7 +408,7 @@ void FindReplaceBar::_update_matches_label() { } else { matches_label->show(); - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), EditorStringName(Editor))); if (results_count == 0) { matches_label->set_text(TTR("No match")); @@ -954,41 +955,41 @@ Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptLanguage::CodeCo Ref<Texture2D> tex; switch (p_option.kind) { case ScriptLanguage::CODE_COMPLETION_KIND_CLASS: { - if (has_theme_icon(p_option.display, SNAME("EditorIcons"))) { - tex = get_theme_icon(p_option.display, SNAME("EditorIcons")); + if (has_theme_icon(p_option.display, EditorStringName(EditorIcons))) { + tex = get_editor_theme_icon(p_option.display); } else { - tex = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); + tex = get_editor_theme_icon(SNAME("Object")); } } break; case ScriptLanguage::CODE_COMPLETION_KIND_ENUM: - tex = get_theme_icon(SNAME("Enum"), SNAME("EditorIcons")); + tex = get_editor_theme_icon(SNAME("Enum")); break; case ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH: - tex = get_theme_icon(SNAME("File"), SNAME("EditorIcons")); + tex = get_editor_theme_icon(SNAME("File")); break; case ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH: - tex = get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")); + tex = get_editor_theme_icon(SNAME("NodePath")); break; case ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE: - tex = get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")); + tex = get_editor_theme_icon(SNAME("Variant")); break; case ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT: - tex = get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons")); + tex = get_editor_theme_icon(SNAME("MemberConstant")); break; case ScriptLanguage::CODE_COMPLETION_KIND_MEMBER: - tex = get_theme_icon(SNAME("MemberProperty"), SNAME("EditorIcons")); + tex = get_editor_theme_icon(SNAME("MemberProperty")); break; case ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL: - tex = get_theme_icon(SNAME("MemberSignal"), SNAME("EditorIcons")); + tex = get_editor_theme_icon(SNAME("MemberSignal")); break; case ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION: - tex = get_theme_icon(SNAME("MemberMethod"), SNAME("EditorIcons")); + tex = get_editor_theme_icon(SNAME("MemberMethod")); break; case ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT: - tex = get_theme_icon(SNAME("BoxMesh"), SNAME("EditorIcons")); + tex = get_editor_theme_icon(SNAME("BoxMesh")); break; default: - tex = get_theme_icon(SNAME("String"), SNAME("EditorIcons")); + tex = get_editor_theme_icon(SNAME("String")); break; } return tex; @@ -1679,12 +1680,12 @@ void CodeTextEditor::_update_text_editor_theme() { emit_signal(SNAME("load_theme_settings")); error->begin_bulk_theme_override(); - error->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); - error->add_theme_font_size_override(SNAME("font_size"), get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); - error->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts))); + error->add_theme_font_size_override(SNAME("font_size"), get_theme_font_size(SNAME("status_source_size"), EditorStringName(EditorFonts))); + error->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), EditorStringName(Editor))); - Ref<Font> status_bar_font = get_theme_font(SNAME("status_source"), SNAME("EditorFonts")); - int status_bar_font_size = get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")); + Ref<Font> status_bar_font = get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts)); + int status_bar_font_size = get_theme_font_size(SNAME("status_source_size"), EditorStringName(EditorFonts)); error->add_theme_font_override("font", status_bar_font); error->add_theme_font_size_override("font_size", status_bar_font_size); int count = status_bar->get_child_count(); @@ -1802,18 +1803,18 @@ void CodeTextEditor::_error_pressed(const Ref<InputEvent> &p_event) { } void CodeTextEditor::_update_status_bar_theme() { - error_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); - error_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - error_button->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); - error_button->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); + error_button->set_icon(get_editor_theme_icon(SNAME("StatusError"))); + error_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); + error_button->add_theme_font_override("font", get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts))); + error_button->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), EditorStringName(EditorFonts))); - warning_button->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); - warning_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); - warning_button->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); - warning_button->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); + warning_button->set_icon(get_editor_theme_icon(SNAME("NodeWarning"))); + warning_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); + warning_button->add_theme_font_override("font", get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts))); + warning_button->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), EditorStringName(EditorFonts))); - line_and_col_txt->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); - line_and_col_txt->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); + line_and_col_txt->add_theme_font_override("font", get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts))); + line_and_col_txt->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), EditorStringName(EditorFonts))); } void CodeTextEditor::_notification(int p_what) { @@ -1949,9 +1950,9 @@ void CodeTextEditor::show_toggle_scripts_button() { void CodeTextEditor::update_toggle_scripts_button() { if (is_layout_rtl()) { - toggle_scripts_button->set_icon(get_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Forward") : SNAME("Back"), SNAME("EditorIcons"))); + toggle_scripts_button->set_icon(get_editor_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Forward") : SNAME("Back"))); } else { - toggle_scripts_button->set_icon(get_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Back") : SNAME("Forward"), SNAME("EditorIcons"))); + toggle_scripts_button->set_icon(get_editor_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Back") : SNAME("Forward"))); } toggle_scripts_button->set_tooltip_text(vformat("%s (%s)", TTR("Toggle Scripts Panel"), ED_GET_SHORTCUT("script_editor/toggle_scripts_panel")->get_as_text())); } diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index b3ca04420f..11fc5efd62 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -38,6 +38,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/scene_tree_editor.h" #include "editor/node_dock.h" @@ -323,7 +324,7 @@ List<MethodInfo> ConnectDialog::_filter_method_list(const List<MethodInfo> &p_me void ConnectDialog::_update_method_tree() { method_tree->clear(); - Color disabled_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")) * 0.7; + Color disabled_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)) * 0.7; String search_string = method_search->get_text(); Node *target = tree->get_selected(); if (!target) { @@ -359,7 +360,7 @@ void ConnectDialog::_update_method_tree() { if (!methods.is_empty()) { TreeItem *si_item = method_tree->create_item(root_item); si_item->set_text(0, TTR("Attached Script")); - si_item->set_icon(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons"))); + si_item->set_icon(0, get_editor_theme_icon(SNAME("Script"))); si_item->set_selectable(0, false); _create_method_tree_items(methods, si_item); @@ -376,9 +377,9 @@ void ConnectDialog::_update_method_tree() { do { TreeItem *class_item = method_tree->create_item(root_item); class_item->set_text(0, current_class); - Ref<Texture2D> icon = get_theme_icon(SNAME("Node"), SNAME("EditorIcons")); - if (has_theme_icon(current_class, SNAME("EditorIcons"))) { - icon = get_theme_icon(current_class, SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(SNAME("Node")); + if (has_theme_icon(current_class, EditorStringName(EditorIcons))) { + icon = get_editor_theme_icon(current_class); } class_item->set_icon(0, icon); class_item->set_selectable(0, false); @@ -443,7 +444,7 @@ void ConnectDialog::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < type_list->get_item_count(); i++) { String type_name = Variant::get_type_name((Variant::Type)type_list->get_item_id(i)); - type_list->set_item_icon(i, get_theme_icon(type_name, SNAME("EditorIcons"))); + type_list->set_item_icon(i, get_editor_theme_icon(type_name)); } Ref<StyleBox> style = get_theme_stylebox("normal", "LineEdit")->duplicate(); @@ -451,8 +452,8 @@ void ConnectDialog::_notification(int p_what) { style->set_content_margin(SIDE_TOP, style->get_content_margin(SIDE_TOP) + 1.0); from_signal->add_theme_style_override("normal", style); } - method_search->set_right_icon(get_theme_icon("Search", "EditorIcons")); - open_method_tree->set_icon(get_theme_icon("Edit", "EditorIcons")); + method_search->set_right_icon(get_editor_theme_icon("Search")); + open_method_tree->set_icon(get_editor_theme_icon("Edit")); } break; } } @@ -592,7 +593,7 @@ void ConnectDialog::init(const ConnectionData &p_cd, const PackedStringArray &p_ void ConnectDialog::popup_dialog(const String p_for_signal) { from_signal->set_text(p_for_signal); - error_label->add_theme_color_override("font_color", error_label->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_label->add_theme_color_override("font_color", error_label->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); filter_nodes->clear(); if (!advanced->is_pressed()) { @@ -995,15 +996,15 @@ void ConnectionsDock::_tree_item_selected() { TreeItem *item = tree->get_selected(); if (item && _get_item_type(*item) == TREE_ITEM_TYPE_SIGNAL) { connect_button->set_text(TTR("Connect...")); - connect_button->set_icon(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + connect_button->set_icon(get_editor_theme_icon(SNAME("Instance"))); connect_button->set_disabled(false); } else if (item && _get_item_type(*item) == TREE_ITEM_TYPE_CONNECTION) { connect_button->set_text(TTR("Disconnect")); - connect_button->set_icon(get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons"))); + connect_button->set_icon(get_editor_theme_icon(SNAME("Unlinked"))); connect_button->set_disabled(false); } else { connect_button->set_text(TTR("Connect...")); - connect_button->set_icon(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + connect_button->set_icon(get_editor_theme_icon(SNAME("Instance"))); connect_button->set_disabled(true); } } @@ -1261,18 +1262,18 @@ void ConnectionsDock::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + search_box->set_right_icon(get_editor_theme_icon(SNAME("Search"))); - class_menu->set_item_icon(class_menu->get_item_index(CLASS_MENU_OPEN_DOCS), get_theme_icon(SNAME("Help"), SNAME("EditorIcons"))); + class_menu->set_item_icon(class_menu->get_item_index(CLASS_MENU_OPEN_DOCS), get_editor_theme_icon(SNAME("Help"))); - signal_menu->set_item_icon(signal_menu->get_item_index(SIGNAL_MENU_CONNECT), get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); - signal_menu->set_item_icon(signal_menu->get_item_index(SIGNAL_MENU_DISCONNECT_ALL), get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons"))); - signal_menu->set_item_icon(signal_menu->get_item_index(SIGNAL_MENU_COPY_NAME), get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); - signal_menu->set_item_icon(signal_menu->get_item_index(SIGNAL_MENU_OPEN_DOCS), get_theme_icon(SNAME("Help"), SNAME("EditorIcons"))); + signal_menu->set_item_icon(signal_menu->get_item_index(SIGNAL_MENU_CONNECT), get_editor_theme_icon(SNAME("Instance"))); + signal_menu->set_item_icon(signal_menu->get_item_index(SIGNAL_MENU_DISCONNECT_ALL), get_editor_theme_icon(SNAME("Unlinked"))); + signal_menu->set_item_icon(signal_menu->get_item_index(SIGNAL_MENU_COPY_NAME), get_editor_theme_icon(SNAME("ActionCopy"))); + signal_menu->set_item_icon(signal_menu->get_item_index(SIGNAL_MENU_OPEN_DOCS), get_editor_theme_icon(SNAME("Help"))); - slot_menu->set_item_icon(slot_menu->get_item_index(SLOT_MENU_EDIT), get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - slot_menu->set_item_icon(slot_menu->get_item_index(SLOT_MENU_GO_TO_METHOD), get_theme_icon(SNAME("ArrowRight"), SNAME("EditorIcons"))); - slot_menu->set_item_icon(slot_menu->get_item_index(SLOT_MENU_DISCONNECT), get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons"))); + slot_menu->set_item_icon(slot_menu->get_item_index(SLOT_MENU_EDIT), get_editor_theme_icon(SNAME("Edit"))); + slot_menu->set_item_icon(slot_menu->get_item_index(SLOT_MENU_GO_TO_METHOD), get_editor_theme_icon(SNAME("ArrowRight"))); + slot_menu->set_item_icon(slot_menu->get_item_index(SLOT_MENU_DISCONNECT), get_editor_theme_icon(SNAME("Unlinked"))); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { @@ -1342,8 +1343,8 @@ void ConnectionsDock::update_tree() { } class_icon = editor_data.get_script_icon(script_base); - if (class_icon.is_null() && has_theme_icon(native_base, SNAME("EditorIcons"))) { - class_icon = get_theme_icon(native_base, SNAME("EditorIcons")); + if (class_icon.is_null() && has_theme_icon(native_base, EditorStringName(EditorIcons))) { + class_icon = get_editor_theme_icon(native_base); } script_base->get_script_signal_list(&class_signals); @@ -1382,8 +1383,8 @@ void ConnectionsDock::update_tree() { doc_class_name = String(); } - if (has_theme_icon(native_base, SNAME("EditorIcons"))) { - class_icon = get_theme_icon(native_base, SNAME("EditorIcons")); + if (has_theme_icon(native_base, EditorStringName(EditorIcons))) { + class_icon = get_editor_theme_icon(native_base); } ClassDB::get_signal_list(native_base, &class_signals, true); @@ -1392,7 +1393,7 @@ void ConnectionsDock::update_tree() { } if (class_icon.is_null()) { - class_icon = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); + class_icon = get_editor_theme_icon(SNAME("Object")); } TreeItem *section_item = nullptr; @@ -1408,7 +1409,7 @@ void ConnectionsDock::update_tree() { section_item->set_icon(0, class_icon); section_item->set_selectable(0, false); section_item->set_editable(0, false); - section_item->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + section_item->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); section_item->set_metadata(0, doc_class_name); } @@ -1434,7 +1435,7 @@ void ConnectionsDock::update_tree() { sinfo["name"] = signal_name; sinfo["args"] = argnames; signal_item->set_metadata(0, sinfo); - signal_item->set_icon(0, get_theme_icon(SNAME("Signal"), SNAME("EditorIcons"))); + signal_item->set_icon(0, get_editor_theme_icon(SNAME("Signal"))); // Set tooltip with the signal's documentation. { @@ -1491,11 +1492,11 @@ void ConnectionsDock::update_tree() { TreeItem *connection_item = tree->create_item(signal_item); connection_item->set_text(0, path); connection_item->set_metadata(0, connection); - connection_item->set_icon(0, get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); + connection_item->set_icon(0, get_editor_theme_icon(SNAME("Slot"))); if (_is_connection_inherited(connection)) { // The scene inherits this connection. - connection_item->set_custom_color(0, get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + connection_item->set_custom_color(0, get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); connection_item->set_meta("_inherited_connection", true); } } @@ -1503,7 +1504,7 @@ void ConnectionsDock::update_tree() { } connect_button->set_text(TTR("Connect...")); - connect_button->set_icon(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + connect_button->set_icon(get_editor_theme_icon(SNAME("Instance"))); connect_button->set_disabled(true); } diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index e2cb989e6a..a8a2ac0c20 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -37,11 +37,12 @@ #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const String &p_current_type, const String &p_current_name) { _fill_type_list(); - icon_fallback = search_options->has_theme_icon(base_type, SNAME("EditorIcons")) ? base_type : "Object"; + icon_fallback = search_options->has_theme_icon(base_type, EditorStringName(EditorIcons)) ? base_type : "Object"; if (p_dont_clear) { search_box->select_all(); @@ -170,7 +171,7 @@ void CreateDialog::_update_search() { TreeItem *root = search_options->create_item(); root->set_text(0, base_type); - root->set_icon(0, search_options->get_theme_icon(icon_fallback, SNAME("EditorIcons"))); + root->set_icon(0, search_options->get_editor_theme_icon(icon_fallback)); search_options_types[base_type] = root; _configure_search_option_item(root, base_type, ClassDB::class_exists(base_type) ? TypeCategory::CPP_TYPE : TypeCategory::OTHER_TYPE); @@ -295,16 +296,16 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type)); if (!instantiable) { - r_item->set_custom_color(0, search_options->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + r_item->set_custom_color(0, search_options->get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); } bool is_deprecated = EditorHelp::get_doc_data()->class_list[p_type].is_deprecated; bool is_experimental = EditorHelp::get_doc_data()->class_list[p_type].is_experimental; if (is_deprecated) { - r_item->add_button(0, get_theme_icon("StatusError", SNAME("EditorIcons")), 0, false, TTR("This class is marked as deprecated.")); + r_item->add_button(0, get_editor_theme_icon("StatusError"), 0, false, TTR("This class is marked as deprecated.")); } else if (is_experimental) { - r_item->add_button(0, get_theme_icon("NodeWarning", SNAME("EditorIcons")), 0, false, TTR("This class is marked as experimental.")); + r_item->add_button(0, get_editor_theme_icon("NodeWarning"), 0, false, TTR("This class is marked as experimental.")); } if (!search_box->get_text().is_empty()) { @@ -450,8 +451,8 @@ void CreateDialog::_sbox_input(const Ref<InputEvent> &p_ie) { } void CreateDialog::_update_theme() { - search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - favorite->set_icon(search_options->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); + search_box->set_right_icon(search_options->get_editor_theme_icon(SNAME("Search"))); + favorite->set_icon(search_options->get_editor_theme_icon(SNAME("Favorites"))); } void CreateDialog::_notification(int p_what) { @@ -475,7 +476,7 @@ void CreateDialog::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - const int icon_width = get_theme_constant(SNAME("class_icon_size"), SNAME("Editor")); + const int icon_width = get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)); search_options->add_theme_constant_override("icon_max_width", icon_width); favorites->add_theme_constant_override("icon_max_width", icon_width); recent->set_fixed_icon_size(Size2(icon_width, icon_width)); diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 6143f5ac00..99c66261e4 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -36,6 +36,7 @@ #include "editor/editor_log.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_run_bar.h" #include "editor/inspector_dock.h" @@ -62,8 +63,8 @@ EditorDebuggerNode::EditorDebuggerNode() { singleton = this; } - add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_LEFT)); - add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_RIGHT)); + add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_LEFT)); + add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_RIGHT)); tabs = memnew(TabContainer); tabs->set_tabs_visible(false); @@ -118,7 +119,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() { if (tabs->get_tab_count() > 1) { node->clear_style(); tabs->set_tabs_visible(true); - tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); + tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), EditorStringName(EditorStyles))); } if (!debugger_plugins.is_empty()) { @@ -283,10 +284,10 @@ void EditorDebuggerNode::_notification(int p_what) { switch (p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { if (tabs->get_tab_count() > 1) { - add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_LEFT)); - add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_RIGHT)); + add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_LEFT)); + add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_RIGHT)); - tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); + tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), EditorStringName(EditorStyles))); } } break; @@ -386,15 +387,15 @@ void EditorDebuggerNode::_update_errors() { } else { debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")"); if (error_count >= 1 && warning_count >= 1) { - debugger_button->set_icon(get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons"))); + debugger_button->set_icon(get_editor_theme_icon(SNAME("ErrorWarning"))); // Use error color to represent the highest level of severity reported. - debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); } else if (error_count >= 1) { - debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); - debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + debugger_button->set_icon(get_editor_theme_icon(SNAME("Error"))); + debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); } else { - debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); - debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + debugger_button->set_icon(get_editor_theme_icon(SNAME("Warning"))); + debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); } } last_error_count = error_count; diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index 65f8951c30..2e24a233a1 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -115,8 +115,8 @@ void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position, Mou item->select(0); item_menu->clear(); - item_menu->add_icon_item(get_theme_icon(SNAME("CreateNewSceneFrom"), SNAME("EditorIcons")), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE); - item_menu->add_icon_item(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH); + item_menu->add_icon_item(get_editor_theme_icon(SNAME("CreateNewSceneFrom")), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE); + item_menu->add_icon_item(get_editor_theme_icon(SNAME("CopyNodePath")), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH); item_menu->set_position(get_screen_position() + get_local_mouse_position()); item_menu->reset_size(); item_menu->popup(); @@ -198,7 +198,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int const Color remote_button_color = Color(1, 1, 1, 0.8); if (!node.scene_file_path.is_empty()) { String node_scene_file_path = node.scene_file_path; - Ref<Texture2D> button_icon = get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")); + Ref<Texture2D> button_icon = get_editor_theme_icon(SNAME("InstanceOptions")); String tooltip = vformat(TTR("This node has been instantiated from a PackedScene file:\n%s\nClick to open the original file in the Editor."), node_scene_file_path); item->set_meta("scene_file_path", node_scene_file_path); @@ -209,7 +209,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int if (node.view_flags & SceneDebuggerTree::RemoteNode::VIEW_HAS_VISIBLE_METHOD) { bool node_visible = node.view_flags & SceneDebuggerTree::RemoteNode::VIEW_VISIBLE; bool node_visible_in_tree = node.view_flags & SceneDebuggerTree::RemoteNode::VIEW_VISIBLE_IN_TREE; - Ref<Texture2D> button_icon = get_theme_icon(node_visible ? SNAME("GuiVisibilityVisible") : SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")); + Ref<Texture2D> button_icon = get_editor_theme_icon(node_visible ? SNAME("GuiVisibilityVisible") : SNAME("GuiVisibilityHidden")); String tooltip = TTR("Toggle Visibility"); item->set_meta("visible", node_visible); diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index 641c7d3114..e6e9d4e33d 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -33,6 +33,7 @@ #include "editor/editor_property_name_processor.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "main/performance.h" EditorPerformanceProfiler::Monitor::Monitor() {} @@ -131,7 +132,7 @@ void EditorPerformanceProfiler::_monitor_draw() { rect.position += graph_style_box->get_offset(); rect.size -= graph_style_box->get_minimum_size(); - Color draw_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color draw_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_color.set_hsv(Math::fmod(hue_shift * float(current.frame_index), 0.9f), draw_color.get_s() * 0.9f, draw_color.get_v() * value_multiplier, 0.6f); monitor_draw->draw_string(graph_font, rect.position + Point2(0, graph_font->get_ascent(font_size)), current.item->get_text(0), HORIZONTAL_ALIGNMENT_LEFT, rect.size.x, font_size, draw_color); @@ -235,7 +236,7 @@ TreeItem *EditorPerformanceProfiler::_get_monitor_base(const StringName &p_base_ base->set_selectable(0, false); base->set_expand_right(0, true); if (is_inside_tree()) { - base->set_custom_font(0, get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); + base->set_custom_font(0, get_theme_font(SNAME("bold"), EditorStringName(EditorFonts))); } base_map.insert(p_base_name, base); return base; @@ -374,7 +375,7 @@ void EditorPerformanceProfiler::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { for (KeyValue<StringName, TreeItem *> &E : base_map) { - E.value->set_custom_font(0, get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); + E.value->set_custom_font(0, get_theme_font(SNAME("bold"), EditorStringName(EditorFonts))); } } break; } diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index e59fc6186a..f72538e3de 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -33,6 +33,7 @@ #include "core/os/os.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/resources/image_texture.h" void EditorProfiler::_make_metric_ptrs(Metric &m) { @@ -140,11 +141,11 @@ String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_ca } Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) const { - Color bc = get_theme_color(SNAME("error_color"), SNAME("Editor")); + Color bc = get_theme_color(SNAME("error_color"), EditorStringName(Editor)); double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.lerp(get_theme_color(SNAME("base_color"), SNAME("Editor")), 0.07); + return c.lerp(get_theme_color(SNAME("base_color"), EditorStringName(Editor)), 0.07); } void EditorProfiler::_item_edited() { @@ -185,7 +186,7 @@ void EditorProfiler::_update_plot() { } uint8_t *wr = graph_image.ptrw(); - const Color background_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); + const Color background_color = get_theme_color(SNAME("dark_color_2"), EditorStringName(Editor)); // Clear the previous frame and set the background color. for (int i = 0; i < desired_len; i += 4) { @@ -379,10 +380,10 @@ void EditorProfiler::_update_frame() { void EditorProfiler::_update_button_text() { if (activate->is_pressed()) { - activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); + activate->set_icon(get_editor_theme_icon(SNAME("Stop"))); activate->set_text(TTR("Stop")); } else { - activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); + activate->set_icon(get_editor_theme_icon(SNAME("Play"))); activate->set_text(TTR("Start")); } } @@ -409,8 +410,8 @@ void EditorProfiler::_notification(int p_what) { case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { - activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); - clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); + activate->set_icon(get_editor_theme_icon(SNAME("Play"))); + clear_button->set_icon(get_editor_theme_icon(SNAME("Clear"))); } break; } } diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 984d8e33c5..7df942e288 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -33,6 +33,7 @@ #include "core/os/os.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/resources/image_texture.h" void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { @@ -124,11 +125,11 @@ String EditorVisualProfiler::_get_time_as_text(float p_time) { } Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signature) const { - Color bc = get_theme_color(SNAME("error_color"), SNAME("Editor")); + Color bc = get_theme_color(SNAME("error_color"), EditorStringName(Editor)); double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.lerp(get_theme_color(SNAME("base_color"), SNAME("Editor")), 0.07); + return c.lerp(get_theme_color(SNAME("base_color"), EditorStringName(Editor)), 0.07); } void EditorVisualProfiler::_item_selected() { @@ -158,7 +159,7 @@ void EditorVisualProfiler::_update_plot() { } uint8_t *wr = graph_image.ptrw(); - const Color background_color = get_theme_color("dark_color_2", "Editor"); + const Color background_color = get_theme_color("dark_color_2", EditorStringName(Editor)); // Clear the previous frame and set the background color. for (int i = 0; i < desired_len; i += 4) { @@ -318,7 +319,7 @@ void EditorVisualProfiler::_update_plot() { void EditorVisualProfiler::_update_frame(bool p_focus_selected) { int cursor_metric = _get_cursor_index(); - Ref<Texture> track_icon = get_theme_icon(SNAME("TrackColor"), SNAME("EditorIcons")); + Ref<Texture> track_icon = get_editor_theme_icon(SNAME("TrackColor")); ERR_FAIL_INDEX(cursor_metric, frame_metrics.size()); @@ -407,12 +408,12 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { void EditorVisualProfiler::_activate_pressed() { if (activate->is_pressed()) { - activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); + activate->set_icon(get_editor_theme_icon(SNAME("Stop"))); activate->set_text(TTR("Stop")); _clear_pressed(); //always clear on start clear_button->set_disabled(false); } else { - activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); + activate->set_icon(get_editor_theme_icon(SNAME("Play"))); activate->set_text(TTR("Start")); } emit_signal(SNAME("enable_profiling"), activate->is_pressed()); @@ -431,11 +432,11 @@ void EditorVisualProfiler::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { if (is_layout_rtl()) { - activate->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons"))); + activate->set_icon(get_editor_theme_icon(SNAME("PlayBackwards"))); } else { - activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); + activate->set_icon(get_editor_theme_icon(SNAME("Play"))); } - clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); + clear_button->set_icon(get_editor_theme_icon(SNAME("Clear"))); } break; } } @@ -447,7 +448,7 @@ void EditorVisualProfiler::_graph_tex_draw() { Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); - const Color color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + const Color color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); if (seeking) { int max_frames = frame_metrics.size(); @@ -653,10 +654,10 @@ void EditorVisualProfiler::_bind_methods() { void EditorVisualProfiler::_update_button_text() { if (activate->is_pressed()) { - activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); + activate->set_icon(get_editor_theme_icon(SNAME("Stop"))); activate->set_text(TTR("Stop")); } else { - activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); + activate->set_icon(get_editor_theme_icon(SNAME("Play"))); activate->set_text(TTR("Start")); } } diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index ff59911159..c55942acef 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -46,6 +46,7 @@ #include "editor/editor_property_name_processor.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_file_dialog.h" #include "editor/inspector_dock.h" #include "editor/plugins/canvas_item_editor_plugin.h" @@ -93,9 +94,9 @@ void ScriptEditorDebugger::debug_copy() { void ScriptEditorDebugger::debug_skip_breakpoints() { skip_breakpoints_value = !skip_breakpoints_value; if (skip_breakpoints_value) { - skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOn"), SNAME("EditorIcons"))); + skip_breakpoints->set_icon(get_editor_theme_icon(SNAME("DebugSkipBreakpointsOn"))); } else { - skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons"))); + skip_breakpoints->set_icon(get_editor_theme_icon(SNAME("DebugSkipBreakpointsOff"))); } Array msg; @@ -143,11 +144,11 @@ void ScriptEditorDebugger::update_tabs() { } else { errors_tab->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")"); if (error_count >= 1 && warning_count >= 1) { - tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons"))); + tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_editor_theme_icon(SNAME("ErrorWarning"))); } else if (error_count >= 1) { - tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_editor_theme_icon(SNAME("Error"))); } else { - tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); + tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_editor_theme_icon(SNAME("Warning"))); } } } @@ -420,8 +421,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread it->set_text(3, String::humanize_size(bytes)); total += bytes; - if (has_theme_icon(type, SNAME("EditorIcons"))) { - it->set_icon(0, get_theme_icon(type, SNAME("EditorIcons"))); + if (has_theme_icon(type, EditorStringName(EditorIcons))) { + it->set_icon(0, get_editor_theme_icon(type)); } } @@ -560,11 +561,11 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread } error->set_collapsed(true); - error->set_icon(0, get_theme_icon(oe.warning ? SNAME("Warning") : SNAME("Error"), SNAME("EditorIcons"))); + error->set_icon(0, get_editor_theme_icon(oe.warning ? SNAME("Warning") : SNAME("Error"))); error->set_text(0, time); error->set_text_alignment(0, HORIZONTAL_ALIGNMENT_LEFT); - const Color color = get_theme_color(oe.warning ? SNAME("warning_color") : SNAME("error_color"), SNAME("Editor")); + const Color color = get_theme_color(oe.warning ? SNAME("warning_color") : SNAME("error_color"), EditorStringName(Editor)); error->set_custom_color(0, color); error->set_custom_color(1, color); @@ -821,13 +822,13 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType p_type) { switch (p_type) { case MESSAGE_ERROR: - reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); break; case MESSAGE_WARNING: - reason->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); break; default: - reason->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor"))); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), EditorStringName(Editor))); } reason->set_text(p_reason); @@ -853,32 +854,32 @@ void ScriptEditorDebugger::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - tabs->add_theme_style_override("panel", get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); + tabs->add_theme_style_override("panel", get_theme_stylebox(SNAME("DebuggerPanel"), EditorStringName(EditorStyles))); - skip_breakpoints->set_icon(get_theme_icon(skip_breakpoints_value ? SNAME("DebugSkipBreakpointsOn") : SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons"))); - copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); - step->set_icon(get_theme_icon(SNAME("DebugStep"), SNAME("EditorIcons"))); - next->set_icon(get_theme_icon(SNAME("DebugNext"), SNAME("EditorIcons"))); - dobreak->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); - docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons"))); - vmem_refresh->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); - vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); - search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + skip_breakpoints->set_icon(get_editor_theme_icon(skip_breakpoints_value ? SNAME("DebugSkipBreakpointsOn") : SNAME("DebugSkipBreakpointsOff"))); + copy->set_icon(get_editor_theme_icon(SNAME("ActionCopy"))); + step->set_icon(get_editor_theme_icon(SNAME("DebugStep"))); + next->set_icon(get_editor_theme_icon(SNAME("DebugNext"))); + dobreak->set_icon(get_editor_theme_icon(SNAME("Pause"))); + docontinue->set_icon(get_editor_theme_icon(SNAME("DebugContinue"))); + vmem_refresh->set_icon(get_editor_theme_icon(SNAME("Reload"))); + vmem_export->set_icon(get_editor_theme_icon(SNAME("Save"))); + search->set_right_icon(get_editor_theme_icon(SNAME("Search"))); - reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); TreeItem *error_root = error_tree->get_root(); if (error_root) { TreeItem *error = error_root->get_first_child(); while (error) { if (error->has_meta("_is_warning")) { - error->set_icon(0, get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); - error->set_custom_color(0, get_theme_color(SNAME("warning_color"), SNAME("Editor"))); - error->set_custom_color(1, get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + error->set_icon(0, get_editor_theme_icon(SNAME("Warning"))); + error->set_custom_color(0, get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); + error->set_custom_color(1, get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); } else if (error->has_meta("_is_error")) { - error->set_icon(0, get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); - error->set_custom_color(0, get_theme_color(SNAME("error_color"), SNAME("Editor"))); - error->set_custom_color(1, get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error->set_icon(0, get_editor_theme_icon(SNAME("Error"))); + error->set_custom_color(0, get_theme_color(SNAME("error_color"), EditorStringName(Editor))); + error->set_custom_color(1, get_theme_color(SNAME("error_color"), EditorStringName(Editor))); } error = error->get_next(); @@ -1598,11 +1599,11 @@ void ScriptEditorDebugger::_breakpoints_item_rmb_selected(const Vector2 &p_pos, const TreeItem *selected = breakpoints_tree->get_selected(); String file = selected->get_text(0); if (selected->has_meta("line")) { - breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Breakpoint"), ACTION_DELETE_BREAKPOINT); + breakpoints_menu->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Delete Breakpoint"), ACTION_DELETE_BREAKPOINT); file = selected->get_parent()->get_text(0); } - breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete All Breakpoints in:") + " " + file, ACTION_DELETE_BREAKPOINTS_IN_FILE); - breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete All Breakpoints"), ACTION_DELETE_ALL_BREAKPOINTS); + breakpoints_menu->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Delete All Breakpoints in:") + " " + file, ACTION_DELETE_BREAKPOINTS_IN_FILE); + breakpoints_menu->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Delete All Breakpoints"), ACTION_DELETE_ALL_BREAKPOINTS); breakpoints_menu->set_position(breakpoints_tree->get_global_position() + p_pos); breakpoints_menu->popup(); @@ -1618,8 +1619,8 @@ void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos, M item_menu->reset_size(); if (error_tree->is_anything_selected()) { - item_menu->add_icon_item(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), TTR("Copy Error"), ACTION_COPY_ERROR); - item_menu->add_icon_item(get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), TTR("Open C++ Source on GitHub"), ACTION_OPEN_SOURCE); + item_menu->add_icon_item(get_editor_theme_icon(SNAME("ActionCopy")), TTR("Copy Error"), ACTION_COPY_ERROR); + item_menu->add_icon_item(get_editor_theme_icon(SNAME("ExternalLink")), TTR("Open C++ Source on GitHub"), ACTION_OPEN_SOURCE); } if (item_menu->get_item_count() > 0) { diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 3660e7f285..26779f5b52 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -304,9 +304,9 @@ void DependencyEditorOwners::_list_rmb_clicked(int p_item, const Vector2 &p_pos, } if (only_scenes_selected) { - file_options->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTRN("Open Scene", "Open Scenes", selected_items.size()), FILE_OPEN); + file_options->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTRN("Open Scene", "Open Scenes", selected_items.size()), FILE_OPEN); } else if (selected_items.size() == 1) { - file_options->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open"), FILE_OPEN); + file_options->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Open"), FILE_OPEN); } else { return; } @@ -508,17 +508,17 @@ void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<Removed if (!tree_items.has(rd.dependency_folder)) { TreeItem *folder_item = owners->create_item(owners->get_root()); folder_item->set_text(0, rd.dependency_folder); - folder_item->set_icon(0, owners->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + folder_item->set_icon(0, owners->get_editor_theme_icon(SNAME("Folder"))); tree_items[rd.dependency_folder] = folder_item; } TreeItem *dependency_item = owners->create_item(tree_items[rd.dependency_folder]); dependency_item->set_text(0, rd.dependency); - dependency_item->set_icon(0, owners->get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); + dependency_item->set_icon(0, owners->get_editor_theme_icon(SNAME("Warning"))); tree_items[rd.dependency] = dependency_item; } else { TreeItem *dependency_item = owners->create_item(owners->get_root()); dependency_item->set_text(0, rd.dependency); - dependency_item->set_icon(0, owners->get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); + dependency_item->set_icon(0, owners->get_editor_theme_icon(SNAME("Warning"))); tree_items[rd.dependency] = dependency_item; } } @@ -804,7 +804,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa int ds = efsd->get_file_deps(i).size(); ti->set_text(1, itos(ds)); if (ds) { - ti->add_button(1, files->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")), -1, false, TTR("Show Dependencies")); + ti->add_button(1, files->get_editor_theme_icon(SNAME("GuiVisibilityVisible")), -1, false, TTR("Show Dependencies")); } ti->set_metadata(0, path); has_children = true; diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index a4147acade..848510f9c3 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -34,20 +34,21 @@ #include "core/donors.gen.h" #include "core/license.gen.h" #include "core/version.h" +#include "editor/editor_string_names.h" // The metadata key used to store and retrieve the version text to copy to the clipboard. const String EditorAbout::META_TEXT_TO_COPY = "text_to_copy"; void EditorAbout::_theme_changed() { - const Ref<Font> font = get_theme_font(SNAME("source"), SNAME("EditorFonts")); - const int font_size = get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts")); + const Ref<Font> font = get_theme_font(SNAME("source"), EditorStringName(EditorFonts)); + const int font_size = get_theme_font_size(SNAME("source_size"), EditorStringName(EditorFonts)); _tpl_text->add_theme_font_override("normal_font", font); _tpl_text->add_theme_font_size_override("normal_font_size", font_size); _tpl_text->add_theme_constant_override("line_separation", 4 * EDSCALE); _license_text->add_theme_font_override("normal_font", font); _license_text->add_theme_font_size_override("normal_font_size", font_size); _license_text->add_theme_constant_override("line_separation", 4 * EDSCALE); - _logo->set_texture(get_theme_icon(SNAME("Logo"), SNAME("EditorIcons"))); + _logo->set_texture(get_editor_theme_icon(SNAME("Logo"))); } void EditorAbout::_notification(int p_what) { diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index a5bc90159a..27833ea499 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -35,6 +35,7 @@ #include "core/io/zip_io.h" #include "editor/editor_file_system.h" #include "editor/editor_node.h" +#include "editor/editor_string_names.h" #include "editor/progress_dialog.h" void EditorAssetInstaller::_item_edited() { @@ -89,56 +90,56 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { HashMap<String, Ref<Texture2D>> extension_guess; { - extension_guess["bmp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); - extension_guess["dds"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); - extension_guess["exr"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); - extension_guess["hdr"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); - extension_guess["jpg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); - extension_guess["jpeg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); - extension_guess["png"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); - extension_guess["svg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); - extension_guess["tga"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); - extension_guess["webp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); - - extension_guess["wav"] = tree->get_theme_icon(SNAME("AudioStreamWAV"), SNAME("EditorIcons")); - extension_guess["ogg"] = tree->get_theme_icon(SNAME("AudioStreamOggVorbis"), SNAME("EditorIcons")); - extension_guess["mp3"] = tree->get_theme_icon(SNAME("AudioStreamMP3"), SNAME("EditorIcons")); - - extension_guess["scn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); - extension_guess["tscn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); - extension_guess["escn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); - extension_guess["dae"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); - extension_guess["gltf"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); - extension_guess["glb"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); - - extension_guess["gdshader"] = tree->get_theme_icon(SNAME("Shader"), SNAME("EditorIcons")); - extension_guess["gdshaderinc"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); - extension_guess["gd"] = tree->get_theme_icon(SNAME("GDScript"), SNAME("EditorIcons")); + extension_guess["bmp"] = tree->get_editor_theme_icon(SNAME("ImageTexture")); + extension_guess["dds"] = tree->get_editor_theme_icon(SNAME("ImageTexture")); + extension_guess["exr"] = tree->get_editor_theme_icon(SNAME("ImageTexture")); + extension_guess["hdr"] = tree->get_editor_theme_icon(SNAME("ImageTexture")); + extension_guess["jpg"] = tree->get_editor_theme_icon(SNAME("ImageTexture")); + extension_guess["jpeg"] = tree->get_editor_theme_icon(SNAME("ImageTexture")); + extension_guess["png"] = tree->get_editor_theme_icon(SNAME("ImageTexture")); + extension_guess["svg"] = tree->get_editor_theme_icon(SNAME("ImageTexture")); + extension_guess["tga"] = tree->get_editor_theme_icon(SNAME("ImageTexture")); + extension_guess["webp"] = tree->get_editor_theme_icon(SNAME("ImageTexture")); + + extension_guess["wav"] = tree->get_editor_theme_icon(SNAME("AudioStreamWAV")); + extension_guess["ogg"] = tree->get_editor_theme_icon(SNAME("AudioStreamOggVorbis")); + extension_guess["mp3"] = tree->get_editor_theme_icon(SNAME("AudioStreamMP3")); + + extension_guess["scn"] = tree->get_editor_theme_icon(SNAME("PackedScene")); + extension_guess["tscn"] = tree->get_editor_theme_icon(SNAME("PackedScene")); + extension_guess["escn"] = tree->get_editor_theme_icon(SNAME("PackedScene")); + extension_guess["dae"] = tree->get_editor_theme_icon(SNAME("PackedScene")); + extension_guess["gltf"] = tree->get_editor_theme_icon(SNAME("PackedScene")); + extension_guess["glb"] = tree->get_editor_theme_icon(SNAME("PackedScene")); + + extension_guess["gdshader"] = tree->get_editor_theme_icon(SNAME("Shader")); + extension_guess["gdshaderinc"] = tree->get_editor_theme_icon(SNAME("TextFile")); + extension_guess["gd"] = tree->get_editor_theme_icon(SNAME("GDScript")); if (Engine::get_singleton()->has_singleton("GodotSharp")) { - extension_guess["cs"] = tree->get_theme_icon(SNAME("CSharpScript"), SNAME("EditorIcons")); + extension_guess["cs"] = tree->get_editor_theme_icon(SNAME("CSharpScript")); } else { // Mark C# support as unavailable. - extension_guess["cs"] = tree->get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); + extension_guess["cs"] = tree->get_editor_theme_icon(SNAME("ImportFail")); } - extension_guess["res"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons")); - extension_guess["tres"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons")); - extension_guess["atlastex"] = tree->get_theme_icon(SNAME("AtlasTexture"), SNAME("EditorIcons")); + extension_guess["res"] = tree->get_editor_theme_icon(SNAME("Resource")); + extension_guess["tres"] = tree->get_editor_theme_icon(SNAME("Resource")); + extension_guess["atlastex"] = tree->get_editor_theme_icon(SNAME("AtlasTexture")); // By default, OBJ files are imported as Mesh resources rather than PackedScenes. - extension_guess["obj"] = tree->get_theme_icon(SNAME("Mesh"), SNAME("EditorIcons")); - - extension_guess["txt"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); - extension_guess["md"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); - extension_guess["rst"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); - extension_guess["json"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); - extension_guess["yml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); - extension_guess["yaml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); - extension_guess["toml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); - extension_guess["cfg"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); - extension_guess["ini"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["obj"] = tree->get_editor_theme_icon(SNAME("Mesh")); + + extension_guess["txt"] = tree->get_editor_theme_icon(SNAME("TextFile")); + extension_guess["md"] = tree->get_editor_theme_icon(SNAME("TextFile")); + extension_guess["rst"] = tree->get_editor_theme_icon(SNAME("TextFile")); + extension_guess["json"] = tree->get_editor_theme_icon(SNAME("TextFile")); + extension_guess["yml"] = tree->get_editor_theme_icon(SNAME("TextFile")); + extension_guess["yaml"] = tree->get_editor_theme_icon(SNAME("TextFile")); + extension_guess["toml"] = tree->get_editor_theme_icon(SNAME("TextFile")); + extension_guess["cfg"] = tree->get_editor_theme_icon(SNAME("TextFile")); + extension_guess["ini"] = tree->get_editor_theme_icon(SNAME("TextFile")); } - Ref<Texture2D> generic_extension = tree->get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); + Ref<Texture2D> generic_extension = tree->get_editor_theme_icon(SNAME("Object")); unzClose(pkg); @@ -213,7 +214,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { String res_path = "res://" + path; if (FileAccess::exists(res_path)) { num_file_conflicts += 1; - ti->set_custom_color(0, tree->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + ti->set_custom_color(0, tree->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); ti->set_tooltip_text(0, vformat(TTR("%s (already exists)"), res_path)); ti->set_checked(0, false); ti->propagate_check(0); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 93788dc8b1..8b60ac405a 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -37,6 +37,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/filesystem_dock.h" #include "editor/gui/editor_file_dialog.h" @@ -69,7 +70,7 @@ void EditorAudioBus::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - Ref<Texture2D> active_bus_texture = get_theme_icon(SNAME("BusVuActive"), SNAME("EditorIcons")); + Ref<Texture2D> active_bus_texture = get_editor_theme_icon(SNAME("BusVuActive")); for (int i = 0; i < CHANNELS_MAX; i++) { channel[i].vu_l->set_under_texture(active_bus_texture); channel[i].vu_l->set_tint_under(Color(0.75, 0.75, 0.75)); @@ -81,20 +82,20 @@ void EditorAudioBus::_notification(int p_what) { channel[i].prev_active = true; } - disabled_vu = get_theme_icon(SNAME("BusVuFrozen"), SNAME("EditorIcons")); + disabled_vu = get_editor_theme_icon(SNAME("BusVuFrozen")); Color solo_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0, 0.89, 0.22) : Color(1.0, 0.92, 0.44); Color mute_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0, 0.16, 0.16) : Color(1.0, 0.44, 0.44); Color bypass_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(0.13, 0.8, 1.0) : Color(0.44, 0.87, 1.0); - solo->set_icon(get_theme_icon(SNAME("AudioBusSolo"), SNAME("EditorIcons"))); + solo->set_icon(get_editor_theme_icon(SNAME("AudioBusSolo"))); solo->add_theme_color_override("icon_pressed_color", solo_color); - mute->set_icon(get_theme_icon(SNAME("AudioBusMute"), SNAME("EditorIcons"))); + mute->set_icon(get_editor_theme_icon(SNAME("AudioBusMute"))); mute->add_theme_color_override("icon_pressed_color", mute_color); - bypass->set_icon(get_theme_icon(SNAME("AudioBusBypass"), SNAME("EditorIcons"))); + bypass->set_icon(get_editor_theme_icon(SNAME("AudioBusBypass"))); bypass->add_theme_color_override("icon_pressed_color", bypass_color); - bus_options->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + bus_options->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); audio_value_preview_label->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("TooltipLabel"))); audio_value_preview_label->add_theme_color_override("font_shadow_color", get_theme_color(SNAME("font_shadow_color"), SNAME("TooltipLabel"))); @@ -122,7 +123,7 @@ void EditorAudioBus::_notification(int p_what) { } if (get_index() != 0 && hovering_drop) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false); } @@ -970,7 +971,7 @@ void EditorAudioBusDrop::_notification(int p_what) { draw_style_box(get_theme_stylebox(SNAME("normal"), SNAME("Button")), Rect2(Vector2(), get_size())); if (hovering_drop) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false); } @@ -1443,7 +1444,7 @@ Size2 EditorAudioMeterNotches::get_minimum_size() const { void EditorAudioMeterNotches::_update_theme_item_cache() { Control::_update_theme_item_cache(); - theme_cache.notch_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + theme_cache.notch_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); theme_cache.font = get_theme_font(SNAME("font"), SNAME("Label")); theme_cache.font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 5bcef467f6..57172142e3 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -34,6 +34,7 @@ #include "core/core_constants.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/filesystem_dock.h" #include "editor/gui/editor_file_dialog.h" @@ -59,11 +60,11 @@ void EditorAutoloadSettings::_notification(int p_what) { get_tree()->get_root()->call_deferred(SNAME("add_child"), info.node); } } - browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + browse_button->set_icon(get_editor_theme_icon(SNAME("Folder"))); } break; case NOTIFICATION_THEME_CHANGED: { - browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + browse_button->set_icon(get_editor_theme_icon(SNAME("Folder"))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -517,10 +518,10 @@ void EditorAutoloadSettings::update_autoload() { item->set_editable(2, true); item->set_text(2, TTR("Enable")); item->set_checked(2, info.is_singleton); - item->add_button(3, get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), BUTTON_OPEN); - item->add_button(3, get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), BUTTON_MOVE_UP); - item->add_button(3, get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), BUTTON_MOVE_DOWN); - item->add_button(3, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_DELETE); + item->add_button(3, get_editor_theme_icon(SNAME("Load")), BUTTON_OPEN); + item->add_button(3, get_editor_theme_icon(SNAME("MoveUp")), BUTTON_MOVE_UP); + item->add_button(3, get_editor_theme_icon(SNAME("MoveDown")), BUTTON_MOVE_DOWN); + item->add_button(3, get_editor_theme_icon(SNAME("Remove")), BUTTON_DELETE); item->set_selectable(3, false); } @@ -881,7 +882,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { error_message = memnew(Label); error_message->hide(); error_message->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT); - error_message->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_message->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); add_child(error_message); Label *l = memnew(Label); diff --git a/editor/editor_build_profile.cpp b/editor/editor_build_profile.cpp index 1377537245..bca30b2d2d 100644 --- a/editor/editor_build_profile.cpp +++ b/editor/editor_build_profile.cpp @@ -38,6 +38,7 @@ #include "editor/editor_property_name_processor.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_file_dialog.h" const char *EditorBuildProfile::build_option_identifiers[BUILD_OPTION_MAX] = { @@ -600,7 +601,7 @@ void EditorBuildProfileManager::_fill_classes_from(TreeItem *p_parent, const Str bool disabled = edited->is_class_disabled(p_class); if (disabled) { - class_item->set_custom_color(0, class_list->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + class_item->set_custom_color(0, class_list->get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); } class_item->set_text(0, text); diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index b44792bf0f..168fe5a7ac 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -33,6 +33,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/gui/control.h" #include "scene/gui/tree.h" @@ -127,8 +128,8 @@ void EditorCommandPalette::_update_command_search(const String &search_text) { section->set_text(0, item_name); section->set_selectable(0, false); section->set_selectable(1, false); - section->set_custom_bg_color(0, search_options->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); - section->set_custom_bg_color(1, search_options->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + section->set_custom_bg_color(0, search_options->get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); + section->set_custom_bg_color(1, search_options->get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); sections[section_name] = section; } @@ -139,7 +140,7 @@ void EditorCommandPalette::_update_command_search(const String &search_text) { ti->set_metadata(0, entries[i].key_name); ti->set_text_alignment(1, HORIZONTAL_ALIGNMENT_RIGHT); ti->set_text(1, shortcut_text); - Color c = get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5); + Color c = get_theme_color(SNAME("font_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.5); ti->set_custom_color(1, c); } @@ -294,7 +295,7 @@ Ref<Shortcut> EditorCommandPalette::add_shortcut_command(const String &p_command } void EditorCommandPalette::_theme_changed() { - command_search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + command_search_box->set_right_icon(search_options->get_editor_theme_icon(SNAME("Search"))); } void EditorCommandPalette::_save_history() const { diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 6019e9e895..50406bea6a 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -37,6 +37,7 @@ #include "editor/editor_property_name_processor.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_file_dialog.h" const char *EditorFeatureProfile::feature_names[FEATURE_MAX] = { @@ -502,7 +503,7 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S bool disabled_editor = edited->is_class_editor_disabled(p_class); bool disabled_properties = edited->has_class_properties_disabled(p_class); if (disabled) { - class_item->set_custom_color(0, class_list->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + class_item->set_custom_color(0, class_list->get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); } else if (disabled_editor && disabled_properties) { text += " " + TTR("(Editor Disabled, Properties Disabled)"); } else if (disabled_properties) { diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index bc8bcb1134..6c51be8361 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -34,6 +34,7 @@ #include "core/io/dir_access.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/resources/font.h" Ref<FontFile> load_external_font(const String &p_path, TextServer::Hinting p_hinting, TextServer::FontAntialiasing p_aa, bool p_autohint, TextServer::SubpixelPositioning p_font_subpixel_positioning, bool p_msdf = false, TypedArray<Font> *r_fallbacks = nullptr) { @@ -157,11 +158,11 @@ void editor_register_fonts(Ref<Theme> p_theme) { Ref<FontFile> georgian_font = load_internal_font(_font_NotoSansGeorgian_Regular, _font_NotoSansGeorgian_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); Ref<FontFile> hebrew_font = load_internal_font(_font_NotoSansHebrew_Regular, _font_NotoSansHebrew_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); Ref<FontFile> malayalam_font = load_internal_font(_font_NotoSansMalayalamUI_Regular, _font_NotoSansMalayalamUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); - Ref<FontFile> oriya_font = load_internal_font(_font_NotoSansOriyaUI_Regular, _font_NotoSansOriyaUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); + Ref<FontFile> oriya_font = load_internal_font(_font_NotoSansOriya_Regular, _font_NotoSansOriya_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); Ref<FontFile> sinhala_font = load_internal_font(_font_NotoSansSinhalaUI_Regular, _font_NotoSansSinhalaUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); Ref<FontFile> tamil_font = load_internal_font(_font_NotoSansTamilUI_Regular, _font_NotoSansTamilUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); Ref<FontFile> telugu_font = load_internal_font(_font_NotoSansTeluguUI_Regular, _font_NotoSansTeluguUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); - Ref<FontFile> thai_font = load_internal_font(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); + Ref<FontFile> thai_font = load_internal_font(_font_NotoSansThai_Regular, _font_NotoSansThai_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); Ref<FontFile> fallback_font = load_internal_font(_font_DroidSansFallback, _font_DroidSansFallback_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); Ref<FontFile> japanese_font = load_internal_font(_font_DroidSansJapanese, _font_DroidSansJapanese_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks); default_font->set_fallbacks(fallbacks); @@ -177,11 +178,11 @@ void editor_register_fonts(Ref<Theme> p_theme) { Ref<FontFile> georgian_font_bold = load_internal_font(_font_NotoSansGeorgian_Bold, _font_NotoSansGeorgian_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold); Ref<FontFile> hebrew_font_bold = load_internal_font(_font_NotoSansHebrew_Bold, _font_NotoSansHebrew_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold); Ref<FontFile> malayalam_font_bold = load_internal_font(_font_NotoSansMalayalamUI_Bold, _font_NotoSansMalayalamUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold); - Ref<FontFile> oriya_font_bold = load_internal_font(_font_NotoSansOriyaUI_Bold, _font_NotoSansOriyaUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold); + Ref<FontFile> oriya_font_bold = load_internal_font(_font_NotoSansOriya_Bold, _font_NotoSansOriya_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold); Ref<FontFile> sinhala_font_bold = load_internal_font(_font_NotoSansSinhalaUI_Bold, _font_NotoSansSinhalaUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold); Ref<FontFile> tamil_font_bold = load_internal_font(_font_NotoSansTamilUI_Bold, _font_NotoSansTamilUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold); Ref<FontFile> telugu_font_bold = load_internal_font(_font_NotoSansTeluguUI_Bold, _font_NotoSansTeluguUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold); - Ref<FontFile> thai_font_bold = load_internal_font(_font_NotoSansThaiUI_Bold, _font_NotoSansThaiUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold); + Ref<FontFile> thai_font_bold = load_internal_font(_font_NotoSansThai_Bold, _font_NotoSansThai_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold); Ref<FontVariation> fallback_font_bold = make_bold_font(fallback_font, embolden_strength, &fallbacks_bold); Ref<FontVariation> japanese_font_bold = make_bold_font(japanese_font, embolden_strength, &fallbacks_bold); @@ -377,21 +378,21 @@ void editor_register_fonts(Ref<Theme> p_theme) { // Main font. - p_theme->set_font("main", "EditorFonts", default_fc); - p_theme->set_font("main_msdf", "EditorFonts", default_fc_msdf); - p_theme->set_font_size("main_size", "EditorFonts", default_font_size); + p_theme->set_font("main", EditorStringName(EditorFonts), default_fc); + p_theme->set_font("main_msdf", EditorStringName(EditorFonts), default_fc_msdf); + p_theme->set_font_size("main_size", EditorStringName(EditorFonts), default_font_size); - p_theme->set_font("bold", "EditorFonts", bold_fc); - p_theme->set_font("main_bold_msdf", "EditorFonts", bold_fc_msdf); - p_theme->set_font_size("bold_size", "EditorFonts", default_font_size); + p_theme->set_font("bold", EditorStringName(EditorFonts), bold_fc); + p_theme->set_font("main_bold_msdf", EditorStringName(EditorFonts), bold_fc_msdf); + p_theme->set_font_size("bold_size", EditorStringName(EditorFonts), default_font_size); // Title font. - p_theme->set_font("title", "EditorFonts", bold_fc); - p_theme->set_font_size("title_size", "EditorFonts", default_font_size + 1 * EDSCALE); + p_theme->set_font("title", EditorStringName(EditorFonts), bold_fc); + p_theme->set_font_size("title_size", EditorStringName(EditorFonts), default_font_size + 1 * EDSCALE); - p_theme->set_font("main_button_font", "EditorFonts", bold_fc); - p_theme->set_font_size("main_button_font_size", "EditorFonts", default_font_size + 1 * EDSCALE); + p_theme->set_font("main_button_font", EditorStringName(EditorFonts), bold_fc); + p_theme->set_font_size("main_button_font_size", EditorStringName(EditorFonts), default_font_size + 1 * EDSCALE); p_theme->set_font("font", "Label", default_fc); @@ -408,41 +409,41 @@ void editor_register_fonts(Ref<Theme> p_theme) { p_theme->set_font_size("font_size", "HeaderLarge", default_font_size + 3 * EDSCALE); // Documentation fonts - p_theme->set_font_size("doc_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE); - p_theme->set_font("doc", "EditorFonts", default_fc); - p_theme->set_font("doc_bold", "EditorFonts", bold_fc); - p_theme->set_font("doc_italic", "EditorFonts", italic_fc); - p_theme->set_font_size("doc_title_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE); - p_theme->set_font("doc_title", "EditorFonts", bold_fc); - p_theme->set_font_size("doc_source_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE); - p_theme->set_font("doc_source", "EditorFonts", mono_fc); - p_theme->set_font_size("doc_keyboard_size", "EditorFonts", (int(EDITOR_GET("text_editor/help/help_source_font_size")) - 1) * EDSCALE); - p_theme->set_font("doc_keyboard", "EditorFonts", mono_fc); + p_theme->set_font_size("doc_size", EditorStringName(EditorFonts), int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE); + p_theme->set_font("doc", EditorStringName(EditorFonts), default_fc); + p_theme->set_font("doc_bold", EditorStringName(EditorFonts), bold_fc); + p_theme->set_font("doc_italic", EditorStringName(EditorFonts), italic_fc); + p_theme->set_font_size("doc_title_size", EditorStringName(EditorFonts), int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE); + p_theme->set_font("doc_title", EditorStringName(EditorFonts), bold_fc); + p_theme->set_font_size("doc_source_size", EditorStringName(EditorFonts), int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE); + p_theme->set_font("doc_source", EditorStringName(EditorFonts), mono_fc); + p_theme->set_font_size("doc_keyboard_size", EditorStringName(EditorFonts), (int(EDITOR_GET("text_editor/help/help_source_font_size")) - 1) * EDSCALE); + p_theme->set_font("doc_keyboard", EditorStringName(EditorFonts), mono_fc); // Ruler font - p_theme->set_font_size("rulers_size", "EditorFonts", 8 * EDSCALE); - p_theme->set_font("rulers", "EditorFonts", default_fc); + p_theme->set_font_size("rulers_size", EditorStringName(EditorFonts), 8 * EDSCALE); + p_theme->set_font("rulers", EditorStringName(EditorFonts), default_fc); // Rotation widget font - p_theme->set_font_size("rotation_control_size", "EditorFonts", 14 * EDSCALE); - p_theme->set_font("rotation_control", "EditorFonts", default_fc); + p_theme->set_font_size("rotation_control_size", EditorStringName(EditorFonts), 14 * EDSCALE); + p_theme->set_font("rotation_control", EditorStringName(EditorFonts), default_fc); // Code font - p_theme->set_font_size("source_size", "EditorFonts", int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE); - p_theme->set_font("source", "EditorFonts", mono_fc); + p_theme->set_font_size("source_size", EditorStringName(EditorFonts), int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE); + p_theme->set_font("source", EditorStringName(EditorFonts), mono_fc); - p_theme->set_font_size("expression_size", "EditorFonts", (int(EDITOR_GET("interface/editor/code_font_size")) - 1) * EDSCALE); - p_theme->set_font("expression", "EditorFonts", mono_other_fc); + p_theme->set_font_size("expression_size", EditorStringName(EditorFonts), (int(EDITOR_GET("interface/editor/code_font_size")) - 1) * EDSCALE); + p_theme->set_font("expression", EditorStringName(EditorFonts), mono_other_fc); - p_theme->set_font_size("output_source_size", "EditorFonts", int(EDITOR_GET("run/output/font_size")) * EDSCALE); - p_theme->set_font("output_source", "EditorFonts", mono_other_fc); - p_theme->set_font("output_source_bold", "EditorFonts", mono_other_fc_bold); - p_theme->set_font("output_source_italic", "EditorFonts", mono_other_fc_italic); - p_theme->set_font("output_source_bold_italic", "EditorFonts", mono_other_fc_bold_italic); - p_theme->set_font("output_source_mono", "EditorFonts", mono_other_fc_mono); + p_theme->set_font_size("output_source_size", EditorStringName(EditorFonts), int(EDITOR_GET("run/output/font_size")) * EDSCALE); + p_theme->set_font("output_source", EditorStringName(EditorFonts), mono_other_fc); + p_theme->set_font("output_source_bold", EditorStringName(EditorFonts), mono_other_fc_bold); + p_theme->set_font("output_source_italic", EditorStringName(EditorFonts), mono_other_fc_italic); + p_theme->set_font("output_source_bold_italic", EditorStringName(EditorFonts), mono_other_fc_bold_italic); + p_theme->set_font("output_source_mono", EditorStringName(EditorFonts), mono_other_fc_mono); - p_theme->set_font_size("status_source_size", "EditorFonts", default_font_size); - p_theme->set_font("status_source", "EditorFonts", mono_other_fc); + p_theme->set_font_size("status_source_size", EditorStringName(EditorFonts), default_font_size); + p_theme->set_font("status_source", EditorStringName(EditorFonts), mono_other_fc); OS::get_singleton()->benchmark_end_measure("editor_register_fonts"); } diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 14d80334b3..e35b305837 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -40,6 +40,7 @@ #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/plugins/script_editor_plugin.h" #include "scene/gui/line_edit.h" @@ -143,17 +144,17 @@ void EditorHelp::_update_theme_item_cache() { theme_cache.qualifier_color = get_theme_color(SNAME("qualifier_color"), SNAME("EditorHelp")); theme_cache.type_color = get_theme_color(SNAME("type_color"), SNAME("EditorHelp")); - theme_cache.doc_font = get_theme_font(SNAME("doc"), SNAME("EditorFonts")); - theme_cache.doc_bold_font = get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); - theme_cache.doc_italic_font = get_theme_font(SNAME("doc_italic"), SNAME("EditorFonts")); - theme_cache.doc_title_font = get_theme_font(SNAME("doc_title"), SNAME("EditorFonts")); - theme_cache.doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); - theme_cache.doc_kbd_font = get_theme_font(SNAME("doc_keyboard"), SNAME("EditorFonts")); + theme_cache.doc_font = get_theme_font(SNAME("doc"), EditorStringName(EditorFonts)); + theme_cache.doc_bold_font = get_theme_font(SNAME("doc_bold"), EditorStringName(EditorFonts)); + theme_cache.doc_italic_font = get_theme_font(SNAME("doc_italic"), EditorStringName(EditorFonts)); + theme_cache.doc_title_font = get_theme_font(SNAME("doc_title"), EditorStringName(EditorFonts)); + theme_cache.doc_code_font = get_theme_font(SNAME("doc_source"), EditorStringName(EditorFonts)); + theme_cache.doc_kbd_font = get_theme_font(SNAME("doc_keyboard"), EditorStringName(EditorFonts)); - theme_cache.doc_font_size = get_theme_font_size(SNAME("doc_size"), SNAME("EditorFonts")); - theme_cache.doc_title_font_size = get_theme_font_size(SNAME("doc_title_size"), SNAME("EditorFonts")); - theme_cache.doc_code_font_size = get_theme_font_size(SNAME("doc_source_size"), SNAME("EditorFonts")); - theme_cache.doc_kbd_font_size = get_theme_font_size(SNAME("doc_keyboard_size"), SNAME("EditorFonts")); + theme_cache.doc_font_size = get_theme_font_size(SNAME("doc_size"), EditorStringName(EditorFonts)); + theme_cache.doc_title_font_size = get_theme_font_size(SNAME("doc_title_size"), EditorStringName(EditorFonts)); + theme_cache.doc_code_font_size = get_theme_font_size(SNAME("doc_source_size"), EditorStringName(EditorFonts)); + theme_cache.doc_kbd_font_size = get_theme_font_size(SNAME("doc_keyboard_size"), EditorStringName(EditorFonts)); theme_cache.background_style = get_theme_stylebox(SNAME("background"), SNAME("EditorHelp")); @@ -393,17 +394,17 @@ String EditorHelp::_fix_constant(const String &p_constant) const { } // Macros for assigning the deprecation/experimental information to class members -#define DEPRECATED_DOC_TAG \ - class_desc->push_color(get_theme_color(SNAME("error_color"), SNAME("Editor"))); \ - Ref<Texture2D> error_icon = get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")); \ - class_desc->add_text(" "); \ - class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height()); \ - class_desc->add_text(" (" + TTR("Deprecated") + ")"); \ +#define DEPRECATED_DOC_TAG \ + class_desc->push_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor))); \ + Ref<Texture2D> error_icon = get_editor_theme_icon(SNAME("StatusError")); \ + class_desc->add_text(" "); \ + class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height()); \ + class_desc->add_text(" (" + TTR("Deprecated") + ")"); \ class_desc->pop(); #define EXPERIMENTAL_DOC_TAG \ - class_desc->push_color(get_theme_color(SNAME("warning_color"), SNAME("Editor"))); \ - Ref<Texture2D> warning_icon = get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")); \ + class_desc->push_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); \ + Ref<Texture2D> warning_icon = get_editor_theme_icon(SNAME("NodeWarning")); \ class_desc->add_text(" "); \ class_desc->add_image(warning_icon, warning_icon->get_width(), warning_icon->get_height()); \ class_desc->add_text(" (" + TTR("Experimental") + ")"); \ @@ -641,7 +642,7 @@ void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods) class_desc->add_newline(); } -void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, const String &p_method_type) { +void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, MethodType p_method_type) { String link_color_text = theme_cache.title_color.to_html(false); class_desc->add_newline(); @@ -696,14 +697,27 @@ void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc, if (!methods_filtered[i].description.strip_edges().is_empty()) { _add_text(DTR(methods_filtered[i].description)); } else { - class_desc->add_image(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + class_desc->add_image(get_editor_theme_icon(SNAME("Error"))); class_desc->add_text(" "); class_desc->push_color(theme_cache.comment_color); + + String message; if (p_classdoc.is_script_doc) { - class_desc->append_text(vformat(TTR("There is currently no description for this %s."), p_method_type)); + static const char *messages_by_type[METHOD_TYPE_MAX] = { + TTRC("There is currently no description for this method."), + TTRC("There is currently no description for this constructor."), + TTRC("There is currently no description for this operator."), + }; + message = TTRGET(messages_by_type[p_method_type]); } else { - class_desc->append_text(vformat(TTR("There is currently no description for this %s. Please help us by [color=$color][url=$url]contributing one[/url][/color]!"), p_method_type).replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text)); + static const char *messages_by_type[METHOD_TYPE_MAX] = { + TTRC("There is currently no description for this method. Please help us by [color=$color][url=$url]contributing one[/url][/color]!"), + TTRC("There is currently no description for this constructor. Please help us by [color=$color][url=$url]contributing one[/url][/color]!"), + TTRC("There is currently no description for this operator. Please help us by [color=$color][url=$url]contributing one[/url][/color]!"), + }; + message = TTRGET(messages_by_type[p_method_type]).replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text); } + class_desc->append_text(message); class_desc->pop(); } @@ -746,12 +760,12 @@ void EditorHelp::_update_doc() { if (cd.is_deprecated) { class_desc->add_text(" "); - Ref<Texture2D> error_icon = get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")); + Ref<Texture2D> error_icon = get_editor_theme_icon(SNAME("StatusError")); class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height()); } if (cd.is_experimental) { class_desc->add_text(" "); - Ref<Texture2D> warning_icon = get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")); + Ref<Texture2D> warning_icon = get_editor_theme_icon(SNAME("NodeWarning")); class_desc->add_image(warning_icon, warning_icon->get_width(), warning_icon->get_height()); } class_desc->add_newline(); @@ -818,8 +832,8 @@ void EditorHelp::_update_doc() { // Note if deprecated. if (cd.is_deprecated) { - Ref<Texture2D> error_icon = get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")); - class_desc->push_color(get_theme_color(SNAME("error_color"), SNAME("Editor"))); + Ref<Texture2D> error_icon = get_editor_theme_icon(SNAME("StatusError")); + class_desc->push_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor))); class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height()); class_desc->add_text(String(" ") + TTR("This class is marked as deprecated. It will be removed in future versions.")); class_desc->pop(); @@ -828,8 +842,8 @@ void EditorHelp::_update_doc() { // Note if experimental. if (cd.is_experimental) { - Ref<Texture2D> warning_icon = get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")); - class_desc->push_color(get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + Ref<Texture2D> warning_icon = get_editor_theme_icon(SNAME("NodeWarning")); + class_desc->push_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); class_desc->add_image(warning_icon, warning_icon->get_width(), warning_icon->get_height()); class_desc->add_text(String(" ") + TTR("This class is marked as experimental. It is subject to likely change or possible removal in future versions. Use at your own discretion.")); class_desc->pop(); @@ -884,7 +898,7 @@ void EditorHelp::_update_doc() { } if (!has_description) { - class_desc->add_image(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + class_desc->add_image(get_editor_theme_icon(SNAME("Error"))); class_desc->add_text(" "); class_desc->push_color(theme_cache.comment_color); @@ -1633,7 +1647,7 @@ void EditorHelp::_update_doc() { class_desc->pop(); // color } else { class_desc->push_indent(1); - class_desc->add_image(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + class_desc->add_image(get_editor_theme_icon(SNAME("Error"))); class_desc->add_text(" "); class_desc->push_color(theme_cache.comment_color); if (cd.is_script_doc) { @@ -1815,7 +1829,7 @@ void EditorHelp::_update_doc() { if (!cd.properties[i].description.strip_edges().is_empty()) { _add_text(DTR(cd.properties[i].description)); } else { - class_desc->add_image(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + class_desc->add_image(get_editor_theme_icon(SNAME("Error"))); class_desc->add_text(" "); class_desc->push_color(theme_cache.comment_color); if (cd.is_script_doc) { @@ -1842,7 +1856,7 @@ void EditorHelp::_update_doc() { class_desc->add_text(TTR("Constructor Descriptions")); _pop_title_font(); - _update_method_descriptions(cd, cd.constructors, "constructor"); + _update_method_descriptions(cd, cd.constructors, METHOD_TYPE_CONSTRUCTOR); } // Method descriptions @@ -1852,7 +1866,7 @@ void EditorHelp::_update_doc() { class_desc->add_text(TTR("Method Descriptions")); _pop_title_font(); - _update_method_descriptions(cd, methods, "method"); + _update_method_descriptions(cd, methods, METHOD_TYPE_METHOD); } // Operator descriptions @@ -1862,7 +1876,7 @@ void EditorHelp::_update_doc() { class_desc->add_text(TTR("Operator Descriptions")); _pop_title_font(); - _update_method_descriptions(cd, cd.operators, "operator"); + _update_method_descriptions(cd, cd.operators, METHOD_TYPE_OPERATOR); } // Free the scroll. @@ -1949,14 +1963,14 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control DocTools *doc = EditorHelp::get_doc_data(); String base_path; - Ref<Font> doc_font = p_owner_node->get_theme_font(SNAME("doc"), SNAME("EditorFonts")); - Ref<Font> doc_bold_font = p_owner_node->get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); - Ref<Font> doc_italic_font = p_owner_node->get_theme_font(SNAME("doc_italic"), SNAME("EditorFonts")); - Ref<Font> doc_code_font = p_owner_node->get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); - Ref<Font> doc_kbd_font = p_owner_node->get_theme_font(SNAME("doc_keyboard"), SNAME("EditorFonts")); + Ref<Font> doc_font = p_owner_node->get_theme_font(SNAME("doc"), EditorStringName(EditorFonts)); + Ref<Font> doc_bold_font = p_owner_node->get_theme_font(SNAME("doc_bold"), EditorStringName(EditorFonts)); + Ref<Font> doc_italic_font = p_owner_node->get_theme_font(SNAME("doc_italic"), EditorStringName(EditorFonts)); + Ref<Font> doc_code_font = p_owner_node->get_theme_font(SNAME("doc_source"), EditorStringName(EditorFonts)); + Ref<Font> doc_kbd_font = p_owner_node->get_theme_font(SNAME("doc_keyboard"), EditorStringName(EditorFonts)); - int doc_code_font_size = p_owner_node->get_theme_font_size(SNAME("doc_source_size"), SNAME("EditorFonts")); - int doc_kbd_font_size = p_owner_node->get_theme_font_size(SNAME("doc_keyboard_size"), SNAME("EditorFonts")); + int doc_code_font_size = p_owner_node->get_theme_font_size(SNAME("doc_source_size"), EditorStringName(EditorFonts)); + int doc_kbd_font_size = p_owner_node->get_theme_font_size(SNAME("doc_keyboard_size"), EditorStringName(EditorFonts)); const Color type_color = p_owner_node->get_theme_color(SNAME("type_color"), SNAME("EditorHelp")); const Color code_color = p_owner_node->get_theme_color(SNAME("code_color"), SNAME("EditorHelp")); @@ -1964,9 +1978,9 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control const Color code_dark_color = Color(code_color, 0.8); const Color link_color = p_owner_node->get_theme_color(SNAME("link_color"), SNAME("EditorHelp")); - const Color link_method_color = p_owner_node->get_theme_color(SNAME("accent_color"), SNAME("Editor")); - const Color link_property_color = link_color.lerp(p_owner_node->get_theme_color(SNAME("accent_color"), SNAME("Editor")), 0.25); - const Color link_annotation_color = link_color.lerp(p_owner_node->get_theme_color(SNAME("accent_color"), SNAME("Editor")), 0.5); + const Color link_method_color = p_owner_node->get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); + const Color link_property_color = link_color.lerp(p_owner_node->get_theme_color(SNAME("accent_color"), EditorStringName(Editor)), 0.25); + const Color link_annotation_color = link_color.lerp(p_owner_node->get_theme_color(SNAME("accent_color"), EditorStringName(Editor)), 0.5); const Color code_bg_color = p_owner_node->get_theme_color(SNAME("code_bg_color"), SNAME("EditorHelp")); const Color kbd_bg_color = p_owner_node->get_theme_color(SNAME("kbd_bg_color"), SNAME("EditorHelp")); @@ -2187,7 +2201,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control p_rt->push_font(doc_code_font); p_rt->push_font_size(doc_code_font_size); p_rt->push_bgcolor(code_bg_color); - p_rt->push_color(code_color.lerp(p_owner_node->get_theme_color(SNAME("error_color"), SNAME("Editor")), 0.6)); + p_rt->push_color(code_color.lerp(p_owner_node->get_theme_color(SNAME("error_color"), EditorStringName(Editor)), 0.6)); code_tag = true; pos = brk_end + 1; @@ -2486,9 +2500,9 @@ void EditorHelp::set_scroll(int p_scroll) { void EditorHelp::update_toggle_scripts_button() { if (is_layout_rtl()) { - toggle_scripts_button->set_icon(get_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Forward") : SNAME("Back"), SNAME("EditorIcons"))); + toggle_scripts_button->set_icon(get_editor_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Forward") : SNAME("Back"))); } else { - toggle_scripts_button->set_icon(get_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Back") : SNAME("Forward"), SNAME("EditorIcons"))); + toggle_scripts_button->set_icon(get_editor_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Back") : SNAME("Forward"))); } toggle_scripts_button->set_tooltip_text(vformat("%s (%s)", TTR("Toggle Scripts Panel"), ED_GET_SHORTCUT("script_editor/toggle_scripts_panel")->get_as_text())); } @@ -2668,13 +2682,13 @@ void FindBar::popup_search() { void FindBar::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); - find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); - hide_button->set_texture_normal(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); - hide_button->set_texture_hover(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); - hide_button->set_texture_pressed(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + find_prev->set_icon(get_editor_theme_icon(SNAME("MoveUp"))); + find_next->set_icon(get_editor_theme_icon(SNAME("MoveDown"))); + hide_button->set_texture_normal(get_editor_theme_icon(SNAME("Close"))); + hide_button->set_texture_hover(get_editor_theme_icon(SNAME("Close"))); + hide_button->set_texture_pressed(get_editor_theme_icon(SNAME("Close"))); hide_button->set_custom_minimum_size(hide_button->get_texture_normal()->get_size()); - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), EditorStringName(Editor))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -2742,7 +2756,7 @@ void FindBar::_update_matches_label() { } else { matches_label->show(); - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), EditorStringName(Editor))); matches_label->set_text(vformat(results_count == 1 ? TTR("%d match.") : TTR("%d matches."), results_count)); } } diff --git a/editor/editor_help.h b/editor/editor_help.h index 0aa8302b27..1f1528945b 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -86,14 +86,11 @@ public: class EditorHelp : public VBoxContainer { GDCLASS(EditorHelp, VBoxContainer); - enum Page { - PAGE_CLASS_LIST, - PAGE_CLASS_DESC, - PAGE_CLASS_PREV, - PAGE_CLASS_NEXT, - PAGE_SEARCH, - CLASS_SEARCH, - + enum MethodType { + METHOD_TYPE_METHOD, + METHOD_TYPE_CONSTRUCTOR, + METHOD_TYPE_OPERATOR, + METHOD_TYPE_MAX }; bool select_locked = false; @@ -181,7 +178,7 @@ class EditorHelp : public VBoxContainer { Error _goto_desc(const String &p_class); //void _update_history_buttons(); void _update_method_list(const Vector<DocData::MethodDoc> p_methods); - void _update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, const String &p_method_type); + void _update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, MethodType p_method_type); void _update_doc(); void _request_help(const String &p_string); diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index f06a23607e..c0459e9496 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -35,13 +35,14 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" void EditorHelpSearch::_update_icons() { - search_box->set_right_icon(results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + search_box->set_right_icon(results_tree->get_editor_theme_icon(SNAME("Search"))); search_box->set_clear_button_enabled(true); - search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - case_sensitive_button->set_icon(results_tree->get_theme_icon(SNAME("MatchCase"), SNAME("EditorIcons"))); - hierarchy_button->set_icon(results_tree->get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); + search_box->add_theme_icon_override("right_icon", results_tree->get_editor_theme_icon(SNAME("Search"))); + case_sensitive_button->set_icon(results_tree->get_editor_theme_icon(SNAME("MatchCase"))); + hierarchy_button->set_icon(results_tree->get_editor_theme_icon(SNAME("ClassList"))); if (is_visible()) { _update_results(); @@ -608,10 +609,10 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const } if (p_doc->is_deprecated) { - Ref<Texture2D> error_icon = ui_service->get_theme_icon("StatusError", SNAME("EditorIcons")); + Ref<Texture2D> error_icon = ui_service->get_editor_theme_icon("StatusError"); item->add_button(0, error_icon, 0, false, TTR("This class is marked as deprecated.")); } else if (p_doc->is_experimental) { - Ref<Texture2D> warning_icon = ui_service->get_theme_icon("NodeWarning", SNAME("EditorIcons")); + Ref<Texture2D> warning_icon = ui_service->get_editor_theme_icon("NodeWarning"); item->add_button(0, warning_icon, 0, false, TTR("This class is marked as experimental.")); } @@ -656,10 +657,10 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons Ref<Texture2D> icon; String text; if (search_flags & SEARCH_SHOW_HIERARCHY) { - icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons")); + icon = ui_service->get_editor_theme_icon(p_icon); text = p_text; } else { - icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons")); + icon = ui_service->get_editor_theme_icon(p_icon); text = p_class_name + "." + p_text; } @@ -672,10 +673,10 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons item->set_metadata(0, "class_" + p_metatype + ":" + p_class_name + ":" + p_name); if (is_deprecated) { - Ref<Texture2D> error_icon = ui_service->get_theme_icon("StatusError", SNAME("EditorIcons")); + Ref<Texture2D> error_icon = ui_service->get_editor_theme_icon("StatusError"); item->add_button(0, error_icon, 0, false, TTR("This member is marked as deprecated.")); } else if (is_experimental) { - Ref<Texture2D> warning_icon = ui_service->get_theme_icon("NodeWarning", SNAME("EditorIcons")); + Ref<Texture2D> warning_icon = ui_service->get_editor_theme_icon("NodeWarning"); item->add_button(0, warning_icon, 0, false, TTR("This member is marked as experimental.")); } @@ -700,5 +701,5 @@ EditorHelpSearch::Runner::Runner(Control *p_icon_service, Tree *p_results_tree, results_tree(p_results_tree), term((p_search_flags & SEARCH_CASE_SENSITIVE) == 0 ? p_term.strip_edges().to_lower() : p_term.strip_edges()), search_flags(p_search_flags), - disabled_color(ui_service->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))) { + disabled_color(ui_service->get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))) { } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 3c14dedb2d..2d402f6510 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -37,6 +37,7 @@ #include "editor/editor_property_name_processor.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_validation_panel.h" #include "editor/inspector_dock.h" @@ -89,12 +90,12 @@ Size2 EditorProperty::get_minimum_size() const { } if (keying) { - Ref<Texture2D> key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons")); + Ref<Texture2D> key = get_editor_theme_icon(SNAME("Key")); ms.width += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } if (deletable) { - Ref<Texture2D> key = get_theme_icon(SNAME("Close"), SNAME("EditorIcons")); + Ref<Texture2D> key = get_editor_theme_icon(SNAME("Close")); ms.width += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } @@ -180,9 +181,9 @@ void EditorProperty::_notification(int p_what) { Ref<Texture2D> key; if (use_keying_next()) { - key = get_theme_icon(SNAME("KeyNext"), SNAME("EditorIcons")); + key = get_editor_theme_icon(SNAME("KeyNext")); } else { - key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons")); + key = get_editor_theme_icon(SNAME("Key")); } rect.size.x -= key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); @@ -198,7 +199,7 @@ void EditorProperty::_notification(int p_what) { if (deletable) { Ref<Texture2D> close; - close = get_theme_icon(SNAME("Close"), SNAME("EditorIcons")); + close = get_editor_theme_icon(SNAME("Close")); rect.size.x -= close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); @@ -278,9 +279,9 @@ void EditorProperty::_notification(int p_what) { if (checkable) { Ref<Texture2D> checkbox; if (checked) { - checkbox = get_theme_icon(SNAME("GuiChecked"), SNAME("EditorIcons")); + checkbox = get_editor_theme_icon(SNAME("GuiChecked")); } else { - checkbox = get_theme_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons")); + checkbox = get_editor_theme_icon(SNAME("GuiUnchecked")); } Color color2(1, 1, 1); @@ -303,7 +304,7 @@ void EditorProperty::_notification(int p_what) { } if (can_revert && !is_read_only()) { - Ref<Texture2D> reload_icon = get_theme_icon(SNAME("ReloadSmall"), SNAME("EditorIcons")); + Ref<Texture2D> reload_icon = get_editor_theme_icon(SNAME("ReloadSmall")); text_limit -= reload_icon->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")) * 2; revert_rect = Rect2(ofs + text_limit, (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height()); @@ -323,7 +324,7 @@ void EditorProperty::_notification(int p_what) { } if (!pin_hidden && pinned) { - Ref<Texture2D> pinned_icon = get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")); + Ref<Texture2D> pinned_icon = get_editor_theme_icon(SNAME("Pin")); int margin_w = get_theme_constant(SNAME("hseparator"), SNAME("Tree")) * 2; int total_icon_w = margin_w + pinned_icon->get_width(); int text_w = font->get_string_size(label, rtl ? HORIZONTAL_ALIGNMENT_RIGHT : HORIZONTAL_ALIGNMENT_LEFT, text_limit - total_icon_w, font_size).x; @@ -349,9 +350,9 @@ void EditorProperty::_notification(int p_what) { Ref<Texture2D> key; if (use_keying_next()) { - key = get_theme_icon(SNAME("KeyNext"), SNAME("EditorIcons")); + key = get_editor_theme_icon(SNAME("KeyNext")); } else { - key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons")); + key = get_editor_theme_icon(SNAME("Key")); } ofs -= key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); @@ -376,7 +377,7 @@ void EditorProperty::_notification(int p_what) { if (deletable) { Ref<Texture2D> close; - close = get_theme_icon(SNAME("Close"), SNAME("EditorIcons")); + close = get_editor_theme_icon(SNAME("Close")); ofs -= close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); @@ -757,10 +758,10 @@ void EditorProperty::shortcut_input(const Ref<InputEvent> &p_event) { const Color *EditorProperty::_get_property_colors() { static Color c[4]; - c[0] = get_theme_color(SNAME("property_color_x"), SNAME("Editor")); - c[1] = get_theme_color(SNAME("property_color_y"), SNAME("Editor")); - c[2] = get_theme_color(SNAME("property_color_z"), SNAME("Editor")); - c[3] = get_theme_color(SNAME("property_color_w"), SNAME("Editor")); + c[0] = get_theme_color(SNAME("property_color_x"), EditorStringName(Editor)); + c[1] = get_theme_color(SNAME("property_color_y"), EditorStringName(Editor)); + c[2] = get_theme_color(SNAME("property_color_z"), EditorStringName(Editor)); + c[3] = get_theme_color(SNAME("property_color_w"), EditorStringName(Editor)); return c; } @@ -1047,17 +1048,17 @@ void EditorProperty::_update_popup() { add_child(menu); menu->connect("id_pressed", callable_mp(this, &EditorProperty::menu_option)); } - menu->add_icon_shortcut(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), ED_GET_SHORTCUT("property_editor/copy_value"), MENU_COPY_VALUE); - menu->add_icon_shortcut(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons")), ED_GET_SHORTCUT("property_editor/paste_value"), MENU_PASTE_VALUE); - menu->add_icon_shortcut(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), ED_GET_SHORTCUT("property_editor/copy_property_path"), MENU_COPY_PROPERTY_PATH); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionCopy")), ED_GET_SHORTCUT("property_editor/copy_value"), MENU_COPY_VALUE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionPaste")), ED_GET_SHORTCUT("property_editor/paste_value"), MENU_PASTE_VALUE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("CopyNodePath")), ED_GET_SHORTCUT("property_editor/copy_property_path"), MENU_COPY_PROPERTY_PATH); menu->set_item_disabled(MENU_PASTE_VALUE, is_read_only()); if (!pin_hidden) { menu->add_separator(); if (can_pin) { - menu->add_icon_check_item(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")), TTR("Pin Value"), MENU_PIN_VALUE); + menu->add_icon_check_item(get_editor_theme_icon(SNAME("Pin")), TTR("Pin Value"), MENU_PIN_VALUE); menu->set_item_checked(menu->get_item_index(MENU_PIN_VALUE), pinned); } else { - menu->add_icon_check_item(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")), vformat(TTR("Pin Value [Disabled because '%s' is editor-only]"), property), MENU_PIN_VALUE); + menu->add_icon_check_item(get_editor_theme_icon(SNAME("Pin")), vformat(TTR("Pin Value [Disabled because '%s' is editor-only]"), property), MENU_PIN_VALUE); menu->set_item_disabled(menu->get_item_index(MENU_PIN_VALUE), true); } menu->set_item_tooltip(menu->get_item_index(MENU_PIN_VALUE), TTR("Pinning a value forces it to be saved even if it's equal to the default.")); @@ -1065,7 +1066,7 @@ void EditorProperty::_update_popup() { if (!doc_path.is_empty()) { menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("Help"), SNAME("EditorIcons")), TTR("Open Documentation"), MENU_OPEN_DOCUMENTATION); + menu->add_icon_item(get_editor_theme_icon(SNAME("Help")), TTR("Open Documentation"), MENU_OPEN_DOCUMENTATION); } } @@ -1142,18 +1143,18 @@ void EditorInspectorCategory::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - menu->set_item_icon(menu->get_item_index(MENU_OPEN_DOCS), get_theme_icon(SNAME("Help"), SNAME("EditorIcons"))); + menu->set_item_icon(menu->get_item_index(MENU_OPEN_DOCS), get_editor_theme_icon(SNAME("Help"))); } break; case NOTIFICATION_DRAW: { Ref<StyleBox> sb = get_theme_stylebox(SNAME("bg")); draw_style_box(sb, Rect2(Vector2(), get_size())); - Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); int hs = get_theme_constant(SNAME("h_separation"), SNAME("Tree")); - int icon_size = get_theme_constant(SNAME("class_icon_size"), SNAME("Editor")); + int icon_size = get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)); int w = font->get_string_size(label, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width; if (icon.is_valid()) { @@ -1181,8 +1182,8 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons } Size2 EditorInspectorCategory::get_minimum_size() const { - Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); Size2 ms; ms.height = font->get_height(font_size); @@ -1255,8 +1256,8 @@ Ref<Texture2D> EditorInspectorSection::_get_arrow() { } int EditorInspectorSection::_get_header_height() { - Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); int header_height = font->get_height(font_size); Ref<Texture2D> arrow = _get_arrow(); @@ -1279,7 +1280,7 @@ void EditorInspectorSection::_notification(int p_what) { return; } - int inspector_margin = get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")); + int inspector_margin = get_theme_constant(SNAME("inspector_margin"), EditorStringName(Editor)); int section_indent_size = get_theme_constant(SNAME("indent_size"), SNAME("EditorInspectorSection")); if (indent_depth > 0 && section_indent_size > 0) { inspector_margin += indent_depth * section_indent_size; @@ -1362,16 +1363,16 @@ void EditorInspectorSection::_notification(int p_what) { bool folded = foldable && !object->editor_is_section_unfolded(section); - Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); - Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); + Color font_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); if (folded && revertable_properties.size()) { int label_width = font->get_string_size(label, HORIZONTAL_ALIGNMENT_LEFT, available, font_size, TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_CONSTRAIN_ELLIPSIS).x; - Ref<Font> light_font = get_theme_font(SNAME("main"), SNAME("EditorFonts")); - int light_font_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts")); - Color light_font_color = get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")); + Ref<Font> light_font = get_theme_font(SNAME("main"), EditorStringName(EditorFonts)); + int light_font_size = get_theme_font_size(SNAME("main_size"), EditorStringName(EditorFonts)); + Color light_font_color = get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor)); // Can we fit the long version of the revertable count text? num_revertable_str = vformat(TTRN("(%d change)", "(%d changes)", revertable_properties.size()), revertable_properties.size()); @@ -1406,7 +1407,7 @@ void EditorInspectorSection::_notification(int p_what) { // Draw dropping highlight. if (dropping && !vbox->is_visible_in_tree()) { - Color accent_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); draw_rect(Rect2(Point2(), get_size()), accent_color, false); } @@ -1467,7 +1468,7 @@ Size2 EditorInspectorSection::get_minimum_size() const { Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); ms.height += font->get_height(font_size) + get_theme_constant(SNAME("v_separation"), SNAME("Tree")); - ms.width += get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")); + ms.width += get_theme_constant(SNAME("inspector_margin"), EditorStringName(Editor)); int section_indent_size = get_theme_constant(SNAME("indent_size"), SNAME("EditorInspectorSection")); if (indent_depth > 0 && section_indent_size > 0) { @@ -1686,7 +1687,7 @@ void EditorInspectorArray::_control_dropping_draw() { from = xform.xform(Vector2(0, child->get_size().y)); to = xform.xform(Vector2(elements_vbox->get_size().x, child->get_size().y)); } - Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); control_dropping->draw_line(from, to, color, 2); } } @@ -1698,7 +1699,7 @@ void EditorInspectorArray::_vbox_visibility_changed() { void EditorInspectorArray::_panel_draw(int p_index) { ERR_FAIL_INDEX(p_index, (int)array_elements.size()); - Ref<StyleBox> style = get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles")); + Ref<StyleBox> style = get_theme_stylebox(SNAME("Focus"), EditorStringName(EditorStyles)); if (!style.is_valid()) { return; } @@ -2103,7 +2104,7 @@ void EditorInspectorArray::_setup() { int numbers_min_w = 0; if (numbered) { - numbers_font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + numbers_font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); int digits_found = count; String test; while (digits_found) { @@ -2133,7 +2134,7 @@ void EditorInspectorArray::_setup() { ae.margin = memnew(MarginContainer); ae.margin->set_mouse_filter(MOUSE_FILTER_PASS); if (is_inside_tree()) { - Size2 min_size = get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles"))->get_minimum_size(); + Size2 min_size = get_theme_stylebox(SNAME("Focus"), EditorStringName(EditorStyles))->get_minimum_size(); ae.margin->add_theme_constant_override("margin_left", min_size.x / 2); ae.margin->add_theme_constant_override("margin_top", min_size.y / 2); ae.margin->add_theme_constant_override("margin_right", min_size.x / 2); @@ -2156,7 +2157,7 @@ void EditorInspectorArray::_setup() { if (element_position > 0) { ae.move_up = memnew(Button); - ae.move_up->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + ae.move_up->set_icon(get_editor_theme_icon(SNAME("MoveUp"))); ae.move_up->connect("pressed", callable_mp(this, &EditorInspectorArray::_move_element).bind(element_position, element_position - 1)); move_vbox->add_child(ae.move_up); } @@ -2166,13 +2167,13 @@ void EditorInspectorArray::_setup() { ae.move_texture_rect->set_default_cursor_shape(Control::CURSOR_MOVE); if (is_inside_tree()) { - ae.move_texture_rect->set_texture(get_theme_icon(SNAME("TripleBar"), SNAME("EditorIcons"))); + ae.move_texture_rect->set_texture(get_editor_theme_icon(SNAME("TripleBar"))); } move_vbox->add_child(ae.move_texture_rect); if (element_position < _get_array_count() - 1) { ae.move_down = memnew(Button); - ae.move_down->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); + ae.move_down->set_icon(get_editor_theme_icon(SNAME("MoveDown"))); ae.move_down->connect("pressed", callable_mp(this, &EditorInspectorArray::_move_element).bind(element_position, element_position + 2)); move_vbox->add_child(ae.move_down); } @@ -2195,7 +2196,7 @@ void EditorInspectorArray::_setup() { ae.hbox->add_child(ae.vbox); ae.erase = memnew(Button); - ae.erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + ae.erase->set_icon(get_editor_theme_icon(SNAME("Remove"))); ae.erase->set_v_size_flags(SIZE_SHRINK_CENTER); ae.erase->connect("pressed", callable_mp(this, &EditorInspectorArray::_remove_item).bind(begin_array_index + i)); ae.hbox->add_child(ae.erase); @@ -2268,32 +2269,32 @@ void EditorInspectorArray::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - Color color = get_theme_color(SNAME("dark_color_1"), SNAME("Editor")); + Color color = get_theme_color(SNAME("dark_color_1"), EditorStringName(Editor)); odd_style->set_bg_color(color.darkened(-0.08)); even_style->set_bg_color(color.darkened(0.08)); for (ArrayElement &ae : array_elements) { if (ae.move_texture_rect) { - ae.move_texture_rect->set_texture(get_theme_icon(SNAME("TripleBar"), SNAME("EditorIcons"))); + ae.move_texture_rect->set_texture(get_editor_theme_icon(SNAME("TripleBar"))); } if (ae.move_up) { - ae.move_up->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + ae.move_up->set_icon(get_editor_theme_icon(SNAME("MoveUp"))); } if (ae.move_down) { - ae.move_down->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); + ae.move_down->set_icon(get_editor_theme_icon(SNAME("MoveDown"))); } - Size2 min_size = get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles"))->get_minimum_size(); + Size2 min_size = get_theme_stylebox(SNAME("Focus"), EditorStringName(EditorStyles))->get_minimum_size(); ae.margin->add_theme_constant_override("margin_left", min_size.x / 2); ae.margin->add_theme_constant_override("margin_top", min_size.y / 2); ae.margin->add_theme_constant_override("margin_right", min_size.x / 2); ae.margin->add_theme_constant_override("margin_bottom", min_size.y / 2); if (ae.erase) { - ae.erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + ae.erase->set_icon(get_editor_theme_icon(SNAME("Remove"))); } } - add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_button->set_icon(get_editor_theme_icon(SNAME("Add"))); update_minimum_size(); } break; @@ -2462,10 +2463,10 @@ void EditorPaginator::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - first_page_button->set_icon(get_theme_icon(SNAME("PageFirst"), SNAME("EditorIcons"))); - prev_page_button->set_icon(get_theme_icon(SNAME("PagePrevious"), SNAME("EditorIcons"))); - next_page_button->set_icon(get_theme_icon(SNAME("PageNext"), SNAME("EditorIcons"))); - last_page_button->set_icon(get_theme_icon(SNAME("PageLast"), SNAME("EditorIcons"))); + first_page_button->set_icon(get_editor_theme_icon(SNAME("PageFirst"))); + prev_page_button->set_icon(get_editor_theme_icon(SNAME("PagePrevious"))); + next_page_button->set_icon(get_editor_theme_icon(SNAME("PageNext"))); + last_page_button->set_icon(get_editor_theme_icon(SNAME("PageLast"))); } break; } } @@ -2748,7 +2749,7 @@ void EditorInspector::update_tree() { HashMap<VBoxContainer *, HashMap<String, VBoxContainer *>> vbox_per_path; HashMap<String, EditorInspectorArray *> editor_inspector_array_per_prefix; - Color sscolor = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); + Color sscolor = get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor)); // Get the lists of editors to add the beginning. for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { @@ -3417,7 +3418,7 @@ void EditorInspector::update_tree() { main_vbox->add_child(spacer); Button *add_md = EditorInspector::create_inspector_action_button(TTR("Add Metadata")); - add_md->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_md->set_icon(get_editor_theme_icon(SNAME("Add"))); add_md->connect(SNAME("pressed"), callable_mp(this, &EditorInspector::_show_add_meta_dialog)); main_vbox->add_child(add_md); if (all_read_only) { @@ -3679,7 +3680,7 @@ void EditorInspector::_update_inspector_bg() { n = n->get_parent(); } count_subinspectors = MIN(15, count_subinspectors); - add_theme_style_override("panel", get_theme_stylebox("sub_inspector_bg" + itos(count_subinspectors), SNAME("Editor"))); + add_theme_style_override("panel", get_theme_stylebox("sub_inspector_bg" + itos(count_subinspectors), EditorStringName(Editor))); } else { add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); } @@ -4200,7 +4201,7 @@ void EditorInspector::_show_add_meta_dialog() { } String type = i == Variant::OBJECT ? String("Resource") : Variant::get_type_name(Variant::Type(i)); - add_meta_type->add_icon_item(get_theme_icon(type, "EditorIcons"), type, i); + add_meta_type->add_icon_item(get_editor_theme_icon(type), type, i); } hbc->add_child(add_meta_type); diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 4c2f6b3176..3cd5bbfad6 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -37,6 +37,7 @@ #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/gui/center_container.h" #include "scene/gui/separator.h" #include "scene/resources/font.h" @@ -65,27 +66,27 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_f } void EditorLog::_update_theme() { - const Ref<Font> normal_font = get_theme_font(SNAME("output_source"), SNAME("EditorFonts")); + const Ref<Font> normal_font = get_theme_font(SNAME("output_source"), EditorStringName(EditorFonts)); if (normal_font.is_valid()) { log->add_theme_font_override("normal_font", normal_font); } - const Ref<Font> bold_font = get_theme_font(SNAME("output_source_bold"), SNAME("EditorFonts")); + const Ref<Font> bold_font = get_theme_font(SNAME("output_source_bold"), EditorStringName(EditorFonts)); if (bold_font.is_valid()) { log->add_theme_font_override("bold_font", bold_font); } - const Ref<Font> italics_font = get_theme_font(SNAME("output_source_italic"), SNAME("EditorFonts")); + const Ref<Font> italics_font = get_theme_font(SNAME("output_source_italic"), EditorStringName(EditorFonts)); if (italics_font.is_valid()) { log->add_theme_font_override("italics_font", italics_font); } - const Ref<Font> bold_italics_font = get_theme_font(SNAME("output_source_bold_italic"), SNAME("EditorFonts")); + const Ref<Font> bold_italics_font = get_theme_font(SNAME("output_source_bold_italic"), EditorStringName(EditorFonts)); if (bold_italics_font.is_valid()) { log->add_theme_font_override("bold_italics_font", bold_italics_font); } - const Ref<Font> mono_font = get_theme_font(SNAME("output_source_mono"), SNAME("EditorFonts")); + const Ref<Font> mono_font = get_theme_font(SNAME("output_source_mono"), EditorStringName(EditorFonts)); if (mono_font.is_valid()) { log->add_theme_font_override("mono_font", mono_font); } @@ -95,33 +96,33 @@ void EditorLog::_update_theme() { log->add_theme_constant_override("text_highlight_h_padding", 0); log->add_theme_constant_override("text_highlight_v_padding", 0); - const int font_size = get_theme_font_size(SNAME("output_source_size"), SNAME("EditorFonts")); + const int font_size = get_theme_font_size(SNAME("output_source_size"), EditorStringName(EditorFonts)); log->add_theme_font_size_override("normal_font_size", font_size); log->add_theme_font_size_override("bold_font_size", font_size); log->add_theme_font_size_override("italics_font_size", font_size); log->add_theme_font_size_override("mono_font_size", font_size); - type_filter_map[MSG_TYPE_STD]->toggle_button->set_icon(get_theme_icon(SNAME("Popup"), SNAME("EditorIcons"))); - type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); - type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); - type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + type_filter_map[MSG_TYPE_STD]->toggle_button->set_icon(get_editor_theme_icon(SNAME("Popup"))); + type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_icon(get_editor_theme_icon(SNAME("StatusError"))); + type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_editor_theme_icon(SNAME("StatusWarning"))); + type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_icon(get_editor_theme_icon(SNAME("Edit"))); type_filter_map[MSG_TYPE_STD]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); - clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); - copy_button->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); - collapse_button->set_icon(get_theme_icon(SNAME("CombineLines"), SNAME("EditorIcons"))); - show_search_button->set_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - - theme_cache.error_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); - theme_cache.error_icon = get_theme_icon(SNAME("Error"), SNAME("EditorIcons")); - theme_cache.warning_color = get_theme_color(SNAME("warning_color"), SNAME("Editor")); - theme_cache.warning_icon = get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")); - theme_cache.message_color = get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.6); + clear_button->set_icon(get_editor_theme_icon(SNAME("Clear"))); + copy_button->set_icon(get_editor_theme_icon(SNAME("ActionCopy"))); + collapse_button->set_icon(get_editor_theme_icon(SNAME("CombineLines"))); + show_search_button->set_icon(get_editor_theme_icon(SNAME("Search"))); + search_box->set_right_icon(get_editor_theme_icon(SNAME("Search"))); + + theme_cache.error_color = get_theme_color(SNAME("error_color"), EditorStringName(Editor)); + theme_cache.error_icon = get_editor_theme_icon(SNAME("Error")); + theme_cache.warning_color = get_theme_color(SNAME("warning_color"), EditorStringName(Editor)); + theme_cache.warning_icon = get_editor_theme_icon(SNAME("Warning")); + theme_cache.message_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.6); } void EditorLog::_notification(int p_what) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index ea743fe470..2d867ed8c2 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -44,6 +44,7 @@ #include "core/string/print_string.h" #include "core/string/translation.h" #include "core/version.h" +#include "editor/editor_string_names.h" #include "main/main.h" #include "scene/gui/color_picker.h" #include "scene/gui/dialogs.h" @@ -62,6 +63,7 @@ #include "scene/resources/image_texture.h" #include "scene/resources/packed_scene.h" #include "scene/resources/portable_compressed_texture.h" +#include "scene/theme/theme_db.h" #include "servers/display_server.h" #include "servers/navigation_server_3d.h" #include "servers/physics_server_2d.h" @@ -453,6 +455,119 @@ void EditorNode::_select_default_main_screen_plugin() { editor_select(-1); } +void EditorNode::_update_theme(bool p_skip_creation) { + if (!p_skip_creation) { + theme = create_custom_theme(theme); + DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), EditorStringName(Editor))); + } + + List<Ref<Theme>> editor_themes; + editor_themes.push_back(theme); + editor_themes.push_back(ThemeDB::get_singleton()->get_default_theme()); + + ThemeContext *node_tc = ThemeDB::get_singleton()->get_theme_context(this); + if (node_tc) { + node_tc->set_themes(editor_themes); + } else { + ThemeDB::get_singleton()->create_theme_context(this, editor_themes); + } + + Window *window = get_window(); + if (window) { + ThemeContext *window_tc = ThemeDB::get_singleton()->get_theme_context(window); + if (window_tc) { + window_tc->set_themes(editor_themes); + } else { + ThemeDB::get_singleton()->create_theme_context(window, editor_themes); + } + } + + if (CanvasItemEditor::get_singleton()->get_theme_preview() == CanvasItemEditor::THEME_PREVIEW_EDITOR) { + update_preview_themes(CanvasItemEditor::THEME_PREVIEW_EDITOR); + } + + gui_base->add_theme_style_override("panel", theme->get_stylebox(SNAME("Background"), EditorStringName(EditorStyles))); + main_vbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT, Control::PRESET_MODE_MINSIZE, theme->get_constant(SNAME("window_border_margin"), EditorStringName(Editor))); + main_vbox->add_theme_constant_override("separation", theme->get_constant(SNAME("top_bar_separation"), EditorStringName(Editor))); + + 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))); + prev_scene->set_icon(theme->get_icon(SNAME("PrevScene"), EditorStringName(EditorIcons))); + distraction_free->set_icon(theme->get_icon(SNAME("DistractionFree"), EditorStringName(EditorIcons))); + bottom_panel_raise->set_icon(theme->get_icon(SNAME("ExpandBottomDock"), EditorStringName(EditorIcons))); + + if (gui_base->is_layout_rtl()) { + dock_tab_move_left->set_icon(theme->get_icon(SNAME("Forward"), EditorStringName(EditorIcons))); + dock_tab_move_right->set_icon(theme->get_icon(SNAME("Back"), EditorStringName(EditorIcons))); + } else { + dock_tab_move_left->set_icon(theme->get_icon(SNAME("Back"), EditorStringName(EditorIcons))); + dock_tab_move_right->set_icon(theme->get_icon(SNAME("Forward"), EditorStringName(EditorIcons))); + } + + help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), theme->get_icon(SNAME("HelpSearch"), EditorStringName(EditorIcons))); + help_menu->set_item_icon(help_menu->get_item_index(HELP_DOCS), theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons))); + help_menu->set_item_icon(help_menu->get_item_index(HELP_QA), theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons))); + help_menu->set_item_icon(help_menu->get_item_index(HELP_REPORT_A_BUG), theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons))); + help_menu->set_item_icon(help_menu->get_item_index(HELP_COPY_SYSTEM_INFO), theme->get_icon(SNAME("ActionCopy"), EditorStringName(EditorIcons))); + help_menu->set_item_icon(help_menu->get_item_index(HELP_SUGGEST_A_FEATURE), theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons))); + help_menu->set_item_icon(help_menu->get_item_index(HELP_SEND_DOCS_FEEDBACK), theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons))); + help_menu->set_item_icon(help_menu->get_item_index(HELP_COMMUNITY), theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons))); + help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), theme->get_icon(SNAME("Godot"), EditorStringName(EditorIcons))); + help_menu->set_item_icon(help_menu->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), theme->get_icon(SNAME("Heart"), EditorStringName(EditorIcons))); + + for (int i = 0; i < main_editor_buttons.size(); i++) { + main_editor_buttons.write[i]->add_theme_font_override("font", theme->get_font(SNAME("main_button_font"), EditorStringName(EditorFonts))); + main_editor_buttons.write[i]->add_theme_font_size_override("font_size", theme->get_font_size(SNAME("main_button_font_size"), EditorStringName(EditorFonts))); + } + + if (EditorDebuggerNode::get_singleton()->is_visible()) { + bottom_panel->add_theme_style_override("panel", theme->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))); + } + + for (int i = 0; i < main_editor_buttons.size(); i++) { + Button *tb = main_editor_buttons[i]; + EditorPlugin *p_editor = editor_table[i]; + Ref<Texture2D> icon = p_editor->get_icon(); + + if (icon.is_valid()) { + tb->set_icon(icon); + } else if (theme->has_icon(p_editor->get_name(), EditorStringName(EditorIcons))) { + tb->set_icon(theme->get_icon(p_editor->get_name(), EditorStringName(EditorIcons))); + } + } +} + +void EditorNode::update_preview_themes(int p_mode) { + if (!scene_root->is_inside_tree()) { + return; // Too early. + } + + List<Ref<Theme>> preview_themes; + + switch (p_mode) { + case CanvasItemEditor::THEME_PREVIEW_PROJECT: + preview_themes.push_back(ThemeDB::get_singleton()->get_project_theme()); + break; + + case CanvasItemEditor::THEME_PREVIEW_EDITOR: + preview_themes.push_back(get_editor_theme()); + break; + + default: + break; + } + + preview_themes.push_back(ThemeDB::get_singleton()->get_default_theme()); + + ThemeContext *preview_context = ThemeDB::get_singleton()->get_theme_context(scene_root); + if (preview_context) { + preview_context->set_themes(preview_themes); + } else { + ThemeDB::get_singleton()->create_theme_context(scene_root, preview_themes); + } +} + void EditorNode::_notification(int p_what) { switch (p_what) { case NOTIFICATION_PROCESS: { @@ -486,7 +601,7 @@ void EditorNode::_notification(int p_what) { // Update the icon itself only when the spinner is visible. if (EDITOR_GET("interface/editor/show_update_spinner")) { - update_spinner->set_icon(gui_base->get_theme_icon("Progress" + itos(update_spinner_step + 1), SNAME("EditorIcons"))); + update_spinner->set_icon(theme->get_icon("Progress" + itos(update_spinner_step + 1), EditorStringName(EditorIcons))); } } @@ -506,9 +621,11 @@ void EditorNode::_notification(int p_what) { if (window) { // Handle macOS fullscreen and extend-to-title changes. window->connect("titlebar_changed", callable_mp(this, &EditorNode::_titlebar_resized)); - window->set_theme(theme); } + // Theme has already been created in the constructor, so we can skip that step. + _update_theme(true); + OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec"))); get_tree()->get_root()->set_as_audio_listener_3d(false); get_tree()->get_root()->set_as_audio_listener_2d(false); @@ -523,6 +640,7 @@ void EditorNode::_notification(int p_what) { command_palette->register_shortcuts_as_command(); MessageQueue::get_singleton()->push_callable(callable_mp(this, &EditorNode::_begin_first_scan)); + /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ } break; @@ -584,6 +702,10 @@ void EditorNode::_notification(int p_what) { _titlebar_resized(); + // Set up a theme context for the 2D preview viewport using the stored preview theme. + CanvasItemEditor::ThemePreviewMode theme_preview_mode = (CanvasItemEditor::ThemePreviewMode)(int)EditorSettings::get_singleton()->get_project_metadata("2d_editor", "theme_preview", CanvasItemEditor::THEME_PREVIEW_PROJECT); + update_preview_themes(theme_preview_mode); + /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ } break; @@ -631,73 +753,14 @@ void EditorNode::_notification(int p_what) { EditorSettings::get_singleton()->check_changed_settings_in_group("interface/touchscreen/scale_gizmo_handles"); if (theme_changed) { - theme = create_custom_theme(theme_base->get_theme()); - DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), SNAME("Editor"))); - - theme_base->set_theme(theme); - gui_base->set_theme(theme); - get_window()->set_theme(theme); - - gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); - main_vbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT, Control::PRESET_MODE_MINSIZE, gui_base->get_theme_constant(SNAME("window_border_margin"), SNAME("Editor"))); - main_vbox->add_theme_constant_override("separation", gui_base->get_theme_constant(SNAME("top_bar_separation"), SNAME("Editor"))); - scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles"))); - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanel"), SNAME("EditorStyles"))); - main_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + _update_theme(); } scene_tabs->update_scene_tabs(); recent_scenes->reset_size(); - // Update debugger area. - if (EditorDebuggerNode::get_singleton()->is_visible()) { - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))); - } - - // Update icons. - for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { - Button *tb = singleton->main_editor_buttons[i]; - EditorPlugin *p_editor = singleton->editor_table[i]; - Ref<Texture2D> icon = p_editor->get_icon(); - - if (icon.is_valid()) { - tb->set_icon(icon); - } else if (singleton->gui_base->has_theme_icon(p_editor->get_name(), SNAME("EditorIcons"))) { - tb->set_icon(singleton->gui_base->get_theme_icon(p_editor->get_name(), SNAME("EditorIcons"))); - } - } - _build_icon_type_cache(); - prev_scene->set_icon(gui_base->get_theme_icon(SNAME("PrevScene"), SNAME("EditorIcons"))); - distraction_free->set_icon(gui_base->get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons"))); - - bottom_panel_raise->set_icon(gui_base->get_theme_icon(SNAME("ExpandBottomDock"), SNAME("EditorIcons"))); - - if (gui_base->is_layout_rtl()) { - dock_tab_move_left->set_icon(theme->get_icon(SNAME("Forward"), SNAME("EditorIcons"))); - dock_tab_move_right->set_icon(theme->get_icon(SNAME("Back"), SNAME("EditorIcons"))); - } else { - dock_tab_move_left->set_icon(theme->get_icon(SNAME("Back"), SNAME("EditorIcons"))); - dock_tab_move_right->set_icon(theme->get_icon(SNAME("Forward"), SNAME("EditorIcons"))); - } - - help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons"))); - help_menu->set_item_icon(help_menu->get_item_index(HELP_DOCS), gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons"))); - help_menu->set_item_icon(help_menu->get_item_index(HELP_QA), gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons"))); - help_menu->set_item_icon(help_menu->get_item_index(HELP_REPORT_A_BUG), gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons"))); - help_menu->set_item_icon(help_menu->get_item_index(HELP_COPY_SYSTEM_INFO), gui_base->get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); - help_menu->set_item_icon(help_menu->get_item_index(HELP_SUGGEST_A_FEATURE), gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons"))); - help_menu->set_item_icon(help_menu->get_item_index(HELP_SEND_DOCS_FEEDBACK), gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons"))); - help_menu->set_item_icon(help_menu->get_item_index(HELP_COMMUNITY), gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons"))); - help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), gui_base->get_theme_icon(SNAME("Godot"), SNAME("EditorIcons"))); - help_menu->set_item_icon(help_menu->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), gui_base->get_theme_icon(SNAME("Heart"), SNAME("EditorIcons"))); - - for (int i = 0; i < main_editor_buttons.size(); i++) { - main_editor_buttons.write[i]->add_theme_font_override("font", gui_base->get_theme_font(SNAME("main_button_font"), SNAME("EditorFonts"))); - main_editor_buttons.write[i]->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("main_button_font_size"), SNAME("EditorFonts"))); - } - HashSet<String> updated_textfile_extensions; bool extensions_match = true; const Vector<String> textfile_ext = ((String)(EDITOR_GET("docks/filesystem/textfile_extensions"))).split(",", false); @@ -734,8 +797,7 @@ void EditorNode::_update_update_spinner() { // Make the icon modulate color overbright because icons are not completely white on a dark theme. // On a light theme, icons are dark, so we need to modulate them with an even brighter color. const bool dark_theme = EditorSettings::get_singleton()->is_dark_theme(); - update_spinner->set_self_modulate( - gui_base->get_theme_color(SNAME("error_color"), SNAME("Editor")) * (dark_theme ? Color(1.1, 1.1, 1.1) : Color(4.25, 4.25, 4.25))); + update_spinner->set_self_modulate(theme->get_color(SNAME("error_color"), EditorStringName(Editor)) * (dark_theme ? Color(1.1, 1.1, 1.1) : Color(4.25, 4.25, 4.25))); } else { update_spinner->set_tooltip_text(TTR("Spins when the editor window redraws.")); update_spinner->set_self_modulate(Color(1, 1, 1)); @@ -3130,12 +3192,12 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed tb->set_icon(icon); // Make sure the control is updated if the icon is reimported. icon->connect_changed(callable_mp((Control *)tb, &Control::update_minimum_size)); - } else if (singleton->gui_base->has_theme_icon(p_editor->get_name(), SNAME("EditorIcons"))) { - tb->set_icon(singleton->gui_base->get_theme_icon(p_editor->get_name(), SNAME("EditorIcons"))); + } else if (singleton->theme->has_icon(p_editor->get_name(), EditorStringName(EditorIcons))) { + tb->set_icon(singleton->theme->get_icon(p_editor->get_name(), EditorStringName(EditorIcons))); } - tb->add_theme_font_override("font", singleton->gui_base->get_theme_font(SNAME("main_button_font"), SNAME("EditorFonts"))); - tb->add_theme_font_size_override("font_size", singleton->gui_base->get_theme_font_size(SNAME("main_button_font_size"), SNAME("EditorFonts"))); + tb->add_theme_font_override("font", singleton->theme->get_font(SNAME("main_button_font"), EditorStringName(EditorFonts))); + tb->add_theme_font_size_override("font_size", singleton->theme->get_font_size(SNAME("main_button_font_size"), EditorStringName(EditorFonts))); singleton->main_editor_buttons.push_back(tb); singleton->main_editor_button_hb->add_child(tb); @@ -4066,14 +4128,14 @@ void EditorNode::notify_all_debug_sessions_exited() { void EditorNode::add_io_error(const String &p_error) { DEV_ASSERT(Thread::get_caller_id() == Thread::get_main_id()); - singleton->load_errors->add_image(singleton->gui_base->get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + singleton->load_errors->add_image(singleton->theme->get_icon(SNAME("Error"), EditorStringName(EditorIcons))); singleton->load_errors->add_text(p_error + "\n"); EditorInterface::get_singleton()->popup_dialog_centered_ratio(singleton->load_error_dialog, 0.5); } void EditorNode::add_io_warning(const String &p_warning) { DEV_ASSERT(Thread::get_caller_id() == Thread::get_main_id()); - singleton->load_errors->add_image(singleton->gui_base->get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); + singleton->load_errors->add_image(singleton->theme->get_icon(SNAME("Warning"), EditorStringName(EditorIcons))); singleton->load_errors->add_text(p_warning + "\n"); EditorInterface::get_singleton()->popup_dialog_centered_ratio(singleton->load_error_dialog, 0.5); } @@ -4207,12 +4269,12 @@ Ref<Texture2D> EditorNode::_get_class_or_script_icon(const String &p_class, cons } if (p_fallback_script_to_theme) { - // Look for the base type in the editor theme. - // This is only relevant for built-in classes. - String base_type; - p_script->get_language()->get_global_class_name(p_script->get_path(), &base_type); - if (gui_base && gui_base->has_theme_icon(base_type, SNAME("EditorIcons"))) { - return gui_base->get_theme_icon(base_type, SNAME("EditorIcons")); + // Look for the native base type in the editor theme. This is relevant for + // scripts extending other scripts and for built-in classes. + String script_class_name = p_script->get_language()->get_global_class_name(p_script->get_path()); + String base_type = ScriptServer::get_global_class_native_base(script_class_name); + if (theme.is_valid() && theme->has_icon(base_type, EditorStringName(EditorIcons))) { + return theme->get_icon(base_type, EditorStringName(EditorIcons)); } } } @@ -4235,22 +4297,22 @@ Ref<Texture2D> EditorNode::_get_class_or_script_icon(const String &p_class, cons // Look up the class name or the fallback name in the editor theme. // This is only relevant for built-in classes. - if (gui_base) { - if (gui_base->has_theme_icon(p_class, SNAME("EditorIcons"))) { - return gui_base->get_theme_icon(p_class, SNAME("EditorIcons")); + if (theme.is_valid()) { + if (theme->has_icon(p_class, EditorStringName(EditorIcons))) { + return theme->get_icon(p_class, EditorStringName(EditorIcons)); } - if (!p_fallback.is_empty() && gui_base->has_theme_icon(p_fallback, SNAME("EditorIcons"))) { - return gui_base->get_theme_icon(p_fallback, SNAME("EditorIcons")); + if (!p_fallback.is_empty() && theme->has_icon(p_fallback, EditorStringName(EditorIcons))) { + return theme->get_icon(p_fallback, EditorStringName(EditorIcons)); } // If the fallback is empty or wasn't found, use the default fallback. if (ClassDB::class_exists(p_class)) { bool instantiable = !ClassDB::is_virtual(p_class) && ClassDB::can_instantiate(p_class); if (ClassDB::is_parent_class(p_class, SNAME("Node"))) { - return gui_base->get_theme_icon(instantiable ? "Node" : "NodeDisabled", SNAME("EditorIcons")); + return theme->get_icon(instantiable ? "Node" : "NodeDisabled", EditorStringName(EditorIcons)); } else { - return gui_base->get_theme_icon(instantiable ? "Object" : "ObjectDisabled", SNAME("EditorIcons")); + return theme->get_icon(instantiable ? "Object" : "ObjectDisabled", EditorStringName(EditorIcons)); } } } @@ -4463,12 +4525,12 @@ Ref<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) { void EditorNode::_build_icon_type_cache() { List<StringName> tl; - theme_base->get_theme()->get_icon_list(SNAME("EditorIcons"), &tl); + theme->get_icon_list(EditorStringName(EditorIcons), &tl); for (const StringName &E : tl) { if (!ClassDB::class_exists(E)) { continue; } - icon_type_cache[E] = theme_base->get_theme()->get_icon(E, SNAME("EditorIcons")); + icon_type_cache[E] = theme->get_icon(E, EditorStringName(EditorIcons)); } } @@ -4727,7 +4789,7 @@ void EditorNode::_dock_select_draw() { Color used = Color(0.6, 0.6, 0.6, 0.8); Color used_selected = Color(0.8, 0.8, 0.8, 0.8); - Color tab_selected = theme_base->get_theme_color(SNAME("mono_color"), SNAME("Editor")); + Color tab_selected = theme->get_color(SNAME("mono_color"), EditorStringName(Editor)); Color unused = used; unused.a = 0.4; Color unusable = unused; @@ -5665,9 +5727,9 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { } if (EditorDebuggerNode::get_singleton() == bottom_panel_items[p_idx].control) { // This is the debug panel which uses tabs, so the top section should be smaller. - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))); + bottom_panel->add_theme_style_override("panel", theme->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))); } else { - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanel"), SNAME("EditorStyles"))); + bottom_panel->add_theme_style_override("panel", theme->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))); } center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE); center_split->set_collapsed(false); @@ -5676,7 +5738,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { } bottom_panel_raise->show(); } else { - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanel"), SNAME("EditorStyles"))); + bottom_panel->add_theme_style_override("panel", theme->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))); bottom_panel_items[p_idx].button->set_pressed(false); bottom_panel_items[p_idx].control->set_visible(false); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); @@ -5765,7 +5827,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { { // TODO: make proper previews - Ref<ImageTexture> texture = gui_base->get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons")); + Ref<ImageTexture> texture = theme->get_icon(SNAME("FileBigThumb"), EditorStringName(EditorIcons)); Ref<Image> img = texture->get_image(); img = img->duplicate(); img->resize(48, 48); // meh @@ -5815,10 +5877,10 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control * if (p_paths[i].ends_with("/")) { label->set_text(p_paths[i].substr(0, p_paths[i].length() - 1).get_file()); - icon->set_texture(gui_base->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + icon->set_texture(theme->get_icon(SNAME("Folder"), EditorStringName(EditorIcons))); } else { label->set_text(p_paths[i].get_file()); - icon->set_texture(gui_base->get_theme_icon(SNAME("File"), SNAME("EditorIcons"))); + icon->set_texture(theme->get_icon(SNAME("File"), EditorStringName(EditorIcons))); } icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); icon->set_size(Size2(16, 16)); @@ -6834,7 +6896,7 @@ EditorNode::EditorNode() { // Exporters might need the theme. EditorColorMap::create(); theme = create_custom_theme(); - DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), SNAME("Editor"))); + DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), EditorStringName(Editor))); register_exporters(); @@ -6874,32 +6936,22 @@ EditorNode::EditorNode() { textfile_extensions.insert(E); } - theme_base = memnew(Control); - add_child(theme_base); - theme_base->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); - - gui_base = memnew(Panel); - theme_base->add_child(gui_base); - gui_base->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); - - theme_base->set_theme(theme); - gui_base->set_theme(theme); - gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); - resource_preview = memnew(EditorResourcePreview); add_child(resource_preview); progress_dialog = memnew(ProgressDialog); progress_dialog->set_unparent_when_invisible(true); + gui_base = memnew(Panel); + add_child(gui_base); + // Take up all screen. + gui_base->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); gui_base->set_anchor(SIDE_RIGHT, Control::ANCHOR_END); gui_base->set_anchor(SIDE_BOTTOM, Control::ANCHOR_END); gui_base->set_end(Point2(0, 0)); main_vbox = memnew(VBoxContainer); gui_base->add_child(main_vbox); - main_vbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT, Control::PRESET_MODE_MINSIZE, gui_base->get_theme_constant(SNAME("window_border_margin"), SNAME("Editor"))); - main_vbox->add_theme_constant_override("separation", gui_base->get_theme_constant(SNAME("top_bar_separation"), SNAME("Editor"))); title_bar = memnew(EditorTitleBar); main_vbox->add_child(title_bar); @@ -6977,11 +7029,6 @@ EditorNode::EditorNode() { HBoxContainer *dock_hb = memnew(HBoxContainer); dock_tab_move_left = memnew(Button); dock_tab_move_left->set_flat(true); - if (gui_base->is_layout_rtl()) { - dock_tab_move_left->set_icon(theme->get_icon(SNAME("Forward"), SNAME("EditorIcons"))); - } else { - dock_tab_move_left->set_icon(theme->get_icon(SNAME("Back"), SNAME("EditorIcons"))); - } dock_tab_move_left->set_focus_mode(Control::FOCUS_NONE); dock_tab_move_left->connect("pressed", callable_mp(this, &EditorNode::_dock_move_left)); dock_hb->add_child(dock_tab_move_left); @@ -6994,11 +7041,6 @@ EditorNode::EditorNode() { dock_tab_move_right = memnew(Button); dock_tab_move_right->set_flat(true); - if (gui_base->is_layout_rtl()) { - dock_tab_move_right->set_icon(theme->get_icon(SNAME("Back"), SNAME("EditorIcons"))); - } else { - dock_tab_move_right->set_icon(theme->get_icon(SNAME("Forward"), SNAME("EditorIcons"))); - } dock_tab_move_right->set_focus_mode(Control::FOCUS_NONE); dock_tab_move_right->connect("pressed", callable_mp(this, &EditorNode::_dock_move_right)); @@ -7015,7 +7057,7 @@ EditorNode::EditorNode() { if (!SceneTree::get_singleton()->get_root()->is_embedding_subwindows() && !EDITOR_GET("interface/editor/single_window_mode") && EDITOR_GET("interface/multi_window/enable")) { dock_float = memnew(Button); - dock_float->set_icon(theme->get_icon("MakeFloating", "EditorIcons")); + dock_float->set_icon(theme->get_icon("MakeFloating", EditorStringName(EditorIcons))); dock_float->set_text(TTR("Make Floating")); dock_float->set_focus_mode(Control::FOCUS_NONE); dock_float->set_h_size_flags(Control::SIZE_SHRINK_CENTER); @@ -7064,14 +7106,13 @@ EditorNode::EditorNode() { 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")); distraction_free->set_tooltip_text(TTR("Toggle distraction-free mode.")); - distraction_free->set_icon(gui_base->get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons"))); distraction_free->set_toggle_mode(true); scene_tabs->add_extra_button(distraction_free); distraction_free->connect("pressed", callable_mp(this, &EditorNode::_toggle_distraction_free_mode)); scene_root_parent = memnew(PanelContainer); scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE); - scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles"))); + scene_root_parent->add_theme_style_override("panel", theme->get_stylebox(SNAME("Content"), EditorStringName(EditorStyles))); scene_root_parent->set_draw_behind_parent(true); srt->add_child(scene_root_parent); scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -7079,7 +7120,6 @@ EditorNode::EditorNode() { scene_root = memnew(SubViewport); scene_root->set_embedding_subwindows(true); scene_root->set_disable_3d(true); - scene_root->set_disable_input(true); scene_root->set_as_audio_listener_2d(true); @@ -7102,7 +7142,7 @@ EditorNode::EditorNode() { main_menu = memnew(MenuBar); title_bar->add_child(main_menu); - main_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + main_menu->add_theme_style_override("hover", theme->get_stylebox(SNAME("MenuHover"), EditorStringName(EditorStyles))); main_menu->set_flat(true); main_menu->set_start_index(0); // Main menu, add to the start of global menu. main_menu->set_prefer_global_menu(global_menu); @@ -7115,7 +7155,6 @@ EditorNode::EditorNode() { prev_scene = memnew(Button); prev_scene->set_flat(true); - prev_scene->set_icon(gui_base->get_theme_icon(SNAME("PrevScene"), SNAME("EditorIcons"))); prev_scene->set_tooltip_text(TTR("Go to previously opened scene.")); prev_scene->set_disabled(true); prev_scene->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(FILE_OPEN_PREV)); @@ -7276,8 +7315,8 @@ EditorNode::EditorNode() { if (can_expand && global_menu) { project_title = memnew(Label); - project_title->add_theme_font_override("font", gui_base->get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); - project_title->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"))); + project_title->add_theme_font_override("font", theme->get_font(SNAME("bold"), EditorStringName(EditorFonts))); + project_title->add_theme_font_size_override("font_size", theme->get_font_size(SNAME("bold_size"), EditorStringName(EditorFonts))); project_title->set_focus_mode(Control::FOCUS_NONE); project_title->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS); project_title->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER); @@ -7353,22 +7392,22 @@ EditorNode::EditorNode() { ED_SHORTCUT_AND_COMMAND("editor/editor_help", TTR("Search Help"), Key::F1); ED_SHORTCUT_OVERRIDE("editor/editor_help", "macos", KeyModifierMask::ALT | Key::SPACE); - help_menu->add_icon_shortcut(gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons")), ED_GET_SHORTCUT("editor/editor_help"), HELP_SEARCH); + help_menu->add_icon_shortcut(theme->get_icon(SNAME("HelpSearch"), EditorStringName(EditorIcons)), ED_GET_SHORTCUT("editor/editor_help"), HELP_SEARCH); help_menu->add_separator(); - help_menu->add_icon_shortcut(gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/online_docs", TTR("Online Documentation")), HELP_DOCS); - help_menu->add_icon_shortcut(gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/q&a", TTR("Questions & Answers")), HELP_QA); - help_menu->add_icon_shortcut(gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/report_a_bug", TTR("Report a Bug")), HELP_REPORT_A_BUG); - help_menu->add_icon_shortcut(gui_base->get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/copy_system_info", TTR("Copy System Info")), HELP_COPY_SYSTEM_INFO); + help_menu->add_icon_shortcut(theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons)), ED_SHORTCUT_AND_COMMAND("editor/online_docs", TTR("Online Documentation")), HELP_DOCS); + help_menu->add_icon_shortcut(theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons)), ED_SHORTCUT_AND_COMMAND("editor/q&a", TTR("Questions & Answers")), HELP_QA); + help_menu->add_icon_shortcut(theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons)), ED_SHORTCUT_AND_COMMAND("editor/report_a_bug", TTR("Report a Bug")), HELP_REPORT_A_BUG); + help_menu->add_icon_shortcut(theme->get_icon(SNAME("ActionCopy"), EditorStringName(EditorIcons)), ED_SHORTCUT_AND_COMMAND("editor/copy_system_info", TTR("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_icon_shortcut(gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/suggest_a_feature", TTR("Suggest a Feature")), HELP_SUGGEST_A_FEATURE); - help_menu->add_icon_shortcut(gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/send_docs_feedback", TTR("Send Docs Feedback")), HELP_SEND_DOCS_FEEDBACK); - help_menu->add_icon_shortcut(gui_base->get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/community", TTR("Community")), HELP_COMMUNITY); + help_menu->add_icon_shortcut(theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons)), ED_SHORTCUT_AND_COMMAND("editor/suggest_a_feature", TTR("Suggest a Feature")), HELP_SUGGEST_A_FEATURE); + help_menu->add_icon_shortcut(theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons)), ED_SHORTCUT_AND_COMMAND("editor/send_docs_feedback", TTR("Send Docs Feedback")), HELP_SEND_DOCS_FEEDBACK); + help_menu->add_icon_shortcut(theme->get_icon(SNAME("ExternalLink"), EditorStringName(EditorIcons)), ED_SHORTCUT_AND_COMMAND("editor/community", TTR("Community")), HELP_COMMUNITY); 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(gui_base->get_theme_icon(SNAME("Godot"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/about", TTR("About Godot")), HELP_ABOUT); + help_menu->add_icon_shortcut(theme->get_icon(SNAME("Godot"), EditorStringName(EditorIcons)), ED_SHORTCUT_AND_COMMAND("editor/about", TTR("About Godot")), HELP_ABOUT); } - help_menu->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Heart"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/support_development", TTR("Support Godot Development")), HELP_SUPPORT_GODOT_DEVELOPMENT); + help_menu->add_icon_shortcut(theme->get_icon(SNAME("Heart"), EditorStringName(EditorIcons)), ED_SHORTCUT_AND_COMMAND("editor/support_development", TTR("Support Godot Development")), HELP_SUPPORT_GODOT_DEVELOPMENT); // Spacer to center 2D / 3D / Script buttons. Control *right_spacer = memnew(Control); @@ -7390,8 +7429,8 @@ EditorNode::EditorNode() { renderer->set_fit_to_longest_item(false); renderer->set_focus_mode(Control::FOCUS_NONE); renderer->connect("item_selected", callable_mp(this, &EditorNode::_renderer_selected)); - renderer->add_theme_font_override("font", gui_base->get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); - renderer->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"))); + renderer->add_theme_font_override("font", theme->get_font(SNAME("bold"), EditorStringName(EditorFonts))); + renderer->add_theme_font_size_override("font_size", theme->get_font_size(SNAME("bold_size"), EditorStringName(EditorFonts))); renderer->set_tooltip_text(TTR("Choose a renderer.")); right_menu_hb->add_child(renderer); @@ -7452,7 +7491,7 @@ EditorNode::EditorNode() { update_spinner = memnew(MenuButton); right_menu_hb->add_child(update_spinner); - update_spinner->set_icon(gui_base->get_theme_icon(SNAME("Progress1"), SNAME("EditorIcons"))); + update_spinner->set_icon(theme->get_icon(SNAME("Progress1"), EditorStringName(EditorIcons))); update_spinner->get_popup()->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); PopupMenu *p = update_spinner->get_popup(); p->add_radio_check_item(TTR("Update Continuously"), SETTINGS_UPDATE_CONTINUOUSLY); @@ -7535,7 +7574,7 @@ EditorNode::EditorNode() { // Bottom panels. bottom_panel = memnew(PanelContainer); - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanel"), SNAME("EditorStyles"))); + bottom_panel->add_theme_style_override("panel", theme->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))); center_split->add_child(bottom_panel); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); @@ -7580,14 +7619,11 @@ EditorNode::EditorNode() { bottom_panel_hb->add_child(h_spacer); bottom_panel_raise = memnew(Button); - bottom_panel_raise->set_flat(true); - bottom_panel_raise->set_icon(gui_base->get_theme_icon(SNAME("ExpandBottomDock"), SNAME("EditorIcons"))); - - bottom_panel_raise->set_shortcut(ED_SHORTCUT_AND_COMMAND("editor/bottom_panel_expand", TTR("Expand Bottom Panel"), KeyModifierMask::SHIFT | Key::F12)); - bottom_panel_hb->add_child(bottom_panel_raise); bottom_panel_raise->hide(); + bottom_panel_raise->set_flat(true); 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)); log = memnew(EditorLog); diff --git a/editor/editor_node.h b/editor/editor_node.h index 4a529afc50..a83570b2ea 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -295,7 +295,6 @@ private: bool is_main_screen_editing = false; PanelContainer *scene_root_parent = nullptr; - Control *theme_base = nullptr; Control *gui_base = nullptr; VBoxContainer *main_vbox = nullptr; OptionButton *renderer = nullptr; @@ -525,6 +524,7 @@ private: static void _resource_saved(Ref<Resource> p_resource, const String &p_path); static void _resource_loaded(Ref<Resource> p_resource, const String &p_path); + void _update_theme(bool p_skip_creation = false); void _build_icon_type_cache(); void _enable_pending_addons(); @@ -851,6 +851,8 @@ public: void stop_child_process(OS::ProcessID p_pid); Ref<Theme> get_editor_theme() const { return theme; } + void update_preview_themes(int p_mode); + Ref<Script> get_object_custom_type_base(const Object *p_object) const; StringName get_object_custom_type_name(const Object *p_object) const; Ref<Texture2D> get_object_icon(const Object *p_object, const String &p_fallback = "Object"); @@ -867,7 +869,6 @@ public: Error export_preset(const String &p_preset, const String &p_path, bool p_debug, bool p_pack_only); Control *get_gui_base() { return gui_base; } - Control *get_theme_base() { return gui_base->get_parent_control(); } void save_scene_to_path(String p_file, bool p_with_preview = true) { if (p_with_preview) { diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index 453ae76266..167a151419 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -123,7 +123,7 @@ void EditorPluginSettings::update_plugins() { bool is_active = EditorNode::get_singleton()->is_addon_plugin_enabled(path); item->set_checked(3, is_active); item->set_editable(3, true); - item->add_button(4, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin")); + item->add_button(4, get_editor_theme_icon(SNAME("Edit")), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin")); } } } @@ -245,7 +245,7 @@ EditorPluginSettings::EditorPluginSettings() { plugin_list->set_column_custom_minimum_width(3, 80 * EDSCALE); plugin_list->set_column_custom_minimum_width(4, 40 * EDSCALE); plugin_list->set_hide_root(true); - plugin_list->connect("item_edited", callable_mp(this, &EditorPluginSettings::_plugin_activity_changed)); + plugin_list->connect("item_edited", callable_mp(this, &EditorPluginSettings::_plugin_activity_changed), CONNECT_DEFERRED); VBoxContainer *mc = memnew(VBoxContainer); mc->add_child(plugin_list); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 92789275a9..2a82b2cde4 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -39,6 +39,7 @@ #include "editor/editor_resource_picker.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_file_dialog.h" #include "editor/gui/editor_spin_slider.h" #include "editor/gui/scene_tree_editor.h" @@ -162,8 +163,8 @@ void EditorPropertyMultilineText::_open_big_text() { big_text = memnew(TextEdit); if (expression) { big_text->set_syntax_highlighter(text->get_syntax_highlighter()); - big_text->add_theme_font_override("font", get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); - big_text->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); + big_text->add_theme_font_override("font", get_theme_font(SNAME("expression"), EditorStringName(EditorFonts))); + big_text->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("expression_size"), EditorStringName(EditorFonts))); } big_text->connect("text_changed", callable_mp(this, &EditorPropertyMultilineText::_big_text_changed)); big_text->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); @@ -192,14 +193,14 @@ void EditorPropertyMultilineText::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { - Ref<Texture2D> df = get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons")); + Ref<Texture2D> df = get_editor_theme_icon(SNAME("DistractionFree")); open_big_text->set_icon(df); Ref<Font> font; int font_size; if (expression) { - font = get_theme_font(SNAME("expression"), SNAME("EditorFonts")); - font_size = get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts")); + font = get_theme_font(SNAME("expression"), EditorStringName(EditorFonts)); + font_size = get_theme_font_size(SNAME("expression_size"), EditorStringName(EditorFonts)); text->add_theme_font_override("font", font); text->add_theme_font_size_override("font_size", font_size); @@ -347,9 +348,9 @@ void EditorPropertyTextEnum::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - edit_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - accept_button->set_icon(get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons"))); - cancel_button->set_icon(get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"))); + edit_button->set_icon(get_editor_theme_icon(SNAME("Edit"))); + accept_button->set_icon(get_editor_theme_icon(SNAME("ImportCheck"))); + cancel_button->set_icon(get_editor_theme_icon(SNAME("ImportFail"))); } break; } } @@ -435,7 +436,7 @@ void EditorPropertyLocale::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - locale_edit->set_icon(get_theme_icon(SNAME("Translation"), SNAME("EditorIcons"))); + locale_edit->set_icon(get_editor_theme_icon(SNAME("Translation"))); } break; } } @@ -531,7 +532,7 @@ void EditorPropertyPath::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - path_edit->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + path_edit->set_icon(get_editor_theme_icon(SNAME("Folder"))); } break; } } @@ -989,12 +990,12 @@ void EditorPropertyLayersGrid::_notification(int p_what) { const int bsize = (grid_size.height * 80 / 100) / 2; const int h = bsize * 2 + 1; - Color color = get_theme_color(read_only ? SNAME("disabled_highlight_color") : SNAME("highlight_color"), SNAME("Editor")); + Color color = get_theme_color(read_only ? SNAME("disabled_highlight_color") : SNAME("highlight_color"), EditorStringName(Editor)); - Color text_color = get_theme_color(read_only ? SNAME("disabled_font_color") : SNAME("font_color"), SNAME("Editor")); + Color text_color = get_theme_color(read_only ? SNAME("disabled_font_color") : SNAME("font_color"), EditorStringName(Editor)); text_color.a *= 0.5; - Color text_color_on = get_theme_color(read_only ? SNAME("disabled_font_color") : SNAME("font_hover_color"), SNAME("Editor")); + Color text_color_on = get_theme_color(read_only ? SNAME("disabled_font_color") : SNAME("font_hover_color"), EditorStringName(Editor)); text_color_on.a *= 0.7; const int vofs = (grid_size.height - h) / 2; @@ -1080,7 +1081,7 @@ void EditorPropertyLayersGrid::_notification(int p_what) { Ref<Texture2D> arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree")); ERR_FAIL_COND(arrow.is_null()); - Color arrow_color = get_theme_color(SNAME("highlight_color"), SNAME("Editor")); + Color arrow_color = get_theme_color(SNAME("highlight_color"), EditorStringName(Editor)); arrow_color.a = expand_hovered ? 1.0 : 0.6; arrow_pos.x += 2.0; @@ -1117,9 +1118,9 @@ void EditorPropertyLayers::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - button->set_texture_normal(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - button->set_texture_pressed(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - button->set_texture_disabled(get_theme_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons"))); + button->set_texture_normal(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); + button->set_texture_pressed(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); + button->set_texture_disabled(get_editor_theme_icon(SNAME("GuiTabMenu"))); } break; } } @@ -1244,7 +1245,7 @@ void EditorPropertyLayers::_button_pressed() { layers->set_item_disabled(0, true); } layers->add_separator(); - layers->add_icon_item(get_theme_icon("Edit", "EditorIcons"), TTR("Edit Layer Names"), grid->layer_count); + layers->add_icon_item(get_editor_theme_icon("Edit"), TTR("Edit Layer Names"), grid->layer_count); Rect2 gp = button->get_screen_rect(); layers->reset_size(); @@ -1408,7 +1409,7 @@ void EditorPropertySignal::update_property() { edit->set_text("Signal: " + signal.get_name()); edit->set_disabled(false); - edit->set_icon(get_theme_icon(SNAME("Signals"), SNAME("EditorIcons"))); + edit->set_icon(get_editor_theme_icon(SNAME("Signals"))); } void EditorPropertySignal::_bind_methods() { @@ -1430,7 +1431,7 @@ void EditorPropertyCallable::update_property() { edit->set_text("Callable"); edit->set_disabled(true); - edit->set_icon(get_theme_icon(SNAME("Callable"), SNAME("EditorIcons"))); + edit->set_icon(get_editor_theme_icon(SNAME("Callable"))); } void EditorPropertyCallable::_bind_methods() { @@ -1579,7 +1580,7 @@ void EditorPropertyEasing::_draw_easing() { const Color font_color = get_theme_color(is_read_only() ? SNAME("font_uneditable_color") : SNAME("font_color"), SNAME("LineEdit")); Color line_color; if (dragging) { - line_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + line_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); } else { line_color = get_theme_color(is_read_only() ? SNAME("font_uneditable_color") : SNAME("font_color"), SNAME("LineEdit")) * Color(1, 1, 1, 0.9); } @@ -1672,13 +1673,13 @@ void EditorPropertyEasing::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { preset->clear(); - preset->add_icon_item(get_theme_icon(SNAME("CurveLinear"), SNAME("EditorIcons")), "Linear", EASING_LINEAR); - preset->add_icon_item(get_theme_icon(SNAME("CurveIn"), SNAME("EditorIcons")), "Ease In", EASING_IN); - preset->add_icon_item(get_theme_icon(SNAME("CurveOut"), SNAME("EditorIcons")), "Ease Out", EASING_OUT); - preset->add_icon_item(get_theme_icon(SNAME("CurveConstant"), SNAME("EditorIcons")), "Zero", EASING_ZERO); + preset->add_icon_item(get_editor_theme_icon(SNAME("CurveLinear")), "Linear", EASING_LINEAR); + preset->add_icon_item(get_editor_theme_icon(SNAME("CurveIn")), "Ease In", EASING_IN); + preset->add_icon_item(get_editor_theme_icon(SNAME("CurveOut")), "Ease Out", EASING_OUT); + preset->add_icon_item(get_editor_theme_icon(SNAME("CurveConstant")), "Zero", EASING_ZERO); if (!positive_only) { - preset->add_icon_item(get_theme_icon(SNAME("CurveInOut"), SNAME("EditorIcons")), "Ease In-Out", EASING_IN_OUT); - preset->add_icon_item(get_theme_icon(SNAME("CurveOutIn"), SNAME("EditorIcons")), "Ease Out-In", EASING_OUT_IN); + preset->add_icon_item(get_editor_theme_icon(SNAME("CurveInOut")), "Ease In-Out", EASING_IN_OUT); + preset->add_icon_item(get_editor_theme_icon(SNAME("CurveOutIn")), "Ease Out-In", EASING_OUT_IN); } easing_draw->set_custom_minimum_size(Size2(0, get_theme_font(SNAME("font"), SNAME("Label"))->get_height(get_theme_font_size(SNAME("font_size"), SNAME("Label"))) * 2)); } break; @@ -2114,10 +2115,10 @@ void EditorPropertyQuaternion::_notification(int p_what) { for (int i = 0; i < 3; i++) { euler[i]->add_theme_color_override("label_color", colors[i]); } - edit_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - euler_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("property_color"), SNAME("Editor"))); - warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); - warning->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + edit_button->set_icon(get_editor_theme_icon(SNAME("Edit"))); + euler_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("property_color"), EditorStringName(Editor))); + warning->set_icon(get_editor_theme_icon(SNAME("NodeWarning"))); + warning->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); } break; } } @@ -2724,7 +2725,7 @@ void EditorPropertyColor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - picker->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); + picker->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor)))); } break; } } @@ -2921,7 +2922,7 @@ void EditorPropertyNodePath::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")); + Ref<Texture2D> t = get_editor_theme_icon(SNAME("Clear")); clear->set_icon(t); } break; } @@ -3210,9 +3211,9 @@ void EditorPropertyResource::_update_property_bg() { } count_subinspectors = MIN(15, count_subinspectors); - add_theme_color_override("property_color", get_theme_color(SNAME("sub_inspector_property_color"), SNAME("Editor"))); - add_theme_style_override("bg_selected", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), SNAME("Editor"))); - add_theme_style_override("bg", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), SNAME("Editor"))); + add_theme_color_override("property_color", get_theme_color(SNAME("sub_inspector_property_color"), EditorStringName(Editor))); + add_theme_style_override("bg_selected", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), EditorStringName(Editor))); + add_theme_style_override("bg", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), EditorStringName(Editor))); add_theme_constant_override("v_separation", 0); } else { diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 3a84fcb785..61c6c0bcdb 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -36,6 +36,7 @@ #include "editor/editor_properties_vector.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_spin_slider.h" #include "editor/inspector_dock.h" #include "scene/gui/button.h" @@ -312,7 +313,7 @@ void EditorPropertyArray::update_property() { vbox->add_child(property_vbox); button_add_item = EditorInspector::create_inspector_action_button(TTR("Add Element")); - button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); button_add_item->connect(SNAME("pressed"), callable_mp(this, &EditorPropertyArray::_add_element)); button_add_item->set_disabled(is_read_only()); vbox->add_child(button_add_item); @@ -357,7 +358,7 @@ void EditorPropertyArray::update_property() { property_vbox->add_child(hbox); Button *reorder_button = memnew(Button); - reorder_button->set_icon(get_theme_icon(SNAME("TripleBar"), SNAME("EditorIcons"))); + reorder_button->set_icon(get_editor_theme_icon(SNAME("TripleBar"))); reorder_button->set_default_cursor_shape(Control::CURSOR_MOVE); reorder_button->set_disabled(is_read_only()); reorder_button->connect("gui_input", callable_mp(this, &EditorPropertyArray::_reorder_button_gui_input)); @@ -397,13 +398,13 @@ void EditorPropertyArray::update_property() { if (is_untyped_array) { Button *edit_btn = memnew(Button); - edit_btn->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + edit_btn->set_icon(get_editor_theme_icon(SNAME("Edit"))); hbox->add_child(edit_btn); edit_btn->set_disabled(is_read_only()); edit_btn->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type).bind(edit_btn, i + offset)); } else { Button *remove_btn = memnew(Button); - remove_btn->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + remove_btn->set_icon(get_editor_theme_icon(SNAME("Remove"))); remove_btn->set_disabled(is_read_only()); remove_btn->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed).bind(i + offset)); hbox->add_child(remove_btn); @@ -438,7 +439,7 @@ void EditorPropertyArray::_remove_pressed(int p_index) { void EditorPropertyArray::_button_draw() { if (dropping) { - Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); edit->draw_rect(Rect2(Point2(), edit->get_size()), color, false); } } @@ -529,13 +530,13 @@ void EditorPropertyArray::_notification(int p_what) { } String type = Variant::get_type_name(Variant::Type(i)); - change_type->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i); + change_type->add_icon_item(get_editor_theme_icon(type), type, i); } change_type->add_separator(); - change_type->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Remove Item"), Variant::VARIANT_MAX); + change_type->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Remove Item"), Variant::VARIANT_MAX); if (button_add_item) { - button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); } } break; @@ -1117,7 +1118,7 @@ void EditorPropertyDictionary::update_property() { if (i == amount) { PanelContainer *pc = memnew(PanelContainer); property_vbox->add_child(pc); - pc->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("DictionaryAddItem"), SNAME("EditorStyles"))); + pc->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("DictionaryAddItem"), EditorStringName(EditorStyles))); add_vbox = memnew(VBoxContainer); pc->add_child(add_vbox); @@ -1151,7 +1152,7 @@ void EditorPropertyDictionary::update_property() { hbox->add_child(prop); prop->set_h_size_flags(SIZE_EXPAND_FILL); Button *edit_btn = memnew(Button); - edit_btn->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + edit_btn->set_icon(get_editor_theme_icon(SNAME("Edit"))); edit_btn->set_disabled(is_read_only()); hbox->add_child(edit_btn); edit_btn->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type).bind(edit_btn, change_index)); @@ -1160,7 +1161,7 @@ void EditorPropertyDictionary::update_property() { if (i == amount + 1) { button_add_item = EditorInspector::create_inspector_action_button(TTR("Add Key/Value Pair")); - button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); button_add_item->set_disabled(is_read_only()); button_add_item->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_add_key_value)); add_vbox->add_child(button_add_item); @@ -1195,13 +1196,13 @@ void EditorPropertyDictionary::_notification(int p_what) { } String type = Variant::get_type_name(Variant::Type(i)); - change_type->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i); + change_type->add_icon_item(get_editor_theme_icon(type), type, i); } change_type->add_separator(); - change_type->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Remove Item"), Variant::VARIANT_MAX); + change_type->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Remove Item"), Variant::VARIANT_MAX); if (button_add_item) { - button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); } } break; } @@ -1380,7 +1381,7 @@ void EditorPropertyLocalizableString::update_property() { hbox->add_child(prop); prop->set_h_size_flags(SIZE_EXPAND_FILL); Button *edit_btn = memnew(Button); - edit_btn->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + edit_btn->set_icon(get_editor_theme_icon(SNAME("Remove"))); hbox->add_child(edit_btn); edit_btn->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_remove_item).bind(edit_btn, remove_index)); @@ -1389,7 +1390,7 @@ void EditorPropertyLocalizableString::update_property() { if (page_index == max_page) { button_add_item = EditorInspector::create_inspector_action_button(TTR("Add Translation")); - button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); button_add_item->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_add_locale_popup)); property_vbox->add_child(button_add_item); } @@ -1415,7 +1416,7 @@ void EditorPropertyLocalizableString::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { if (button_add_item) { - button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); } } break; } diff --git a/editor/editor_properties_vector.cpp b/editor/editor_properties_vector.cpp index 66ed95b97e..9e9848f142 100644 --- a/editor/editor_properties_vector.cpp +++ b/editor/editor_properties_vector.cpp @@ -136,8 +136,8 @@ void EditorPropertyVectorN::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - linked->set_texture_normal(get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons"))); - linked->set_texture_pressed(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + linked->set_texture_normal(get_editor_theme_icon(SNAME("Unlinked"))); + linked->set_texture_pressed(get_editor_theme_icon(SNAME("Instance"))); const Color *colors = _get_property_colors(); for (int i = 0; i < component_count; i++) { diff --git a/editor/editor_quick_open.cpp b/editor/editor_quick_open.cpp index f75ab875e4..82313c12e2 100644 --- a/editor/editor_quick_open.cpp +++ b/editor/editor_quick_open.cpp @@ -257,7 +257,7 @@ void EditorQuickOpen::_notification(int p_what) { } void EditorQuickOpen::_theme_changed() { - search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + search_box->set_right_icon(search_options->get_editor_theme_icon(SNAME("Search"))); } void EditorQuickOpen::_bind_methods() { diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index ea7e1549f5..e284c1e440 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -36,6 +36,7 @@ #include "editor/editor_resource_preview.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/filesystem_dock.h" #include "editor/gui/editor_file_dialog.h" #include "editor/plugins/editor_resource_conversion_plugin.h" @@ -193,10 +194,10 @@ void EditorResourcePicker::_update_menu_items() { set_create_options(edit_menu); // Add an option to load a resource from a file using the QuickOpen dialog. - edit_menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Quick Load"), OBJ_MENU_QUICKLOAD); + edit_menu->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Quick Load"), OBJ_MENU_QUICKLOAD); // Add an option to load a resource from a file using the regular file dialog. - edit_menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Load"), OBJ_MENU_LOAD); + edit_menu->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Load"), OBJ_MENU_LOAD); } // Add options for changing existing value of the resource. @@ -208,14 +209,14 @@ void EditorResourcePicker::_update_menu_items() { // since will only be able to view its properties in read-only mode. if (is_edited_resource_foreign_import) { // The 'Search' icon is a magnifying glass, which seems appropriate, but maybe a bespoke icon is preferred here. - edit_menu->add_icon_item(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")), TTR("Inspect"), OBJ_MENU_INSPECT); + edit_menu->add_icon_item(get_editor_theme_icon(SNAME("Search")), TTR("Inspect"), OBJ_MENU_INSPECT); } else { - edit_menu->add_icon_item(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), TTR("Edit"), OBJ_MENU_INSPECT); + edit_menu->add_icon_item(get_editor_theme_icon(SNAME("Edit")), TTR("Edit"), OBJ_MENU_INSPECT); } if (is_editable()) { - edit_menu->add_icon_item(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), TTR("Clear"), OBJ_MENU_CLEAR); - edit_menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); + edit_menu->add_icon_item(get_editor_theme_icon(SNAME("Clear")), TTR("Clear"), OBJ_MENU_CLEAR); + edit_menu->add_icon_item(get_editor_theme_icon(SNAME("Duplicate")), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); // Check whether the resource has subresources. List<PropertyInfo> property_list; @@ -228,10 +229,10 @@ void EditorResourcePicker::_update_menu_items() { } } if (has_subresources) { - edit_menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Make Unique (Recursive)"), OBJ_MENU_MAKE_UNIQUE_RECURSIVE); + edit_menu->add_icon_item(get_editor_theme_icon(SNAME("Duplicate")), TTR("Make Unique (Recursive)"), OBJ_MENU_MAKE_UNIQUE_RECURSIVE); } - edit_menu->add_icon_item(get_theme_icon(SNAME("Save"), SNAME("EditorIcons")), TTR("Save"), OBJ_MENU_SAVE); + edit_menu->add_icon_item(get_editor_theme_icon(SNAME("Save")), TTR("Save"), OBJ_MENU_SAVE); } if (edited_resource->get_path().is_resource_file()) { @@ -282,8 +283,8 @@ void EditorResourcePicker::_update_menu_items() { for (int i = 0; i < conversions.size(); i++) { String what = conversions[i]->converts_to(); Ref<Texture2D> icon; - if (has_theme_icon(what, SNAME("EditorIcons"))) { - icon = get_theme_icon(what, SNAME("EditorIcons")); + if (has_theme_icon(what, EditorStringName(EditorIcons))) { + icon = get_editor_theme_icon(what); } else { icon = get_theme_icon(what, SNAME("Resource")); } @@ -516,7 +517,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) { inheritors_array.push_back(t); if (!icon.is_valid()) { - icon = get_theme_icon(has_theme_icon(t, SNAME("EditorIcons")) ? t : String("Object"), SNAME("EditorIcons")); + icon = get_editor_theme_icon(has_theme_icon(t, EditorStringName(EditorIcons)) ? t : String("Object")); } int id = TYPE_BASE_ID + idx; @@ -539,7 +540,7 @@ bool EditorResourcePicker::handle_menu_selected(int p_which) { void EditorResourcePicker::_button_draw() { if (dropping) { - Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); assign_button->draw_rect(Rect2(Point2(), assign_button->get_size()), color, false); } } @@ -806,7 +807,7 @@ void EditorResourcePicker::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - assign_button->add_theme_constant_override("icon_max_width", get_theme_constant(SNAME("class_icon_size"), SNAME("Editor"))); + assign_button->add_theme_constant_override("icon_max_width", get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor))); edit_button->set_icon(get_theme_icon(SNAME("select_arrow"), SNAME("Tree"))); } break; @@ -1072,11 +1073,11 @@ void EditorScriptPicker::set_create_options(Object *p_menu_node) { return; } - menu_node->add_icon_item(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons")), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); + menu_node->add_icon_item(get_editor_theme_icon(SNAME("ScriptCreate")), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); if (script_owner) { Ref<Script> scr = script_owner->get_script(); if (scr.is_valid()) { - menu_node->add_icon_item(get_theme_icon(SNAME("ScriptExtend"), SNAME("EditorIcons")), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT); + menu_node->add_icon_item(get_editor_theme_icon(SNAME("ScriptExtend")), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT); } } menu_node->add_separator(); @@ -1128,7 +1129,7 @@ void EditorShaderPicker::set_create_options(Object *p_menu_node) { return; } - menu_node->add_icon_item(get_theme_icon(SNAME("Shader"), SNAME("EditorIcons")), TTR("New Shader"), OBJ_MENU_NEW_SHADER); + menu_node->add_icon_item(get_editor_theme_icon(SNAME("Shader")), TTR("New Shader"), OBJ_MENU_NEW_SHADER); menu_node->add_separator(); } @@ -1277,12 +1278,12 @@ void EditorAudioStreamPicker::_preview_draw() { points.write[idx * 2 + 1] = Vector2(i + 1, rect.position.y + max * rect.size.y); } - Vector<Color> colors = { get_theme_color(SNAME("contrast_color_2"), SNAME("Editor")) }; + Vector<Color> colors = { get_theme_color(SNAME("contrast_color_2"), EditorStringName(Editor)) }; RS::get_singleton()->canvas_item_add_multiline(stream_preview_rect->get_canvas_item(), points, colors); if (tagged_frame_offset_count) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); for (uint32_t i = 0; i < tagged_frame_offset_count; i++) { int x = CLAMP(tagged_frame_offsets[i] * size.width / preview_len, 0, size.width); @@ -1299,9 +1300,9 @@ void EditorAudioStreamPicker::_preview_draw() { Color icon_modulate(1, 1, 1, 1); if (tagged_frame_offset_count > 0) { - icon = get_theme_icon(SNAME("Play"), SNAME("EditorIcons")); + icon = get_editor_theme_icon(SNAME("Play")); if ((OS::get_singleton()->get_ticks_msec() % 500) > 250) { - icon_modulate = Color(1, 0.5, 0.5, 1); // get_theme_color(SNAME("accent_color"), SNAME("Editor")); + icon_modulate = Color(1, 0.5, 0.5, 1); // get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); } } else { icon = EditorNode::get_singleton()->get_object_icon(audio_stream.operator->(), "Object"); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index c6747c4481..ac098a354d 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -40,6 +40,7 @@ #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/resources/image_texture.h" bool EditorResourcePreviewGenerator::handles(const String &p_type) const { @@ -341,7 +342,8 @@ void EditorResourcePreview::_thread() { void EditorResourcePreview::_update_thumbnail_sizes() { if (small_thumbnail_size == -1) { - small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))->get_width(); // Kind of a workaround to retrieve the default icon size + // Kind of a workaround to retrieve the default icon size. + small_thumbnail_size = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Object"), EditorStringName(EditorIcons))->get_width(); } } diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index cf6a8f1368..6744e79931 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -40,7 +40,7 @@ void EditorRunNative::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - remote_debug->set_icon(get_theme_icon(SNAME("PlayRemote"), SNAME("EditorIcons"))); + remote_debug->set_icon(get_editor_theme_icon(SNAME("PlayRemote"))); } break; case NOTIFICATION_PROCESS: { diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 92aa74dd9d..7bf88ba94f 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -33,6 +33,7 @@ #include "editor/editor_property_name_processor.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" static bool _property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style) { if (p_property_path.findn(p_filter) != -1) { @@ -264,8 +265,8 @@ void SectionedInspector::update_category_list() { for (int i = 0; i < sc; i++) { TreeItem *parent = section_map[metasection]; - //parent->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); - parent->set_custom_font(0, get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); + //parent->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); + parent->set_custom_font(0, get_theme_font(SNAME("bold"), EditorStringName(EditorFonts))); if (i > 0) { metasection += "/" + sectionarr[i]; diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index 548492e488..85b59663c3 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -40,6 +40,7 @@ #include "editor/editor_property_name_processor.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/event_listener_line_edit.h" #include "editor/input_event_configuration_dialog.h" @@ -197,15 +198,15 @@ void EditorSettingsDialog::shortcut_input(const Ref<InputEvent> &p_event) { } void EditorSettingsDialog::_update_icons() { - search_box->set_right_icon(shortcuts->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + search_box->set_right_icon(shortcuts->get_editor_theme_icon(SNAME("Search"))); search_box->set_clear_button_enabled(true); - shortcut_search_box->set_right_icon(shortcuts->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + shortcut_search_box->set_right_icon(shortcuts->get_editor_theme_icon(SNAME("Search"))); shortcut_search_box->set_clear_button_enabled(true); - restart_close_button->set_icon(shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + restart_close_button->set_icon(shortcuts->get_editor_theme_icon(SNAME("Close"))); restart_container->add_theme_style_override("panel", shortcuts->get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - restart_icon->set_texture(shortcuts->get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); - restart_label->add_theme_color_override("font_color", shortcuts->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + restart_icon->set_texture(shortcuts->get_editor_theme_icon(SNAME("StatusWarning"))); + restart_label->add_theme_color_override("font_color", shortcuts->get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); } void EditorSettingsDialog::_event_config_confirmed() { @@ -303,11 +304,11 @@ void EditorSettingsDialog::_create_shortcut_treeitem(TreeItem *p_parent, const S } if (p_allow_revert) { - shortcut_item->add_button(1, shortcuts->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), SHORTCUT_REVERT); + shortcut_item->add_button(1, shortcuts->get_editor_theme_icon(SNAME("Reload")), SHORTCUT_REVERT); } - shortcut_item->add_button(1, shortcuts->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), SHORTCUT_ADD); - shortcut_item->add_button(1, shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons")), SHORTCUT_ERASE); + shortcut_item->add_button(1, shortcuts->get_editor_theme_icon(SNAME("Add")), SHORTCUT_ADD); + shortcut_item->add_button(1, shortcuts->get_editor_theme_icon(SNAME("Close")), SHORTCUT_ERASE); shortcut_item->set_meta("is_action", p_is_action); shortcut_item->set_meta("type", "shortcut"); @@ -326,11 +327,11 @@ void EditorSettingsDialog::_create_shortcut_treeitem(TreeItem *p_parent, const S event_item->set_text(0, shortcut_item->get_child_count() == 1 ? "Primary" : ""); event_item->set_text(1, ie->as_text()); - event_item->add_button(1, shortcuts->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), SHORTCUT_EDIT); - event_item->add_button(1, shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons")), SHORTCUT_ERASE); + event_item->add_button(1, shortcuts->get_editor_theme_icon(SNAME("Edit")), SHORTCUT_EDIT); + event_item->add_button(1, shortcuts->get_editor_theme_icon(SNAME("Close")), SHORTCUT_ERASE); - event_item->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("dark_color_3"), SNAME("Editor"))); - event_item->set_custom_bg_color(1, shortcuts->get_theme_color(SNAME("dark_color_3"), SNAME("Editor"))); + event_item->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("dark_color_3"), EditorStringName(Editor))); + event_item->set_custom_bg_color(1, shortcuts->get_theme_color(SNAME("dark_color_3"), EditorStringName(Editor))); event_item->set_meta("is_action", p_is_action); event_item->set_meta("type", "event"); @@ -399,8 +400,8 @@ void EditorSettingsDialog::_update_shortcuts() { if (collapsed.has("Common")) { common_section->set_collapsed(collapsed["Common"]); } - common_section->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); - common_section->set_custom_bg_color(1, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + common_section->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); + common_section->set_custom_bg_color(1, shortcuts->get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); // Get the action map for the editor, and add each item to the "Common" section. for (const KeyValue<StringName, InputMap::Action> &E : InputMap::get_singleton()->get_action_map()) { @@ -452,8 +453,8 @@ void EditorSettingsDialog::_update_shortcuts() { section->set_tooltip_text(0, tooltip); section->set_selectable(0, false); section->set_selectable(1, false); - section->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); - section->set_custom_bg_color(1, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + section->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); + section->set_custom_bg_color(1, shortcuts->get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); if (collapsed.has(item_name)) { section->set_collapsed(collapsed[item_name]); diff --git a/editor/editor_string_names.cpp b/editor/editor_string_names.cpp new file mode 100644 index 0000000000..bd31d32b2d --- /dev/null +++ b/editor/editor_string_names.cpp @@ -0,0 +1,40 @@ +/**************************************************************************/ +/* editor_string_names.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "editor_string_names.h" + +EditorStringNames *EditorStringNames::singleton = nullptr; + +EditorStringNames::EditorStringNames() { + Editor = StaticCString::create("Editor"); + EditorFonts = StaticCString::create("EditorFonts"); + EditorIcons = StaticCString::create("EditorIcons"); + EditorStyles = StaticCString::create("EditorStyles"); +} diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginInfoProvider.java b/editor/editor_string_names.h index 63999a8321..55d8a9c1ec 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginInfoProvider.java +++ b/editor/editor_string_names.h @@ -1,5 +1,5 @@ /**************************************************************************/ -/* GodotPluginInfoProvider.java */ +/* editor_string_names.h */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,45 +28,31 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -package org.godotengine.godot.plugin; +#ifndef EDITOR_STRING_NAMES_H +#define EDITOR_STRING_NAMES_H -import androidx.annotation.NonNull; +#include "core/string/string_name.h" -import java.util.Collections; -import java.util.Set; +class EditorStringNames { + static EditorStringNames *singleton; -/** - * Provides the set of information expected from a Godot plugin. - */ -public interface GodotPluginInfoProvider { - /** - * Returns the name of the plugin. - */ - @NonNull - String getPluginName(); + EditorStringNames(); - /** - * Returns the list of signals to be exposed to Godot. - */ - @NonNull - default Set<SignalInfo> getPluginSignals() { - return Collections.emptySet(); +public: + static void create() { singleton = memnew(EditorStringNames); } + static void free() { + memdelete(singleton); + singleton = nullptr; } - /** - * Returns the paths for the plugin's gdextension libraries (if any). - * - * The paths must be relative to the 'assets' directory and point to a '*.gdextension' file. - */ - @NonNull - default Set<String> getPluginGDExtensionLibrariesPaths() { - return Collections.emptySet(); - } + _FORCE_INLINE_ static EditorStringNames *get_singleton() { return singleton; } - /** - * This is invoked on the render thread when the plugin described by this instance has been - * registered. - */ - default void onPluginRegistered() { - } -} + StringName Editor; + StringName EditorFonts; + StringName EditorIcons; + StringName EditorStyles; +}; + +#define EditorStringName(m_name) EditorStringNames::get_singleton()->m_name + +#endif // EDITOR_STRING_NAMES_H diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 9712297ec8..f605c44dd0 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -36,6 +36,7 @@ #include "editor/editor_icons.gen.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/resources/image_texture.h" #include "scene/resources/style_box_flat.h" #include "scene/resources/style_box_line.h" @@ -313,9 +314,9 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme, f } } // These colors should be converted even if we are using a dark theme. - const Color error_color = p_theme->get_color(SNAME("error_color"), SNAME("Editor")); - const Color success_color = p_theme->get_color(SNAME("success_color"), SNAME("Editor")); - const Color warning_color = p_theme->get_color(SNAME("warning_color"), SNAME("Editor")); + const Color error_color = p_theme->get_color(SNAME("error_color"), EditorStringName(Editor)); + const Color success_color = p_theme->get_color(SNAME("success_color"), EditorStringName(Editor)); + const Color warning_color = p_theme->get_color(SNAME("warning_color"), EditorStringName(Editor)); color_conversion_map[Color::html("#ff5f5f")] = error_color; color_conversion_map[Color::html("#5fff97")] = success_color; color_conversion_map[Color::html("#ffdd65")] = warning_color; @@ -335,7 +336,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme, f HashMap<Color, Color> accent_color_map; HashSet<StringName> accent_color_icons; - const Color accent_color = p_theme->get_color(SNAME("accent_color"), SNAME("Editor")); + const Color accent_color = p_theme->get_color(SNAME("accent_color"), EditorStringName(Editor)); accent_color_map[Color::html("699ce8")] = accent_color; if (accent_color.get_luminance() > 0.75) { accent_color_map[Color::html("ffffff")] = Color(0.2, 0.2, 0.2); @@ -369,7 +370,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme, f } } - p_theme->set_icon(editor_icon_name, SNAME("EditorIcons"), icon); + p_theme->set_icon(editor_icon_name, EditorStringName(EditorIcons), icon); } } @@ -396,7 +397,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme, f } } - p_theme->set_icon(editor_icons_names[index], SNAME("EditorIcons"), icon); + p_theme->set_icon(editor_icons_names[index], EditorStringName(EditorIcons), icon); } } else { const float scale = (float)p_thumb_size / 32.0 * EDSCALE; @@ -419,7 +420,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme, f } } - p_theme->set_icon(editor_icons_names[index], SNAME("EditorIcons"), icon); + p_theme->set_icon(editor_icons_names[index], EditorStringName(EditorIcons), icon); } } OS::get_singleton()->benchmark_end_measure("editor_register_and_generate_icons_" + String((p_only_thumbs ? "with_only_thumbs" : "all"))); @@ -572,38 +573,38 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color disabled_highlight_color = highlight_color.lerp(dark_theme ? Color(0, 0, 0) : Color(1, 1, 1), 0.5); // Can't save single float in theme, so using Color. - theme->set_color("icon_saturation", "Editor", Color(icon_saturation, icon_saturation, icon_saturation)); - theme->set_color("accent_color", "Editor", accent_color); - theme->set_color("highlight_color", "Editor", highlight_color); - theme->set_color("disabled_highlight_color", "Editor", disabled_highlight_color); - theme->set_color("base_color", "Editor", base_color); - theme->set_color("dark_color_1", "Editor", dark_color_1); - theme->set_color("dark_color_2", "Editor", dark_color_2); - theme->set_color("dark_color_3", "Editor", dark_color_3); - theme->set_color("contrast_color_1", "Editor", contrast_color_1); - theme->set_color("contrast_color_2", "Editor", contrast_color_2); - theme->set_color("box_selection_fill_color", "Editor", accent_color * Color(1, 1, 1, 0.3)); - theme->set_color("box_selection_stroke_color", "Editor", accent_color * Color(1, 1, 1, 0.8)); - - theme->set_color("axis_x_color", "Editor", Color(0.96, 0.20, 0.32)); - theme->set_color("axis_y_color", "Editor", Color(0.53, 0.84, 0.01)); - theme->set_color("axis_z_color", "Editor", Color(0.16, 0.55, 0.96)); - theme->set_color("axis_w_color", "Editor", Color(0.55, 0.55, 0.55)); + theme->set_color("icon_saturation", EditorStringName(Editor), Color(icon_saturation, icon_saturation, icon_saturation)); + theme->set_color("accent_color", EditorStringName(Editor), accent_color); + theme->set_color("highlight_color", EditorStringName(Editor), highlight_color); + theme->set_color("disabled_highlight_color", EditorStringName(Editor), disabled_highlight_color); + theme->set_color("base_color", EditorStringName(Editor), base_color); + theme->set_color("dark_color_1", EditorStringName(Editor), dark_color_1); + theme->set_color("dark_color_2", EditorStringName(Editor), dark_color_2); + theme->set_color("dark_color_3", EditorStringName(Editor), dark_color_3); + theme->set_color("contrast_color_1", EditorStringName(Editor), contrast_color_1); + theme->set_color("contrast_color_2", EditorStringName(Editor), contrast_color_2); + theme->set_color("box_selection_fill_color", EditorStringName(Editor), accent_color * Color(1, 1, 1, 0.3)); + theme->set_color("box_selection_stroke_color", EditorStringName(Editor), accent_color * Color(1, 1, 1, 0.8)); + + theme->set_color("axis_x_color", EditorStringName(Editor), Color(0.96, 0.20, 0.32)); + theme->set_color("axis_y_color", EditorStringName(Editor), Color(0.53, 0.84, 0.01)); + theme->set_color("axis_z_color", EditorStringName(Editor), Color(0.16, 0.55, 0.96)); + theme->set_color("axis_w_color", EditorStringName(Editor), Color(0.55, 0.55, 0.55)); const float prop_color_saturation = accent_color.get_s() * 0.75; const float prop_color_value = accent_color.get_v(); - theme->set_color("property_color_x", "Editor", Color().from_hsv(0.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); - theme->set_color("property_color_y", "Editor", Color().from_hsv(1.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); - theme->set_color("property_color_z", "Editor", Color().from_hsv(2.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); - theme->set_color("property_color_w", "Editor", Color().from_hsv(1.5 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("property_color_x", EditorStringName(Editor), Color().from_hsv(0.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("property_color_y", EditorStringName(Editor), Color().from_hsv(1.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("property_color_z", EditorStringName(Editor), Color().from_hsv(2.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("property_color_w", EditorStringName(Editor), Color().from_hsv(1.5 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); - theme->set_color("font_color", "Editor", font_color); - theme->set_color("highlighted_font_color", "Editor", font_hover_color); - theme->set_color("disabled_font_color", "Editor", font_disabled_color); - theme->set_color("readonly_font_color", "Editor", font_readonly_color); + theme->set_color("font_color", EditorStringName(Editor), font_color); + theme->set_color("highlighted_font_color", EditorStringName(Editor), font_hover_color); + theme->set_color("disabled_font_color", EditorStringName(Editor), font_disabled_color); + theme->set_color("readonly_font_color", EditorStringName(Editor), font_readonly_color); - theme->set_color("mono_color", "Editor", mono_color); + theme->set_color("mono_color", EditorStringName(Editor), mono_color); Color success_color = Color(0.45, 0.95, 0.5); Color warning_color = Color(1, 0.87, 0.4); @@ -619,27 +620,27 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { error_color = error_color.lerp(mono_color, 0.25); } - theme->set_color("success_color", "Editor", success_color); - theme->set_color("warning_color", "Editor", warning_color); - theme->set_color("error_color", "Editor", error_color); - theme->set_color("property_color", "Editor", property_color); - theme->set_color("readonly_color", "Editor", readonly_color); + theme->set_color("success_color", EditorStringName(Editor), success_color); + theme->set_color("warning_color", EditorStringName(Editor), warning_color); + theme->set_color("error_color", EditorStringName(Editor), error_color); + theme->set_color("property_color", EditorStringName(Editor), property_color); + theme->set_color("readonly_color", EditorStringName(Editor), readonly_color); if (!dark_theme) { - theme->set_color("highend_color", "Editor", Color::hex(0xad1128ff)); + theme->set_color("highend_color", EditorStringName(Editor), Color::hex(0xad1128ff)); } else { - theme->set_color("highend_color", "Editor", Color(1.0, 0.0, 0.0)); + theme->set_color("highend_color", EditorStringName(Editor), Color(1.0, 0.0, 0.0)); } const int thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size"); - theme->set_constant("scale", "Editor", EDSCALE); - theme->set_constant("thumb_size", "Editor", thumb_size); - theme->set_constant("class_icon_size", "Editor", 16 * EDSCALE); - theme->set_constant("dark_theme", "Editor", dark_theme); - theme->set_constant("color_picker_button_height", "Editor", 28 * EDSCALE); - theme->set_constant("gizmo_handle_scale", "Editor", gizmo_handle_scale); - theme->set_constant("window_border_margin", "Editor", 8); - theme->set_constant("top_bar_separation", "Editor", 8 * EDSCALE); + theme->set_constant("scale", EditorStringName(Editor), EDSCALE); + theme->set_constant("thumb_size", EditorStringName(Editor), thumb_size); + theme->set_constant("class_icon_size", EditorStringName(Editor), 16 * EDSCALE); + theme->set_constant("dark_theme", EditorStringName(Editor), dark_theme); + theme->set_constant("color_picker_button_height", EditorStringName(Editor), 28 * EDSCALE); + theme->set_constant("gizmo_handle_scale", EditorStringName(Editor), gizmo_handle_scale); + theme->set_constant("window_border_margin", EditorStringName(Editor), 8); + theme->set_constant("top_bar_separation", EditorStringName(Editor), 8 * EDSCALE); // Register editor icons. // If the settings are comparable to the old theme, then just copy them over. @@ -651,11 +652,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // That doesn't really work as expected, since theme constants are integers, and scales are floats. // So this check will never work when changing between 100-199% values. - const float prev_scale = (float)p_theme->get_constant(SNAME("scale"), SNAME("Editor")); - const bool prev_dark_theme = (bool)p_theme->get_constant(SNAME("dark_theme"), SNAME("Editor")); - const Color prev_accent_color = p_theme->get_color(SNAME("accent_color"), SNAME("Editor")); - const float prev_icon_saturation = p_theme->get_color(SNAME("icon_saturation"), SNAME("Editor")).r; - const float prev_gizmo_handle_scale = (float)p_theme->get_constant(SNAME("gizmo_handle_scale"), SNAME("Editor")); + const float prev_scale = (float)p_theme->get_constant(SNAME("scale"), EditorStringName(Editor)); + const bool prev_dark_theme = (bool)p_theme->get_constant(SNAME("dark_theme"), EditorStringName(Editor)); + const Color prev_accent_color = p_theme->get_color(SNAME("accent_color"), EditorStringName(Editor)); + const float prev_icon_saturation = p_theme->get_color(SNAME("icon_saturation"), EditorStringName(Editor)).r; + const float prev_gizmo_handle_scale = (float)p_theme->get_constant(SNAME("gizmo_handle_scale"), EditorStringName(Editor)); keep_old_icons = (Math::is_equal_approx(prev_scale, EDSCALE) && Math::is_equal_approx(prev_gizmo_handle_scale, gizmo_handle_scale) && @@ -663,7 +664,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { prev_accent_color == accent_color && prev_icon_saturation == icon_saturation); - const double prev_thumb_size = (double)p_theme->get_constant(SNAME("thumb_size"), SNAME("Editor")); + const double prev_thumb_size = (double)p_theme->get_constant(SNAME("thumb_size"), EditorStringName(Editor)); regenerate_thumb_icons = !Math::is_equal_approx(prev_thumb_size, thumb_size); } @@ -674,7 +675,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { if (keep_old_icons) { for (int i = 0; i < editor_icons_count; i++) { - theme->set_icon(editor_icons_names[i], SNAME("EditorIcons"), p_theme->get_icon(editor_icons_names[i], SNAME("EditorIcons"))); + theme->set_icon(editor_icons_names[i], EditorStringName(EditorIcons), p_theme->get_icon(editor_icons_names[i], EditorStringName(EditorIcons))); } } else { editor_register_and_generate_icons(theme, dark_theme, icon_saturation, thumb_size, false); @@ -815,27 +816,27 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Editor background Color background_color_opaque = background_color; background_color_opaque.a = 1.0; - theme->set_color("background", "Editor", background_color_opaque); - theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(background_color_opaque, default_margin_size, default_margin_size, default_margin_size, default_margin_size)); + theme->set_color("background", EditorStringName(Editor), background_color_opaque); + theme->set_stylebox("Background", EditorStringName(EditorStyles), make_flat_stylebox(background_color_opaque, default_margin_size, default_margin_size, default_margin_size, default_margin_size)); // Focus - theme->set_stylebox("Focus", "EditorStyles", style_widget_focus); + theme->set_stylebox("Focus", EditorStringName(EditorStyles), style_widget_focus); // Use a less opaque color to be less distracting for the 2D and 3D editor viewports. Ref<StyleBoxFlat> style_widget_focus_viewport = style_widget_focus->duplicate(); style_widget_focus_viewport->set_border_color(accent_color * Color(1, 1, 1, 0.5)); - theme->set_stylebox("FocusViewport", "EditorStyles", style_widget_focus_viewport); + theme->set_stylebox("FocusViewport", EditorStringName(EditorStyles), style_widget_focus_viewport); // Menu Ref<StyleBoxFlat> style_menu = style_widget->duplicate(); style_menu->set_draw_center(false); style_menu->set_border_width_all(0); theme->set_stylebox("panel", "PanelContainer", style_menu); - theme->set_stylebox("MenuPanel", "EditorStyles", style_menu); + theme->set_stylebox("MenuPanel", EditorStringName(EditorStyles), style_menu); // CanvasItem Editor Ref<StyleBoxFlat> style_canvas_editor_info = make_flat_stylebox(Color(0.0, 0.0, 0.0, 0.2)); style_canvas_editor_info->set_expand_margin_all(4 * EDSCALE); - theme->set_stylebox("CanvasItemInfoOverlay", "EditorStyles", style_canvas_editor_info); + theme->set_stylebox("CanvasItemInfoOverlay", EditorStringName(EditorStyles), style_canvas_editor_info); // 2D and 3D contextual toolbar. // Use a custom stylebox to make contextual menu items stand out from the rest. @@ -850,25 +851,25 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { toolbar_stylebox->set_border_color(accent_color); toolbar_stylebox->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE)); toolbar_stylebox->set_content_margin(SIDE_BOTTOM, 0); - theme->set_stylebox("ContextualToolbar", "EditorStyles", toolbar_stylebox); + theme->set_stylebox("ContextualToolbar", EditorStringName(EditorStyles), toolbar_stylebox); // Script Editor - theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size)); - theme->set_stylebox("ScriptEditorPanelFloating", "EditorStyles", make_empty_stylebox(0, 0, 0, 0)); + theme->set_stylebox("ScriptEditorPanel", EditorStringName(EditorStyles), make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size)); + theme->set_stylebox("ScriptEditorPanelFloating", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0)); - theme->set_stylebox("ScriptEditor", "EditorStyles", make_empty_stylebox(0, 0, 0, 0)); + theme->set_stylebox("ScriptEditor", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0)); // Launch Pad and Play buttons Ref<StyleBoxFlat> style_launch_pad = make_flat_stylebox(dark_color_1, 2 * EDSCALE, 0, 2 * EDSCALE, 0, corner_width); style_launch_pad->set_corner_radius_all(corner_radius * EDSCALE); - theme->set_stylebox("LaunchPadNormal", "EditorStyles", style_launch_pad); + theme->set_stylebox("LaunchPadNormal", EditorStringName(EditorStyles), style_launch_pad); Ref<StyleBoxFlat> style_launch_pad_movie = style_launch_pad->duplicate(); style_launch_pad_movie->set_bg_color(accent_color * Color(1, 1, 1, 0.1)); style_launch_pad_movie->set_border_color(accent_color); style_launch_pad_movie->set_border_width_all(Math::round(2 * EDSCALE)); - theme->set_stylebox("LaunchPadMovieMode", "EditorStyles", style_launch_pad_movie); + theme->set_stylebox("LaunchPadMovieMode", EditorStringName(EditorStyles), style_launch_pad_movie); - theme->set_stylebox("MovieWriterButtonNormal", "EditorStyles", make_empty_stylebox(0, 0, 0, 0)); + theme->set_stylebox("MovieWriterButtonNormal", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0)); Ref<StyleBoxFlat> style_write_movie_button = style_widget_pressed->duplicate(); style_write_movie_button->set_bg_color(accent_color); style_write_movie_button->set_corner_radius_all(corner_radius * EDSCALE); @@ -877,7 +878,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_write_movie_button->set_content_margin(SIDE_LEFT, 0); style_write_movie_button->set_content_margin(SIDE_RIGHT, 0); style_write_movie_button->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE); - theme->set_stylebox("MovieWriterButtonPressed", "EditorStyles", style_write_movie_button); + theme->set_stylebox("MovieWriterButtonPressed", EditorStringName(EditorStyles), style_write_movie_button); // MenuButton theme->set_stylebox("normal", "MenuButton", style_menu); @@ -894,7 +895,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("outline_size", "MenuButton", 0); - theme->set_stylebox("MenuHover", "EditorStyles", style_widget_hover); + theme->set_stylebox("MenuHover", EditorStringName(EditorStyles), style_widget_hover); // Buttons theme->set_stylebox("normal", "Button", style_widget); @@ -1061,7 +1062,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("icon_pressed_color", "OptionButton", icon_pressed_color); theme->set_color("icon_disabled_color", "OptionButton", icon_disabled_color); - theme->set_icon("arrow", "OptionButton", theme->get_icon(SNAME("GuiOptionArrow"), SNAME("EditorIcons"))); + theme->set_icon("arrow", "OptionButton", theme->get_icon(SNAME("GuiOptionArrow"), EditorStringName(EditorIcons))); theme->set_constant("arrow_margin", "OptionButton", widget_default_margin.x - 2 * EDSCALE); theme->set_constant("modulate_arrow", "OptionButton", true); theme->set_constant("h_separation", "OptionButton", 4 * EDSCALE); @@ -1074,15 +1075,15 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("hover", "CheckButton", style_menu); theme->set_stylebox("hover_pressed", "CheckButton", style_menu); - theme->set_icon("checked", "CheckButton", theme->get_icon(SNAME("GuiToggleOn"), SNAME("EditorIcons"))); - theme->set_icon("checked_disabled", "CheckButton", theme->get_icon(SNAME("GuiToggleOnDisabled"), SNAME("EditorIcons"))); - theme->set_icon("unchecked", "CheckButton", theme->get_icon(SNAME("GuiToggleOff"), SNAME("EditorIcons"))); - theme->set_icon("unchecked_disabled", "CheckButton", theme->get_icon(SNAME("GuiToggleOffDisabled"), SNAME("EditorIcons"))); + theme->set_icon("checked", "CheckButton", theme->get_icon(SNAME("GuiToggleOn"), EditorStringName(EditorIcons))); + theme->set_icon("checked_disabled", "CheckButton", theme->get_icon(SNAME("GuiToggleOnDisabled"), EditorStringName(EditorIcons))); + theme->set_icon("unchecked", "CheckButton", theme->get_icon(SNAME("GuiToggleOff"), EditorStringName(EditorIcons))); + theme->set_icon("unchecked_disabled", "CheckButton", theme->get_icon(SNAME("GuiToggleOffDisabled"), EditorStringName(EditorIcons))); - theme->set_icon("checked_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOnMirrored"), SNAME("EditorIcons"))); - theme->set_icon("checked_disabled_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOnDisabledMirrored"), SNAME("EditorIcons"))); - theme->set_icon("unchecked_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOffMirrored"), SNAME("EditorIcons"))); - theme->set_icon("unchecked_disabled_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOffDisabledMirrored"), SNAME("EditorIcons"))); + theme->set_icon("checked_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOnMirrored"), EditorStringName(EditorIcons))); + theme->set_icon("checked_disabled_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOnDisabledMirrored"), EditorStringName(EditorIcons))); + theme->set_icon("unchecked_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOffMirrored"), EditorStringName(EditorIcons))); + theme->set_icon("unchecked_disabled_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOffDisabledMirrored"), EditorStringName(EditorIcons))); theme->set_color("font_color", "CheckButton", font_color); theme->set_color("font_hover_color", "CheckButton", font_hover_color); @@ -1111,14 +1112,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("disabled", "CheckBox", sb_checkbox); theme->set_stylebox("hover", "CheckBox", sb_checkbox); theme->set_stylebox("hover_pressed", "CheckBox", sb_checkbox); - theme->set_icon("checked", "CheckBox", theme->get_icon(SNAME("GuiChecked"), SNAME("EditorIcons"))); - theme->set_icon("unchecked", "CheckBox", theme->get_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons"))); - theme->set_icon("radio_checked", "CheckBox", theme->get_icon(SNAME("GuiRadioChecked"), SNAME("EditorIcons"))); - theme->set_icon("radio_unchecked", "CheckBox", theme->get_icon(SNAME("GuiRadioUnchecked"), SNAME("EditorIcons"))); - theme->set_icon("checked_disabled", "CheckBox", theme->get_icon(SNAME("GuiCheckedDisabled"), SNAME("EditorIcons"))); - theme->set_icon("unchecked_disabled", "CheckBox", theme->get_icon(SNAME("GuiUncheckedDisabled"), SNAME("EditorIcons"))); - theme->set_icon("radio_checked_disabled", "CheckBox", theme->get_icon(SNAME("GuiRadioCheckedDisabled"), SNAME("EditorIcons"))); - theme->set_icon("radio_unchecked_disabled", "CheckBox", theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), SNAME("EditorIcons"))); + theme->set_icon("checked", "CheckBox", theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons))); + theme->set_icon("unchecked", "CheckBox", theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons))); + theme->set_icon("radio_checked", "CheckBox", theme->get_icon(SNAME("GuiRadioChecked"), EditorStringName(EditorIcons))); + theme->set_icon("radio_unchecked", "CheckBox", theme->get_icon(SNAME("GuiRadioUnchecked"), EditorStringName(EditorIcons))); + theme->set_icon("checked_disabled", "CheckBox", theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons))); + theme->set_icon("unchecked_disabled", "CheckBox", theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons))); + theme->set_icon("radio_checked_disabled", "CheckBox", theme->get_icon(SNAME("GuiRadioCheckedDisabled"), EditorStringName(EditorIcons))); + theme->set_icon("radio_unchecked_disabled", "CheckBox", theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), EditorStringName(EditorIcons))); theme->set_color("font_color", "CheckBox", font_color); theme->set_color("font_hover_color", "CheckBox", font_hover_color); @@ -1171,19 +1172,19 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_disabled_color", "PopupMenu", font_disabled_color); theme->set_color("font_separator_color", "PopupMenu", font_disabled_color); theme->set_color("font_outline_color", "PopupMenu", font_outline_color); - theme->set_icon("checked", "PopupMenu", theme->get_icon(SNAME("GuiChecked"), SNAME("EditorIcons"))); - theme->set_icon("unchecked", "PopupMenu", theme->get_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons"))); - theme->set_icon("radio_checked", "PopupMenu", theme->get_icon(SNAME("GuiRadioChecked"), SNAME("EditorIcons"))); - theme->set_icon("radio_unchecked", "PopupMenu", theme->get_icon(SNAME("GuiRadioUnchecked"), SNAME("EditorIcons"))); - theme->set_icon("checked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiCheckedDisabled"), SNAME("EditorIcons"))); - theme->set_icon("unchecked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiUncheckedDisabled"), SNAME("EditorIcons"))); - theme->set_icon("radio_checked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiRadioCheckedDisabled"), SNAME("EditorIcons"))); - theme->set_icon("radio_unchecked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), SNAME("EditorIcons"))); - theme->set_icon("submenu", "PopupMenu", theme->get_icon(SNAME("ArrowRight"), SNAME("EditorIcons"))); - theme->set_icon("submenu_mirrored", "PopupMenu", theme->get_icon(SNAME("ArrowLeft"), SNAME("EditorIcons"))); - theme->set_icon("visibility_hidden", "PopupMenu", theme->get_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"))); - theme->set_icon("visibility_visible", "PopupMenu", theme->get_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); - theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon(SNAME("GuiVisibilityXray"), SNAME("EditorIcons"))); + theme->set_icon("checked", "PopupMenu", theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons))); + theme->set_icon("unchecked", "PopupMenu", theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons))); + theme->set_icon("radio_checked", "PopupMenu", theme->get_icon(SNAME("GuiRadioChecked"), EditorStringName(EditorIcons))); + theme->set_icon("radio_unchecked", "PopupMenu", theme->get_icon(SNAME("GuiRadioUnchecked"), EditorStringName(EditorIcons))); + theme->set_icon("checked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons))); + theme->set_icon("unchecked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons))); + theme->set_icon("radio_checked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiRadioCheckedDisabled"), EditorStringName(EditorIcons))); + theme->set_icon("radio_unchecked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), EditorStringName(EditorIcons))); + theme->set_icon("submenu", "PopupMenu", theme->get_icon(SNAME("ArrowRight"), EditorStringName(EditorIcons))); + theme->set_icon("submenu_mirrored", "PopupMenu", theme->get_icon(SNAME("ArrowLeft"), EditorStringName(EditorIcons))); + theme->set_icon("visibility_hidden", "PopupMenu", theme->get_icon(SNAME("GuiVisibilityHidden"), EditorStringName(EditorIcons))); + theme->set_icon("visibility_visible", "PopupMenu", theme->get_icon(SNAME("GuiVisibilityVisible"), EditorStringName(EditorIcons))); + theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon(SNAME("GuiVisibilityXray"), EditorStringName(EditorIcons))); // Force the v_separation to be even so that the spacing on top and bottom is even. // If the vsep is odd and cannot be split into 2 even groups (of pixels), then it will be lopsided. @@ -1212,7 +1213,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { sub_inspector_bg->set_corner_radius(CORNER_TOP_LEFT, 0); sub_inspector_bg->set_corner_radius(CORNER_TOP_RIGHT, 0); - theme->set_stylebox("sub_inspector_bg" + itos(i), "Editor", sub_inspector_bg); + theme->set_stylebox("sub_inspector_bg" + itos(i), EditorStringName(Editor), sub_inspector_bg); // EditorProperty background while it has a sub-inspector open. Ref<StyleBoxFlat> bg_color = make_flat_stylebox(si_base_color * Color(0.7, 0.7, 0.7, 0.8), 0, 0, 0, 0, corner_radius); @@ -1220,10 +1221,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { bg_color->set_corner_radius(CORNER_BOTTOM_LEFT, 0); bg_color->set_corner_radius(CORNER_BOTTOM_RIGHT, 0); - theme->set_stylebox("sub_inspector_property_bg" + itos(i), "Editor", bg_color); + theme->set_stylebox("sub_inspector_property_bg" + itos(i), EditorStringName(Editor), bg_color); } - theme->set_color("sub_inspector_property_color", "Editor", dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1)); + theme->set_color("sub_inspector_property_color", EditorStringName(Editor), dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1)); // EditorSpinSlider. theme->set_color("label_color", "EditorSpinSlider", font_color); @@ -1269,7 +1270,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("indent_box", "EditorInspectorSection", inspector_indent_style); theme->set_constant("indent_size", "EditorInspectorSection", 6.0 * EDSCALE); - theme->set_constant("inspector_margin", "Editor", 12 * EDSCALE); + theme->set_constant("inspector_margin", EditorStringName(Editor), 12 * EDSCALE); // Tree & ItemList background Ref<StyleBoxFlat> style_tree_bg = style_default->duplicate(); @@ -1286,14 +1287,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("panel", "EditorValidationPanel", style_tree_bg); // Tree - theme->set_icon("checked", "Tree", theme->get_icon(SNAME("GuiChecked"), SNAME("EditorIcons"))); - theme->set_icon("indeterminate", "Tree", theme->get_icon(SNAME("GuiIndeterminate"), SNAME("EditorIcons"))); - theme->set_icon("unchecked", "Tree", theme->get_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons"))); - theme->set_icon("arrow", "Tree", theme->get_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons"))); - theme->set_icon("arrow_collapsed", "Tree", theme->get_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons"))); - theme->set_icon("arrow_collapsed_mirrored", "Tree", theme->get_icon(SNAME("GuiTreeArrowLeft"), SNAME("EditorIcons"))); - theme->set_icon("updown", "Tree", theme->get_icon(SNAME("GuiTreeUpdown"), SNAME("EditorIcons"))); - theme->set_icon("select_arrow", "Tree", theme->get_icon(SNAME("GuiDropdown"), SNAME("EditorIcons"))); + theme->set_icon("checked", "Tree", theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons))); + theme->set_icon("indeterminate", "Tree", theme->get_icon(SNAME("GuiIndeterminate"), EditorStringName(EditorIcons))); + theme->set_icon("unchecked", "Tree", theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons))); + theme->set_icon("arrow", "Tree", theme->get_icon(SNAME("GuiTreeArrowDown"), EditorStringName(EditorIcons))); + theme->set_icon("arrow_collapsed", "Tree", theme->get_icon(SNAME("GuiTreeArrowRight"), EditorStringName(EditorIcons))); + theme->set_icon("arrow_collapsed_mirrored", "Tree", theme->get_icon(SNAME("GuiTreeArrowLeft"), EditorStringName(EditorIcons))); + theme->set_icon("updown", "Tree", theme->get_icon(SNAME("GuiTreeUpdown"), EditorStringName(EditorIcons))); + theme->set_icon("select_arrow", "Tree", theme->get_icon(SNAME("GuiDropdown"), EditorStringName(EditorIcons))); theme->set_stylebox("focus", "Tree", style_widget_focus); theme->set_stylebox("custom_button", "Tree", make_empty_stylebox()); theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox()); @@ -1376,9 +1377,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Color prop_category_color = dark_color_1.lerp(mono_color, 0.12); Color prop_section_color = dark_color_1.lerp(mono_color, 0.09); Color prop_subsection_color = dark_color_1.lerp(mono_color, 0.06); - theme->set_color("prop_category", "Editor", prop_category_color); - theme->set_color("prop_section", "Editor", prop_section_color); - theme->set_color("prop_subsection", "Editor", prop_subsection_color); + theme->set_color("prop_category", EditorStringName(Editor), prop_category_color); + theme->set_color("prop_section", EditorStringName(Editor), prop_section_color); + theme->set_color("prop_subsection", EditorStringName(Editor), prop_subsection_color); theme->set_color("drop_position_color", "Tree", accent_color); // EditorInspectorCategory @@ -1452,19 +1453,19 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_outline_color", "TabBar", font_outline_color); theme->set_color("drop_mark_color", "TabContainer", tab_highlight); theme->set_color("drop_mark_color", "TabBar", tab_highlight); - theme->set_icon("menu", "TabContainer", theme->get_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons"))); - theme->set_icon("menu_highlight", "TabContainer", theme->get_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - theme->set_icon("close", "TabBar", theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons"))); - theme->set_icon("increment", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowRight"), SNAME("EditorIcons"))); - theme->set_icon("decrement", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowLeft"), SNAME("EditorIcons"))); - theme->set_icon("increment", "TabBar", theme->get_icon(SNAME("GuiScrollArrowRight"), SNAME("EditorIcons"))); - theme->set_icon("decrement", "TabBar", theme->get_icon(SNAME("GuiScrollArrowLeft"), SNAME("EditorIcons"))); - theme->set_icon("increment_highlight", "TabBar", theme->get_icon(SNAME("GuiScrollArrowRightHl"), SNAME("EditorIcons"))); - theme->set_icon("decrement_highlight", "TabBar", theme->get_icon(SNAME("GuiScrollArrowLeftHl"), SNAME("EditorIcons"))); - theme->set_icon("increment_highlight", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowRightHl"), SNAME("EditorIcons"))); - theme->set_icon("decrement_highlight", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowLeftHl"), SNAME("EditorIcons"))); - theme->set_icon("drop_mark", "TabContainer", theme->get_icon(SNAME("GuiTabDropMark"), SNAME("EditorIcons"))); - theme->set_icon("drop_mark", "TabBar", theme->get_icon(SNAME("GuiTabDropMark"), SNAME("EditorIcons"))); + theme->set_icon("menu", "TabContainer", theme->get_icon(SNAME("GuiTabMenu"), EditorStringName(EditorIcons))); + theme->set_icon("menu_highlight", "TabContainer", theme->get_icon(SNAME("GuiTabMenuHl"), EditorStringName(EditorIcons))); + theme->set_icon("close", "TabBar", theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons))); + theme->set_icon("increment", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowRight"), EditorStringName(EditorIcons))); + theme->set_icon("decrement", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowLeft"), EditorStringName(EditorIcons))); + theme->set_icon("increment", "TabBar", theme->get_icon(SNAME("GuiScrollArrowRight"), EditorStringName(EditorIcons))); + theme->set_icon("decrement", "TabBar", theme->get_icon(SNAME("GuiScrollArrowLeft"), EditorStringName(EditorIcons))); + theme->set_icon("increment_highlight", "TabBar", theme->get_icon(SNAME("GuiScrollArrowRightHl"), EditorStringName(EditorIcons))); + theme->set_icon("decrement_highlight", "TabBar", theme->get_icon(SNAME("GuiScrollArrowLeftHl"), EditorStringName(EditorIcons))); + theme->set_icon("increment_highlight", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowRightHl"), EditorStringName(EditorIcons))); + theme->set_icon("decrement_highlight", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowLeftHl"), EditorStringName(EditorIcons))); + theme->set_icon("drop_mark", "TabContainer", theme->get_icon(SNAME("GuiTabDropMark"), EditorStringName(EditorIcons))); + theme->set_icon("drop_mark", "TabBar", theme->get_icon(SNAME("GuiTabDropMark"), EditorStringName(EditorIcons))); theme->set_constant("side_margin", "TabContainer", 0); theme->set_constant("outline_size", "TabContainer", 0); theme->set_constant("h_separation", "TabBar", 4 * EDSCALE); @@ -1484,7 +1485,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Bottom panel. Ref<StyleBoxFlat> style_bottom_panel = style_content_panel->duplicate(); style_bottom_panel->set_corner_radius_all(corner_radius * EDSCALE); - theme->set_stylebox("BottomPanel", "EditorStyles", style_bottom_panel); + theme->set_stylebox("BottomPanel", EditorStringName(EditorStyles), style_bottom_panel); // TabContainerOdd can be used on tabs against the base color background (e.g. nested tabs). theme->set_type_variation("TabContainerOdd", "TabContainer"); @@ -1500,20 +1501,20 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // This stylebox is used in 3d and 2d viewports (no borders). Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate(); style_content_panel_vp->set_content_margin_individual(border_width * 2, default_margin_size * EDSCALE, border_width * 2, border_width * 2); - theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp); + theme->set_stylebox("Content", EditorStringName(EditorStyles), style_content_panel_vp); // This stylebox is used by preview tabs in the Theme Editor. Ref<StyleBoxFlat> style_theme_preview_tab = style_tab_selected_odd->duplicate(); style_theme_preview_tab->set_expand_margin(SIDE_BOTTOM, 5 * EDSCALE); - theme->set_stylebox("ThemeEditorPreviewFG", "EditorStyles", style_theme_preview_tab); + theme->set_stylebox("ThemeEditorPreviewFG", EditorStringName(EditorStyles), style_theme_preview_tab); Ref<StyleBoxFlat> style_theme_preview_bg_tab = style_tab_unselected->duplicate(); style_theme_preview_bg_tab->set_expand_margin(SIDE_BOTTOM, 2 * EDSCALE); - theme->set_stylebox("ThemeEditorPreviewBG", "EditorStyles", style_theme_preview_bg_tab); + theme->set_stylebox("ThemeEditorPreviewBG", EditorStringName(EditorStyles), style_theme_preview_bg_tab); Ref<StyleBoxFlat> style_texture_region_bg = style_tree_bg->duplicate(); style_texture_region_bg->set_content_margin_all(0); - theme->set_stylebox("TextureRegionPreviewBG", "EditorStyles", style_texture_region_bg); - theme->set_stylebox("TextureRegionPreviewFG", "EditorStyles", make_empty_stylebox(0, 0, 0, 0)); + theme->set_stylebox("TextureRegionPreviewBG", EditorStringName(EditorStyles), style_texture_region_bg); + theme->set_stylebox("TextureRegionPreviewFG", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0)); // Separators theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, MAX(Math::round(EDSCALE), border_width))); @@ -1523,13 +1524,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Ref<StyleBoxFlat> style_panel_debugger = style_content_panel->duplicate(); style_panel_debugger->set_border_width(SIDE_BOTTOM, 0); - theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger); + theme->set_stylebox("DebuggerPanel", EditorStringName(EditorStyles), style_panel_debugger); Ref<StyleBoxFlat> style_panel_invisible_top = style_content_panel->duplicate(); int stylebox_offset = theme->get_font(SNAME("tab_selected"), SNAME("TabContainer"))->get_height(theme->get_font_size(SNAME("tab_selected"), SNAME("TabContainer"))) + theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->get_minimum_size().height + theme->get_stylebox(SNAME("panel"), SNAME("TabContainer"))->get_content_margin(SIDE_TOP); style_panel_invisible_top->set_expand_margin(SIDE_TOP, -stylebox_offset); style_panel_invisible_top->set_content_margin(SIDE_TOP, 0); - theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top); + theme->set_stylebox("BottomPanelDebuggerOverride", EditorStringName(EditorStyles), style_panel_invisible_top); // LineEdit @@ -1559,7 +1560,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("normal", "LineEdit", style_line_edit); theme->set_stylebox("focus", "LineEdit", style_widget_focus); theme->set_stylebox("read_only", "LineEdit", style_line_edit_disabled); - theme->set_icon("clear", "LineEdit", theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons"))); + theme->set_icon("clear", "LineEdit", theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons))); theme->set_color("font_color", "LineEdit", font_color); theme->set_color("font_selected_color", "LineEdit", mono_color); theme->set_color("font_uneditable_color", "LineEdit", font_readonly_color); @@ -1578,8 +1579,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("normal", "TextEdit", style_line_edit); theme->set_stylebox("focus", "TextEdit", style_widget_focus); theme->set_stylebox("read_only", "TextEdit", style_line_edit_disabled); - theme->set_icon("tab", "TextEdit", theme->get_icon(SNAME("GuiTab"), SNAME("EditorIcons"))); - theme->set_icon("space", "TextEdit", theme->get_icon(SNAME("GuiSpace"), SNAME("EditorIcons"))); + theme->set_icon("tab", "TextEdit", theme->get_icon(SNAME("GuiTab"), EditorStringName(EditorIcons))); + theme->set_icon("space", "TextEdit", theme->get_icon(SNAME("GuiSpace"), EditorStringName(EditorIcons))); theme->set_color("font_color", "TextEdit", font_color); theme->set_color("font_readonly_color", "TextEdit", font_readonly_color); theme->set_color("font_placeholder_color", "TextEdit", font_placeholder_color); @@ -1592,10 +1593,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("outline_size", "TextEdit", 0); theme->set_constant("caret_width", "TextEdit", 1); - theme->set_icon("h_grabber", "SplitContainer", theme->get_icon(SNAME("GuiHsplitter"), SNAME("EditorIcons"))); - theme->set_icon("v_grabber", "SplitContainer", theme->get_icon(SNAME("GuiVsplitter"), SNAME("EditorIcons"))); - theme->set_icon("grabber", "VSplitContainer", theme->get_icon(SNAME("GuiVsplitter"), SNAME("EditorIcons"))); - theme->set_icon("grabber", "HSplitContainer", theme->get_icon(SNAME("GuiHsplitter"), SNAME("EditorIcons"))); + theme->set_icon("h_grabber", "SplitContainer", theme->get_icon(SNAME("GuiHsplitter"), EditorStringName(EditorIcons))); + theme->set_icon("v_grabber", "SplitContainer", theme->get_icon(SNAME("GuiVsplitter"), EditorStringName(EditorIcons))); + theme->set_icon("grabber", "VSplitContainer", theme->get_icon(SNAME("GuiVsplitter"), EditorStringName(EditorIcons))); + theme->set_icon("grabber", "HSplitContainer", theme->get_icon(SNAME("GuiHsplitter"), EditorStringName(EditorIcons))); theme->set_constant("separation", "SplitContainer", default_margin_size * 2 * EDSCALE); theme->set_constant("separation", "HSplitContainer", default_margin_size * 2 * EDSCALE); @@ -1646,14 +1647,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("embedded_unfocused_border", "Window", style_window); theme->set_color("title_color", "Window", font_color); - theme->set_icon("close", "Window", theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons"))); - theme->set_icon("close_pressed", "Window", theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons"))); + theme->set_icon("close", "Window", theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons))); + theme->set_icon("close_pressed", "Window", theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons))); theme->set_constant("close_h_offset", "Window", 22 * EDSCALE); theme->set_constant("close_v_offset", "Window", 20 * EDSCALE); theme->set_constant("title_height", "Window", 24 * EDSCALE); theme->set_constant("resize_margin", "Window", 4 * EDSCALE); - theme->set_font("title_font", "Window", theme->get_font(SNAME("title"), SNAME("EditorFonts"))); - theme->set_font_size("title_font_size", "Window", theme->get_font_size(SNAME("title_size"), SNAME("EditorFonts"))); + theme->set_font("title_font", "Window", theme->get_font(SNAME("title"), EditorStringName(EditorFonts))); + theme->set_font_size("title_font_size", "Window", theme->get_font_size(SNAME("title_size"), EditorStringName(EditorFonts))); // Complex window (currently only Editor Settings and Project Settings) Ref<StyleBoxFlat> style_complex_window = style_window->duplicate(); @@ -1673,12 +1674,12 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { if (increase_scrollbar_touch_area) { theme->set_stylebox("scroll", "HScrollBar", make_line_stylebox(separator_color, 50)); } else { - theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 1, 1, 1, 1)); + theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1)); } - theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 1, 1, 1, 1)); - theme->set_stylebox("grabber", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabber"), SNAME("EditorIcons")), 6, 6, 6, 6, 1, 1, 1, 1)); - theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberHl"), SNAME("EditorIcons")), 5, 5, 5, 5, 1, 1, 1, 1)); - theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberPressed"), SNAME("EditorIcons")), 6, 6, 6, 6, 1, 1, 1, 1)); + theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1)); + theme->set_stylebox("grabber", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabber"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1)); + theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberHl"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1)); + theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberPressed"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1)); theme->set_icon("increment", "HScrollBar", empty_icon); theme->set_icon("increment_highlight", "HScrollBar", empty_icon); @@ -1691,12 +1692,12 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { if (increase_scrollbar_touch_area) { theme->set_stylebox("scroll", "VScrollBar", make_line_stylebox(separator_color, 50, 1, 1, true)); } else { - theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 1, 1, 1, 1)); + theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1)); } - theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 1, 1, 1, 1)); - theme->set_stylebox("grabber", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabber"), SNAME("EditorIcons")), 6, 6, 6, 6, 1, 1, 1, 1)); - theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberHl"), SNAME("EditorIcons")), 5, 5, 5, 5, 1, 1, 1, 1)); - theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberPressed"), SNAME("EditorIcons")), 6, 6, 6, 6, 1, 1, 1, 1)); + theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1)); + theme->set_stylebox("grabber", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabber"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1)); + theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberHl"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1)); + theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberPressed"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1)); theme->set_icon("increment", "VScrollBar", empty_icon); theme->set_icon("increment_highlight", "VScrollBar", empty_icon); @@ -1706,8 +1707,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("decrement_pressed", "VScrollBar", empty_icon); // HSlider - theme->set_icon("grabber_highlight", "HSlider", theme->get_icon(SNAME("GuiSliderGrabberHl"), SNAME("EditorIcons"))); - theme->set_icon("grabber", "HSlider", theme->get_icon(SNAME("GuiSliderGrabber"), SNAME("EditorIcons"))); + theme->set_icon("grabber_highlight", "HSlider", theme->get_icon(SNAME("GuiSliderGrabberHl"), EditorStringName(EditorIcons))); + theme->set_icon("grabber", "HSlider", theme->get_icon(SNAME("GuiSliderGrabber"), EditorStringName(EditorIcons))); theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width)); theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width)); theme->set_stylebox("grabber_area_highlight", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2)); @@ -1715,8 +1716,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("grabber_offset", "HSlider", 0); // VSlider - theme->set_icon("grabber", "VSlider", theme->get_icon(SNAME("GuiSliderGrabber"), SNAME("EditorIcons"))); - theme->set_icon("grabber_highlight", "VSlider", theme->get_icon(SNAME("GuiSliderGrabberHl"), SNAME("EditorIcons"))); + theme->set_icon("grabber", "VSlider", theme->get_icon(SNAME("GuiSliderGrabber"), EditorStringName(EditorIcons))); + theme->set_icon("grabber_highlight", "VSlider", theme->get_icon(SNAME("GuiSliderGrabberHl"), EditorStringName(EditorIcons))); theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width)); theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width)); theme->set_stylebox("grabber_area_highlight", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0)); @@ -1764,7 +1765,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Panel theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4, corner_width)); - theme->set_stylebox("PanelForeground", "EditorStyles", style_default); + theme->set_stylebox("PanelForeground", EditorStringName(EditorStyles), style_default); // Label theme->set_stylebox("normal", "Label", style_empty); @@ -1816,12 +1817,12 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_type_variation("ControlEditorPopupPanel", "PopupPanel"); // SpinBox - theme->set_icon("updown", "SpinBox", theme->get_icon(SNAME("GuiSpinboxUpdown"), SNAME("EditorIcons"))); - theme->set_icon("updown_disabled", "SpinBox", theme->get_icon(SNAME("GuiSpinboxUpdownDisabled"), SNAME("EditorIcons"))); + theme->set_icon("updown", "SpinBox", theme->get_icon(SNAME("GuiSpinboxUpdown"), EditorStringName(EditorIcons))); + theme->set_icon("updown_disabled", "SpinBox", theme->get_icon(SNAME("GuiSpinboxUpdownDisabled"), EditorStringName(EditorIcons))); // ProgressBar - theme->set_stylebox("background", "ProgressBar", make_stylebox(theme->get_icon(SNAME("GuiProgressBar"), SNAME("EditorIcons")), 4, 4, 4, 4, 0, 0, 0, 0)); - theme->set_stylebox("fill", "ProgressBar", make_stylebox(theme->get_icon(SNAME("GuiProgressFill"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 1, 2, 1)); + theme->set_stylebox("background", "ProgressBar", make_stylebox(theme->get_icon(SNAME("GuiProgressBar"), EditorStringName(EditorIcons)), 4, 4, 4, 4, 0, 0, 0, 0)); + theme->set_stylebox("fill", "ProgressBar", make_stylebox(theme->get_icon(SNAME("GuiProgressFill"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 2, 1, 2, 1)); theme->set_color("font_color", "ProgressBar", font_color); theme->set_color("font_outline_color", "ProgressBar", font_outline_color); theme->set_constant("outline_size", "ProgressBar", 0); @@ -1835,17 +1836,17 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("grid_major", "GraphEdit", Color(0.0, 0.0, 0.0, 0.15)); theme->set_color("grid_minor", "GraphEdit", Color(0.0, 0.0, 0.0, 0.07)); } - theme->set_color("selection_fill", "GraphEdit", theme->get_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); - theme->set_color("selection_stroke", "GraphEdit", theme->get_color(SNAME("box_selection_stroke_color"), SNAME("Editor"))); + theme->set_color("selection_fill", "GraphEdit", theme->get_color(SNAME("box_selection_fill_color"), EditorStringName(Editor))); + theme->set_color("selection_stroke", "GraphEdit", theme->get_color(SNAME("box_selection_stroke_color"), EditorStringName(Editor))); theme->set_color("activity", "GraphEdit", accent_color); - theme->set_icon("zoom_out", "GraphEdit", theme->get_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); - theme->set_icon("zoom_in", "GraphEdit", theme->get_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); - theme->set_icon("zoom_reset", "GraphEdit", theme->get_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); - theme->set_icon("grid_toggle", "GraphEdit", theme->get_icon(SNAME("GridToggle"), SNAME("EditorIcons"))); - theme->set_icon("minimap_toggle", "GraphEdit", theme->get_icon(SNAME("GridMinimap"), SNAME("EditorIcons"))); - theme->set_icon("snapping_toggle", "GraphEdit", theme->get_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); - theme->set_icon("layout", "GraphEdit", theme->get_icon(SNAME("GridLayout"), SNAME("EditorIcons"))); + theme->set_icon("zoom_out", "GraphEdit", theme->get_icon(SNAME("ZoomLess"), EditorStringName(EditorIcons))); + theme->set_icon("zoom_in", "GraphEdit", theme->get_icon(SNAME("ZoomMore"), EditorStringName(EditorIcons))); + theme->set_icon("zoom_reset", "GraphEdit", theme->get_icon(SNAME("ZoomReset"), EditorStringName(EditorIcons))); + theme->set_icon("grid_toggle", "GraphEdit", theme->get_icon(SNAME("GridToggle"), EditorStringName(EditorIcons))); + theme->set_icon("minimap_toggle", "GraphEdit", theme->get_icon(SNAME("GridMinimap"), EditorStringName(EditorIcons))); + theme->set_icon("snapping_toggle", "GraphEdit", theme->get_icon(SNAME("SnapGrid"), EditorStringName(EditorIcons))); + theme->set_icon("layout", "GraphEdit", theme->get_icon(SNAME("GridLayout"), EditorStringName(EditorIcons))); // GraphEditMinimap Ref<StyleBoxFlat> style_minimap_bg = make_flat_stylebox(dark_color_1, 0, 0, 0, 0); @@ -1874,7 +1875,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { } else { minimap_resizer_color = Color(0, 0, 0, 0.65); } - theme->set_icon("resizer", "GraphEditMinimap", theme->get_icon(SNAME("GuiResizerTopLeft"), SNAME("EditorIcons"))); + theme->set_icon("resizer", "GraphEditMinimap", theme->get_icon(SNAME("GuiResizerTopLeft"), EditorStringName(EditorIcons))); theme->set_color("resizer_color", "GraphEditMinimap", minimap_resizer_color); // GraphNode @@ -1950,25 +1951,25 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("close_offset", "GraphNode", 20 * EDSCALE); theme->set_constant("separation", "GraphNode", 1 * EDSCALE); - theme->set_icon("close", "GraphNode", theme->get_icon(SNAME("GuiCloseCustomizable"), SNAME("EditorIcons"))); - theme->set_icon("resizer", "GraphNode", theme->get_icon(SNAME("GuiResizer"), SNAME("EditorIcons"))); - Ref<ImageTexture> port_icon = theme->get_icon(SNAME("GuiGraphNodePort"), SNAME("EditorIcons")); + theme->set_icon("close", "GraphNode", theme->get_icon(SNAME("GuiCloseCustomizable"), EditorStringName(EditorIcons))); + theme->set_icon("resizer", "GraphNode", theme->get_icon(SNAME("GuiResizer"), EditorStringName(EditorIcons))); + Ref<ImageTexture> port_icon = theme->get_icon(SNAME("GuiGraphNodePort"), EditorStringName(EditorIcons)); // The true size is 24x24 This is necessary for sharp port icons at high zoom levels in GraphEdit (up to ~200%). port_icon->set_size_override(Size2(12, 12)); theme->set_icon("port", "GraphNode", port_icon); - theme->set_font("title_font", "GraphNode", theme->get_font(SNAME("main_bold_msdf"), SNAME("EditorFonts"))); + theme->set_font("title_font", "GraphNode", theme->get_font(SNAME("main_bold_msdf"), EditorStringName(EditorFonts))); // GridContainer theme->set_constant("v_separation", "GridContainer", Math::round(widget_default_margin.y - 2 * EDSCALE)); // FileDialog - theme->set_icon("folder", "FileDialog", theme->get_icon(SNAME("Folder"), SNAME("EditorIcons"))); - theme->set_icon("parent_folder", "FileDialog", theme->get_icon(SNAME("ArrowUp"), SNAME("EditorIcons"))); - theme->set_icon("back_folder", "FileDialog", theme->get_icon(SNAME("Back"), SNAME("EditorIcons"))); - theme->set_icon("forward_folder", "FileDialog", theme->get_icon(SNAME("Forward"), SNAME("EditorIcons"))); - theme->set_icon("reload", "FileDialog", theme->get_icon(SNAME("Reload"), SNAME("EditorIcons"))); - theme->set_icon("toggle_hidden", "FileDialog", theme->get_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); + theme->set_icon("folder", "FileDialog", theme->get_icon(SNAME("Folder"), EditorStringName(EditorIcons))); + theme->set_icon("parent_folder", "FileDialog", theme->get_icon(SNAME("ArrowUp"), EditorStringName(EditorIcons))); + theme->set_icon("back_folder", "FileDialog", theme->get_icon(SNAME("Back"), EditorStringName(EditorIcons))); + theme->set_icon("forward_folder", "FileDialog", theme->get_icon(SNAME("Forward"), EditorStringName(EditorIcons))); + theme->set_icon("reload", "FileDialog", theme->get_icon(SNAME("Reload"), EditorStringName(EditorIcons))); + theme->set_icon("toggle_hidden", "FileDialog", theme->get_icon(SNAME("GuiVisibilityVisible"), EditorStringName(EditorIcons))); // Use a different color for folder icons to make them easier to distinguish from files. // On a light theme, the icon will be dark, so we need to lighten it before blending it with the accent color. theme->set_color("folder_icon_color", "FileDialog", (dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).lerp(accent_color, 0.7)); @@ -1981,36 +1982,36 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("h_width", "ColorPicker", 30 * EDSCALE); theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE); theme->set_constant("center_slider_grabbers", "ColorPicker", 1); - theme->set_icon("screen_picker", "ColorPicker", theme->get_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); - theme->set_icon("shape_circle", "ColorPicker", theme->get_icon(SNAME("PickerShapeCircle"), SNAME("EditorIcons"))); - theme->set_icon("shape_rect", "ColorPicker", theme->get_icon(SNAME("PickerShapeRectangle"), SNAME("EditorIcons"))); - theme->set_icon("shape_rect_wheel", "ColorPicker", theme->get_icon(SNAME("PickerShapeRectangleWheel"), SNAME("EditorIcons"))); - theme->set_icon("add_preset", "ColorPicker", theme->get_icon(SNAME("Add"), SNAME("EditorIcons"))); - theme->set_icon("sample_bg", "ColorPicker", theme->get_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons"))); - theme->set_icon("overbright_indicator", "ColorPicker", theme->get_icon(SNAME("OverbrightIndicator"), SNAME("EditorIcons"))); - theme->set_icon("bar_arrow", "ColorPicker", theme->get_icon(SNAME("ColorPickerBarArrow"), SNAME("EditorIcons"))); - theme->set_icon("picker_cursor", "ColorPicker", theme->get_icon(SNAME("PickerCursor"), SNAME("EditorIcons"))); + theme->set_icon("screen_picker", "ColorPicker", theme->get_icon(SNAME("ColorPick"), EditorStringName(EditorIcons))); + theme->set_icon("shape_circle", "ColorPicker", theme->get_icon(SNAME("PickerShapeCircle"), EditorStringName(EditorIcons))); + theme->set_icon("shape_rect", "ColorPicker", theme->get_icon(SNAME("PickerShapeRectangle"), EditorStringName(EditorIcons))); + theme->set_icon("shape_rect_wheel", "ColorPicker", theme->get_icon(SNAME("PickerShapeRectangleWheel"), EditorStringName(EditorIcons))); + theme->set_icon("add_preset", "ColorPicker", theme->get_icon(SNAME("Add"), EditorStringName(EditorIcons))); + theme->set_icon("sample_bg", "ColorPicker", theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons))); + theme->set_icon("overbright_indicator", "ColorPicker", theme->get_icon(SNAME("OverbrightIndicator"), EditorStringName(EditorIcons))); + theme->set_icon("bar_arrow", "ColorPicker", theme->get_icon(SNAME("ColorPickerBarArrow"), EditorStringName(EditorIcons))); + theme->set_icon("picker_cursor", "ColorPicker", theme->get_icon(SNAME("PickerCursor"), EditorStringName(EditorIcons))); // ColorPickerButton - theme->set_icon("bg", "ColorPickerButton", theme->get_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons"))); + theme->set_icon("bg", "ColorPickerButton", theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons))); // ColorPresetButton Ref<StyleBoxFlat> preset_sb = make_flat_stylebox(Color(1, 1, 1), 2, 2, 2, 2, 2); theme->set_stylebox("preset_fg", "ColorPresetButton", preset_sb); - theme->set_icon("preset_bg", "ColorPresetButton", theme->get_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons"))); - theme->set_icon("overbright_indicator", "ColorPresetButton", theme->get_icon(SNAME("OverbrightIndicator"), SNAME("EditorIcons"))); + theme->set_icon("preset_bg", "ColorPresetButton", theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons))); + theme->set_icon("overbright_indicator", "ColorPresetButton", theme->get_icon(SNAME("OverbrightIndicator"), EditorStringName(EditorIcons))); // Information on 3D viewport Ref<StyleBoxFlat> style_info_3d_viewport = style_default->duplicate(); style_info_3d_viewport->set_bg_color(style_info_3d_viewport->get_bg_color() * Color(1, 1, 1, 0.5)); style_info_3d_viewport->set_border_width_all(0); - theme->set_stylebox("Information3dViewport", "EditorStyles", style_info_3d_viewport); + theme->set_stylebox("Information3dViewport", EditorStringName(EditorStyles), style_info_3d_viewport); // Asset Library. theme->set_stylebox("bg", "AssetLib", style_empty); theme->set_stylebox("panel", "AssetLib", style_content_panel); theme->set_color("status_color", "AssetLib", Color(0.5, 0.5, 0.5)); - theme->set_icon("dismiss", "AssetLib", theme->get_icon(SNAME("Close"), SNAME("EditorIcons"))); + theme->set_icon("dismiss", "AssetLib", theme->get_icon(SNAME("Close"), EditorStringName(EditorIcons))); // Theme editor. theme->set_color("preview_picker_overlay_color", "ThemeEditor", Color(0.1, 0.1, 0.1, 0.25)); @@ -2030,7 +2031,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Ref<StyleBoxFlat> style_dictionary_add_item = make_flat_stylebox(prop_subsection_color, 0, 4, 0, 4, corner_radius); style_dictionary_add_item->set_expand_margin(SIDE_LEFT, 4 * EDSCALE); style_dictionary_add_item->set_expand_margin(SIDE_RIGHT, 4 * EDSCALE); - theme->set_stylebox("DictionaryAddItem", "EditorStyles", style_dictionary_add_item); + theme->set_stylebox("DictionaryAddItem", EditorStringName(EditorStyles), style_dictionary_add_item); Ref<StyleBoxEmpty> vshader_label_style = make_empty_stylebox(2, 1, 2, 1); theme->set_stylebox("label_style", "VShaderEditor", vshader_label_style); @@ -2131,20 +2132,20 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { } // Now theme is loaded, apply it to CodeEdit. - theme->set_font("font", "CodeEdit", theme->get_font(SNAME("source"), SNAME("EditorFonts"))); - theme->set_font_size("font_size", "CodeEdit", theme->get_font_size(SNAME("source_size"), SNAME("EditorFonts"))); + theme->set_font("font", "CodeEdit", theme->get_font(SNAME("source"), EditorStringName(EditorFonts))); + theme->set_font_size("font_size", "CodeEdit", theme->get_font_size(SNAME("source_size"), EditorStringName(EditorFonts))); Ref<StyleBoxFlat> code_edit_stylebox = make_flat_stylebox(EDITOR_GET("text_editor/theme/highlighting/background_color"), widget_default_margin.x, widget_default_margin.y, widget_default_margin.x, widget_default_margin.y, corner_radius); theme->set_stylebox("normal", "CodeEdit", code_edit_stylebox); theme->set_stylebox("read_only", "CodeEdit", code_edit_stylebox); theme->set_stylebox("focus", "CodeEdit", Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty))); - theme->set_icon("tab", "CodeEdit", theme->get_icon(SNAME("GuiTab"), SNAME("EditorIcons"))); - theme->set_icon("space", "CodeEdit", theme->get_icon(SNAME("GuiSpace"), SNAME("EditorIcons"))); - theme->set_icon("folded", "CodeEdit", theme->get_icon(SNAME("CodeFoldedRightArrow"), SNAME("EditorIcons"))); - theme->set_icon("can_fold", "CodeEdit", theme->get_icon(SNAME("CodeFoldDownArrow"), SNAME("EditorIcons"))); - theme->set_icon("executing_line", "CodeEdit", theme->get_icon(SNAME("TextEditorPlay"), SNAME("EditorIcons"))); - theme->set_icon("breakpoint", "CodeEdit", theme->get_icon(SNAME("Breakpoint"), SNAME("EditorIcons"))); + theme->set_icon("tab", "CodeEdit", theme->get_icon(SNAME("GuiTab"), EditorStringName(EditorIcons))); + theme->set_icon("space", "CodeEdit", theme->get_icon(SNAME("GuiSpace"), EditorStringName(EditorIcons))); + theme->set_icon("folded", "CodeEdit", theme->get_icon(SNAME("CodeFoldedRightArrow"), EditorStringName(EditorIcons))); + theme->set_icon("can_fold", "CodeEdit", theme->get_icon(SNAME("CodeFoldDownArrow"), EditorStringName(EditorIcons))); + theme->set_icon("executing_line", "CodeEdit", theme->get_icon(SNAME("TextEditorPlay"), EditorStringName(EditorIcons))); + theme->set_icon("breakpoint", "CodeEdit", theme->get_icon(SNAME("Breakpoint"), EditorStringName(EditorIcons))); theme->set_constant("line_spacing", "CodeEdit", EDITOR_GET("text_editor/appearance/whitespace/line_spacing")); diff --git a/editor/event_listener_line_edit.cpp b/editor/event_listener_line_edit.cpp index b9e182d780..e51808c78c 100644 --- a/editor/event_listener_line_edit.cpp +++ b/editor/event_listener_line_edit.cpp @@ -215,7 +215,7 @@ void EventListenerLineEdit::_notification(int p_what) { connect("text_changed", callable_mp(this, &EventListenerLineEdit::_on_text_changed)); connect("focus_entered", callable_mp(this, &EventListenerLineEdit::_on_focus)); connect("focus_exited", callable_mp(this, &EventListenerLineEdit::_on_unfocus)); - set_right_icon(get_theme_icon(SNAME("Keyboard"), SNAME("EditorIcons"))); + set_right_icon(get_editor_theme_icon(SNAME("Keyboard"))); set_clear_button_enabled(true); } break; } diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 208451acce..891bba6ce9 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -42,6 +42,7 @@ #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/export/editor_export.h" #include "editor/plugins/script_editor_plugin.h" #include "editor_export_plugin.h" @@ -72,12 +73,12 @@ bool EditorExportPlatform::fill_log_messages(RichTextLabel *p_log, Error p_err) p_log->add_text(" - "); if (p_err == OK) { if (get_worst_message_type() >= EditorExportPlatform::EXPORT_MESSAGE_WARNING) { - p_log->add_image(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")), 16 * EDSCALE, 16 * EDSCALE, Color(1.0, 1.0, 1.0), INLINE_ALIGNMENT_CENTER); + p_log->add_image(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("StatusWarning")), 16 * EDSCALE, 16 * EDSCALE, Color(1.0, 1.0, 1.0), INLINE_ALIGNMENT_CENTER); p_log->add_text(" "); p_log->add_text(TTR("Completed with warnings.")); has_messages = true; } else { - p_log->add_image(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons")), 16 * EDSCALE, 16 * EDSCALE, Color(1.0, 1.0, 1.0), INLINE_ALIGNMENT_CENTER); + p_log->add_image(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("StatusSuccess")), 16 * EDSCALE, 16 * EDSCALE, Color(1.0, 1.0, 1.0), INLINE_ALIGNMENT_CENTER); p_log->add_text(" "); p_log->add_text(TTR("Completed successfully.")); if (msg_count > 0) { @@ -85,7 +86,7 @@ bool EditorExportPlatform::fill_log_messages(RichTextLabel *p_log, Error p_err) } } } else { - p_log->add_image(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")), 16 * EDSCALE, 16 * EDSCALE, Color(1.0, 1.0, 1.0), INLINE_ALIGNMENT_CENTER); + p_log->add_image(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("StatusError")), 16 * EDSCALE, 16 * EDSCALE, Color(1.0, 1.0, 1.0), INLINE_ALIGNMENT_CENTER); p_log->add_text(" "); p_log->add_text(TTR("Failed.")); has_messages = true; @@ -103,15 +104,15 @@ bool EditorExportPlatform::fill_log_messages(RichTextLabel *p_log, Error p_err) switch (msg.msg_type) { case EditorExportPlatform::EXPORT_MESSAGE_INFO: { - color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.6); + color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("font_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.6); } break; case EditorExportPlatform::EXPORT_MESSAGE_WARNING: { - icon = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")); - color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor")); + icon = EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Warning")); + color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), EditorStringName(Editor)); } break; case EditorExportPlatform::EXPORT_MESSAGE_ERROR: { - icon = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Error"), SNAME("EditorIcons")); - color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")); + icon = EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Error")); + color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), EditorStringName(Editor)); } break; default: break; @@ -293,9 +294,9 @@ Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const { Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); ERR_FAIL_COND_V(theme.is_null(), Ref<ImageTexture>()); if (EditorNode::get_singleton()->get_main_screen_control()->is_layout_rtl()) { - return theme->get_icon(SNAME("PlayBackwards"), SNAME("EditorIcons")); + return theme->get_icon(SNAME("PlayBackwards"), EditorStringName(EditorIcons)); } else { - return theme->get_icon(SNAME("Play"), SNAME("EditorIcons")); + return theme->get_icon(SNAME("Play"), EditorStringName(EditorIcons)); } } diff --git a/editor/export/export_template_manager.cpp b/editor/export/export_template_manager.cpp index 42e4b6f6f6..3a034c8dcc 100644 --- a/editor/export/export_template_manager.cpp +++ b/editor/export/export_template_manager.cpp @@ -38,6 +38,7 @@ #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/progress_dialog.h" #include "scene/gui/file_dialog.h" #include "scene/gui/menu_button.h" @@ -109,8 +110,8 @@ void ExportTemplateManager::_update_template_status() { TreeItem *ti = installed_table->create_item(installed_root); ti->set_text(0, version_string); - ti->add_button(0, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), OPEN_TEMPLATE_FOLDER, false, TTR("Open the folder containing these templates.")); - ti->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), UNINSTALL_TEMPLATE, false, TTR("Uninstall these templates.")); + ti->add_button(0, get_editor_theme_icon(SNAME("Folder")), OPEN_TEMPLATE_FOLDER, false, TTR("Open the folder containing these templates.")); + ti->add_button(0, get_editor_theme_icon(SNAME("Remove")), UNINSTALL_TEMPLATE, false, TTR("Uninstall these templates.")); } } @@ -360,7 +361,7 @@ void ExportTemplateManager::_set_current_progress_status(const String &p_status, download_progress_label->set_text(p_status); if (p_error) { - download_progress_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + download_progress_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); } else { download_progress_label->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("Label"))); } @@ -755,11 +756,11 @@ void ExportTemplateManager::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - current_value->add_theme_font_override("font", get_theme_font(SNAME("main"), SNAME("EditorFonts"))); - current_missing_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - current_installed_label->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + current_value->add_theme_font_override("font", get_theme_font(SNAME("main"), EditorStringName(EditorFonts))); + current_missing_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); + current_installed_label->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); - mirror_options_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + mirror_options_button->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp index f723a20368..24a9e2ae36 100644 --- a/editor/export/project_export.cpp +++ b/editor/export/project_export.cpp @@ -37,6 +37,7 @@ #include "editor/editor_properties.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/export/editor_export.h" #include "editor/gui/editor_file_dialog.h" #include "editor/import/resource_importer_texture_settings.h" @@ -66,7 +67,7 @@ void ProjectExportTextureFormatError::_bind_methods() { void ProjectExportTextureFormatError::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - texture_format_error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + texture_format_error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); } break; } } @@ -90,8 +91,8 @@ ProjectExportTextureFormatError::ProjectExportTextureFormatError() { } void ProjectExportDialog::_theme_changed() { - duplicate_preset->set_icon(presets->get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons"))); - delete_preset->set_icon(presets->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + duplicate_preset->set_icon(presets->get_editor_theme_icon(SNAME("Duplicate"))); + delete_preset->set_icon(presets->get_editor_theme_icon(SNAME("Remove"))); } void ProjectExportDialog::_notification(int p_what) { @@ -103,8 +104,8 @@ void ProjectExportDialog::_notification(int p_what) { } break; case NOTIFICATION_READY: { - duplicate_preset->set_icon(presets->get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons"))); - delete_preset->set_icon(presets->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + duplicate_preset->set_icon(presets->get_editor_theme_icon(SNAME("Duplicate"))); + delete_preset->set_icon(presets->get_editor_theme_icon(SNAME("Remove"))); connect("confirmed", callable_mp(this, &ProjectExportDialog::_export_pck_zip)); _update_export_all(); } break; @@ -812,7 +813,7 @@ void ProjectExportDialog::_setup_item_for_file_mode(TreeItem *p_item, EditorExpo p_item->set_cell_mode(1, TreeItem::CELL_MODE_STRING); p_item->set_editable(1, false); p_item->set_selectable(1, false); - p_item->set_custom_color(1, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + p_item->set_custom_color(1, get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); } else { p_item->set_checked(0, true); p_item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); @@ -1327,7 +1328,7 @@ ProjectExportDialog::ProjectExportDialog() { script_key->connect("text_changed", callable_mp(this, &ProjectExportDialog::_script_encryption_key_changed)); script_key_error = memnew(Label); script_key_error->set_text(String::utf8("• ") + TTR("Invalid Encryption Key (must be 64 hexadecimal characters long)")); - script_key_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + script_key_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); sec_vb->add_margin_child(TTR("Encryption Key (256-bits as hexadecimal):"), script_key); sec_vb->add_child(script_key_error); sections->add_child(sec_vb); @@ -1412,12 +1413,12 @@ ProjectExportDialog::ProjectExportDialog() { export_error = memnew(Label); main_vb->add_child(export_error); export_error->hide(); - export_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + export_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); export_warning = memnew(Label); main_vb->add_child(export_warning); export_warning->hide(); - export_warning->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + export_warning->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); export_templates_error = memnew(HBoxContainer); main_vb->add_child(export_templates_error); @@ -1425,7 +1426,7 @@ ProjectExportDialog::ProjectExportDialog() { Label *export_error2 = memnew(Label); export_templates_error->add_child(export_error2); - export_error2->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + export_error2->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); export_error2->set_text(String::utf8("• ") + TTR("Export templates for this platform are missing:") + " "); result_dialog = memnew(AcceptDialog); diff --git a/editor/fbx_importer_manager.cpp b/editor/fbx_importer_manager.cpp index 87f2d596e8..5922cbf312 100644 --- a/editor/fbx_importer_manager.cpp +++ b/editor/fbx_importer_manager.cpp @@ -34,6 +34,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/gui/link_button.h" void FBXImporterManager::_notification(int p_what) { @@ -88,11 +89,11 @@ void FBXImporterManager::_validate_path(const String &p_path) { if (success) { path_status->set_text(TTR("FBX2glTF executable is valid.")); - path_status->add_theme_color_override("font_color", path_status->get_theme_color(SNAME("success_color"), SNAME("Editor"))); + path_status->add_theme_color_override("font_color", path_status->get_theme_color(SNAME("success_color"), EditorStringName(Editor))); get_ok_button()->set_disabled(false); } else { path_status->set_text(error); - path_status->add_theme_color_override("font_color", path_status->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + path_status->add_theme_color_override("font_color", path_status->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); get_ok_button()->set_disabled(true); } } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 3c010112ad..364a453e0a 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -44,6 +44,7 @@ #include "editor/editor_resource_preview.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_dir_dialog.h" #include "editor/gui/editor_scene_tabs.h" #include "editor/import/resource_importer_scene.h" @@ -170,9 +171,9 @@ FileSystemDock *FileSystemDock::singleton = nullptr; Ref<Texture2D> FileSystemDock::_get_tree_item_icon(bool p_is_valid, String p_file_type) { Ref<Texture2D> file_icon; if (!p_is_valid) { - file_icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); + file_icon = get_editor_theme_icon(SNAME("ImportFail")); } else { - file_icon = (has_theme_icon(p_file_type, SNAME("EditorIcons"))) ? get_theme_icon(p_file_type, SNAME("EditorIcons")) : get_theme_icon(SNAME("File"), SNAME("EditorIcons")); + file_icon = (has_theme_icon(p_file_type, EditorStringName(EditorIcons))) ? get_editor_theme_icon(p_file_type) : get_editor_theme_icon(SNAME("File")); } return file_icon; } @@ -212,7 +213,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory subdirectory_item->set_text(0, dname); subdirectory_item->set_structured_text_bidi_override(0, TextServer::STRUCTURED_TEXT_FILE); - subdirectory_item->set_icon(0, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + subdirectory_item->set_icon(0, get_editor_theme_icon(SNAME("Folder"))); subdirectory_item->set_selectable(0, true); subdirectory_item->set_metadata(0, lpath); if (!p_select_in_favorites && (current_path == lpath || ((display_mode == DISPLAY_MODE_SPLIT) && current_path.get_base_dir() == lpath))) { @@ -294,7 +295,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory file_item->set_as_cursor(0); } if (main_scene == file_metadata) { - file_item->set_custom_color(0, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); + file_item->set_custom_color(0, get_theme_color(SNAME("accent_color"), EditorStringName(Editor))); } Array udata; udata.push_back(tree_update_id); @@ -362,7 +363,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo // Handles the favorites. TreeItem *favorites_item = tree->create_item(root); - favorites_item->set_icon(0, get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); + favorites_item->set_icon(0, get_editor_theme_icon(SNAME("Favorites"))); favorites_item->set_text(0, TTR("Favorites:")); favorites_item->set_metadata(0, "Favorites"); favorites_item->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0); @@ -382,7 +383,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo EditorSettings::get_singleton()->set_favorites(favorite_paths); } - Ref<Texture2D> folder_icon = get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")); + Ref<Texture2D> folder_icon = get_editor_theme_icon(SNAME("Folder")); const Color default_folder_color = get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog")); for (int i = 0; i < favorite_paths.size(); i++) { @@ -409,7 +410,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo if (dir) { icon = _get_tree_item_icon(dir->get_file_import_is_valid(index), dir->get_file_type(index)); } else { - icon = get_theme_icon(SNAME("File"), SNAME("EditorIcons")); + icon = get_editor_theme_icon(SNAME("File")); } color = Color(1, 1, 1); } @@ -498,28 +499,28 @@ void FileSystemDock::_notification(int p_what) { EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &FileSystemDock::_fs_changed)); EditorResourcePreview::get_singleton()->connect("preview_invalidated", callable_mp(this, &FileSystemDock::_preview_invalidated)); - button_reload->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); - button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons"))); + button_reload->set_icon(get_editor_theme_icon(SNAME("Reload"))); + button_toggle_display_mode->set_icon(get_editor_theme_icon(SNAME("Panels2"))); button_file_list_display_mode->connect("pressed", callable_mp(this, &FileSystemDock::_toggle_file_display)); files->connect("item_activated", callable_mp(this, &FileSystemDock::_file_list_activate_file)); button_hist_next->connect("pressed", callable_mp(this, &FileSystemDock::_fw_history)); button_hist_prev->connect("pressed", callable_mp(this, &FileSystemDock::_bw_history)); - tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + tree_search_box->set_right_icon(get_editor_theme_icon(SNAME("Search"))); tree_search_box->set_clear_button_enabled(true); - tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); + tree_button_sort->set_icon(get_editor_theme_icon(SNAME("Sort"))); - file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + file_list_search_box->set_right_icon(get_editor_theme_icon(SNAME("Search"))); file_list_search_box->set_clear_button_enabled(true); - file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); + file_list_button_sort->set_icon(get_editor_theme_icon(SNAME("Sort"))); if (is_layout_rtl()) { - button_hist_next->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); - button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + button_hist_next->set_icon(get_editor_theme_icon(SNAME("Back"))); + button_hist_prev->set_icon(get_editor_theme_icon(SNAME("Forward"))); } else { - button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); - button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + button_hist_next->set_icon(get_editor_theme_icon(SNAME("Forward"))); + button_hist_prev->set_icon(get_editor_theme_icon(SNAME("Back"))); } file_list_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_file_list_rmb_option)); tree_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_tree_rmb_option)); @@ -585,28 +586,28 @@ void FileSystemDock::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { // Update icons. - button_reload->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); - button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons"))); + button_reload->set_icon(get_editor_theme_icon(SNAME("Reload"))); + button_toggle_display_mode->set_icon(get_editor_theme_icon(SNAME("Panels2"))); if (is_layout_rtl()) { - button_hist_next->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); - button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + button_hist_next->set_icon(get_editor_theme_icon(SNAME("Back"))); + button_hist_prev->set_icon(get_editor_theme_icon(SNAME("Forward"))); } else { - button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); - button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + button_hist_next->set_icon(get_editor_theme_icon(SNAME("Forward"))); + button_hist_prev->set_icon(get_editor_theme_icon(SNAME("Back"))); } if (file_list_display_mode == FILE_LIST_DISPLAY_LIST) { - button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); + button_file_list_display_mode->set_icon(get_editor_theme_icon(SNAME("FileThumbnail"))); } else { - button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); + button_file_list_display_mode->set_icon(get_editor_theme_icon(SNAME("FileList"))); } - tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + tree_search_box->set_right_icon(get_editor_theme_icon(SNAME("Search"))); tree_search_box->set_clear_button_enabled(true); - tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); + tree_button_sort->set_icon(get_editor_theme_icon(SNAME("Sort"))); - file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + file_list_search_box->set_right_icon(get_editor_theme_icon(SNAME("Search"))); file_list_search_box->set_clear_button_enabled(true); - file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); + file_list_button_sort->set_icon(get_editor_theme_icon(SNAME("Sort"))); // Update editor dark theme & always show folders states from editor settings, redraw if needed. bool do_redraw = false; @@ -775,11 +776,11 @@ void FileSystemDock::_toggle_file_display() { void FileSystemDock::_set_file_display(bool p_active) { if (p_active) { file_list_display_mode = FILE_LIST_DISPLAY_LIST; - button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); + button_file_list_display_mode->set_icon(get_editor_theme_icon(SNAME("FileThumbnail"))); button_file_list_display_mode->set_tooltip_text(TTR("View items as a grid of thumbnails.")); } else { file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS; - button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); + button_file_list_display_mode->set_icon(get_editor_theme_icon(SNAME("FileList"))); button_file_list_display_mode->set_tooltip_text(TTR("View items as a list.")); } @@ -922,13 +923,13 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size)); if (thumbnail_size < 64) { - folder_thumbnail = get_theme_icon(SNAME("FolderMediumThumb"), SNAME("EditorIcons")); - file_thumbnail = get_theme_icon(SNAME("FileMediumThumb"), SNAME("EditorIcons")); - file_thumbnail_broken = get_theme_icon(SNAME("FileDeadMediumThumb"), SNAME("EditorIcons")); + folder_thumbnail = get_editor_theme_icon(SNAME("FolderMediumThumb")); + file_thumbnail = get_editor_theme_icon(SNAME("FileMediumThumb")); + file_thumbnail_broken = get_editor_theme_icon(SNAME("FileDeadMediumThumb")); } else { - folder_thumbnail = get_theme_icon(SNAME("FolderBigThumb"), SNAME("EditorIcons")); - file_thumbnail = get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons")); - file_thumbnail_broken = get_theme_icon(SNAME("FileDeadBigThumb"), SNAME("EditorIcons")); + folder_thumbnail = get_editor_theme_icon(SNAME("FolderBigThumb")); + file_thumbnail = get_editor_theme_icon(SNAME("FileBigThumb")); + file_thumbnail_broken = get_editor_theme_icon(SNAME("FileDeadBigThumb")); } } else { // No thumbnails. @@ -1087,10 +1088,10 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { // Select the icons. if (!finfo->import_broken) { - type_icon = (has_theme_icon(ftype, SNAME("EditorIcons"))) ? get_theme_icon(ftype, SNAME("EditorIcons")) : get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); + type_icon = (has_theme_icon(ftype, EditorStringName(EditorIcons))) ? get_editor_theme_icon(ftype) : get_editor_theme_icon(SNAME("Object")); big_icon = file_thumbnail; } else { - type_icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); + type_icon = get_editor_theme_icon(SNAME("ImportFail")); big_icon = file_thumbnail_broken; tooltip += "\n" + TTR("Status: Import of file failed. Please fix file and reimport manually."); } @@ -1110,7 +1111,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { } if (fpath == main_scene) { - files->set_item_custom_fg_color(item_index, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); + files->set_item_custom_fg_color(item_index, get_theme_color(SNAME("accent_color"), EditorStringName(Editor))); } // Generate the preview. @@ -2794,6 +2795,12 @@ void FileSystemDock::_folder_color_index_pressed(int p_index, PopupMenu *p_menu) } } + if (!ProjectSettings::get_singleton()->has_setting("file_customization/folder_colors")) { + ProjectSettings::get_singleton()->set_setting("file_customization/folder_colors", assigned_folder_colors); + } else if (assigned_folder_colors.is_empty()) { + ProjectSettings::get_singleton()->set_setting("file_customization/folder_colors", Variant()); + } + ProjectSettings::get_singleton()->save(); _update_tree(get_uncollapsed_paths()); @@ -2844,18 +2851,18 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str if (all_files) { if (all_files_scenes) { if (filenames.size() == 1) { - p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open Scene"), FILE_OPEN); - p_popup->add_icon_item(get_theme_icon(SNAME("CreateNewSceneFrom"), SNAME("EditorIcons")), TTR("New Inherited Scene"), FILE_INHERIT); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Open Scene"), FILE_OPEN); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("CreateNewSceneFrom")), TTR("New Inherited Scene"), FILE_INHERIT); if (GLOBAL_GET("application/run/main_scene") != filenames[0]) { - p_popup->add_icon_item(get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons")), TTR("Set As Main Scene"), FILE_MAIN_SCENE); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("PlayScene")), TTR("Set As Main Scene"), FILE_MAIN_SCENE); } } else { - p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open Scenes"), FILE_OPEN); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Open Scenes"), FILE_OPEN); } - p_popup->add_icon_item(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Instantiate"), FILE_INSTANTIATE); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("Instance")), TTR("Instantiate"), FILE_INSTANTIATE); p_popup->add_separator(); } else if (filenames.size() == 1) { - p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open"), FILE_OPEN); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Open"), FILE_OPEN); p_popup->add_separator(); } @@ -2873,22 +2880,22 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str p_popup->add_child(new_menu); p_popup->add_submenu_item(TTR("Create New"), "New", FILE_NEW); - p_popup->set_item_icon(p_popup->get_item_index(FILE_NEW), get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + p_popup->set_item_icon(p_popup->get_item_index(FILE_NEW), get_editor_theme_icon(SNAME("Add"))); - new_menu->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("Folder..."), FILE_NEW_FOLDER); - new_menu->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("Scene..."), FILE_NEW_SCENE); - new_menu->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("Script..."), FILE_NEW_SCRIPT); - new_menu->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("Resource..."), FILE_NEW_RESOURCE); - new_menu->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("TextFile..."), FILE_NEW_TEXTFILE); + new_menu->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTR("Folder..."), FILE_NEW_FOLDER); + new_menu->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTR("Scene..."), FILE_NEW_SCENE); + new_menu->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTR("Script..."), FILE_NEW_SCRIPT); + new_menu->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTR("Resource..."), FILE_NEW_RESOURCE); + new_menu->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTR("TextFile..."), FILE_NEW_TEXTFILE); p_popup->add_separator(); } if (all_folders && foldernames.size() > 0) { - p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Expand Folder"), FILE_OPEN); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Expand Folder"), FILE_OPEN); if (foldernames.size() == 1) { - p_popup->add_icon_item(get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")), TTR("Expand Hierarchy"), FOLDER_EXPAND_ALL); - p_popup->add_icon_item(get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")), TTR("Collapse Hierarchy"), FOLDER_COLLAPSE_ALL); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("GuiTreeArrowDown")), TTR("Expand Hierarchy"), FOLDER_EXPAND_ALL); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("GuiTreeArrowRight")), TTR("Collapse Hierarchy"), FOLDER_COLLAPSE_ALL); } p_popup->add_separator(); @@ -2900,14 +2907,14 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str p_popup->add_child(folder_colors_menu); p_popup->add_submenu_item(TTR("Set Folder Color..."), "FolderColor"); - p_popup->set_item_icon(-1, get_theme_icon(SNAME("CanvasItem"), SNAME("EditorIcons"))); + p_popup->set_item_icon(-1, get_editor_theme_icon(SNAME("CanvasItem"))); - folder_colors_menu->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("Default (Reset)")); + folder_colors_menu->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTR("Default (Reset)")); folder_colors_menu->set_item_icon_modulate(0, get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog"))); folder_colors_menu->add_separator(); for (const KeyValue<String, Color> &E : folder_colors) { - folder_colors_menu->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR(E.key.capitalize())); + folder_colors_menu->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTR(E.key.capitalize())); folder_colors_menu->set_item_icon_modulate(-1, editor_is_dark_theme ? E.value : E.value * 2); folder_colors_menu->set_item_metadata(-1, E.key); @@ -2916,29 +2923,29 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str } if (p_paths.size() == 1) { - p_popup->add_icon_shortcut(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH); + p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionCopy")), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH); if (ResourceLoader::get_resource_uid(p_paths[0]) != ResourceUID::INVALID_ID) { - p_popup->add_icon_shortcut(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/copy_uid"), FILE_COPY_UID); + p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Instance")), ED_GET_SHORTCUT("filesystem_dock/copy_uid"), FILE_COPY_UID); } if (p_paths[0] != "res://") { - p_popup->add_icon_shortcut(get_theme_icon(SNAME("Rename"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/rename"), FILE_RENAME); - p_popup->add_icon_shortcut(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/duplicate"), FILE_DUPLICATE); + p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Rename")), ED_GET_SHORTCUT("filesystem_dock/rename"), FILE_RENAME); + p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Duplicate")), ED_GET_SHORTCUT("filesystem_dock/duplicate"), FILE_DUPLICATE); } } if (p_paths.size() > 1 || p_paths[0] != "res://") { - p_popup->add_icon_item(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), TTR("Move/Duplicate To..."), FILE_MOVE); - p_popup->add_icon_shortcut(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/delete"), FILE_REMOVE); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("MoveUp")), TTR("Move/Duplicate To..."), FILE_MOVE); + p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Remove")), ED_GET_SHORTCUT("filesystem_dock/delete"), FILE_REMOVE); } p_popup->add_separator(); if (p_paths.size() >= 1) { if (!all_favorites) { - p_popup->add_icon_item(get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")), TTR("Add to Favorites"), FILE_ADD_FAVORITE); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("Favorites")), TTR("Add to Favorites"), FILE_ADD_FAVORITE); } if (!all_not_favorites) { - p_popup->add_icon_item(get_theme_icon(SNAME("NonFavorite"), SNAME("EditorIcons")), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("NonFavorite")), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE); } { @@ -2968,7 +2975,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str } if (resource_valid) { - p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Reimport"), FILE_REIMPORT); + p_popup->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Reimport"), FILE_REIMPORT); } } } @@ -2982,10 +2989,10 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str // Opening the system file manager is not supported on the Android and web editors. const bool is_directory = fpath.ends_with("/"); const String item_text = is_directory ? TTR("Open in File Manager") : TTR("Show in File Manager"); - p_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER); + p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Filesystem")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER); p_popup->set_item_text(p_popup->get_item_index(FILE_SHOW_IN_EXPLORER), item_text); if (!is_directory) { - p_popup->add_icon_shortcut(get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/open_in_external_program"), FILE_OPEN_EXTERNAL); + p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("ExternalLink")), ED_GET_SHORTCUT("filesystem_dock/open_in_external_program"), FILE_OPEN_EXTERNAL); } #endif @@ -3022,15 +3029,15 @@ void FileSystemDock::_tree_empty_click(const Vector2 &p_pos, MouseButton p_butto current_path = "res://"; tree_popup->clear(); tree_popup->reset_size(); - tree_popup->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("New Folder..."), FILE_NEW_FOLDER); - tree_popup->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("New Scene..."), FILE_NEW_SCENE); - tree_popup->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("New Script..."), FILE_NEW_SCRIPT); - tree_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); - tree_popup->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("New TextFile..."), FILE_NEW_TEXTFILE); + tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTR("New Folder..."), FILE_NEW_FOLDER); + tree_popup->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTR("New Scene..."), FILE_NEW_SCENE); + tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTR("New Script..."), FILE_NEW_SCRIPT); + tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTR("New Resource..."), FILE_NEW_RESOURCE); + tree_popup->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTR("New TextFile..."), FILE_NEW_TEXTFILE); #if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED) // Opening the system file manager is not supported on the Android and web editors. tree_popup->add_separator(); - tree_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER); + tree_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Filesystem")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER); #endif tree_popup->set_position(tree->get_screen_position() + p_pos); @@ -3086,13 +3093,13 @@ void FileSystemDock::_file_list_empty_clicked(const Vector2 &p_pos, MouseButton file_list_popup->clear(); file_list_popup->reset_size(); - file_list_popup->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("New Folder..."), FILE_NEW_FOLDER); - file_list_popup->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("New Scene..."), FILE_NEW_SCENE); - file_list_popup->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("New Script..."), FILE_NEW_SCRIPT); - file_list_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); - file_list_popup->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("New TextFile..."), FILE_NEW_TEXTFILE); + file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTR("New Folder..."), FILE_NEW_FOLDER); + file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTR("New Scene..."), FILE_NEW_SCENE); + file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTR("New Script..."), FILE_NEW_SCRIPT); + file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTR("New Resource..."), FILE_NEW_RESOURCE); + file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTR("New TextFile..."), FILE_NEW_TEXTFILE); file_list_popup->add_separator(); - file_list_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER); + file_list_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Filesystem")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER); file_list_popup->set_position(files->get_screen_position() + p_pos); file_list_popup->reset_size(); diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 4c341a6d52..3e580e5f08 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -35,6 +35,7 @@ #include "core/os/os.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" #include "scene/gui/check_box.h" @@ -685,10 +686,10 @@ void FindInFilesPanel::stop_search() { void FindInFilesPanel::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - _search_text_label->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts"))); - _search_text_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts"))); - _results_display->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts"))); - _results_display->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts"))); + _search_text_label->add_theme_font_override("font", get_theme_font(SNAME("source"), EditorStringName(EditorFonts))); + _search_text_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("source_size"), EditorStringName(EditorFonts))); + _results_display->add_theme_font_override("font", get_theme_font(SNAME("source"), EditorStringName(EditorFonts))); + _results_display->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("source_size"), EditorStringName(EditorFonts))); // Rebuild search tree. if (!_finder->get_search_text().is_empty()) { @@ -776,8 +777,8 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) { match_rect.position.y += 1 * EDSCALE; match_rect.size.y -= 2 * EDSCALE; - _results_display->draw_rect(match_rect, get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.33), false, 2.0); - _results_display->draw_rect(match_rect, get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.17), true); + _results_display->draw_rect(match_rect, get_theme_color(SNAME("accent_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.33), false, 2.0); + _results_display->draw_rect(match_rect, get_theme_color(SNAME("accent_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.17), true); // Text is drawn by Tree already. } diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 37b4654113..09e5fe790d 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -32,6 +32,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/scene_tree_editor.h" #include "editor/scene_tree_dock.h" @@ -116,7 +117,7 @@ void GroupDialog::_load_nodes(Node *p_current) { if (!can_edit(p_current, selected_group)) { node->set_selectable(0, false); - node->set_custom_color(0, groups->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + node->set_custom_color(0, groups->get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); } } @@ -210,8 +211,8 @@ void GroupDialog::_add_group(String p_name) { TreeItem *new_group = groups->create_item(groups_root); new_group->set_text(0, name); - new_group->add_button(0, groups->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), DELETE_GROUP); - new_group->add_button(0, groups->get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), COPY_GROUP); + new_group->add_button(0, groups->get_editor_theme_icon(SNAME("Remove")), DELETE_GROUP); + new_group->add_button(0, groups->get_editor_theme_icon(SNAME("ActionCopy")), COPY_GROUP); new_group->set_editable(0, true); new_group->select(0); groups->ensure_cursor_is_visible(); @@ -393,16 +394,16 @@ void GroupDialog::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { if (is_layout_rtl()) { - add_button->set_icon(groups->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); - remove_button->set_icon(groups->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + add_button->set_icon(groups->get_editor_theme_icon(SNAME("Back"))); + remove_button->set_icon(groups->get_editor_theme_icon(SNAME("Forward"))); } else { - add_button->set_icon(groups->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); - remove_button->set_icon(groups->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + add_button->set_icon(groups->get_editor_theme_icon(SNAME("Forward"))); + remove_button->set_icon(groups->get_editor_theme_icon(SNAME("Back"))); } - add_filter->set_right_icon(groups->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + add_filter->set_right_icon(groups->get_editor_theme_icon(SNAME("Search"))); add_filter->set_clear_button_enabled(true); - remove_filter->set_right_icon(groups->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + remove_filter->set_right_icon(groups->get_editor_theme_icon(SNAME("Search"))); remove_filter->set_clear_button_enabled(true); } break; } @@ -761,8 +762,8 @@ void GroupsEditor::update_tree() { item->set_text(0, gi.name); item->set_editable(0, true); if (can_be_deleted) { - item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), DELETE_GROUP); - item->add_button(0, get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), COPY_GROUP); + item->add_button(0, get_editor_theme_icon(SNAME("Remove")), DELETE_GROUP); + item->add_button(0, get_editor_theme_icon(SNAME("ActionCopy")), COPY_GROUP); } else { item->set_selectable(0, false); } diff --git a/editor/gui/editor_dir_dialog.cpp b/editor/gui/editor_dir_dialog.cpp index 9da592d639..fada434a03 100644 --- a/editor/gui/editor_dir_dialog.cpp +++ b/editor/gui/editor_dir_dialog.cpp @@ -46,7 +46,7 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p String path = p_dir->get_path(); p_item->set_metadata(0, p_dir->get_path()); - p_item->set_icon(0, tree->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + p_item->set_icon(0, tree->get_editor_theme_icon(SNAME("Folder"))); p_item->set_icon_modulate(0, tree->get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog"))); if (!p_item->get_parent()) { diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp index cf701f1e63..6e1a12073b 100644 --- a/editor/gui/editor_file_dialog.cpp +++ b/editor/gui/editor_file_dialog.cpp @@ -75,37 +75,37 @@ VBoxContainer *EditorFileDialog::get_vbox() { void EditorFileDialog::_update_theme_item_cache() { ConfirmationDialog::_update_theme_item_cache(); - theme_cache.parent_folder = get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons")); - theme_cache.forward_folder = get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")); - theme_cache.back_folder = get_theme_icon(SNAME("Back"), SNAME("EditorIcons")); - theme_cache.reload = get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")); - theme_cache.toggle_hidden = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")); - theme_cache.favorite = get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")); - theme_cache.mode_thumbnails = get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons")); - theme_cache.mode_list = get_theme_icon(SNAME("FileList"), SNAME("EditorIcons")); - theme_cache.favorites_up = get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")); - theme_cache.favorites_down = get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")); - - theme_cache.folder = get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")); + theme_cache.parent_folder = get_editor_theme_icon(SNAME("ArrowUp")); + theme_cache.forward_folder = get_editor_theme_icon(SNAME("Forward")); + theme_cache.back_folder = get_editor_theme_icon(SNAME("Back")); + theme_cache.reload = get_editor_theme_icon(SNAME("Reload")); + theme_cache.toggle_hidden = get_editor_theme_icon(SNAME("GuiVisibilityVisible")); + theme_cache.favorite = get_editor_theme_icon(SNAME("Favorites")); + theme_cache.mode_thumbnails = get_editor_theme_icon(SNAME("FileThumbnail")); + theme_cache.mode_list = get_editor_theme_icon(SNAME("FileList")); + theme_cache.favorites_up = get_editor_theme_icon(SNAME("MoveUp")); + theme_cache.favorites_down = get_editor_theme_icon(SNAME("MoveDown")); + + theme_cache.folder = get_editor_theme_icon(SNAME("Folder")); theme_cache.folder_icon_color = get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog")); - theme_cache.action_copy = get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")); - theme_cache.action_delete = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); - theme_cache.filesystem = get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")); + theme_cache.action_copy = get_editor_theme_icon(SNAME("ActionCopy")); + theme_cache.action_delete = get_editor_theme_icon(SNAME("Remove")); + theme_cache.filesystem = get_editor_theme_icon(SNAME("Filesystem")); - theme_cache.folder_medium_thumbnail = get_theme_icon(SNAME("FolderMediumThumb"), SNAME("EditorIcons")); - theme_cache.file_medium_thumbnail = get_theme_icon(SNAME("FileMediumThumb"), SNAME("EditorIcons")); - theme_cache.folder_big_thumbnail = get_theme_icon(SNAME("FolderBigThumb"), SNAME("EditorIcons")); - theme_cache.file_big_thumbnail = get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons")); + theme_cache.folder_medium_thumbnail = get_editor_theme_icon(SNAME("FolderMediumThumb")); + theme_cache.file_medium_thumbnail = get_editor_theme_icon(SNAME("FileMediumThumb")); + theme_cache.folder_big_thumbnail = get_editor_theme_icon(SNAME("FolderBigThumb")); + theme_cache.file_big_thumbnail = get_editor_theme_icon(SNAME("FileBigThumb")); - theme_cache.progress[0] = get_theme_icon("Progress1", SNAME("EditorIcons")); - theme_cache.progress[1] = get_theme_icon("Progress2", SNAME("EditorIcons")); - theme_cache.progress[2] = get_theme_icon("Progress3", SNAME("EditorIcons")); - theme_cache.progress[3] = get_theme_icon("Progress4", SNAME("EditorIcons")); - theme_cache.progress[4] = get_theme_icon("Progress5", SNAME("EditorIcons")); - theme_cache.progress[5] = get_theme_icon("Progress6", SNAME("EditorIcons")); - theme_cache.progress[6] = get_theme_icon("Progress7", SNAME("EditorIcons")); - theme_cache.progress[7] = get_theme_icon("Progress8", SNAME("EditorIcons")); + theme_cache.progress[0] = get_editor_theme_icon("Progress1"); + theme_cache.progress[1] = get_editor_theme_icon("Progress2"); + theme_cache.progress[2] = get_editor_theme_icon("Progress3"); + theme_cache.progress[3] = get_editor_theme_icon("Progress4"); + theme_cache.progress[4] = get_editor_theme_icon("Progress5"); + theme_cache.progress[5] = get_editor_theme_icon("Progress6"); + theme_cache.progress[6] = get_editor_theme_icon("Progress7"); + theme_cache.progress[7] = get_editor_theme_icon("Progress8"); } void EditorFileDialog::_notification(int p_what) { @@ -1535,7 +1535,7 @@ void EditorFileDialog::_recent_selected(int p_idx) { } void EditorFileDialog::_go_up() { - dir_access->change_dir(get_current_dir().get_base_dir()); + dir_access->change_dir(get_current_dir().trim_suffix("/").get_base_dir()); update_file_list(); update_dir(); _push_history(); diff --git a/editor/gui/editor_object_selector.cpp b/editor/gui/editor_object_selector.cpp index 7cc830416c..9acd38bcf4 100644 --- a/editor/gui/editor_object_selector.cpp +++ b/editor/gui/editor_object_selector.cpp @@ -33,6 +33,7 @@ #include "editor/editor_data.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/multi_node_edit.h" Size2 EditorObjectSelector::get_minimum_size() const { @@ -200,10 +201,10 @@ void EditorObjectSelector::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { update_path(); - int icon_size = get_theme_constant(SNAME("class_icon_size"), SNAME("Editor")); + int icon_size = get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)); current_object_icon->set_custom_minimum_size(Size2(icon_size, icon_size)); - current_object_label->add_theme_font_override("font", get_theme_font(SNAME("main"), SNAME("EditorFonts"))); + current_object_label->add_theme_font_override("font", get_theme_font(SNAME("main"), EditorStringName(EditorFonts))); sub_objects_icon->set_texture(get_theme_icon(SNAME("arrow"), SNAME("OptionButton"))); sub_objects_menu->add_theme_constant_override("icon_max_width", icon_size); } break; diff --git a/editor/gui/editor_run_bar.cpp b/editor/gui/editor_run_bar.cpp index e144d1d10d..4dfe40f0ad 100644 --- a/editor/gui/editor_run_bar.cpp +++ b/editor/gui/editor_run_bar.cpp @@ -37,6 +37,7 @@ #include "editor/editor_quick_open.h" #include "editor/editor_run_native.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" #include "scene/gui/panel_container.h" @@ -51,18 +52,18 @@ void EditorRunBar::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { _update_play_buttons(); - pause_button->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); - stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); + pause_button->set_icon(get_editor_theme_icon(SNAME("Pause"))); + stop_button->set_icon(get_editor_theme_icon(SNAME("Stop"))); if (is_movie_maker_enabled()) { - main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadMovieMode"), SNAME("EditorStyles"))); - write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonPressed"), SNAME("EditorStyles"))); + main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadMovieMode"), EditorStringName(EditorStyles))); + write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonPressed"), EditorStringName(EditorStyles))); } else { - main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadNormal"), SNAME("EditorStyles"))); - write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonNormal"), SNAME("EditorStyles"))); + main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadNormal"), EditorStringName(EditorStyles))); + write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonNormal"), EditorStringName(EditorStyles))); } - write_movie_button->set_icon(get_theme_icon(SNAME("MainMovieWrite"), SNAME("EditorIcons"))); + write_movie_button->set_icon(get_editor_theme_icon(SNAME("MainMovieWrite"))); // This button behaves differently, so color it as such. write_movie_button->add_theme_color_override("icon_normal_color", Color(1, 1, 1, 0.7)); write_movie_button->add_theme_color_override("icon_pressed_color", Color(0, 0, 0, 0.84)); @@ -73,15 +74,15 @@ void EditorRunBar::_notification(int p_what) { void EditorRunBar::_reset_play_buttons() { play_button->set_pressed(false); - play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); play_button->set_tooltip_text(TTR("Play the project.")); play_scene_button->set_pressed(false); - play_scene_button->set_icon(get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons"))); + play_scene_button->set_icon(get_editor_theme_icon(SNAME("PlayScene"))); play_scene_button->set_tooltip_text(TTR("Play the edited scene.")); play_custom_scene_button->set_pressed(false); - play_custom_scene_button->set_icon(get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons"))); + play_custom_scene_button->set_icon(get_editor_theme_icon(SNAME("PlayCustom"))); play_custom_scene_button->set_tooltip_text(TTR("Play a custom scene.")); } @@ -102,18 +103,18 @@ void EditorRunBar::_update_play_buttons() { if (active_button) { active_button->set_pressed(true); - active_button->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + active_button->set_icon(get_editor_theme_icon(SNAME("Reload"))); active_button->set_tooltip_text(TTR("Reload the played scene.")); } } void EditorRunBar::_write_movie_toggled(bool p_enabled) { if (p_enabled) { - add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadMovieMode"), SNAME("EditorStyles"))); - write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonPressed"), SNAME("EditorStyles"))); + add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadMovieMode"), EditorStringName(EditorStyles))); + write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonPressed"), EditorStringName(EditorStyles))); } else { - add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadNormal"), SNAME("EditorStyles"))); - write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonNormal"), SNAME("EditorStyles"))); + add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadNormal"), EditorStringName(EditorStyles))); + write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonNormal"), EditorStringName(EditorStyles))); } } diff --git a/editor/gui/editor_scene_tabs.cpp b/editor/gui/editor_scene_tabs.cpp index 553c45bd7f..a11d3e7b6a 100644 --- a/editor/gui/editor_scene_tabs.cpp +++ b/editor/gui/editor_scene_tabs.cpp @@ -34,6 +34,7 @@ #include "editor/editor_resource_preview.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/inspector_dock.h" #include "scene/gui/box_container.h" @@ -50,9 +51,9 @@ void EditorSceneTabs::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { tabbar_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("tabbar_background"), SNAME("TabContainer"))); - scene_tabs->add_theme_constant_override("icon_max_width", get_theme_constant(SNAME("class_icon_size"), SNAME("Editor"))); + scene_tabs->add_theme_constant_override("icon_max_width", get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor))); - scene_tab_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + scene_tab_add->set_icon(get_editor_theme_icon(SNAME("Add"))); scene_tab_add->add_theme_color_override("icon_normal_color", Color(0.6f, 0.6f, 0.6f, 0.8f)); scene_tab_add_ph->set_custom_minimum_size(scene_tab_add->get_minimum_size()); @@ -213,7 +214,7 @@ void EditorSceneTabs::update_scene_tabs() { scene_tabs->disconnect("tab_changed", callable_mp(this, &EditorSceneTabs::_scene_tab_changed)); scene_tabs->clear_tabs(); - Ref<Texture2D> script_icon = get_theme_icon(SNAME("Script"), SNAME("EditorIcons")); + Ref<Texture2D> script_icon = get_editor_theme_icon(SNAME("Script")); for (int i = 0; i < EditorNode::get_editor_data().get_edited_scene_count(); i++) { Node *type_node = EditorNode::get_editor_data().get_edited_scene_root(i); Ref<Texture2D> icon; diff --git a/editor/gui/editor_toaster.cpp b/editor/gui/editor_toaster.cpp index f928a0fd30..6a415c18da 100644 --- a/editor/gui/editor_toaster.cpp +++ b/editor/gui/editor_toaster.cpp @@ -32,6 +32,7 @@ #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/gui/button.h" #include "scene/gui/label.h" #include "scene/gui/panel_container.h" @@ -110,29 +111,29 @@ void EditorToaster::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { if (vbox_container->is_visible()) { - main_button->set_icon(get_theme_icon(SNAME("Notification"), SNAME("EditorIcons"))); + main_button->set_icon(get_editor_theme_icon(SNAME("Notification"))); } else { - main_button->set_icon(get_theme_icon(SNAME("NotificationDisabled"), SNAME("EditorIcons"))); + main_button->set_icon(get_editor_theme_icon(SNAME("NotificationDisabled"))); } - disable_notifications_button->set_icon(get_theme_icon(SNAME("NotificationDisabled"), SNAME("EditorIcons"))); + disable_notifications_button->set_icon(get_editor_theme_icon(SNAME("NotificationDisabled"))); // Styleboxes background. - info_panel_style_background->set_bg_color(get_theme_color(SNAME("base_color"), SNAME("Editor"))); + info_panel_style_background->set_bg_color(get_theme_color(SNAME("base_color"), EditorStringName(Editor))); - warning_panel_style_background->set_bg_color(get_theme_color(SNAME("base_color"), SNAME("Editor"))); - warning_panel_style_background->set_border_color(get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + warning_panel_style_background->set_bg_color(get_theme_color(SNAME("base_color"), EditorStringName(Editor))); + warning_panel_style_background->set_border_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); - error_panel_style_background->set_bg_color(get_theme_color(SNAME("base_color"), SNAME("Editor"))); - error_panel_style_background->set_border_color(get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_panel_style_background->set_bg_color(get_theme_color(SNAME("base_color"), EditorStringName(Editor))); + error_panel_style_background->set_border_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor))); // Styleboxes progress. - info_panel_style_progress->set_bg_color(get_theme_color(SNAME("base_color"), SNAME("Editor")).lightened(0.03)); + info_panel_style_progress->set_bg_color(get_theme_color(SNAME("base_color"), EditorStringName(Editor)).lightened(0.03)); - warning_panel_style_progress->set_bg_color(get_theme_color(SNAME("base_color"), SNAME("Editor")).lightened(0.03)); - warning_panel_style_progress->set_border_color(get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + warning_panel_style_progress->set_bg_color(get_theme_color(SNAME("base_color"), EditorStringName(Editor)).lightened(0.03)); + warning_panel_style_progress->set_border_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); - error_panel_style_progress->set_bg_color(get_theme_color(SNAME("base_color"), SNAME("Editor")).lightened(0.03)); - error_panel_style_progress->set_border_color(get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_panel_style_progress->set_bg_color(get_theme_color(SNAME("base_color"), EditorStringName(Editor)).lightened(0.03)); + error_panel_style_progress->set_border_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor))); main_button->queue_redraw(); disable_notifications_button->queue_redraw(); @@ -270,13 +271,13 @@ void EditorToaster::_draw_button() { real_t button_radius = main_button->get_size().x / 8; switch (highest_severity) { case SEVERITY_INFO: - color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); break; case SEVERITY_WARNING: - color = get_theme_color(SNAME("warning_color"), SNAME("Editor")); + color = get_theme_color(SNAME("warning_color"), EditorStringName(Editor)); break; case SEVERITY_ERROR: - color = get_theme_color(SNAME("error_color"), SNAME("Editor")); + color = get_theme_color(SNAME("error_color"), EditorStringName(Editor)); break; default: break; @@ -310,9 +311,9 @@ void EditorToaster::_draw_progress(Control *panel) { void EditorToaster::_set_notifications_enabled(bool p_enabled) { vbox_container->set_visible(p_enabled); if (p_enabled) { - main_button->set_icon(get_theme_icon(SNAME("Notification"), SNAME("EditorIcons"))); + main_button->set_icon(get_editor_theme_icon(SNAME("Notification"))); } else { - main_button->set_icon(get_theme_icon(SNAME("NotificationDisabled"), SNAME("EditorIcons"))); + main_button->set_icon(get_editor_theme_icon(SNAME("NotificationDisabled"))); } _update_disable_notifications_button(); } @@ -374,7 +375,7 @@ Control *EditorToaster::popup(Control *p_control, Severity p_severity, double p_ if (p_time > 0.0) { Button *close_button = memnew(Button); close_button->set_flat(true); - close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + close_button->set_icon(get_editor_theme_icon(SNAME("Close"))); close_button->connect("pressed", callable_mp(this, &EditorToaster::close).bind(panel)); close_button->connect("theme_changed", callable_mp(this, &EditorToaster::_close_button_theme_changed).bind(close_button)); hbox_container->add_child(close_button); @@ -490,7 +491,7 @@ void EditorToaster::close(Control *p_control) { void EditorToaster::_close_button_theme_changed(Control *p_close_button) { Button *close_button = Object::cast_to<Button>(p_close_button); if (close_button) { - close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + close_button->set_icon(get_editor_theme_icon(SNAME("Close"))); } } diff --git a/editor/gui/editor_validation_panel.cpp b/editor/gui/editor_validation_panel.cpp index af15010b78..14fe05e906 100644 --- a/editor/gui/editor_validation_panel.cpp +++ b/editor/gui/editor_validation_panel.cpp @@ -31,6 +31,7 @@ #include "editor_validation_panel.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" #include "scene/gui/label.h" @@ -52,9 +53,9 @@ void EditorValidationPanel::_update() { void EditorValidationPanel::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - theme_cache.valid_color = get_theme_color(SNAME("success_color"), SNAME("Editor")); - theme_cache.warning_color = get_theme_color(SNAME("warning_color"), SNAME("Editor")); - theme_cache.error_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); + theme_cache.valid_color = get_theme_color(SNAME("success_color"), EditorStringName(Editor)); + theme_cache.warning_color = get_theme_color(SNAME("warning_color"), EditorStringName(Editor)); + theme_cache.error_color = get_theme_color(SNAME("error_color"), EditorStringName(Editor)); } break; } } diff --git a/editor/gui/editor_zoom_widget.cpp b/editor/gui/editor_zoom_widget.cpp index 3998b33a53..e292dc99ac 100644 --- a/editor/gui/editor_zoom_widget.cpp +++ b/editor/gui/editor_zoom_widget.cpp @@ -145,8 +145,8 @@ void EditorZoomWidget::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - zoom_minus->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); - zoom_plus->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); + zoom_minus->set_icon(get_editor_theme_icon(SNAME("ZoomLess"))); + zoom_plus->set_icon(get_editor_theme_icon(SNAME("ZoomMore"))); } break; } } diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp index 0862af37b6..321d7a3545 100644 --- a/editor/gui/scene_tree_editor.cpp +++ b/editor/gui/scene_tree_editor.cpp @@ -36,6 +36,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/node_dock.h" #include "editor/plugins/animation_player_editor_plugin.h" @@ -226,19 +227,19 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { item->set_metadata(0, p_node->get_path()); if (connect_to_script_mode) { - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); Ref<Script> scr = p_node->get_script(); if (!scr.is_null() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) != scr) { //has script - item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT); + item->add_button(0, get_editor_theme_icon(SNAME("Script")), BUTTON_SCRIPT); } else { //has no script (or script is a custom type) - _set_item_custom_color(item, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + _set_item_custom_color(item, get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); item->set_selectable(0, false); if (!scr.is_null()) { // make sure to mark the script if a custom type - item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT); + item->add_button(0, get_editor_theme_icon(SNAME("Script")), BUTTON_SCRIPT); item->set_button_disabled(0, item->get_button_count(0) - 1, true); } @@ -255,7 +256,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } } else if (part_of_subscene) { if (valid_types.size() == 0) { - _set_item_custom_color(item, get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + _set_item_custom_color(item, get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); } } else if (marked.has(p_node)) { String node_name = p_node->get_name(); @@ -264,15 +265,15 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } item->set_text(0, node_name); item->set_selectable(0, marked_selectable); - _set_item_custom_color(item, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); + _set_item_custom_color(item, get_theme_color(SNAME("accent_color"), EditorStringName(Editor))); } else if (!p_node->can_process()) { - _set_item_custom_color(item, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + _set_item_custom_color(item, get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); } else if (!marked_selectable && !marked_children_selectable) { Node *node = p_node; while (node) { if (marked.has(node)) { item->set_selectable(0, false); - _set_item_custom_color(item, get_theme_color(SNAME("error_color"), SNAME("Editor"))); + _set_item_custom_color(item, get_theme_color(SNAME("error_color"), EditorStringName(Editor))); break; } node = node->get_parent(); @@ -305,11 +306,11 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { String newline = (num_warnings == 1 ? "\n" : "\n\n"); - item->add_button(0, get_theme_icon(warning_icon, SNAME("EditorIcons")), BUTTON_WARNING, false, TTR("Node configuration warning:") + newline + conf_warning); + item->add_button(0, get_editor_theme_icon(warning_icon), BUTTON_WARNING, false, TTR("Node configuration warning:") + newline + conf_warning); } if (p_node->is_unique_name_in_owner()) { - item->add_button(0, get_theme_icon(SNAME("SceneUniqueName"), SNAME("EditorIcons")), BUTTON_UNIQUE, false, vformat(TTR("This node can be accessed from within anywhere in the scene by preceding it with the '%s' prefix in a node path.\nClick to disable this."), UNIQUE_NODE_PREFIX)); + item->add_button(0, get_editor_theme_icon(SNAME("SceneUniqueName")), BUTTON_UNIQUE, false, vformat(TTR("This node can be accessed from within anywhere in the scene by preceding it with the '%s' prefix in a node path.\nClick to disable this."), UNIQUE_NODE_PREFIX)); } int num_connections = p_node->get_persistent_signal_connection_count(); @@ -345,11 +346,11 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { Ref<Texture2D> icon_temp; SceneTreeEditorButton signal_temp = BUTTON_SIGNALS; if (num_connections >= 1 && num_groups >= 1) { - icon_temp = get_theme_icon(SNAME("SignalsAndGroups"), SNAME("EditorIcons")); + icon_temp = get_editor_theme_icon(SNAME("SignalsAndGroups")); } else if (num_connections >= 1) { - icon_temp = get_theme_icon(SNAME("Signals"), SNAME("EditorIcons")); + icon_temp = get_editor_theme_icon(SNAME("Signals")); } else if (num_groups >= 1) { - icon_temp = get_theme_icon(SNAME("Groups"), SNAME("EditorIcons")); + icon_temp = get_editor_theme_icon(SNAME("Groups")); signal_temp = BUTTON_GROUPS; } @@ -364,10 +365,10 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { String tooltip = String(p_node->get_name()); if (p_node == get_scene_node() && p_node->get_scene_inherited_state().is_valid()) { - item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); + item->add_button(0, get_editor_theme_icon(SNAME("InstanceOptions")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); tooltip += String("\n" + TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path()); } else if (p_node != get_scene_node() && !p_node->get_scene_file_path().is_empty() && can_open_instance) { - item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); + item->add_button(0, get_editor_theme_icon(SNAME("InstanceOptions")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); tooltip += String("\n" + TTR("Instance:") + " " + p_node->get_scene_file_path()); } @@ -400,30 +401,30 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { // Can't set tooltip after adding button, need to do it before. if (scr->is_tool()) { additional_notes += "\n" + TTR("This script is currently running in the editor."); - button_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + button_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); } if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == scr) { additional_notes += "\n" + TTR("This script is a custom type."); button_color.a = 0.5; } - item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + scr->get_path() + additional_notes); + item->add_button(0, get_editor_theme_icon(SNAME("Script")), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + scr->get_path() + additional_notes); item->set_button_color(0, item->get_button_count(0) - 1, button_color); } if (p_node->is_class("CanvasItem")) { if (p_node->has_meta("_edit_lock_")) { - item->add_button(0, get_theme_icon(SNAME("Lock"), SNAME("EditorIcons")), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); + item->add_button(0, get_editor_theme_icon(SNAME("Lock")), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); } if (p_node->has_meta("_edit_group_")) { - item->add_button(0, get_theme_icon(SNAME("Group"), SNAME("EditorIcons")), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make them selectable.")); + item->add_button(0, get_editor_theme_icon(SNAME("Group")), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make them selectable.")); } bool v = p_node->call("is_visible"); if (v) { - item->add_button(0, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_editor_theme_icon(SNAME("GuiVisibilityVisible")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } else { - item->add_button(0, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_editor_theme_icon(SNAME("GuiVisibilityHidden")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) { @@ -434,9 +435,9 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } else if (p_node->is_class("CanvasLayer") || p_node->is_class("Window")) { bool v = p_node->call("is_visible"); if (v) { - item->add_button(0, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_editor_theme_icon(SNAME("GuiVisibilityVisible")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } else { - item->add_button(0, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_editor_theme_icon(SNAME("GuiVisibilityHidden")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) { @@ -444,18 +445,18 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } } else if (p_node->is_class("Node3D")) { if (p_node->has_meta("_edit_lock_")) { - item->add_button(0, get_theme_icon(SNAME("Lock"), SNAME("EditorIcons")), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); + item->add_button(0, get_editor_theme_icon(SNAME("Lock")), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); } if (p_node->has_meta("_edit_group_")) { - item->add_button(0, get_theme_icon(SNAME("Group"), SNAME("EditorIcons")), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make them selectable.")); + item->add_button(0, get_editor_theme_icon(SNAME("Group")), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make them selectable.")); } bool v = p_node->call("is_visible"); if (v) { - item->add_button(0, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_editor_theme_icon(SNAME("GuiVisibilityVisible")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } else { - item->add_button(0, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_editor_theme_icon(SNAME("GuiVisibilityHidden")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) { @@ -467,7 +468,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { bool is_pinned = AnimationPlayerEditor::get_singleton()->get_player() == p_node && AnimationPlayerEditor::get_singleton()->is_pinned(); if (is_pinned) { - item->add_button(0, get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin.")); + item->add_button(0, get_editor_theme_icon(SNAME("Pin")), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin.")); } } } @@ -500,7 +501,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } if (!valid) { - _set_item_custom_color(item, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + _set_item_custom_color(item, get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); item->set_selectable(0, false); } } @@ -530,9 +531,9 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) { } if (node_visible) { - item->set_button(0, idx, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); + item->set_button(0, idx, get_editor_theme_icon(SNAME("GuiVisibilityVisible"))); } else { - item->set_button(0, idx, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"))); + item->set_button(0, idx, get_editor_theme_icon(SNAME("GuiVisibilityHidden"))); } _update_visibility_color(p_node, item); @@ -674,7 +675,7 @@ bool SceneTreeEditor::_update_filter(TreeItem *p_parent, bool p_scroll_to_select } p_parent->set_selectable(0, true); } else if (keep_for_children) { - p_parent->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + p_parent->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); p_parent->set_selectable(0, false); p_parent->deselect(0); } @@ -905,7 +906,7 @@ void SceneTreeEditor::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - tree->add_theme_constant_override("icon_max_width", get_theme_constant(SNAME("class_icon_size"), SNAME("Editor"))); + tree->add_theme_constant_override("icon_max_width", get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor))); _update_tree(); } break; @@ -1238,7 +1239,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from if (i < list_max) { HBoxContainer *hb = memnew(HBoxContainer); TextureRect *tf = memnew(TextureRect); - int icon_size = get_theme_constant(SNAME("class_icon_size"), SNAME("Editor")); + int icon_size = get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)); tf->set_custom_minimum_size(Size2(icon_size, icon_size)); tf->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); tf->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE); @@ -1563,9 +1564,9 @@ void SceneTreeDialog::set_valid_types(const Vector<StringName> &p_valid) { } void SceneTreeDialog::_update_theme() { - filter->set_right_icon(tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + filter->set_right_icon(tree->get_editor_theme_icon(SNAME("Search"))); for (TextureRect *trect : valid_type_icons) { - trect->set_custom_minimum_size(Vector2(get_theme_constant(SNAME("class_icon_size"), SNAME("Editor")), 0)); + trect->set_custom_minimum_size(Vector2(get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)), 0)); trect->set_texture(EditorNode::get_singleton()->get_class_icon(trect->get_meta("type"))); } } diff --git a/editor/history_dock.cpp b/editor/history_dock.cpp index 41ca519400..0ec840b8f1 100644 --- a/editor/history_dock.cpp +++ b/editor/history_dock.cpp @@ -31,6 +31,7 @@ #include "history_dock.h" #include "editor/editor_node.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "scene/gui/check_box.h" #include "scene/gui/item_list.h" @@ -100,7 +101,7 @@ void HistoryDock::refresh_history() { for (const EditorUndoRedoManager::Action &E : full_history) { action_list->add_item(E.action_name); if (E.history_id == EditorUndoRedoManager::GLOBAL_HISTORY) { - action_list->set_item_custom_fg_color(-1, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); + action_list->set_item_custom_fg_color(-1, get_theme_color(SNAME("accent_color"), EditorStringName(Editor))); } } diff --git a/editor/import/audio_stream_import_settings.cpp b/editor/import/audio_stream_import_settings.cpp index 1f7fbd8c59..c77143c8ac 100644 --- a/editor/import/audio_stream_import_settings.cpp +++ b/editor/import/audio_stream_import_settings.cpp @@ -32,6 +32,7 @@ #include "editor/audio_stream_preview.h" #include "editor/editor_file_system.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "scene/gui/check_box.h" AudioStreamImportSettings *AudioStreamImportSettings::singleton = nullptr; @@ -45,18 +46,18 @@ void AudioStreamImportSettings::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { - _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); - _stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); - _preview->set_color(get_theme_color(SNAME("dark_color_2"), SNAME("Editor"))); - color_rect->set_color(get_theme_color(SNAME("dark_color_1"), SNAME("Editor"))); - _current_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); - _current_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); - _duration_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); - _duration_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); - - zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); - zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); - zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); + _play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); + _stop_button->set_icon(get_editor_theme_icon(SNAME("Stop"))); + _preview->set_color(get_theme_color(SNAME("dark_color_2"), EditorStringName(Editor))); + color_rect->set_color(get_theme_color(SNAME("dark_color_1"), EditorStringName(Editor))); + _current_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts))); + _current_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), EditorStringName(EditorFonts))); + _duration_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts))); + _duration_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), EditorStringName(EditorFonts))); + + zoom_in->set_icon(get_editor_theme_icon(SNAME("ZoomMore"))); + zoom_out->set_icon(get_editor_theme_icon(SNAME("ZoomLess"))); + zoom_reset->set_icon(get_editor_theme_icon(SNAME("ZoomReset"))); _indicator->queue_redraw(); _preview->queue_redraw(); @@ -84,11 +85,11 @@ void AudioStreamImportSettings::_draw_preview() { float preview_offset = zoom_bar->get_value(); float preview_len = zoom_bar->get_page(); - Ref<Font> beat_font = get_theme_font(SNAME("main"), SNAME("EditorFonts")); - int main_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts")); + Ref<Font> beat_font = get_theme_font(SNAME("main"), EditorStringName(EditorFonts)); + int main_size = get_theme_font_size(SNAME("main_size"), EditorStringName(EditorFonts)); Vector<Vector2> points; points.resize(width * 2); - Color color_active = get_theme_color(SNAME("contrast_color_2"), SNAME("Editor")); + Color color_active = get_theme_color(SNAME("contrast_color_2"), EditorStringName(Editor)); Color color_inactive = color_active; color_inactive.a *= 0.5; Vector<Color> colors; @@ -226,25 +227,25 @@ void AudioStreamImportSettings::_play() { // '_pausing' variable indicates that we want to pause the audio player, not stop it. See '_on_finished()'. _pausing = true; _player->stop(); - _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + _play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); set_process(false); } else { _player->play(_current); - _play_button->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + _play_button->set_icon(get_editor_theme_icon(SNAME("Pause"))); set_process(true); } } void AudioStreamImportSettings::_stop() { _player->stop(); - _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + _play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); _current = 0; _indicator->queue_redraw(); set_process(false); } void AudioStreamImportSettings::_on_finished() { - _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + _play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); if (!_pausing) { _current = 0; _indicator->queue_redraw(); @@ -261,8 +262,8 @@ void AudioStreamImportSettings::_draw_indicator() { Rect2 rect = _preview->get_rect(); - Ref<Font> beat_font = get_theme_font(SNAME("main"), SNAME("EditorFonts")); - int main_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts")); + Ref<Font> beat_font = get_theme_font(SNAME("main"), EditorStringName(EditorFonts)); + int main_size = get_theme_font_size(SNAME("main_size"), EditorStringName(EditorFonts)); if (stream->get_bpm() > 0) { int y_ofs = beat_font->get_height(main_size) + 4 * EDSCALE; @@ -275,11 +276,11 @@ void AudioStreamImportSettings::_draw_indicator() { return; } - const Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); _indicator->draw_line(Point2(ofs_x, rect.position.y), Point2(ofs_x, rect.position.y + rect.size.height), color, Math::round(2 * EDSCALE)); _indicator->draw_texture( - get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons")), - Point2(ofs_x - get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons"))->get_width() * 0.5, rect.position.y), + get_editor_theme_icon(SNAME("TimelineIndicator")), + Point2(ofs_x - get_editor_theme_icon(SNAME("TimelineIndicator"))->get_width() * 0.5, rect.position.y), color); if (stream->get_bpm() > 0 && _hovering_beat != -1) { @@ -316,8 +317,8 @@ void AudioStreamImportSettings::_on_input_indicator(Ref<InputEvent> p_event) { const Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) { if (stream->get_bpm() > 0) { - int main_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts")); - Ref<Font> beat_font = get_theme_font(SNAME("main"), SNAME("EditorFonts")); + int main_size = get_theme_font_size(SNAME("main_size"), EditorStringName(EditorFonts)); + Ref<Font> beat_font = get_theme_font(SNAME("main"), EditorStringName(EditorFonts)); int y_ofs = beat_font->get_height(main_size) + 4 * EDSCALE; if ((!_dragging && mb->get_position().y < y_ofs) || _beat_len_dragging) { if (mb->is_pressed()) { @@ -345,8 +346,8 @@ void AudioStreamImportSettings::_on_input_indicator(Ref<InputEvent> p_event) { _set_beat_len_to(mm->get_position().x); } if (stream->get_bpm() > 0) { - int main_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts")); - Ref<Font> beat_font = get_theme_font(SNAME("main"), SNAME("EditorFonts")); + int main_size = get_theme_font_size(SNAME("main_size"), EditorStringName(EditorFonts)); + Ref<Font> beat_font = get_theme_font(SNAME("main"), EditorStringName(EditorFonts)); int y_ofs = beat_font->get_height(main_size) + 4 * EDSCALE; if (mm->get_position().y < y_ofs) { int new_hovering_beat = _get_beat_at_pos(mm->get_position().x); diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index 1ee795f7d8..8a385aaf82 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -38,6 +38,7 @@ #include "editor/editor_property_name_processor.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_file_dialog.h" /*************************************************************************/ @@ -499,7 +500,7 @@ void DynamicFontImportSettings::_variation_add() { vars_item->set_text(0, TTR("New Configuration")); vars_item->set_editable(0, true); - vars_item->add_button(1, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove Variation")); + vars_item->add_button(1, get_editor_theme_icon(SNAME("Remove")), BUTTON_REMOVE_VAR, false, TTR("Remove Variation")); vars_item->set_button_color(1, 0, Color(1, 1, 1, 0.75)); Ref<DynamicFontImportSettingsData> import_variation_data; @@ -726,8 +727,8 @@ void DynamicFontImportSettings::_glyph_selected() { TreeItem *item = glyph_table->get_selected(); ERR_FAIL_NULL(item); - Color scol = glyph_table->get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor")); - Color fcol = glyph_table->get_theme_color(SNAME("font_selected_color"), SNAME("Editor")); + Color scol = glyph_table->get_theme_color(SNAME("box_selection_fill_color"), EditorStringName(Editor)); + Color fcol = glyph_table->get_theme_color(SNAME("font_selected_color"), EditorStringName(Editor)); scol.a = 1.f; int32_t c = item->get_metadata(glyph_table->get_selected_column()); @@ -798,8 +799,8 @@ void DynamicFontImportSettings::_edit_range(int32_t p_start, int32_t p_end) { TreeItem *root = glyph_table->create_item(); ERR_FAIL_NULL(root); - Color scol = glyph_table->get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor")); - Color fcol = glyph_table->get_theme_color(SNAME("font_selected_color"), SNAME("Editor")); + Color scol = glyph_table->get_theme_color(SNAME("box_selection_fill_color"), EditorStringName(Editor)); + Color fcol = glyph_table->get_theme_color(SNAME("font_selected_color"), EditorStringName(Editor)); scol.a = 1.f; TreeItem *item = nullptr; @@ -814,7 +815,7 @@ void DynamicFontImportSettings::_edit_range(int32_t p_start, int32_t p_end) { item->set_text(0, _pad_zeros(String::num_int64(c, 16))); item->set_text_alignment(0, HORIZONTAL_ALIGNMENT_LEFT); item->set_selectable(0, false); - item->set_custom_bg_color(0, glyph_table->get_theme_color(SNAME("dark_color_3"), SNAME("Editor"))); + item->set_custom_bg_color(0, glyph_table->get_theme_color(SNAME("dark_color_3"), EditorStringName(Editor))); } if (font_main->has_char(c)) { item->set_text(col + 1, String::chr(c)); @@ -827,7 +828,7 @@ void DynamicFontImportSettings::_edit_range(int32_t p_start, int32_t p_end) { item->clear_custom_bg_color(col + 1); } } else { - item->set_custom_bg_color(col + 1, glyph_table->get_theme_color(SNAME("dark_color_2"), SNAME("Editor"))); + item->set_custom_bg_color(col + 1, glyph_table->get_theme_color(SNAME("dark_color_2"), EditorStringName(Editor))); } item->set_metadata(col + 1, c); item->set_text_alignment(col + 1, HORIZONTAL_ALIGNMENT_CENTER); @@ -925,8 +926,8 @@ void DynamicFontImportSettings::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - add_var->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - label_warn->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + add_var->set_icon(get_editor_theme_icon(SNAME("Add"))); + label_warn->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); } break; } } @@ -1082,7 +1083,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { } font_preview_label->set_text(sample); - Ref<Font> bold_font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + Ref<Font> bold_font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); if (bold_font.is_valid()) { font_name_label->add_theme_font_override("bold_font", bold_font); } @@ -1159,7 +1160,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { vars_item->set_text(0, cfg_name); vars_item->set_editable(0, true); - vars_item->add_button(1, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove Variation")); + vars_item->add_button(1, get_editor_theme_icon(SNAME("Remove")), BUTTON_REMOVE_VAR, false, TTR("Remove Variation")); vars_item->set_button_color(1, 0, Color(1, 1, 1, 0.75)); Ref<DynamicFontImportSettingsData> import_variation_data_custom; diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 2142ee3c10..6b42417296 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -36,6 +36,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_file_dialog.h" #include "scene/3d/importer_mesh_instance_3d.h" #include "scene/animation/animation_player.h" @@ -170,7 +171,7 @@ void SceneImportSettings::_fill_material(Tree *p_tree, const Ref<Material> &p_ma MaterialData &material_data = material_map[import_id]; ERR_FAIL_COND(p_material != material_data.material); - Ref<Texture2D> icon = get_theme_icon(SNAME("StandardMaterial3D"), SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(SNAME("StandardMaterial3D")); TreeItem *item = p_tree->create_item(p_parent); if (p_material->get_name().is_empty()) { @@ -224,7 +225,7 @@ void SceneImportSettings::_fill_mesh(Tree *p_tree, const Ref<Mesh> &p_mesh, Tree MeshData &mesh_data = mesh_map[import_id]; - Ref<Texture2D> icon = get_theme_icon(SNAME("Mesh"), SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(SNAME("Mesh")); TreeItem *item = p_tree->create_item(p_parent); item->set_text(0, p_mesh->get_name()); @@ -274,7 +275,7 @@ void SceneImportSettings::_fill_animation(Tree *p_tree, const Ref<Animation> &p_ AnimationData &animation_data = animation_map[p_name]; - Ref<Texture2D> icon = get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(SNAME("Animation")); TreeItem *item = p_tree->create_item(p_parent); item->set_text(0, p_name); @@ -318,17 +319,17 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { String type = p_node->get_class(); - if (!has_theme_icon(type, SNAME("EditorIcons"))) { + if (!has_theme_icon(type, EditorStringName(EditorIcons))) { type = "Node3D"; } - Ref<Texture2D> icon = get_theme_icon(type, SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(type); TreeItem *item = scene_tree->create_item(p_parent_item); item->set_text(0, p_node->get_name()); if (p_node == scene) { - icon = get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + icon = get_editor_theme_icon(SNAME("PackedScene")); item->set_text(0, TTR("Scene")); } @@ -886,11 +887,11 @@ void SceneImportSettings::_play_animation() { if (animation_player->has_animation(id)) { if (animation_player->is_playing()) { animation_player->pause(); - animation_play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + animation_play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); set_process(false); } else { animation_player->play(id); - animation_play_button->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + animation_play_button->set_icon(get_editor_theme_icon(SNAME("Pause"))); set_process(true); } } @@ -899,7 +900,7 @@ void SceneImportSettings::_play_animation() { void SceneImportSettings::_stop_current_animation() { animation_pingpong = false; animation_player->stop(); - animation_play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + animation_play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); animation_slider->set_value_no_signal(0.0); set_process(false); } @@ -911,7 +912,7 @@ void SceneImportSettings::_reset_animation(const String &p_animation_name) { if (animation_player != nullptr && animation_player->is_playing()) { animation_player->stop(); } - animation_play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + animation_play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); _reset_bone_transforms(); set_process(false); @@ -933,7 +934,7 @@ void SceneImportSettings::_reset_animation(const String &p_animation_name) { animation_player->play(p_animation_name); } else { animation_player->stop(true); - animation_play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + animation_play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); animation_player->set_assigned_animation(p_animation_name); animation_player->seek(0.0, true); animation_slider->set_value_no_signal(0.0); @@ -948,7 +949,7 @@ void SceneImportSettings::_animation_slider_value_changed(double p_value) { } if (animation_player->is_playing()) { animation_player->stop(); - animation_play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + animation_play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); set_process(false); } animation_player->seek(p_value * animation_map[selected_id].animation->get_length(), true); @@ -959,7 +960,7 @@ void SceneImportSettings::_animation_finished(const StringName &p_name) { switch (loop_mode) { case Animation::LOOP_NONE: { - animation_play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + animation_play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); animation_slider->set_value_no_signal(1.0); set_process(false); } break; @@ -1145,11 +1146,11 @@ void SceneImportSettings::_notification(int p_what) { action_menu->add_theme_style_override("pressed", get_theme_stylebox("pressed", "Button")); if (animation_player != nullptr && animation_player->is_playing()) { - animation_play_button->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + animation_play_button->set_icon(get_editor_theme_icon(SNAME("Pause"))); } else { - animation_play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + animation_play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); } - animation_stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); + animation_stop_button->set_icon(get_editor_theme_icon(SNAME("Stop"))); } break; case NOTIFICATION_PROCESS: { @@ -1193,11 +1194,11 @@ void SceneImportSettings::_save_path_changed(const String &p_path) { if (FileAccess::exists(p_path)) { save_path_item->set_text(2, TTR("Warning: File exists")); save_path_item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced.")); - save_path_item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + save_path_item->set_icon(2, get_editor_theme_icon(SNAME("StatusWarning"))); } else { save_path_item->set_text(2, TTR("Will create new file")); - save_path_item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); + save_path_item->set_icon(2, get_editor_theme_icon(SNAME("StatusSuccess"))); } } @@ -1231,7 +1232,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { String name = md.material_node->get_text(0); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_icon(0, get_theme_icon(SNAME("StandardMaterial3D"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("StandardMaterial3D"))); item->set_text(0, name); if (md.has_import_id) { @@ -1253,20 +1254,20 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (FileAccess::exists(path)) { item->set_text(2, TTR("Warning: File exists")); item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced.")); - item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + item->set_icon(2, get_editor_theme_icon(SNAME("StatusWarning"))); } else { item->set_text(2, TTR("Will create new file")); - item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); + item->set_icon(2, get_editor_theme_icon(SNAME("StatusSuccess"))); } - item->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + item->add_button(1, get_editor_theme_icon(SNAME("Folder"))); } } else { item->set_text(2, TTR("No import ID")); item->set_tooltip_text(2, TTR("Material has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); - item->set_icon(2, get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); + item->set_icon(2, get_editor_theme_icon(SNAME("StatusError"))); } save_path_items.push_back(item); @@ -1284,7 +1285,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { String name = md.mesh_node->get_text(0); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_icon(0, get_theme_icon(SNAME("Mesh"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("Mesh"))); item->set_text(0, name); if (md.has_import_id) { @@ -1306,20 +1307,20 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (FileAccess::exists(path)) { item->set_text(2, TTR("Warning: File exists")); item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced on import.")); - item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + item->set_icon(2, get_editor_theme_icon(SNAME("StatusWarning"))); } else { item->set_text(2, TTR("Will save to new file")); - item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); + item->set_icon(2, get_editor_theme_icon(SNAME("StatusSuccess"))); } - item->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + item->add_button(1, get_editor_theme_icon(SNAME("Folder"))); } } else { item->set_text(2, TTR("No import ID")); item->set_tooltip_text(2, TTR("Mesh has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); - item->set_icon(2, get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); + item->set_icon(2, get_editor_theme_icon(SNAME("StatusError"))); } save_path_items.push_back(item); @@ -1337,7 +1338,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { String name = ad.scene_node->get_text(0); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_icon(0, get_theme_icon(SNAME("Animation"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("Animation"))); item->set_text(0, name); if (ad.settings.has("save_to_file/enabled") && bool(ad.settings["save_to_file/enabled"])) { @@ -1358,14 +1359,14 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (FileAccess::exists(path)) { item->set_text(2, TTR("Warning: File exists")); item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced on import.")); - item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + item->set_icon(2, get_editor_theme_icon(SNAME("StatusWarning"))); } else { item->set_text(2, TTR("Will save to new file")); - item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); + item->set_icon(2, get_editor_theme_icon(SNAME("StatusSuccess"))); } - item->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + item->add_button(1, get_editor_theme_icon(SNAME("Folder"))); } save_path_items.push_back(item); diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 018231cda5..614047296a 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -35,6 +35,7 @@ #include "editor/editor_resource_preview.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" class ImportDockParameters : public Object { @@ -657,7 +658,7 @@ void ImportDock::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { import_opts->edit(params); - label_warning->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + label_warning->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); } break; } } @@ -670,7 +671,7 @@ void ImportDock::_set_dirty(bool p_dirty) { if (p_dirty) { // Add a dirty marker to notify the user that they should reimport the selected resource to see changes. import->set_text(TTR("Reimport") + " (*)"); - import->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + import->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); import->set_tooltip_text(TTR("You have pending changes that haven't been applied yet. Click Reimport to apply changes made to the import options.\nSelecting another resource in the FileSystem dock without clicking Reimport first will discard changes made in the Import dock.")); } else { // Remove the dirty marker on the Reimport button. diff --git a/editor/input_event_configuration_dialog.cpp b/editor/input_event_configuration_dialog.cpp index 430e81466e..724ad9370b 100644 --- a/editor/input_event_configuration_dialog.cpp +++ b/editor/input_event_configuration_dialog.cpp @@ -31,6 +31,7 @@ #include "editor/input_event_configuration_dialog.h" #include "core/input/input_map.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/event_listener_line_edit.h" #include "scene/gui/check_box.h" #include "scene/gui/line_edit.h" @@ -554,18 +555,18 @@ void InputEventConfigurationDialog::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - input_list_search->set_right_icon(input_list_search->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + input_list_search->set_right_icon(input_list_search->get_editor_theme_icon(SNAME("Search"))); - key_mode->set_item_icon(KEYMODE_KEYCODE, get_theme_icon(SNAME("Keyboard"), SNAME("EditorIcons"))); - key_mode->set_item_icon(KEYMODE_PHY_KEYCODE, get_theme_icon(SNAME("KeyboardPhysical"), SNAME("EditorIcons"))); - key_mode->set_item_icon(KEYMODE_UNICODE, get_theme_icon(SNAME("KeyboardLabel"), SNAME("EditorIcons"))); + key_mode->set_item_icon(KEYMODE_KEYCODE, get_editor_theme_icon(SNAME("Keyboard"))); + key_mode->set_item_icon(KEYMODE_PHY_KEYCODE, get_editor_theme_icon(SNAME("KeyboardPhysical"))); + key_mode->set_item_icon(KEYMODE_UNICODE, get_editor_theme_icon(SNAME("KeyboardLabel"))); - icon_cache.keyboard = get_theme_icon(SNAME("Keyboard"), SNAME("EditorIcons")); - icon_cache.mouse = get_theme_icon(SNAME("Mouse"), SNAME("EditorIcons")); - icon_cache.joypad_button = get_theme_icon(SNAME("JoyButton"), SNAME("EditorIcons")); - icon_cache.joypad_axis = get_theme_icon(SNAME("JoyAxis"), SNAME("EditorIcons")); + icon_cache.keyboard = get_editor_theme_icon(SNAME("Keyboard")); + icon_cache.mouse = get_editor_theme_icon(SNAME("Mouse")); + icon_cache.joypad_button = get_editor_theme_icon(SNAME("JoyButton")); + icon_cache.joypad_axis = get_editor_theme_icon(SNAME("JoyAxis")); - event_as_text->add_theme_font_override("font", get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); + event_as_text->add_theme_font_override("font", get_theme_font(SNAME("bold"), EditorStringName(EditorFonts))); _update_input_list(); } break; diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 39ed7d869b..ac06841b30 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -33,6 +33,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/filesystem_dock.h" #include "editor/gui/editor_file_dialog.h" @@ -424,33 +425,33 @@ void InspectorDock::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { - resource_new_button->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons"))); - resource_load_button->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); - resource_save_button->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); - resource_extra_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - open_docs_button->set_icon(get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons"))); + resource_new_button->set_icon(get_editor_theme_icon(SNAME("New"))); + resource_load_button->set_icon(get_editor_theme_icon(SNAME("Load"))); + resource_save_button->set_icon(get_editor_theme_icon(SNAME("Save"))); + resource_extra_button->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); + open_docs_button->set_icon(get_editor_theme_icon(SNAME("HelpSearch"))); PopupMenu *resource_extra_popup = resource_extra_button->get_popup(); - resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons"))); - resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_COPY), get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); + resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), get_editor_theme_icon(SNAME("ActionPaste"))); + resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_COPY), get_editor_theme_icon(SNAME("ActionCopy"))); if (is_layout_rtl()) { - backward_button->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); - forward_button->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + backward_button->set_icon(get_editor_theme_icon(SNAME("Forward"))); + forward_button->set_icon(get_editor_theme_icon(SNAME("Back"))); } else { - backward_button->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); - forward_button->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + backward_button->set_icon(get_editor_theme_icon(SNAME("Back"))); + forward_button->set_icon(get_editor_theme_icon(SNAME("Forward"))); } - history_menu->set_icon(get_theme_icon(SNAME("History"), SNAME("EditorIcons"))); - object_menu->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); - search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + history_menu->set_icon(get_editor_theme_icon(SNAME("History"))); + object_menu->set_icon(get_editor_theme_icon(SNAME("Tools"))); + search->set_right_icon(get_editor_theme_icon(SNAME("Search"))); if (info_is_warning) { - info->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); - info->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + info->set_icon(get_editor_theme_icon(SNAME("NodeWarning"))); + info->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); } else { - info->set_icon(get_theme_icon(SNAME("NodeInfo"), SNAME("EditorIcons"))); - info->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("Editor"))); + info->set_icon(get_editor_theme_icon(SNAME("NodeInfo"))); + info->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), EditorStringName(Editor))); } } break; } @@ -485,11 +486,11 @@ void InspectorDock::set_info(const String &p_button_text, const String &p_messag info_is_warning = p_is_warning; if (info_is_warning) { - info->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); - info->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + info->set_icon(get_editor_theme_icon(SNAME("NodeWarning"))); + info->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); } else { - info->set_icon(get_theme_icon(SNAME("NodeInfo"), SNAME("EditorIcons"))); - info->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("Editor"))); + info->set_icon(get_editor_theme_icon(SNAME("NodeInfo"))); + info->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), EditorStringName(Editor))); } if (!p_button_text.is_empty() && !p_message.is_empty()) { @@ -540,8 +541,8 @@ void InspectorDock::update(Object *p_object) { PopupMenu *p = object_menu->get_popup(); p->clear(); - p->add_icon_shortcut(get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/expand_all", TTR("Expand All")), EXPAND_ALL); - p->add_icon_shortcut(get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/collapse_all", TTR("Collapse All")), COLLAPSE_ALL); + p->add_icon_shortcut(get_editor_theme_icon(SNAME("GuiTreeArrowDown")), ED_SHORTCUT("property_editor/expand_all", TTR("Expand All")), EXPAND_ALL); + p->add_icon_shortcut(get_editor_theme_icon(SNAME("GuiTreeArrowRight")), ED_SHORTCUT("property_editor/collapse_all", TTR("Collapse All")), COLLAPSE_ALL); // Calling it 'revertable' internally, because that's what the implementation is based on, but labeling it as 'non-default' because that's more user friendly, even if not 100% accurate. p->add_shortcut(ED_SHORTCUT("property_editor/expand_revertable", TTR("Expand Non-Default")), EXPAND_REVERTABLE); diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index 351986a80b..d4154d371b 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -497,7 +497,7 @@ void LocalizationEditor::update_translations() { t->set_text(0, translations[i].replace_first("res://", "")); t->set_tooltip_text(0, translations[i]); t->set_metadata(0, i); - t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); + t->add_button(0, get_editor_theme_icon(SNAME("Remove")), 0, false, TTR("Remove")); } } @@ -531,7 +531,7 @@ void LocalizationEditor::update_translations() { t->set_text(0, keys[i].replace_first("res://", "")); t->set_tooltip_text(0, keys[i]); t->set_metadata(0, keys[i]); - t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); + t->add_button(0, get_editor_theme_icon(SNAME("Remove")), 0, false, TTR("Remove")); // Display that it has been removed if this is the case. if (!FileAccess::exists(keys[i])) { @@ -555,7 +555,7 @@ void LocalizationEditor::update_translations() { t2->set_text(0, path.replace_first("res://", "")); t2->set_tooltip_text(0, path); t2->set_metadata(0, j); - t2->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); + t2->add_button(0, get_editor_theme_icon(SNAME("Remove")), 0, false, TTR("Remove")); t2->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); t2->set_text(1, TranslationServer::get_singleton()->get_locale_name(locale)); t2->set_editable(1, true); @@ -583,7 +583,7 @@ void LocalizationEditor::update_translations() { t->set_text(0, pot_translations[i].replace_first("res://", "")); t->set_tooltip_text(0, pot_translations[i]); t->set_metadata(0, i); - t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); + t->add_button(0, get_editor_theme_icon(SNAME("Remove")), 0, false, TTR("Remove")); } // New translation parser plugin might extend possible file extensions in POT generation. diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp index ebb35eedf9..6521730473 100644 --- a/editor/node_dock.cpp +++ b/editor/node_dock.cpp @@ -55,8 +55,8 @@ void NodeDock::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - connections_button->set_icon(get_theme_icon(SNAME("Signals"), SNAME("EditorIcons"))); - groups_button->set_icon(get_theme_icon(SNAME("Groups"), SNAME("EditorIcons"))); + connections_button->set_icon(get_editor_theme_icon(SNAME("Signals"))); + groups_button->set_icon(get_editor_theme_icon(SNAME("Groups"))); } break; } } diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 4375a33b4f..86653f8775 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -36,6 +36,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "scene/gui/button.h" #include "scene/gui/dialogs.h" @@ -157,9 +158,9 @@ void AbstractPolygon2DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - button_create->set_icon(get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); - button_edit->set_icon(get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); - button_delete->set_icon(get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); + button_create->set_icon(get_editor_theme_icon(SNAME("CurveCreate"))); + button_edit->set_icon(get_editor_theme_icon(SNAME("CurveEdit"))); + button_delete->set_icon(get_editor_theme_icon(SNAME("CurveDelete"))); } break; case NOTIFICATION_READY: { @@ -498,7 +499,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform(); // All polygon points are sharp, so use the sharp handle icon - const Ref<Texture2D> handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); + const Ref<Texture2D> handle = get_editor_theme_icon(SNAME("EditorPathSharpHandle")); const Vertex active_point = get_active_point(); const int n_polygons = _get_polygon_count(); @@ -571,12 +572,12 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, overlay_modulate); if (vertex == hover_point) { - Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); String num = String::num(vertex.vertex); Size2 num_size = font->get_string_size(num, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size); const float outline_size = 4; - Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + Color font_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); Color outline_color = font_color.inverted(); p_overlay->draw_string_outline(font, point - num_size * 0.5, num, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, outline_size, outline_color); p_overlay->draw_string(font, point - num_size * 0.5, num, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color); @@ -585,7 +586,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl } if (edge_point.valid()) { - Ref<Texture2D> add_handle = get_theme_icon(SNAME("EditorHandleAdd"), SNAME("EditorIcons")); + Ref<Texture2D> add_handle = get_editor_theme_icon(SNAME("EditorHandleAdd")); p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5); } } diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 15fa60f11b..373a927ef9 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -34,6 +34,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_file_dialog.h" #include "scene/animation/animation_blend_tree.h" @@ -85,7 +86,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven ap->get_animation_list(&names); for (const StringName &E : names) { - animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); + animations_menu->add_icon_item(get_editor_theme_icon(SNAME("Animation")), E); animations_to_add.push_back(E); } } @@ -224,13 +225,13 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); - Ref<Texture2D> icon = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")); - Ref<Texture2D> icon_selected = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(SNAME("KeyValue")); + Ref<Texture2D> icon_selected = get_editor_theme_icon(SNAME("KeySelected")); Size2 s = blend_space_draw->get_size(); if (blend_space_draw->has_focus()) { - Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); blend_space_draw->draw_rect(Rect2(Point2(), s), color, false); } @@ -303,7 +304,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { { Color color; if (tool_blend->is_pressed()) { - color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); } else { color = linecolor; color.a *= 0.5; @@ -575,18 +576,18 @@ void AnimationNodeBlendSpace1DEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); - tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); - tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); - open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + tool_blend->set_icon(get_editor_theme_icon(SNAME("EditPivot"))); + tool_select->set_icon(get_editor_theme_icon(SNAME("ToolSelect"))); + tool_create->set_icon(get_editor_theme_icon(SNAME("EditKey"))); + tool_erase->set_icon(get_editor_theme_icon(SNAME("Remove"))); + snap->set_icon(get_editor_theme_icon(SNAME("SnapGrid"))); + open_editor->set_icon(get_editor_theme_icon(SNAME("Edit"))); interpolation->clear(); - interpolation->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), "", 0); - interpolation->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), "", 1); - interpolation->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), "", 2); + interpolation->add_icon_item(get_editor_theme_icon(SNAME("TrackContinuous")), "", 0); + interpolation->add_icon_item(get_editor_theme_icon(SNAME("TrackDiscrete")), "", 1); + interpolation->add_icon_item(get_editor_theme_icon(SNAME("TrackCapture")), "", 2); } break; case NOTIFICATION_PROCESS: { diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 924b948525..cd69e90660 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -38,6 +38,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_file_dialog.h" #include "scene/animation/animation_blend_tree.h" @@ -128,7 +129,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven List<StringName> names; ap->get_animation_list(&names); for (const StringName &E : names) { - animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); + animations_menu->add_icon_item(get_editor_theme_icon(SNAME("Animation")), E); animations_to_add.push_back(E); } } @@ -450,13 +451,13 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { linecolor_soft.a *= 0.5; Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); - Ref<Texture2D> icon = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")); - Ref<Texture2D> icon_selected = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(SNAME("KeyValue")); + Ref<Texture2D> icon_selected = get_editor_theme_icon(SNAME("KeySelected")); Size2 s = blend_space_draw->get_size(); if (blend_space_draw->has_focus()) { - Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); blend_space_draw->draw_rect(Rect2(Point2(), s), color, false); } blend_space_draw->draw_line(Point2(1, 0), Point2(1, s.height - 1), linecolor, Math::round(EDSCALE)); @@ -535,7 +536,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { Color color; if (i == selected_triangle) { - color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); color.a *= 0.5; } else { color = linecolor; @@ -597,7 +598,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { { Color color; if (tool_blend->is_pressed()) { - color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); } else { color = linecolor; color.a *= 0.5; @@ -796,20 +797,20 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); - tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); - tool_triangle->set_icon(get_theme_icon(SNAME("ToolTriangle"), SNAME("EditorIcons"))); - tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); - open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - auto_triangles->set_icon(get_theme_icon(SNAME("AutoTriangle"), SNAME("EditorIcons"))); + tool_blend->set_icon(get_editor_theme_icon(SNAME("EditPivot"))); + tool_select->set_icon(get_editor_theme_icon(SNAME("ToolSelect"))); + tool_create->set_icon(get_editor_theme_icon(SNAME("EditKey"))); + tool_triangle->set_icon(get_editor_theme_icon(SNAME("ToolTriangle"))); + tool_erase->set_icon(get_editor_theme_icon(SNAME("Remove"))); + snap->set_icon(get_editor_theme_icon(SNAME("SnapGrid"))); + open_editor->set_icon(get_editor_theme_icon(SNAME("Edit"))); + auto_triangles->set_icon(get_editor_theme_icon(SNAME("AutoTriangle"))); interpolation->clear(); - interpolation->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), "", 0); - interpolation->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), "", 1); - interpolation->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), "", 2); + interpolation->add_icon_item(get_editor_theme_icon(SNAME("TrackContinuous")), "", 0); + interpolation->add_icon_item(get_editor_theme_icon(SNAME("TrackDiscrete")), "", 1); + interpolation->add_icon_item(get_editor_theme_icon(SNAME("TrackCapture")), "", 2); } break; case NOTIFICATION_PROCESS: { diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 8f2839ddb0..f45b160944 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -38,6 +38,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_file_dialog.h" #include "scene/animation/animation_player.h" @@ -204,7 +205,7 @@ void AnimationNodeBlendTreeEditor::update_graph() { node->add_child(memnew(HSeparator)); Button *open_in_editor = memnew(Button); open_in_editor->set_text(TTR("Open Editor")); - open_in_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + open_in_editor->set_icon(get_editor_theme_icon(SNAME("Edit"))); node->add_child(open_in_editor); open_in_editor->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_open_in_editor).bind(E), CONNECT_DEFERRED); open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER); @@ -218,7 +219,7 @@ void AnimationNodeBlendTreeEditor::update_graph() { } else { inspect_filters->set_text(TTR("Edit Filters")); } - inspect_filters->set_icon(get_theme_icon(SNAME("AnimationFilter"), SNAME("EditorIcons"))); + inspect_filters->set_icon(get_editor_theme_icon(SNAME("AnimationFilter"))); node->add_child(inspect_filters); inspect_filters->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_inspect_filters).bind(E), CONNECT_DEFERRED); inspect_filters->set_h_size_flags(SIZE_SHRINK_CENTER); @@ -228,7 +229,7 @@ void AnimationNodeBlendTreeEditor::update_graph() { if (anim.is_valid()) { MenuButton *mb = memnew(MenuButton); mb->set_text(anim->get_animation()); - mb->set_icon(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons"))); + mb->set_icon(get_editor_theme_icon(SNAME("Animation"))); mb->set_disabled(read_only); Array options; @@ -747,7 +748,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano ti->set_text(0, F->get()); ti->set_selectable(0, false); ti->set_editable(0, false); - ti->set_icon(0, get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons"))); + ti->set_icon(0, get_editor_theme_icon(SNAME("BoneAttachment3D"))); } else { ti = parenthood[accum]; } @@ -758,7 +759,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); ti->set_text(0, concat); ti->set_checked(0, anode->is_path_filtered(path)); - ti->set_icon(0, get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons"))); + ti->set_icon(0, get_editor_theme_icon(SNAME("BoneAttachment3D"))); ti->set_metadata(0, path); } else { @@ -828,7 +829,7 @@ void AnimationNodeBlendTreeEditor::_update_editor_settings() { void AnimationNodeBlendTreeEditor::_update_theme() { error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); } void AnimationNodeBlendTreeEditor::_notification(int p_what) { diff --git a/editor/plugins/animation_library_editor.cpp b/editor/plugins/animation_library_editor.cpp index 4db4f870ca..f658b2d5e6 100644 --- a/editor/plugins/animation_library_editor.cpp +++ b/editor/plugins/animation_library_editor.cpp @@ -32,6 +32,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_file_dialog.h" @@ -73,7 +74,7 @@ void AnimationLibraryEditor::_add_library_validate(const String &p_name) { } if (error != "") { - add_library_validate->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + add_library_validate->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); add_library_validate->set_text(error); add_library_dialog->get_ok_button()->set_disabled(true); } else { @@ -86,7 +87,7 @@ void AnimationLibraryEditor::_add_library_validate(const String &p_name) { add_library_validate->set_text(TTR("Library name is valid.")); } } - add_library_validate->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor"))); + add_library_validate->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), EditorStringName(Editor))); add_library_dialog->get_ok_button()->set_disabled(false); } } @@ -622,7 +623,7 @@ void AnimationLibraryEditor::update_tree() { tree->clear(); ERR_FAIL_COND(!player); - Color ss_color = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); + Color ss_color = get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor)); TreeItem *root = tree->create_item(); TypedArray<StringName> libs = player->call("get_animation_library_list"); @@ -669,14 +670,14 @@ void AnimationLibraryEditor::update_tree() { libitem->set_editable(0, !animation_library_is_foreign); libitem->set_metadata(0, K); - libitem->set_icon(0, get_theme_icon("AnimationLibrary", "EditorIcons")); + libitem->set_icon(0, get_editor_theme_icon("AnimationLibrary")); - libitem->add_button(0, get_theme_icon("Add", "EditorIcons"), LIB_BUTTON_ADD, animation_library_is_foreign, TTR("Add Animation to Library")); - libitem->add_button(0, get_theme_icon("Load", "EditorIcons"), LIB_BUTTON_LOAD, animation_library_is_foreign, TTR("Load animation from file and add to library")); - libitem->add_button(0, get_theme_icon("ActionPaste", "EditorIcons"), LIB_BUTTON_PASTE, animation_library_is_foreign, TTR("Paste Animation to Library from clipboard")); + libitem->add_button(0, get_editor_theme_icon("Add"), LIB_BUTTON_ADD, animation_library_is_foreign, TTR("Add Animation to Library")); + libitem->add_button(0, get_editor_theme_icon("Load"), LIB_BUTTON_LOAD, animation_library_is_foreign, TTR("Load animation from file and add to library")); + libitem->add_button(0, get_editor_theme_icon("ActionPaste"), LIB_BUTTON_PASTE, animation_library_is_foreign, TTR("Paste Animation to Library from clipboard")); - libitem->add_button(1, get_theme_icon("Save", "EditorIcons"), LIB_BUTTON_FILE, false, TTR("Save animation library to resource on disk")); - libitem->add_button(1, get_theme_icon("Remove", "EditorIcons"), LIB_BUTTON_DELETE, false, TTR("Remove animation library")); + libitem->add_button(1, get_editor_theme_icon("Save"), LIB_BUTTON_FILE, false, TTR("Save animation library to resource on disk")); + libitem->add_button(1, get_editor_theme_icon("Remove"), LIB_BUTTON_DELETE, false, TTR("Remove animation library")); libitem->set_custom_bg_color(0, ss_color); @@ -687,8 +688,8 @@ void AnimationLibraryEditor::update_tree() { anitem->set_text(0, L); anitem->set_editable(0, !animation_library_is_foreign); anitem->set_metadata(0, L); - anitem->set_icon(0, get_theme_icon("Animation", "EditorIcons")); - anitem->add_button(0, get_theme_icon("ActionCopy", "EditorIcons"), ANIM_BUTTON_COPY, animation_library_is_foreign, TTR("Copy animation to clipboard")); + anitem->set_icon(0, get_editor_theme_icon("Animation")); + anitem->add_button(0, get_editor_theme_icon("ActionCopy"), ANIM_BUTTON_COPY, animation_library_is_foreign, TTR("Copy animation to clipboard")); Ref<Animation> anim = al->get_animation(L); String anim_path = anim->get_path(); @@ -715,8 +716,8 @@ void AnimationLibraryEditor::update_tree() { anitem->set_text(1, anim_path.get_file()); } } - anitem->add_button(1, get_theme_icon("Save", "EditorIcons"), ANIM_BUTTON_FILE, animation_library_is_foreign, TTR("Save animation to resource on disk")); - anitem->add_button(1, get_theme_icon("Remove", "EditorIcons"), ANIM_BUTTON_DELETE, animation_library_is_foreign, TTR("Remove animation from Library")); + anitem->add_button(1, get_editor_theme_icon("Save"), ANIM_BUTTON_FILE, animation_library_is_foreign, TTR("Save animation to resource on disk")); + anitem->add_button(1, get_editor_theme_icon("Remove"), ANIM_BUTTON_DELETE, animation_library_is_foreign, TTR("Remove animation from Library")); } } } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 7f4e7460f8..59e114fe45 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -121,22 +121,22 @@ void AnimationPlayerEditor::_notification(int p_what) { case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_THEME_CHANGED: { - stop_icon = get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")); - pause_icon = get_theme_icon(SNAME("Pause"), SNAME("EditorIcons")); + stop_icon = get_editor_theme_icon(SNAME("Stop")); + pause_icon = get_editor_theme_icon(SNAME("Pause")); if (player && player->is_playing()) { stop->set_icon(pause_icon); } else { stop->set_icon(stop_icon); } - autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons"))); - play->set_icon(get_theme_icon(SNAME("PlayStart"), SNAME("EditorIcons"))); - play_from->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); - play_bw->set_icon(get_theme_icon(SNAME("PlayStartBackwards"), SNAME("EditorIcons"))); - play_bw_from->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons"))); + autoplay->set_icon(get_editor_theme_icon(SNAME("AutoPlay"))); + play->set_icon(get_editor_theme_icon(SNAME("PlayStart"))); + play_from->set_icon(get_editor_theme_icon(SNAME("Play"))); + play_bw->set_icon(get_editor_theme_icon(SNAME("PlayStartBackwards"))); + play_bw_from->set_icon(get_editor_theme_icon(SNAME("PlayBackwards"))); - autoplay_icon = get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons")); - reset_icon = get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")); + autoplay_icon = get_editor_theme_icon(SNAME("AutoPlay")); + reset_icon = get_editor_theme_icon(SNAME("Reload")); { Ref<Image> autoplay_img = autoplay_icon->get_image(); Ref<Image> reset_img = reset_icon->get_image(); @@ -147,15 +147,15 @@ void AnimationPlayerEditor::_notification(int p_what) { autoplay_reset_icon = ImageTexture::create_from_image(autoplay_reset_img); } - onion_toggle->set_icon(get_theme_icon(SNAME("Onion"), SNAME("EditorIcons"))); - onion_skinning->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + onion_toggle->set_icon(get_editor_theme_icon(SNAME("Onion"))); + onion_skinning->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); - pin->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); + pin->set_icon(get_editor_theme_icon(SNAME("Pin"))); tool_anim->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("Button"))); track_editor->get_edit_menu()->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("Button"))); -#define ITEM_ICON(m_item, m_icon) tool_anim->get_popup()->set_item_icon(tool_anim->get_popup()->get_item_index(m_item), get_theme_icon(SNAME(m_icon), SNAME("EditorIcons"))) +#define ITEM_ICON(m_item, m_icon) tool_anim->get_popup()->set_item_icon(tool_anim->get_popup()->get_item_index(m_item), get_editor_theme_icon(SNAME(m_icon))) ITEM_ICON(TOOL_NEW_ANIM, "New"); ITEM_ICON(TOOL_ANIM_LIBRARY, "AnimationLibrary"); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 0b2af0172c..5e40a2f986 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -38,6 +38,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_file_dialog.h" #include "scene/animation/animation_blend_tree.h" @@ -554,7 +555,7 @@ void AnimationNodeStateMachineEditor::_open_menu(const Vector2 &p_position) { List<StringName> names; ap->get_animation_list(&names); for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get()); + animations_menu->add_icon_item(get_editor_theme_icon("Animation"), E->get()); animations_to_add.push_back(E->get()); } } @@ -824,7 +825,7 @@ void AnimationNodeStateMachineEditor::_add_transition(const bool p_nested_action void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, const Vector2 &p_to, AnimationNodeStateMachineTransition::SwitchMode p_mode, bool p_enabled, bool p_selected, bool p_travel, float p_fade_ratio, bool p_auto_advance, bool p_is_across_group) { Color linecolor = get_theme_color(SNAME("font_color"), SNAME("Label")); Color icon_color(1, 1, 1); - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); if (!p_enabled) { linecolor.a *= 0.2; @@ -833,12 +834,12 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co } const Ref<Texture2D> icons[] = { - get_theme_icon(SNAME("TransitionImmediateBig"), SNAME("EditorIcons")), - get_theme_icon(SNAME("TransitionSyncBig"), SNAME("EditorIcons")), - get_theme_icon(SNAME("TransitionEndBig"), SNAME("EditorIcons")), - get_theme_icon(SNAME("TransitionImmediateAutoBig"), SNAME("EditorIcons")), - get_theme_icon(SNAME("TransitionSyncAutoBig"), SNAME("EditorIcons")), - get_theme_icon(SNAME("TransitionEndAutoBig"), SNAME("EditorIcons")) + get_editor_theme_icon(SNAME("TransitionImmediateBig")), + get_editor_theme_icon(SNAME("TransitionSyncBig")), + get_editor_theme_icon(SNAME("TransitionEndBig")), + get_editor_theme_icon(SNAME("TransitionImmediateAutoBig")), + get_editor_theme_icon(SNAME("TransitionSyncAutoBig")), + get_editor_theme_icon(SNAME("TransitionEndAutoBig")) }; const int ICON_COUNT = sizeof(icons) / sizeof(*icons); @@ -911,9 +912,9 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { Ref<Font> font = get_theme_font(SNAME("title_font"), SNAME("GraphNode")); int font_size = get_theme_font_size(SNAME("title_font_size"), SNAME("GraphNode")); Color font_color = get_theme_color(SNAME("title_color"), SNAME("GraphNode")); - Ref<Texture2D> play = get_theme_icon(SNAME("Play"), SNAME("EditorIcons")); - Ref<Texture2D> edit = get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")); - Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Ref<Texture2D> play = get_editor_theme_icon(SNAME("Play")); + Ref<Texture2D> edit = get_editor_theme_icon(SNAME("Edit")); + Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); Color linecolor = get_theme_color(SNAME("font_color"), SNAME("Label")); linecolor.a *= 0.3; Ref<StyleBox> playing_overlay = get_theme_stylebox(SNAME("position"), SNAME("GraphNode")); @@ -1027,7 +1028,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { _connection_draw(from, to, AnimationNodeStateMachineTransition::SwitchMode(switch_mode->get_selected()), true, false, false, 0.0, false, false); } - Ref<Texture2D> tr_reference_icon = get_theme_icon(SNAME("TransitionImmediateBig"), SNAME("EditorIcons")); + Ref<Texture2D> tr_reference_icon = get_editor_theme_icon(SNAME("TransitionImmediateBig")); float tr_bidi_offset = int(tr_reference_icon->get_height() * 0.8); //draw transition lines @@ -1302,25 +1303,25 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - tool_create->set_icon(get_theme_icon(SNAME("ToolAddNode"), SNAME("EditorIcons"))); - tool_connect->set_icon(get_theme_icon(SNAME("ToolConnect"), SNAME("EditorIcons"))); + tool_select->set_icon(get_editor_theme_icon(SNAME("ToolSelect"))); + tool_create->set_icon(get_editor_theme_icon(SNAME("ToolAddNode"))); + tool_connect->set_icon(get_editor_theme_icon(SNAME("ToolConnect"))); switch_mode->clear(); - switch_mode->add_icon_item(get_theme_icon(SNAME("TransitionImmediate"), SNAME("EditorIcons")), TTR("Immediate")); - switch_mode->add_icon_item(get_theme_icon(SNAME("TransitionSync"), SNAME("EditorIcons")), TTR("Sync")); - switch_mode->add_icon_item(get_theme_icon(SNAME("TransitionEnd"), SNAME("EditorIcons")), TTR("At End")); + switch_mode->add_icon_item(get_editor_theme_icon(SNAME("TransitionImmediate")), TTR("Immediate")); + switch_mode->add_icon_item(get_editor_theme_icon(SNAME("TransitionSync")), TTR("Sync")); + switch_mode->add_icon_item(get_editor_theme_icon(SNAME("TransitionEnd")), TTR("At End")); - auto_advance->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons"))); + auto_advance->set_icon(get_editor_theme_icon(SNAME("AutoPlay"))); - tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + tool_erase->set_icon(get_editor_theme_icon(SNAME("Remove"))); play_mode->clear(); - play_mode->add_icon_item(get_theme_icon(SNAME("PlayTravel"), SNAME("EditorIcons")), TTR("Travel")); - play_mode->add_icon_item(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")), TTR("Immediate")); + play_mode->add_icon_item(get_editor_theme_icon(SNAME("PlayTravel")), TTR("Travel")); + play_mode->add_icon_item(get_editor_theme_icon(SNAME("Play")), TTR("Immediate")); } break; case NOTIFICATION_PROCESS: { diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 5c26199af1..5611296019 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -39,6 +39,7 @@ #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_file_dialog.h" #include "editor/project_settings_editor.h" #include "scene/gui/menu_button.h" @@ -73,7 +74,7 @@ void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Textur void EditorAssetLibraryItem::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - icon->set_texture_normal(get_theme_icon(SNAME("ProjectIconLoading"), SNAME("EditorIcons"))); + icon->set_texture_normal(get_editor_theme_icon(SNAME("ProjectIconLoading"))); category->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); author->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); price->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); @@ -157,7 +158,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const for (int i = 0; i < preview_images.size(); i++) { if (preview_images[i].id == p_index) { if (preview_images[i].is_video) { - Ref<Image> overlay = previews->get_theme_icon(SNAME("PlayOverlay"), SNAME("EditorIcons"))->get_image(); + Ref<Image> overlay = previews->get_editor_theme_icon(SNAME("PlayOverlay"))->get_image(); Ref<Image> thumbnail = p_image->get_image(); thumbnail = thumbnail->duplicate(); Point2i overlay_pos = Point2i((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2); @@ -251,12 +252,12 @@ void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, cons new_preview.video_link = p_url; new_preview.is_video = p_video; new_preview.button = memnew(Button); - new_preview.button->set_icon(previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons"))); + new_preview.button->set_icon(previews->get_editor_theme_icon(SNAME("ThumbnailWait"))); new_preview.button->set_toggle_mode(true); new_preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click).bind(p_id)); preview_hb->add_child(new_preview.button); if (!p_video) { - new_preview.image = previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons")); + new_preview.image = previews->get_editor_theme_icon(SNAME("ThumbnailWait")); } preview_images.push_back(new_preview); if (preview_images.size() == 1 && !p_video) { @@ -392,7 +393,7 @@ void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asse icon->set_texture(p_preview); asset_id = p_asset_id; if (!p_preview.is_valid()) { - icon->set_texture(get_theme_icon(SNAME("FileBrokenBigThumb"), SNAME("EditorIcons"))); + icon->set_texture(get_editor_theme_icon(SNAME("FileBrokenBigThumb"))); } host = p_download_url; sha256 = p_sha256_hash; @@ -582,11 +583,11 @@ void EditorAssetLibrary::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); - filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + error_tr->set_texture(get_editor_theme_icon(SNAME("Error"))); + filter->set_right_icon(get_editor_theme_icon(SNAME("Search"))); library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); downloads_scroll->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - error_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -808,7 +809,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB } if (!image_set && final) { - obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon(SNAME("FileBrokenBigThumb"), SNAME("EditorIcons"))); + obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_editor_theme_icon(SNAME("FileBrokenBigThumb"))); } } } @@ -845,7 +846,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons WARN_PRINT("Error getting image file from URL: " + image_queue[p_queue_id].image_url); Object *obj = ObjectDB::get_instance(image_queue[p_queue_id].target); if (obj) { - obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon(SNAME("FileBrokenBigThumb"), SNAME("EditorIcons"))); + obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_editor_theme_icon(SNAME("FileBrokenBigThumb"))); } } diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp index 89579150c2..2be9528019 100644 --- a/editor/plugins/audio_stream_editor_plugin.cpp +++ b/editor/plugins/audio_stream_editor_plugin.cpp @@ -33,6 +33,7 @@ #include "editor/audio_stream_preview.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/resources/audio_stream_wav.h" // AudioStreamEditor @@ -44,16 +45,16 @@ void AudioStreamEditor::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { - Ref<Font> font = get_theme_font(SNAME("status_source"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts)); _current_label->add_theme_font_override(SNAME("font"), font); _duration_label->add_theme_font_override(SNAME("font"), font); - _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); - _stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); - _preview->set_color(get_theme_color(SNAME("dark_color_2"), SNAME("Editor"))); + _play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); + _stop_button->set_icon(get_editor_theme_icon(SNAME("Stop"))); + _preview->set_color(get_theme_color(SNAME("dark_color_2"), EditorStringName(Editor))); - set_color(get_theme_color(SNAME("dark_color_1"), SNAME("Editor"))); + set_color(get_theme_color(SNAME("dark_color_1"), EditorStringName(Editor))); _indicator->queue_redraw(); _preview->queue_redraw(); @@ -98,7 +99,7 @@ void AudioStreamEditor::_draw_preview() { points.write[idx * 2 + 1] = Vector2(i + 1, rect.position.y + max * rect.size.y); } - Vector<Color> colors = { get_theme_color(SNAME("contrast_color_2"), SNAME("Editor")) }; + Vector<Color> colors = { get_theme_color(SNAME("contrast_color_2"), EditorStringName(Editor)) }; RS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), points, colors); } @@ -120,26 +121,26 @@ void AudioStreamEditor::_play() { if (_player->is_playing()) { _pausing = true; _player->stop(); - _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + _play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); set_process(false); } else { _pausing = false; _player->play(_current); - _play_button->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + _play_button->set_icon(get_editor_theme_icon(SNAME("Pause"))); set_process(true); } } void AudioStreamEditor::_stop() { _player->stop(); - _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + _play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); _current = 0; _indicator->queue_redraw(); set_process(false); } void AudioStreamEditor::_on_finished() { - _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + _play_button->set_icon(get_editor_theme_icon(SNAME("MainPlay"))); if (!_pausing) { _current = 0; _indicator->queue_redraw(); @@ -157,8 +158,8 @@ void AudioStreamEditor::_draw_indicator() { Rect2 rect = _preview->get_rect(); float len = stream->get_length(); float ofs_x = _current / len * rect.size.width; - const Color col = get_theme_color(SNAME("accent_color"), SNAME("Editor")); - Ref<Texture2D> icon = get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons")); + const Color col = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); + Ref<Texture2D> icon = get_editor_theme_icon(SNAME("TimelineIndicator")); _indicator->draw_line(Point2(ofs_x, 0), Point2(ofs_x, rect.size.height), col, Math::round(2 * EDSCALE)); _indicator->draw_texture( icon, diff --git a/editor/plugins/bone_map_editor_plugin.cpp b/editor/plugins/bone_map_editor_plugin.cpp index 3d94dd13a7..2c9cff3eff 100644 --- a/editor/plugins/bone_map_editor_plugin.cpp +++ b/editor/plugins/bone_map_editor_plugin.cpp @@ -42,9 +42,9 @@ void BoneMapperButton::fetch_textures() { if (selected) { - set_texture_normal(get_theme_icon(SNAME("BoneMapperHandleSelected"), SNAME("EditorIcons"))); + set_texture_normal(get_editor_theme_icon(SNAME("BoneMapperHandleSelected"))); } else { - set_texture_normal(get_theme_icon(SNAME("BoneMapperHandle"), SNAME("EditorIcons"))); + set_texture_normal(get_editor_theme_icon(SNAME("BoneMapperHandle"))); } set_offset(SIDE_LEFT, 0); set_offset(SIDE_RIGHT, 0); @@ -55,7 +55,7 @@ void BoneMapperButton::fetch_textures() { set_modulate(EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)); circle = memnew(TextureRect); - circle->set_texture(get_theme_icon(SNAME("BoneMapperHandleCircle"), SNAME("EditorIcons"))); + circle->set_texture(get_editor_theme_icon(SNAME("BoneMapperHandleCircle"))); add_child(circle); set_state(BONE_MAP_STATE_UNSET); } @@ -118,7 +118,7 @@ void BoneMapperItem::create_editor() { hbox->add_child(skeleton_bone_selector); picker_button = memnew(Button); - picker_button->set_icon(get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); + picker_button->set_icon(get_editor_theme_icon(SNAME("ClassList"))); picker_button->connect("pressed", callable_mp(this, &BoneMapperItem::_open_picker)); hbox->add_child(picker_button); @@ -194,7 +194,7 @@ void BonePicker::create_bones_tree(Skeleton3D *p_skeleton) { items.insert(-1, root); - Ref<Texture> bone_icon = get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons")); + Ref<Texture> bone_icon = get_editor_theme_icon(SNAME("BoneAttachment3D")); Vector<int> bones_to_process = p_skeleton->get_parentless_bones(); bool is_first = true; @@ -297,7 +297,7 @@ void BoneMapper::create_editor() { group_hbox->add_child(profile_group_selector); clear_mapping_button = memnew(Button); - clear_mapping_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); + clear_mapping_button->set_icon(get_editor_theme_icon(SNAME("Clear"))); clear_mapping_button->set_tooltip_text(TTR("Clear mappings in current group.")); clear_mapping_button->connect("pressed", callable_mp(this, &BoneMapper::_clear_mapping_current_group)); group_hbox->add_child(clear_mapping_button); @@ -398,13 +398,13 @@ void BoneMapper::recreate_editor() { if (hmn) { StringName hmn_group_name = profile->get_group_name(current_group_idx); if (hmn_group_name == "Body") { - profile_texture->set_texture(get_theme_icon(SNAME("BoneMapHumanBody"), SNAME("EditorIcons"))); + profile_texture->set_texture(get_editor_theme_icon(SNAME("BoneMapHumanBody"))); } else if (hmn_group_name == "Face") { - profile_texture->set_texture(get_theme_icon(SNAME("BoneMapHumanFace"), SNAME("EditorIcons"))); + profile_texture->set_texture(get_editor_theme_icon(SNAME("BoneMapHumanFace"))); } else if (hmn_group_name == "LeftHand") { - profile_texture->set_texture(get_theme_icon(SNAME("BoneMapHumanLeftHand"), SNAME("EditorIcons"))); + profile_texture->set_texture(get_editor_theme_icon(SNAME("BoneMapHumanLeftHand"))); } else if (hmn_group_name == "RightHand") { - profile_texture->set_texture(get_theme_icon(SNAME("BoneMapHumanRightHand"), SNAME("EditorIcons"))); + profile_texture->set_texture(get_editor_theme_icon(SNAME("BoneMapHumanRightHand"))); } } else { profile_texture->set_texture(profile->get_texture(current_group_idx)); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 832d0c204d..703cd7ef81 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -37,6 +37,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_run_bar.h" #include "editor/gui/editor_toaster.h" @@ -1033,6 +1034,22 @@ void CanvasItemEditor::_on_grid_menu_id_pressed(int p_id) { viewport->queue_redraw(); } +void CanvasItemEditor::_switch_theme_preview(int p_mode) { + view_menu->get_popup()->hide(); + + if (theme_preview == p_mode) { + return; + } + theme_preview = (ThemePreviewMode)p_mode; + EditorSettings::get_singleton()->set_project_metadata("2d_editor", "theme_preview", theme_preview); + + for (int i = 0; i < THEME_PREVIEW_MAX; i++) { + theme_menu->set_item_checked(i, i == theme_preview); + } + + EditorNode::get_singleton()->update_preview_themes(theme_preview); +} + bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_event) { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); Ref<InputEventMouseButton> b = p_event; @@ -2293,17 +2310,17 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->is_pressed() && b->get_button_index() == MouseButton::RIGHT) { add_node_menu->clear(); - add_node_menu->add_icon_item(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), TTR("Add Node Here..."), ADD_NODE); - add_node_menu->add_icon_item(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Instantiate Scene Here..."), ADD_INSTANCE); + add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("Add")), TTR("Add Node Here..."), ADD_NODE); + add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("Instance")), TTR("Instantiate Scene Here..."), ADD_INSTANCE); for (Node *node : SceneTreeDock::get_singleton()->get_node_clipboard()) { if (Object::cast_to<CanvasItem>(node)) { - add_node_menu->add_icon_item(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons")), TTR("Paste Node(s) Here"), ADD_PASTE); + add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("ActionPaste")), TTR("Paste Node(s) Here"), ADD_PASTE); break; } } for (Node *node : EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()) { if (Object::cast_to<CanvasItem>(node)) { - add_node_menu->add_icon_item(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons")), TTR("Move Node(s) Here"), ADD_MOVE); + add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("ToolMove")), TTR("Move Node(s) Here"), ADD_MOVE); break; } } @@ -2678,7 +2695,7 @@ Control::CursorShape CanvasItemEditor::get_cursor_shape(const Point2 &p_pos) con } void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Side p_side) { - Color color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + Color color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); color.a = 0.8; Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); @@ -2717,7 +2734,7 @@ void CanvasItemEditor::_draw_percentage_at_position(real_t p_value, Point2 p_pos void CanvasItemEditor::_draw_focus() { // Draw the focus around the base viewport if (viewport->has_focus()) { - get_theme_stylebox(SNAME("FocusViewport"), SNAME("EditorStyles"))->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size())); + get_theme_stylebox(SNAME("FocusViewport"), EditorStringName(EditorStyles))->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size())); } } @@ -2747,13 +2764,13 @@ void CanvasItemEditor::_draw_guides() { } // Dragged guide. - Color text_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + Color text_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); Color outline_color = text_color.inverted(); const float outline_size = 2; if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_V_GUIDE) { String str = TS->format_number(vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).x))); - Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); Size2 text_size = font->get_string_size(str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size); viewport->draw_string_outline(font, Point2(dragged_guide_pos.x + 10, RULER_WIDTH + text_size.y / 2 + 10), str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, outline_size, outline_color); viewport->draw_string(font, Point2(dragged_guide_pos.x + 10, RULER_WIDTH + text_size.y / 2 + 10), str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, text_color); @@ -2761,8 +2778,8 @@ void CanvasItemEditor::_draw_guides() { } if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_H_GUIDE) { String str = TS->format_number(vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).y))); - Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); Size2 text_size = font->get_string_size(str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size); viewport->draw_string_outline(font, Point2(RULER_WIDTH + 10, dragged_guide_pos.y + text_size.y / 2 + 10), str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, outline_size, outline_color); viewport->draw_string(font, Point2(RULER_WIDTH + 10, dragged_guide_pos.y + text_size.y / 2 + 10), str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, text_color); @@ -2785,12 +2802,12 @@ void CanvasItemEditor::_draw_smart_snapping() { } void CanvasItemEditor::_draw_rulers() { - Color bg_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); - Color graduation_color = get_theme_color(SNAME("font_color"), SNAME("Editor")).lerp(bg_color, 0.5); - Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + Color bg_color = get_theme_color(SNAME("dark_color_2"), EditorStringName(Editor)); + Color graduation_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)).lerp(bg_color, 0.5); + Color font_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); font_color.a = 0.8; - Ref<Font> font = get_theme_font(SNAME("rulers"), SNAME("EditorFonts")); - int font_size = get_theme_font_size(SNAME("rulers_size"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("rulers"), EditorStringName(EditorFonts)); + int font_size = get_theme_font_size(SNAME("rulers_size"), EditorStringName(EditorFonts)); // The rule transform Transform2D ruler_transform; @@ -2951,7 +2968,7 @@ void CanvasItemEditor::_draw_ruler_tool() { } if (ruler_tool_active) { - Color ruler_primary_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color ruler_primary_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); Color ruler_secondary_color = ruler_primary_color; ruler_secondary_color.a = 0.5; @@ -2963,9 +2980,9 @@ void CanvasItemEditor::_draw_ruler_tool() { const real_t horizontal_angle_rad = length_vector.angle(); const real_t vertical_angle_rad = Math_PI / 2.0 - horizontal_angle_rad; - Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); - Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); + Color font_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); Color font_secondary_color = font_color; font_secondary_color.set_v(font_secondary_color.get_v() > 0.5 ? 0.7 : 0.3); Color outline_color = font_color.inverted(); @@ -3018,8 +3035,8 @@ void CanvasItemEditor::_draw_ruler_tool() { if (begin.is_equal_approx(end)) { viewport->draw_string_outline(font, text_pos, (String)ruler_tool_origin, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, outline_size, outline_color); viewport->draw_string(font, text_pos, (String)ruler_tool_origin, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color); - Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); - viewport->draw_texture(get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); + Ref<Texture2D> position_icon = get_editor_theme_icon(SNAME("EditorPosition")); + viewport->draw_texture(get_editor_theme_icon(SNAME("EditorPosition")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); return; } @@ -3090,8 +3107,8 @@ void CanvasItemEditor::_draw_ruler_tool() { } } else { if (grid_snap_active) { - Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); - viewport->draw_texture(get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); + Ref<Texture2D> position_icon = get_editor_theme_icon(SNAME("EditorPosition")); + viewport->draw_texture(get_editor_theme_icon(SNAME("EditorPosition")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); } } } @@ -3308,9 +3325,9 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { } void CanvasItemEditor::_draw_selection() { - Ref<Texture2D> pivot_icon = get_theme_icon(SNAME("EditorPivot"), SNAME("EditorIcons")); - Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); - Ref<Texture2D> previous_position_icon = get_theme_icon(SNAME("EditorPositionPrevious"), SNAME("EditorIcons")); + Ref<Texture2D> pivot_icon = get_editor_theme_icon(SNAME("EditorPivot")); + Ref<Texture2D> position_icon = get_editor_theme_icon(SNAME("EditorPosition")); + Ref<Texture2D> previous_position_icon = get_editor_theme_icon(SNAME("EditorPositionPrevious")); RID vp_ci = viewport->get_canvas_item(); @@ -3437,16 +3454,16 @@ void CanvasItemEditor::_draw_selection() { Vector2((move_factor.x + 10) * EDSCALE, 0) }; - viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); - viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")), Math::round(EDSCALE)); + viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor))); + viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)), Math::round(EDSCALE)); points.clear(); points.push_back(Vector2(5 * EDSCALE, move_factor.y * EDSCALE)); points.push_back(Vector2(-5 * EDSCALE, move_factor.y * EDSCALE)); points.push_back(Vector2(0, (move_factor.y + 10) * EDSCALE)); - viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); - viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")), Math::round(EDSCALE)); + viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor))); + viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)), Math::round(EDSCALE)); viewport->draw_set_transform_matrix(viewport->get_transform()); } @@ -3476,12 +3493,12 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_set_transform_matrix(simple_xform); Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); - viewport->draw_rect(x_handle_rect, get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); - viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")), Math::round(EDSCALE)); + viewport->draw_rect(x_handle_rect, get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor))); + viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)), Math::round(EDSCALE)); Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); - viewport->draw_rect(y_handle_rect, get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); - viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")), Math::round(EDSCALE)); + viewport->draw_rect(y_handle_rect, get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor))); + viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)), Math::round(EDSCALE)); viewport->draw_set_transform_matrix(viewport->get_transform()); } @@ -3496,11 +3513,11 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_rect( Rect2(bsfrom, bsto - bsfrom), - get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); + get_theme_color(SNAME("box_selection_fill_color"), EditorStringName(Editor))); viewport->draw_rect( Rect2(bsfrom, bsto - bsfrom), - get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")), + get_theme_color(SNAME("box_selection_stroke_color"), EditorStringName(Editor)), false, Math::round(EDSCALE)); } @@ -3510,7 +3527,7 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_line( transform.xform(drag_rotation_center), transform.xform(drag_to), - get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.6), + get_theme_color(SNAME("accent_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.6), Math::round(2 * EDSCALE)); } } @@ -3558,8 +3575,8 @@ void CanvasItemEditor::_draw_straight_line(Point2 p_from, Point2 p_to, Color p_c void CanvasItemEditor::_draw_axis() { if (show_origin) { - _draw_straight_line(Point2(), Point2(1, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")) * Color(1, 1, 1, 0.75)); - _draw_straight_line(Point2(), Point2(0, 1), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")) * Color(1, 1, 1, 0.75)); + _draw_straight_line(Point2(), Point2(1, 0), get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.75)); + _draw_straight_line(Point2(), Point2(0, 1), get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.75)); } if (show_viewport) { @@ -3613,7 +3630,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans Transform2D xform = transform * canvas_xform * parent_xform; // Draw the node's position - Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPositionUnselected"), SNAME("EditorIcons")); + Ref<Texture2D> position_icon = get_editor_theme_icon(SNAME("EditorPositionUnselected")); Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; viewport->draw_set_transform_matrix(simple_xform); @@ -3744,13 +3761,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p if (ci) { real_t offset = 0; - Ref<Texture2D> lock = get_theme_icon(SNAME("LockViewport"), SNAME("EditorIcons")); + Ref<Texture2D> lock = get_editor_theme_icon(SNAME("LockViewport")); if (p_node->has_meta("_edit_lock_") && show_edit_locks) { lock->draw(viewport_ci, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); offset += lock->get_size().x; } - Ref<Texture2D> group = get_theme_icon(SNAME("GroupViewport"), SNAME("EditorIcons")); + Ref<Texture2D> group = get_editor_theme_icon(SNAME("GroupViewport")); if (ci->has_meta("_edit_group_") && show_edit_locks) { group->draw(viewport_ci, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); //offset += group->get_size().x; @@ -3837,41 +3854,41 @@ void CanvasItemEditor::set_current_tool(Tool p_tool) { } void CanvasItemEditor::_update_editor_settings() { - button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); - select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons"))); - list_select_button->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); - move_button->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); - scale_button->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); - rotate_button->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); - smart_snap_button->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); - grid_snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); - snap_config_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - skeleton_menu->set_icon(get_theme_icon(SNAME("Bone"), SNAME("EditorIcons"))); - override_camera_button->set_icon(get_theme_icon(SNAME("Camera2D"), SNAME("EditorIcons"))); - pan_button->set_icon(get_theme_icon(SNAME("ToolPan"), SNAME("EditorIcons"))); - ruler_button->set_icon(get_theme_icon(SNAME("Ruler"), SNAME("EditorIcons"))); - pivot_button->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); - select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); - anchor_handle = get_theme_icon(SNAME("EditorControlAnchor"), SNAME("EditorIcons")); - lock_button->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); - unlock_button->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); - group_button->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); - ungroup_button->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); - key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons"))); - key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons"))); - key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons"))); - key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); - key_auto_insert_button->set_icon(get_theme_icon(SNAME("AutoKey"), SNAME("EditorIcons"))); + button_center_view->set_icon(get_editor_theme_icon(SNAME("CenterView"))); + select_button->set_icon(get_editor_theme_icon(SNAME("ToolSelect"))); + select_sb->set_texture(get_editor_theme_icon(SNAME("EditorRect2D"))); + list_select_button->set_icon(get_editor_theme_icon(SNAME("ListSelect"))); + move_button->set_icon(get_editor_theme_icon(SNAME("ToolMove"))); + scale_button->set_icon(get_editor_theme_icon(SNAME("ToolScale"))); + rotate_button->set_icon(get_editor_theme_icon(SNAME("ToolRotate"))); + smart_snap_button->set_icon(get_editor_theme_icon(SNAME("Snap"))); + grid_snap_button->set_icon(get_editor_theme_icon(SNAME("SnapGrid"))); + snap_config_menu->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); + skeleton_menu->set_icon(get_editor_theme_icon(SNAME("Bone"))); + override_camera_button->set_icon(get_editor_theme_icon(SNAME("Camera2D"))); + pan_button->set_icon(get_editor_theme_icon(SNAME("ToolPan"))); + ruler_button->set_icon(get_editor_theme_icon(SNAME("Ruler"))); + pivot_button->set_icon(get_editor_theme_icon(SNAME("EditPivot"))); + select_handle = get_editor_theme_icon(SNAME("EditorHandle")); + anchor_handle = get_editor_theme_icon(SNAME("EditorControlAnchor")); + lock_button->set_icon(get_editor_theme_icon(SNAME("Lock"))); + unlock_button->set_icon(get_editor_theme_icon(SNAME("Unlock"))); + group_button->set_icon(get_editor_theme_icon(SNAME("Group"))); + ungroup_button->set_icon(get_editor_theme_icon(SNAME("Ungroup"))); + key_loc_button->set_icon(get_editor_theme_icon(SNAME("KeyPosition"))); + key_rot_button->set_icon(get_editor_theme_icon(SNAME("KeyRotation"))); + key_scale_button->set_icon(get_editor_theme_icon(SNAME("KeyScale"))); + key_insert_button->set_icon(get_editor_theme_icon(SNAME("Key"))); + key_auto_insert_button->set_icon(get_editor_theme_icon(SNAME("AutoKey"))); // Use a different color for the active autokey icon to make them easier // to distinguish from the other key icons at the top. On a light theme, // the icon will be dark, so we need to lighten it before blending it // with the red color. const Color key_auto_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25); key_auto_insert_button->add_theme_color_override("icon_pressed_color", key_auto_color.lerp(Color(1, 0, 0), 0.55)); - animation_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + animation_menu->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); - context_menu_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("ContextualToolbar"), SNAME("EditorStyles"))); + context_menu_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("ContextualToolbar"), EditorStringName(EditorStyles))); panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/2d_editor_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning"))); panner->set_scroll_speed(EDITOR_GET("editors/panning/2d_editor_pan_speed")); @@ -3962,7 +3979,7 @@ void CanvasItemEditor::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { - select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons"))); + select_sb->set_texture(get_editor_theme_icon(SNAME("EditorRect2D"))); select_sb->set_texture_margin_all(4); select_sb->set_content_margin_all(4); @@ -5321,6 +5338,20 @@ CanvasItemEditor::CanvasItemEditor() { p->add_separator(); p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/preview_canvas_scale", TTR("Preview Canvas Scale")), PREVIEW_CANVAS_SCALE); + theme_menu = memnew(PopupMenu); + theme_menu->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_switch_theme_preview)); + theme_menu->set_name("ThemeMenu"); + theme_menu->add_radio_check_item(TTR("Project theme"), THEME_PREVIEW_PROJECT); + theme_menu->add_radio_check_item(TTR("Editor theme"), THEME_PREVIEW_EDITOR); + theme_menu->add_radio_check_item(TTR("Default theme"), THEME_PREVIEW_DEFAULT); + p->add_child(theme_menu); + p->add_submenu_item(TTR("Preview Theme"), "ThemeMenu"); + + theme_preview = (ThemePreviewMode)(int)EditorSettings::get_singleton()->get_project_metadata("2d_editor", "theme_preview", THEME_PREVIEW_PROJECT); + for (int i = 0; i < THEME_PREVIEW_MAX; i++) { + theme_menu->set_item_checked(i, i == theme_preview); + } + main_menu_hbox->add_child(memnew(VSeparator)); // Contextual toolbars. @@ -5870,10 +5901,10 @@ void CanvasItemEditorViewport::_update_theme() { for (int i = 0; i < btn_list.size(); i++) { CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]); - check->set_icon(get_theme_icon(check->get_text(), SNAME("EditorIcons"))); + check->set_icon(get_editor_theme_icon(check->get_text())); } - label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); } void CanvasItemEditorViewport::_notification(int p_what) { diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 74f150fd65..674f38c8c0 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -325,6 +325,7 @@ private: Button *override_camera_button = nullptr; MenuButton *view_menu = nullptr; PopupMenu *grid_menu = nullptr; + PopupMenu *theme_menu = nullptr; HBoxContainer *animation_hb = nullptr; MenuButton *animation_menu = nullptr; @@ -404,6 +405,19 @@ private: void _prepare_grid_menu(); void _on_grid_menu_id_pressed(int p_id); +public: + enum ThemePreviewMode { + THEME_PREVIEW_PROJECT, + THEME_PREVIEW_EDITOR, + THEME_PREVIEW_DEFAULT, + + THEME_PREVIEW_MAX // The number of options for enumerating. + }; + +private: + ThemePreviewMode theme_preview = THEME_PREVIEW_PROJECT; + void _switch_theme_preview(int p_mode); + List<CanvasItem *> _get_edited_canvas_items(bool retrieve_locked = false, bool remove_canvas_item_if_parent_in_selection = true) const; Rect2 _get_encompassing_rect_from_list(List<CanvasItem *> p_list); void _expand_encompassing_rect_using_children(Rect2 &r_rect, const Node *p_node, bool &r_first, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D(), bool include_locked_nodes = true); @@ -558,6 +572,8 @@ public: virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override; + ThemePreviewMode get_theme_preview() const { return theme_preview; } + EditorSelection *editor_selection = nullptr; CanvasItemEditor(); diff --git a/editor/plugins/cast_2d_editor_plugin.cpp b/editor/plugins/cast_2d_editor_plugin.cpp index 331b4749cc..a6457e38a7 100644 --- a/editor/plugins/cast_2d_editor_plugin.cpp +++ b/editor/plugins/cast_2d_editor_plugin.cpp @@ -113,7 +113,7 @@ void Cast2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - const Ref<Texture2D> handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); + const Ref<Texture2D> handle = get_editor_theme_icon(SNAME("EditorHandle")); p_overlay->draw_texture(handle, gt.xform((Vector2)node->get("target_position")) - handle->get_size() / 2); } diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index 65e7ee0a3d..a2feea8488 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -435,7 +435,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - Ref<Texture2D> h = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); + Ref<Texture2D> h = get_editor_theme_icon(SNAME("EditorHandle")); Vector2 size = h->get_size() * 0.5; handles.clear(); diff --git a/editor/plugins/control_editor_plugin.cpp b/editor/plugins/control_editor_plugin.cpp index d7c4686bbf..f1667d14ab 100644 --- a/editor/plugins/control_editor_plugin.cpp +++ b/editor/plugins/control_editor_plugin.cpp @@ -50,15 +50,15 @@ void ControlPositioningWarning::_update_warning() { Node *parent_node = control_node->get_parent_control(); if (!parent_node) { - title_icon->set_texture(get_theme_icon(SNAME("SubViewport"), SNAME("EditorIcons"))); + title_icon->set_texture(get_editor_theme_icon(SNAME("SubViewport"))); title_label->set_text(TTR("This node doesn't have a control parent.")); hint_label->set_text(TTR("Use the appropriate layout properties depending on where you are going to put it.")); } else if (Object::cast_to<Container>(parent_node)) { - title_icon->set_texture(get_theme_icon(SNAME("ContainerLayout"), SNAME("EditorIcons"))); + title_icon->set_texture(get_editor_theme_icon(SNAME("ContainerLayout"))); title_label->set_text(TTR("This node is a child of a container.")); hint_label->set_text(TTR("Use container properties for positioning.")); } else { - title_icon->set_texture(get_theme_icon(SNAME("ControlLayout"), SNAME("EditorIcons"))); + title_icon->set_texture(get_editor_theme_icon(SNAME("ControlLayout"))); title_label->set_text(TTR("This node is a child of a regular control.")); hint_label->set_text(TTR("Use anchors and the rectangle for positioning.")); } @@ -193,7 +193,7 @@ void EditorPropertyAnchorsPreset::setup(const Vector<String> &p_options) { String preset_name = option_name.trim_prefix("Preset"); String humanized_name = preset_name.capitalize(); String icon_name = "ControlAlign" + preset_name; - options->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(icon_name, "EditorIcons"), humanized_name); + options->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(icon_name), humanized_name); } else { options->add_item(option_name); } @@ -369,15 +369,15 @@ void EditorPropertySizeFlags::setup(const Vector<String> &p_options, bool p_vert flag_presets->clear(); if (flags.has(SIZE_FILL)) { - flag_presets->add_icon_item(gui_base->get_theme_icon(wide_preset_icon, SNAME("EditorIcons")), TTR("Fill"), SIZE_FLAGS_PRESET_FILL); + flag_presets->add_icon_item(gui_base->get_editor_theme_icon(wide_preset_icon), TTR("Fill"), SIZE_FLAGS_PRESET_FILL); } // Shrink Begin is the same as no flags at all, as such it cannot be disabled. - flag_presets->add_icon_item(gui_base->get_theme_icon(begin_preset_icon, SNAME("EditorIcons")), TTR("Shrink Begin"), SIZE_FLAGS_PRESET_SHRINK_BEGIN); + flag_presets->add_icon_item(gui_base->get_editor_theme_icon(begin_preset_icon), TTR("Shrink Begin"), SIZE_FLAGS_PRESET_SHRINK_BEGIN); if (flags.has(SIZE_SHRINK_CENTER)) { - flag_presets->add_icon_item(gui_base->get_theme_icon(SNAME("ControlAlignCenter"), SNAME("EditorIcons")), TTR("Shrink Center"), SIZE_FLAGS_PRESET_SHRINK_CENTER); + flag_presets->add_icon_item(gui_base->get_editor_theme_icon(SNAME("ControlAlignCenter")), TTR("Shrink Center"), SIZE_FLAGS_PRESET_SHRINK_CENTER); } if (flags.has(SIZE_SHRINK_END)) { - flag_presets->add_icon_item(gui_base->get_theme_icon(end_preset_icon, SNAME("EditorIcons")), TTR("Shrink End"), SIZE_FLAGS_PRESET_SHRINK_END); + flag_presets->add_icon_item(gui_base->get_editor_theme_icon(end_preset_icon), TTR("Shrink End"), SIZE_FLAGS_PRESET_SHRINK_END); } flag_presets->add_separator(); flag_presets->add_item(TTR("Custom"), SIZE_FLAGS_PRESET_CUSTOM); @@ -561,27 +561,27 @@ void AnchorPresetPicker::_notification(int p_notification) { switch (p_notification) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - preset_buttons[PRESET_TOP_LEFT]->set_icon(get_theme_icon(SNAME("ControlAlignTopLeft"), SNAME("EditorIcons"))); - preset_buttons[PRESET_CENTER_TOP]->set_icon(get_theme_icon(SNAME("ControlAlignCenterTop"), SNAME("EditorIcons"))); - preset_buttons[PRESET_TOP_RIGHT]->set_icon(get_theme_icon(SNAME("ControlAlignTopRight"), SNAME("EditorIcons"))); + preset_buttons[PRESET_TOP_LEFT]->set_icon(get_editor_theme_icon(SNAME("ControlAlignTopLeft"))); + preset_buttons[PRESET_CENTER_TOP]->set_icon(get_editor_theme_icon(SNAME("ControlAlignCenterTop"))); + preset_buttons[PRESET_TOP_RIGHT]->set_icon(get_editor_theme_icon(SNAME("ControlAlignTopRight"))); - preset_buttons[PRESET_CENTER_LEFT]->set_icon(get_theme_icon(SNAME("ControlAlignCenterLeft"), SNAME("EditorIcons"))); - preset_buttons[PRESET_CENTER]->set_icon(get_theme_icon(SNAME("ControlAlignCenter"), SNAME("EditorIcons"))); - preset_buttons[PRESET_CENTER_RIGHT]->set_icon(get_theme_icon(SNAME("ControlAlignCenterRight"), SNAME("EditorIcons"))); + preset_buttons[PRESET_CENTER_LEFT]->set_icon(get_editor_theme_icon(SNAME("ControlAlignCenterLeft"))); + preset_buttons[PRESET_CENTER]->set_icon(get_editor_theme_icon(SNAME("ControlAlignCenter"))); + preset_buttons[PRESET_CENTER_RIGHT]->set_icon(get_editor_theme_icon(SNAME("ControlAlignCenterRight"))); - preset_buttons[PRESET_BOTTOM_LEFT]->set_icon(get_theme_icon(SNAME("ControlAlignBottomLeft"), SNAME("EditorIcons"))); - preset_buttons[PRESET_CENTER_BOTTOM]->set_icon(get_theme_icon(SNAME("ControlAlignCenterBottom"), SNAME("EditorIcons"))); - preset_buttons[PRESET_BOTTOM_RIGHT]->set_icon(get_theme_icon(SNAME("ControlAlignBottomRight"), SNAME("EditorIcons"))); + preset_buttons[PRESET_BOTTOM_LEFT]->set_icon(get_editor_theme_icon(SNAME("ControlAlignBottomLeft"))); + preset_buttons[PRESET_CENTER_BOTTOM]->set_icon(get_editor_theme_icon(SNAME("ControlAlignCenterBottom"))); + preset_buttons[PRESET_BOTTOM_RIGHT]->set_icon(get_editor_theme_icon(SNAME("ControlAlignBottomRight"))); - preset_buttons[PRESET_TOP_WIDE]->set_icon(get_theme_icon(SNAME("ControlAlignTopWide"), SNAME("EditorIcons"))); - preset_buttons[PRESET_HCENTER_WIDE]->set_icon(get_theme_icon(SNAME("ControlAlignHCenterWide"), SNAME("EditorIcons"))); - preset_buttons[PRESET_BOTTOM_WIDE]->set_icon(get_theme_icon(SNAME("ControlAlignBottomWide"), SNAME("EditorIcons"))); + preset_buttons[PRESET_TOP_WIDE]->set_icon(get_editor_theme_icon(SNAME("ControlAlignTopWide"))); + preset_buttons[PRESET_HCENTER_WIDE]->set_icon(get_editor_theme_icon(SNAME("ControlAlignHCenterWide"))); + preset_buttons[PRESET_BOTTOM_WIDE]->set_icon(get_editor_theme_icon(SNAME("ControlAlignBottomWide"))); - preset_buttons[PRESET_LEFT_WIDE]->set_icon(get_theme_icon(SNAME("ControlAlignLeftWide"), SNAME("EditorIcons"))); - preset_buttons[PRESET_VCENTER_WIDE]->set_icon(get_theme_icon(SNAME("ControlAlignVCenterWide"), SNAME("EditorIcons"))); - preset_buttons[PRESET_RIGHT_WIDE]->set_icon(get_theme_icon(SNAME("ControlAlignRightWide"), SNAME("EditorIcons"))); + preset_buttons[PRESET_LEFT_WIDE]->set_icon(get_editor_theme_icon(SNAME("ControlAlignLeftWide"))); + preset_buttons[PRESET_VCENTER_WIDE]->set_icon(get_editor_theme_icon(SNAME("ControlAlignVCenterWide"))); + preset_buttons[PRESET_RIGHT_WIDE]->set_icon(get_editor_theme_icon(SNAME("ControlAlignRightWide"))); - preset_buttons[PRESET_FULL_RECT]->set_icon(get_theme_icon(SNAME("ControlAlignFullRect"), SNAME("EditorIcons"))); + preset_buttons[PRESET_FULL_RECT]->set_icon(get_editor_theme_icon(SNAME("ControlAlignFullRect"))); } break; } } @@ -671,17 +671,17 @@ void SizeFlagPresetPicker::_notification(int p_notification) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { if (vertical) { - preset_buttons[SIZE_SHRINK_BEGIN]->set_icon(get_theme_icon(SNAME("ControlAlignCenterTop"), SNAME("EditorIcons"))); - preset_buttons[SIZE_SHRINK_CENTER]->set_icon(get_theme_icon(SNAME("ControlAlignCenter"), SNAME("EditorIcons"))); - preset_buttons[SIZE_SHRINK_END]->set_icon(get_theme_icon(SNAME("ControlAlignCenterBottom"), SNAME("EditorIcons"))); + preset_buttons[SIZE_SHRINK_BEGIN]->set_icon(get_editor_theme_icon(SNAME("ControlAlignCenterTop"))); + preset_buttons[SIZE_SHRINK_CENTER]->set_icon(get_editor_theme_icon(SNAME("ControlAlignCenter"))); + preset_buttons[SIZE_SHRINK_END]->set_icon(get_editor_theme_icon(SNAME("ControlAlignCenterBottom"))); - preset_buttons[SIZE_FILL]->set_icon(get_theme_icon(SNAME("ControlAlignVCenterWide"), SNAME("EditorIcons"))); + preset_buttons[SIZE_FILL]->set_icon(get_editor_theme_icon(SNAME("ControlAlignVCenterWide"))); } else { - preset_buttons[SIZE_SHRINK_BEGIN]->set_icon(get_theme_icon(SNAME("ControlAlignCenterLeft"), SNAME("EditorIcons"))); - preset_buttons[SIZE_SHRINK_CENTER]->set_icon(get_theme_icon(SNAME("ControlAlignCenter"), SNAME("EditorIcons"))); - preset_buttons[SIZE_SHRINK_END]->set_icon(get_theme_icon(SNAME("ControlAlignCenterRight"), SNAME("EditorIcons"))); + preset_buttons[SIZE_SHRINK_BEGIN]->set_icon(get_editor_theme_icon(SNAME("ControlAlignCenterLeft"))); + preset_buttons[SIZE_SHRINK_CENTER]->set_icon(get_editor_theme_icon(SNAME("ControlAlignCenter"))); + preset_buttons[SIZE_SHRINK_END]->set_icon(get_editor_theme_icon(SNAME("ControlAlignCenterRight"))); - preset_buttons[SIZE_FILL]->set_icon(get_theme_icon(SNAME("ControlAlignHCenterWide"), SNAME("EditorIcons"))); + preset_buttons[SIZE_FILL]->set_icon(get_editor_theme_icon(SNAME("ControlAlignHCenterWide"))); } } break; } @@ -968,9 +968,9 @@ void ControlEditorToolbar::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - anchors_button->set_icon(get_theme_icon(SNAME("ControlLayout"), SNAME("EditorIcons"))); - anchor_mode_button->set_icon(get_theme_icon(SNAME("Anchor"), SNAME("EditorIcons"))); - containers_button->set_icon(get_theme_icon(SNAME("ContainerLayout"), SNAME("EditorIcons"))); + anchors_button->set_icon(get_editor_theme_icon(SNAME("ControlLayout"))); + anchor_mode_button->set_icon(get_editor_theme_icon(SNAME("Anchor"))); + containers_button->set_icon(get_editor_theme_icon(SNAME("ContainerLayout"))); } break; } } diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index 3ac9fee03f..967ef3cb6b 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -251,7 +251,7 @@ void CPUParticles2DEditorPlugin::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { menu->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback)); - menu->set_icon(epoints->get_theme_icon(SNAME("CPUParticles2D"), SNAME("EditorIcons"))); + menu->set_icon(epoints->get_editor_theme_icon(SNAME("CPUParticles2D"))); file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected)); } break; } diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp index 1f1bc0e561..7e5fa70f3f 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp @@ -47,7 +47,7 @@ void CPUParticles3DEditor::_node_removed(Node *p_node) { void CPUParticles3DEditor::_notification(int p_notification) { switch (p_notification) { case NOTIFICATION_ENTER_TREE: { - options->set_icon(get_theme_icon(SNAME("CPUParticles3D"), SNAME("EditorIcons"))); + options->set_icon(get_editor_theme_icon(SNAME("CPUParticles3D"))); } break; } } diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 6b5b0f9214..468278bd27 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -38,6 +38,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_spin_slider.h" #include "scene/gui/flow_container.h" @@ -787,8 +788,8 @@ void CurveEdit::_redraw() { Vector2 min_edge = get_world_pos(Vector2(0, view_size.y)); Vector2 max_edge = get_world_pos(Vector2(view_size.x, 0)); - const Color grid_color_primary = get_theme_color(SNAME("mono_color"), SNAME("Editor")) * Color(1, 1, 1, 0.25); - const Color grid_color = get_theme_color(SNAME("mono_color"), SNAME("Editor")) * Color(1, 1, 1, 0.1); + const Color grid_color_primary = get_theme_color(SNAME("mono_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.25); + const Color grid_color = get_theme_color(SNAME("mono_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.1); const Vector2i grid_steps = Vector2i(4, 2); const Vector2 step_size = Vector2(1, curve->get_range()) / grid_steps; @@ -814,7 +815,7 @@ void CurveEdit::_redraw() { Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); float font_height = font->get_height(font_size); - Color text_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + Color text_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); for (int i = 0; i <= grid_steps.x; ++i) { real_t x = i * step_size.x; @@ -832,8 +833,8 @@ void CurveEdit::_redraw() { // The scaling up ensures that the curve rendering doesn't break when we use a quad line to draw it. draw_set_transform_matrix(Transform2D(0, get_view_pos(Vector2(0, 0)))); - const Color line_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); - const Color edge_line_color = get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.75); + const Color line_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); + const Color edge_line_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.75); CanvasItemPlotCurve plot_func(*this, line_color, edge_line_color); plot_curve_accurate(**curve, 2.f, (get_view_pos(Vector2(1, curve->get_max_value())) - get_view_pos(Vector2(0, curve->get_min_value()))) / Vector2(1, curve->get_range()), plot_func); @@ -843,7 +844,7 @@ void CurveEdit::_redraw() { bool shift_pressed = Input::get_singleton()->is_key_pressed(Key::SHIFT); - const Color point_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + const Color point_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); for (int i = 0; i < curve->get_point_count(); ++i) { Vector2 pos = get_view_pos(curve->get_point_position(i)); @@ -859,12 +860,12 @@ void CurveEdit::_redraw() { if (selected_index >= 0) { const Vector2 point_pos = curve->get_point_position(selected_index); - const Color selected_point_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color selected_point_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); // Draw tangents if not dragging a point, or if holding a point without having moved it yet. if (grabbing == GRAB_NONE || initial_grab_pos == point_pos || selected_tangent_index != TANGENT_NONE) { - const Color selected_tangent_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")).darkened(0.25); - const Color tangent_color = get_theme_color(SNAME("font_color"), SNAME("Editor")).darkened(0.25); + const Color selected_tangent_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)).darkened(0.25); + const Color tangent_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)).darkened(0.25); if (selected_index != 0) { Vector2 control_pos = get_tangent_view_pos(selected_index, TANGENT_LEFT); @@ -939,8 +940,8 @@ void CurveEdit::_redraw() { } if (shift_pressed && grabbing != GRAB_NONE && selected_tangent_index == TANGENT_NONE) { - draw_line(Vector2(initial_grab_pos.x, curve->get_min_value()), Vector2(initial_grab_pos.x, curve->get_max_value()), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")).darkened(0.4)); - draw_line(Vector2(0, initial_grab_pos.y), Vector2(1, initial_grab_pos.y), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")).darkened(0.4)); + draw_line(Vector2(initial_grab_pos.x, curve->get_min_value()), Vector2(initial_grab_pos.x, curve->get_max_value()), get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)).darkened(0.4)); + draw_line(Vector2(0, initial_grab_pos.y), Vector2(1, initial_grab_pos.y), get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)).darkened(0.4)); } } @@ -969,14 +970,14 @@ void CurveEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { spacing = Math::round(BASE_SPACING * get_theme_default_base_scale()); - snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + snap_button->set_icon(get_editor_theme_icon(SNAME("SnapGrid"))); PopupMenu *p = presets_button->get_popup(); p->clear(); - p->add_icon_item(get_theme_icon(SNAME("CurveConstant"), SNAME("EditorIcons")), TTR("Constant"), CurveEdit::PRESET_CONSTANT); - p->add_icon_item(get_theme_icon(SNAME("CurveLinear"), SNAME("EditorIcons")), TTR("Linear"), CurveEdit::PRESET_LINEAR); - p->add_icon_item(get_theme_icon(SNAME("CurveIn"), SNAME("EditorIcons")), TTR("Ease In"), CurveEdit::PRESET_EASE_IN); - p->add_icon_item(get_theme_icon(SNAME("CurveOut"), SNAME("EditorIcons")), TTR("Ease Out"), CurveEdit::PRESET_EASE_OUT); - p->add_icon_item(get_theme_icon(SNAME("CurveInOut"), SNAME("EditorIcons")), TTR("Smoothstep"), CurveEdit::PRESET_SMOOTHSTEP); + p->add_icon_item(get_editor_theme_icon(SNAME("CurveConstant")), TTR("Constant"), CurveEdit::PRESET_CONSTANT); + p->add_icon_item(get_editor_theme_icon(SNAME("CurveLinear")), TTR("Linear"), CurveEdit::PRESET_LINEAR); + p->add_icon_item(get_editor_theme_icon(SNAME("CurveIn")), TTR("Ease In"), CurveEdit::PRESET_EASE_IN); + p->add_icon_item(get_editor_theme_icon(SNAME("CurveOut")), TTR("Ease Out"), CurveEdit::PRESET_EASE_OUT); + p->add_icon_item(get_editor_theme_icon(SNAME("CurveInOut")), TTR("Smoothstep"), CurveEdit::PRESET_SMOOTHSTEP); } break; case NOTIFICATION_READY: { Ref<Curve> curve = curve_editor_rect->get_curve(); diff --git a/editor/plugins/font_config_plugin.cpp b/editor/plugins/font_config_plugin.cpp index 5d90a746f9..5dd5de224f 100644 --- a/editor/plugins/font_config_plugin.cpp +++ b/editor/plugins/font_config_plugin.cpp @@ -156,7 +156,7 @@ void EditorPropertyFontMetaOverride::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { if (button_add) { - button_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_add->set_icon(get_editor_theme_icon(SNAME("Add"))); } } break; } @@ -302,7 +302,7 @@ void EditorPropertyFontMetaOverride::update_property() { hbox->add_child(prop); prop->set_h_size_flags(SIZE_EXPAND_FILL); Button *remove = memnew(Button); - remove->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + remove->set_icon(get_editor_theme_icon(SNAME("Remove"))); hbox->add_child(remove); remove->connect("pressed", callable_mp(this, &EditorPropertyFontMetaOverride::_remove).bind(remove, name)); @@ -552,7 +552,7 @@ void EditorPropertyOTFeatures::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { if (button_add) { - button_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_add->set_icon(get_editor_theme_icon(SNAME("Add"))); } } break; } @@ -789,7 +789,7 @@ void EditorPropertyOTFeatures::update_property() { hbox->add_child(prop); prop->set_h_size_flags(SIZE_EXPAND_FILL); Button *remove = memnew(Button); - remove->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + remove->set_icon(get_editor_theme_icon(SNAME("Remove"))); hbox->add_child(remove); remove->connect("pressed", callable_mp(this, &EditorPropertyOTFeatures::_remove).bind(remove, name_tag)); @@ -798,7 +798,7 @@ void EditorPropertyOTFeatures::update_property() { } button_add = EditorInspector::create_inspector_action_button(TTR("Add Feature")); - button_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_add->set_icon(get_editor_theme_icon(SNAME("Add"))); button_add->connect("pressed", callable_mp(this, &EditorPropertyOTFeatures::_add_menu)); property_vbox->add_child(button_add); diff --git a/editor/plugins/gdextension_export_plugin.h b/editor/plugins/gdextension_export_plugin.h index 54e6899796..bbde652c8d 100644 --- a/editor/plugins/gdextension_export_plugin.h +++ b/editor/plugins/gdextension_export_plugin.h @@ -50,6 +50,15 @@ void GDExtensionExportPlugin::_export_file(const String &p_path, const String &p Error err = config->load(p_path); ERR_FAIL_COND_MSG(err, "Failed to load GDExtension file: " + p_path); + // Check whether this GDExtension should be exported. + bool android_aar_plugin = config->get_value("configuration", "android_aar_plugin", false); + if (android_aar_plugin && p_features.has("android")) { + // The gdextension configuration and Android .so files will be provided by the Android aar + // plugin it's part of, so we abort here. + skip(); + return; + } + ERR_FAIL_COND_MSG(!config->has_section_key("configuration", "entry_symbol"), "Failed to export GDExtension file, missing entry symbol: " + p_path); String entry_symbol = config->get_value("configuration", "entry_symbol"); diff --git a/editor/plugins/gizmos/audio_listener_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/audio_listener_3d_gizmo_plugin.cpp index ed0597efd3..894047c524 100644 --- a/editor/plugins/gizmos/audio_listener_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/audio_listener_3d_gizmo_plugin.cpp @@ -34,7 +34,7 @@ #include "scene/3d/audio_listener_3d.h" AudioListener3DGizmoPlugin::AudioListener3DGizmoPlugin() { - create_icon_material("audio_listener_3d_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoAudioListener3D"), SNAME("EditorIcons"))); + create_icon_material("audio_listener_3d_icon", Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("GizmoAudioListener3D"))); } bool AudioListener3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { diff --git a/editor/plugins/gizmos/audio_stream_player_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/audio_stream_player_3d_gizmo_plugin.cpp index 611d4b3c1c..ad40af7784 100644 --- a/editor/plugins/gizmos/audio_stream_player_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/audio_stream_player_3d_gizmo_plugin.cpp @@ -38,7 +38,7 @@ AudioStreamPlayer3DGizmoPlugin::AudioStreamPlayer3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1)); - create_icon_material("stream_player_3d_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("Gizmo3DSamplePlayer"), SNAME("EditorIcons"))); + create_icon_material("stream_player_3d_icon", Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("Gizmo3DSamplePlayer"))); create_material("stream_player_3d_material_primary", gizmo_color); create_material("stream_player_3d_material_secondary", gizmo_color * Color(1, 1, 1, 0.35)); // Enable vertex colors for the billboard material as the gizmo color depends on the diff --git a/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp index 2ef2e3a666..b0fc5d1ec0 100644 --- a/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp @@ -41,7 +41,7 @@ Camera3DGizmoPlugin::Camera3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/camera", Color(0.8, 0.4, 0.8)); create_material("camera_material", gizmo_color); - create_icon_material("camera_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoCamera3D", "EditorIcons")); + create_icon_material("camera_icon", Node3DEditor::get_singleton()->get_editor_theme_icon("GizmoCamera3D")); create_handle_material("handles"); } diff --git a/editor/plugins/gizmos/cpu_particles_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/cpu_particles_3d_gizmo_plugin.cpp index a8ac842945..e00b5349d2 100644 --- a/editor/plugins/gizmos/cpu_particles_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/cpu_particles_3d_gizmo_plugin.cpp @@ -34,7 +34,7 @@ #include "scene/3d/cpu_particles_3d.h" CPUParticles3DGizmoPlugin::CPUParticles3DGizmoPlugin() { - create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoCPUParticles3D"), SNAME("EditorIcons"))); + create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("GizmoCPUParticles3D"))); } bool CPUParticles3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { diff --git a/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.cpp index a46de82e76..f17518482a 100644 --- a/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.cpp @@ -40,7 +40,7 @@ GPUParticles3DGizmoPlugin::GPUParticles3DGizmoPlugin() { create_material("particles_material", gizmo_color); gizmo_color.a = MAX((gizmo_color.a - 0.2) * 0.02, 0.0); create_material("particles_solid_material", gizmo_color); - create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoGPUParticles3D"), SNAME("EditorIcons"))); + create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("GizmoGPUParticles3D"))); create_handle_material("handles"); } diff --git a/editor/plugins/gizmos/light_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/light_3d_gizmo_plugin.cpp index ff959ae836..021cf4e8f1 100644 --- a/editor/plugins/gizmos/light_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/light_3d_gizmo_plugin.cpp @@ -43,9 +43,9 @@ Light3DGizmoPlugin::Light3DGizmoPlugin() { create_material("lines_secondary", Color(1, 1, 1, 0.35), false, false, true); create_material("lines_billboard", Color(1, 1, 1), true, false, true); - create_icon_material("light_directional_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoDirectionalLight"), SNAME("EditorIcons"))); - create_icon_material("light_omni_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoLight"), SNAME("EditorIcons"))); - create_icon_material("light_spot_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoSpotLight"), SNAME("EditorIcons"))); + create_icon_material("light_directional_icon", Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("GizmoDirectionalLight"))); + create_icon_material("light_omni_icon", Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("GizmoLight"))); + create_icon_material("light_spot_icon", Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("GizmoSpotLight"))); create_handle_material("handles"); create_handle_material("handles_billboard", true); diff --git a/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.cpp b/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.cpp index b16a894e6d..a1a25958c4 100644 --- a/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/lightmap_gi_gizmo_plugin.cpp @@ -48,7 +48,7 @@ LightmapGIGizmoPlugin::LightmapGIGizmoPlugin() { add_material("lightmap_probe_material", mat); - create_icon_material("baked_indirect_light_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoLightmapGI"), SNAME("EditorIcons"))); + create_icon_material("baked_indirect_light_icon", Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("GizmoLightmapGI"))); } bool LightmapGIGizmoPlugin::has_gizmo(Node3D *p_spatial) { diff --git a/editor/plugins/gizmos/marker_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/marker_3d_gizmo_plugin.cpp index 50e6f87fcf..d86ede5e44 100644 --- a/editor/plugins/gizmos/marker_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/marker_3d_gizmo_plugin.cpp @@ -31,6 +31,7 @@ #include "marker_3d_gizmo_plugin.h" #include "editor/editor_node.h" +#include "editor/editor_string_names.h" #include "editor/plugins/node_3d_editor_plugin.h" #include "scene/3d/marker_3d.h" @@ -60,7 +61,7 @@ Marker3DGizmoPlugin::Marker3DGizmoPlugin() { // Use a darkened axis color for the negative axis. // This makes it possible to see in which direction the Marker3D node is rotated // (which can be important depending on how it's used). - const Color color_x = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); + const Color color_x = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)); cursor_colors.push_back(color_x); cursor_colors.push_back(color_x); // FIXME: Use less strong darkening factor once GH-48573 is fixed. @@ -68,13 +69,13 @@ Marker3DGizmoPlugin::Marker3DGizmoPlugin() { cursor_colors.push_back(color_x.lerp(Color(0, 0, 0), 0.75)); cursor_colors.push_back(color_x.lerp(Color(0, 0, 0), 0.75)); - const Color color_y = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); + const Color color_y = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)); cursor_colors.push_back(color_y); cursor_colors.push_back(color_y); cursor_colors.push_back(color_y.lerp(Color(0, 0, 0), 0.75)); cursor_colors.push_back(color_y.lerp(Color(0, 0, 0), 0.75)); - const Color color_z = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); + const Color color_z = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_z_color"), EditorStringName(Editor)); cursor_colors.push_back(color_z); cursor_colors.push_back(color_z); cursor_colors.push_back(color_z.lerp(Color(0, 0, 0), 0.75)); diff --git a/editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp b/editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp index 8d61eb0711..d9c2316ce0 100644 --- a/editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp @@ -46,7 +46,7 @@ ReflectionProbeGizmoPlugin::ReflectionProbeGizmoPlugin() { gizmo_color.a = 0.1; create_material("reflection_probe_solid_material", gizmo_color); - create_icon_material("reflection_probe_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoReflectionProbe"), SNAME("EditorIcons"))); + create_icon_material("reflection_probe_icon", Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("GizmoReflectionProbe"))); create_handle_material("handles"); } diff --git a/editor/plugins/gizmos/voxel_gi_gizmo_plugin.cpp b/editor/plugins/gizmos/voxel_gi_gizmo_plugin.cpp index dfcee00eec..08dbe76d87 100644 --- a/editor/plugins/gizmos/voxel_gi_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/voxel_gi_gizmo_plugin.cpp @@ -47,7 +47,7 @@ VoxelGIGizmoPlugin::VoxelGIGizmoPlugin() { gizmo_color.a = 0.05; create_material("voxel_gi_solid_material", gizmo_color); - create_icon_material("voxel_gi_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoVoxelGI"), SNAME("EditorIcons"))); + create_icon_material("voxel_gi_icon", Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("GizmoVoxelGI"))); create_handle_material("handles"); } diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index 78bbc1484b..a6ae6c1256 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -352,7 +352,7 @@ void GPUParticles2DEditorPlugin::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback)); - menu->set_icon(menu->get_theme_icon(SNAME("GPUParticles2D"), SNAME("EditorIcons"))); + menu->set_icon(menu->get_editor_theme_icon(SNAME("GPUParticles2D"))); file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected)); EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &GPUParticles2DEditorPlugin::_selection_changed)); } break; diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index 108f85152f..e47af62b5b 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -237,7 +237,7 @@ void GPUParticles3DEditor::_node_removed(Node *p_node) { void GPUParticles3DEditor::_notification(int p_notification) { switch (p_notification) { case NOTIFICATION_ENTER_TREE: { - options->set_icon(options->get_popup()->get_theme_icon(SNAME("GPUParticles3D"), SNAME("EditorIcons"))); + options->set_icon(options->get_popup()->get_editor_theme_icon(SNAME("GPUParticles3D"))); get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed)); } break; } diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp index 938a541a22..af861b04b5 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp @@ -183,7 +183,7 @@ GPUParticlesCollisionSDF3DEditorPlugin::GPUParticlesCollisionSDF3DEditorPlugin() bake_hb->hide(); bake = memnew(Button); bake->set_flat(true); - bake->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); + bake->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Bake"))); bake->set_text(TTR("Bake SDF")); bake->connect("pressed", callable_mp(this, &GPUParticlesCollisionSDF3DEditorPlugin::_bake)); bake_hb->add_child(bake); diff --git a/editor/plugins/gradient_editor.cpp b/editor/plugins/gradient_editor.cpp index 59bd0f02fc..63dede4850 100644 --- a/editor/plugins/gradient_editor.cpp +++ b/editor/plugins/gradient_editor.cpp @@ -33,6 +33,7 @@ #include "core/os/keyboard.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "scene/resources/gradient_texture.h" @@ -393,7 +394,7 @@ void GradientEditor::_notification(int p_what) { int total_w = get_size().width - get_size().height - draw_spacing - handle_width; // Draw checker pattern for ramp. - draw_texture_rect(get_theme_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons")), Rect2(handle_width / 2, 0, total_w, h), true); + draw_texture_rect(get_editor_theme_icon(SNAME("GuiMiniCheckerboard")), Rect2(handle_width / 2, 0, total_w, h), true); // Draw color ramp. gradient_cache->set_points(points); @@ -417,7 +418,7 @@ void GradientEditor::_notification(int p_what) { draw_rect(rect, points[i].color, true); draw_rect(rect, col, false, 1); if (grabbed == i) { - const Color focus_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color focus_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); rect = rect.grow(-1); if (has_focus()) { draw_rect(rect, focus_color, false, 1); @@ -432,7 +433,7 @@ void GradientEditor::_notification(int p_what) { // Draw "button" for color selector. int button_offset = total_w + handle_width + draw_spacing; - draw_texture_rect(get_theme_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons")), Rect2(button_offset, 0, h, h), true); + draw_texture_rect(get_editor_theme_icon(SNAME("GuiMiniCheckerboard")), Rect2(button_offset, 0, h, h), true); if (grabbed != -1) { // Draw with selection color. draw_rect(Rect2(button_offset, 0, h, h), points[grabbed].color); diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp index 57a7f527ec..c85e19fda6 100644 --- a/editor/plugins/gradient_editor_plugin.cpp +++ b/editor/plugins/gradient_editor_plugin.cpp @@ -40,7 +40,7 @@ void GradientReverseButton::_notification(int p_what) { switch (p_what) { case NOTIFICATION_DRAW: { - Ref<Texture2D> icon = get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(SNAME("ReverseGradient")); if (is_pressed()) { draw_texture_rect(icon, Rect2(margin, margin, icon->get_width(), icon->get_height()), false, get_theme_color(SNAME("icon_pressed_color"), SNAME("Button"))); } else { @@ -51,7 +51,7 @@ void GradientReverseButton::_notification(int p_what) { } Size2 GradientReverseButton::get_minimum_size() const { - return (get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons"))->get_size() + Size2(margin * 2, margin * 2)); + return (get_editor_theme_icon(SNAME("ReverseGradient"))->get_size() + Size2(margin * 2, margin * 2)); } /////////////////////// diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.cpp b/editor/plugins/gradient_texture_2d_editor_plugin.cpp index c48de7c3dd..494d97c45c 100644 --- a/editor/plugins/gradient_texture_2d_editor_plugin.cpp +++ b/editor/plugins/gradient_texture_2d_editor_plugin.cpp @@ -169,7 +169,7 @@ void GradientTexture2DEdit::_notification(int p_what) { } } break; case NOTIFICATION_THEME_CHANGED: { - checkerboard->set_texture(get_theme_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons"))); + checkerboard->set_texture(get_editor_theme_icon(SNAME("GuiMiniCheckerboard"))); } break; case NOTIFICATION_DRAW: { _draw(); @@ -182,8 +182,8 @@ void GradientTexture2DEdit::_draw() { return; } - const Ref<Texture2D> fill_from_icon = get_theme_icon(SNAME("EditorPathSmoothHandle"), SNAME("EditorIcons")); - const Ref<Texture2D> fill_to_icon = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); + const Ref<Texture2D> fill_from_icon = get_editor_theme_icon(SNAME("EditorPathSmoothHandle")); + const Ref<Texture2D> fill_to_icon = get_editor_theme_icon(SNAME("EditorPathSharpHandle")); handle_size = fill_from_icon->get_size(); Size2 rect_size = get_size(); @@ -262,8 +262,8 @@ void GradientTexture2DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - reverse_button->set_icon(get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons"))); - snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + reverse_button->set_icon(get_editor_theme_icon(SNAME("ReverseGradient"))); + snap_button->set_icon(get_editor_theme_icon(SNAME("SnapGrid"))); } break; case NOTIFICATION_READY: { if (texture.is_valid()) { diff --git a/editor/plugins/input_event_editor_plugin.cpp b/editor/plugins/input_event_editor_plugin.cpp index 9a54a8c1a1..973c929059 100644 --- a/editor/plugins/input_event_editor_plugin.cpp +++ b/editor/plugins/input_event_editor_plugin.cpp @@ -40,7 +40,7 @@ void InputEventConfigContainer::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - open_config_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + open_config_button->set_icon(get_editor_theme_icon(SNAME("Edit"))); } break; } } diff --git a/editor/plugins/lightmap_gi_editor_plugin.cpp b/editor/plugins/lightmap_gi_editor_plugin.cpp index b549a958e6..db5593a132 100644 --- a/editor/plugins/lightmap_gi_editor_plugin.cpp +++ b/editor/plugins/lightmap_gi_editor_plugin.cpp @@ -165,7 +165,7 @@ void LightmapGIEditorPlugin::_bind_methods() { LightmapGIEditorPlugin::LightmapGIEditorPlugin() { bake = memnew(Button); bake->set_flat(true); - bake->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); + bake->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Bake"))); bake->set_text(TTR("Bake Lightmaps")); bake->hide(); bake->connect("pressed", Callable(this, "_bake")); diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 60119a5499..2a712caf92 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -63,13 +63,13 @@ void MaterialEditor::gui_input(const Ref<InputEvent> &p_event) { void MaterialEditor::_update_theme_item_cache() { Control::_update_theme_item_cache(); - theme_cache.light_1_icon = get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons")); - theme_cache.light_2_icon = get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons")); + theme_cache.light_1_icon = get_editor_theme_icon(SNAME("MaterialPreviewLight1")); + theme_cache.light_2_icon = get_editor_theme_icon(SNAME("MaterialPreviewLight2")); - theme_cache.sphere_icon = get_theme_icon(SNAME("MaterialPreviewSphere"), SNAME("EditorIcons")); - theme_cache.box_icon = get_theme_icon(SNAME("MaterialPreviewCube"), SNAME("EditorIcons")); + theme_cache.sphere_icon = get_editor_theme_icon(SNAME("MaterialPreviewSphere")); + theme_cache.box_icon = get_editor_theme_icon(SNAME("MaterialPreviewCube")); - theme_cache.checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); + theme_cache.checkerboard = get_editor_theme_icon(SNAME("Checkerboard")); } void MaterialEditor::_notification(int p_what) { diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index b6be971370..729ca5d7f9 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -51,8 +51,8 @@ void MeshEditor::gui_input(const Ref<InputEvent> &p_event) { void MeshEditor::_update_theme_item_cache() { SubViewportContainer::_update_theme_item_cache(); - theme_cache.light_1_icon = get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons")); - theme_cache.light_2_icon = get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons")); + theme_cache.light_1_icon = get_editor_theme_icon(SNAME("MaterialPreviewLight1")); + theme_cache.light_2_icon = get_editor_theme_icon(SNAME("MaterialPreviewLight2")); } void MeshEditor::_notification(int p_what) { diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index a53e254dcc..c299ba97d5 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -32,6 +32,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/plugins/node_3d_editor_plugin.h" #include "scene/3d/collision_shape_3d.h" @@ -463,10 +464,10 @@ void MeshInstance3DEditor::_debug_uv_draw() { } debug_uv->set_clip_contents(true); - debug_uv->draw_rect(Rect2(Vector2(), debug_uv->get_size()), get_theme_color(SNAME("dark_color_3"), SNAME("Editor"))); + debug_uv->draw_rect(Rect2(Vector2(), debug_uv->get_size()), get_theme_color(SNAME("dark_color_3"), EditorStringName(Editor))); debug_uv->draw_set_transform(Vector2(), 0, debug_uv->get_size()); // Use a translucent color to allow overlapping triangles to be visible. - debug_uv->draw_multiline(uv_lines, get_theme_color(SNAME("mono_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5)); + debug_uv->draw_multiline(uv_lines, get_theme_color(SNAME("mono_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.5)); } void MeshInstance3DEditor::_create_outline_mesh() { @@ -521,7 +522,7 @@ MeshInstance3DEditor::MeshInstance3DEditor() { Node3DEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text(TTR("Mesh")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MeshInstance3D"), SNAME("EditorIcons"))); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("MeshInstance3D"))); options->get_popup()->add_item(TTR("Create Trimesh Static Body"), MENU_OPTION_CREATE_STATIC_TRIMESH_BODY); options->get_popup()->set_item_tooltip(-1, TTR("Creates a StaticBody3D and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection.")); diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 4cc96126de..750a71905b 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -275,7 +275,7 @@ MeshLibraryEditor::MeshLibraryEditor() { Node3DEditor::get_singleton()->add_control_to_menu_panel(menu); menu->set_position(Point2(1, 1)); menu->set_text(TTR("MeshLibrary")); - menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MeshLibrary"), SNAME("EditorIcons"))); + menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("MeshLibrary"))); menu->get_popup()->add_item(TTR("Add Item"), MENU_OPTION_ADD_ITEM); menu->get_popup()->add_item(TTR("Remove Selected Item"), MENU_OPTION_REMOVE_ITEM); menu->get_popup()->add_separator(); diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index 15647e1364..a980b30bfe 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -272,7 +272,7 @@ MultiMeshEditor::MultiMeshEditor() { Node3DEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text("MultiMesh"); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MultiMeshInstance3D"), SNAME("EditorIcons"))); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("MultiMeshInstance3D"))); options->get_popup()->add_item(TTR("Populate Surface")); options->get_popup()->connect("id_pressed", callable_mp(this, &MultiMeshEditor::_menu_option)); diff --git a/editor/plugins/navigation_link_2d_editor_plugin.cpp b/editor/plugins/navigation_link_2d_editor_plugin.cpp index dff92ced27..5419e487bf 100644 --- a/editor/plugins/navigation_link_2d_editor_plugin.cpp +++ b/editor/plugins/navigation_link_2d_editor_plugin.cpp @@ -147,7 +147,7 @@ void NavigationLink2DEditor::forward_canvas_draw_over_viewport(Control *p_overla Vector2 global_end_position = gt.xform(node->get_end_position()); // Only drawing the handles here, since the debug rendering will fill in the rest. - const Ref<Texture2D> handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); + const Ref<Texture2D> handle = get_editor_theme_icon(SNAME("EditorHandle")); p_overlay->draw_texture(handle, global_start_position - handle->get_size() / 2); p_overlay->draw_texture(handle, global_end_position - handle->get_size() / 2); } diff --git a/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp b/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp index 2e39d6f67c..4892538a0a 100644 --- a/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp +++ b/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp @@ -46,8 +46,8 @@ void NavigationObstacle3DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - button_create->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - button_edit->set_icon(get_theme_icon(SNAME("MovePoint"), SNAME("EditorIcons"))); + button_create->set_icon(get_editor_theme_icon(SNAME("Edit"))); + button_edit->set_icon(get_editor_theme_icon(SNAME("MovePoint"))); button_edit->set_pressed(true); get_tree()->connect("node_removed", callable_mp(this, &NavigationObstacle3DEditor::_node_removed)); @@ -554,7 +554,7 @@ NavigationObstacle3DEditor::NavigationObstacle3DEditor() { handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); - Ref<Texture2D> handle = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Editor3DHandle"), SNAME("EditorIcons")); + Ref<Texture2D> handle = EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Editor3DHandle")); handle_material->set_point_size(handle->get_width()); handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle); diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 2a91d9f108..f6e93e292f 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -940,7 +940,7 @@ void EditorNode3DGizmoPlugin::create_handle_material(const String &p_name, bool handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true); - Ref<Texture2D> handle_t = p_icon != nullptr ? p_icon : Node3DEditor::get_singleton()->get_theme_icon(SNAME("Editor3DHandle"), SNAME("EditorIcons")); + Ref<Texture2D> handle_t = p_icon != nullptr ? p_icon : Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("Editor3DHandle")); handle_material->set_point_size(handle_t->get_width()); handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle_t); handle_material->set_albedo(Color(1, 1, 1)); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 4284fd8ae2..17c9a097ba 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -39,6 +39,7 @@ #include "editor/debugger/editor_debugger_node.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_run_bar.h" #include "editor/gui/editor_spin_slider.h" @@ -302,9 +303,9 @@ void ViewportRotationControl::_notification(int p_what) { axis_menu_options.push_back(Node3DEditorViewport::VIEW_REAR); axis_colors.clear(); - axis_colors.push_back(get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); - axis_colors.push_back(get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); - axis_colors.push_back(get_theme_color(SNAME("axis_z_color"), SNAME("Editor"))); + axis_colors.push_back(get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor))); + axis_colors.push_back(get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor))); + axis_colors.push_back(get_theme_color(SNAME("axis_z_color"), EditorStringName(Editor))); queue_redraw(); if (!is_connected("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) { @@ -353,7 +354,7 @@ void ViewportRotationControl::_draw_axis(const Axis2D &p_axis) { // Draw the axis letter for the positive axes. const String axis_name = direction == 0 ? "X" : (direction == 1 ? "Y" : "Z"); - draw_char(get_theme_font(SNAME("rotation_control"), SNAME("EditorFonts")), p_axis.screen_point + Vector2i(Math::round(-4.0 * EDSCALE), Math::round(5.0 * EDSCALE)), axis_name, get_theme_font_size(SNAME("rotation_control_size"), SNAME("EditorFonts")), Color(0.0, 0.0, 0.0, alpha)); + draw_char(get_theme_font(SNAME("rotation_control"), EditorStringName(EditorFonts)), p_axis.screen_point + Vector2i(Math::round(-4.0 * EDSCALE), Math::round(5.0 * EDSCALE)), axis_name, get_theme_font_size(SNAME("rotation_control_size"), EditorStringName(EditorFonts)), Color(0.0, 0.0, 0.0, alpha)); } else { // Draw an outline around the negative axes. draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS, c); @@ -2984,32 +2985,32 @@ void Node3DEditorViewport::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - view_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - preview_camera->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); + view_menu->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); + preview_camera->set_icon(get_editor_theme_icon(SNAME("Camera3D"))); Control *gui_base = EditorNode::get_singleton()->get_gui_base(); - view_menu->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - view_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - view_menu->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - view_menu->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - view_menu->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - - preview_camera->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - preview_camera->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - preview_camera->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - preview_camera->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - preview_camera->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - - frame_time_gradient->set_color(0, get_theme_color(SNAME("success_color"), SNAME("Editor"))); - frame_time_gradient->set_color(1, get_theme_color(SNAME("warning_color"), SNAME("Editor"))); - frame_time_gradient->set_color(2, get_theme_color(SNAME("error_color"), SNAME("Editor"))); - - info_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - cpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - gpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - fps_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - cinema_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - locked_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + view_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + view_menu->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + view_menu->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + view_menu->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + + preview_camera->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + preview_camera->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + preview_camera->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + preview_camera->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + preview_camera->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + + frame_time_gradient->set_color(0, get_theme_color(SNAME("success_color"), EditorStringName(Editor))); + frame_time_gradient->set_color(1, get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); + frame_time_gradient->set_color(2, get_theme_color(SNAME("error_color"), EditorStringName(Editor))); + + info_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + cpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + gpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + fps_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + cinema_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); + locked_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), EditorStringName(EditorStyles))); } break; case NOTIFICATION_DRAG_END: { @@ -3059,7 +3060,7 @@ void Node3DEditorViewport::_draw() { if (surface->has_focus()) { Size2 size = surface->get_size(); Rect2 r = Rect2(Point2(), size); - get_theme_stylebox(SNAME("FocusViewport"), SNAME("EditorStyles"))->draw(surface->get_canvas_item(), r); + get_theme_stylebox(SNAME("FocusViewport"), EditorStringName(EditorStyles))->draw(surface->get_canvas_item(), r); } if (cursor.region_select) { @@ -3067,11 +3068,11 @@ void Node3DEditorViewport::_draw() { surface->draw_rect( selection_rect, - get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); + get_theme_color(SNAME("box_selection_fill_color"), EditorStringName(Editor))); surface->draw_rect( selection_rect, - get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")), + get_theme_color(SNAME("box_selection_stroke_color"), EditorStringName(Editor)), false, Math::round(EDSCALE)); } @@ -3093,16 +3094,16 @@ void Node3DEditorViewport::_draw() { Color handle_color; switch (_edit.plane) { case TRANSFORM_X_AXIS: - handle_color = get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); + handle_color = get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)); break; case TRANSFORM_Y_AXIS: - handle_color = get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); + handle_color = get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)); break; case TRANSFORM_Z_AXIS: - handle_color = get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); + handle_color = get_theme_color(SNAME("axis_z_color"), EditorStringName(Editor)); break; default: - handle_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + handle_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); break; } handle_color = handle_color.from_hsv(handle_color.get_h(), 0.25, 1.0, 1); @@ -3157,7 +3158,7 @@ void Node3DEditorViewport::_draw() { draw_indicator_bar( *surface, 1.0 - logscale_t, - get_theme_icon(SNAME("ViewportSpeed"), SNAME("EditorIcons")), + get_editor_theme_icon(SNAME("ViewportSpeed")), get_theme_font(SNAME("font"), SNAME("Label")), get_theme_font_size(SNAME("font_size"), SNAME("Label")), vformat("%s u/s", String::num(freelook_speed).pad_decimals(precision)), @@ -3180,7 +3181,7 @@ void Node3DEditorViewport::_draw() { draw_indicator_bar( *surface, logscale_t, - get_theme_icon(SNAME("ViewportZoom"), SNAME("EditorIcons")), + get_editor_theme_icon(SNAME("ViewportZoom")), get_theme_font(SNAME("font"), SNAME("Label")), get_theme_font_size(SNAME("font_size"), SNAME("Label")), vformat("%s u", String::num(cursor.distance).pad_decimals(precision)), @@ -5439,9 +5440,9 @@ void Node3DEditorViewportContainer::_notification(int p_what) { Ref<Texture2D> h_grabber = get_theme_icon(SNAME("grabber"), SNAME("HSplitContainer")); Ref<Texture2D> v_grabber = get_theme_icon(SNAME("grabber"), SNAME("VSplitContainer")); - Ref<Texture2D> hdiag_grabber = get_theme_icon(SNAME("GuiViewportHdiagsplitter"), SNAME("EditorIcons")); - Ref<Texture2D> vdiag_grabber = get_theme_icon(SNAME("GuiViewportVdiagsplitter"), SNAME("EditorIcons")); - Ref<Texture2D> vh_grabber = get_theme_icon(SNAME("GuiViewportVhsplitter"), SNAME("EditorIcons")); + Ref<Texture2D> hdiag_grabber = get_editor_theme_icon(SNAME("GuiViewportHdiagsplitter")); + Ref<Texture2D> vdiag_grabber = get_editor_theme_icon(SNAME("GuiViewportVdiagsplitter")); + Ref<Texture2D> vh_grabber = get_editor_theme_icon(SNAME("GuiViewportVhsplitter")); Vector2 size = get_size(); @@ -6499,13 +6500,13 @@ void Node3DEditor::_init_indicators() { Color origin_color; switch (i) { case 0: - origin_color = get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); + origin_color = get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)); break; case 1: - origin_color = get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); + origin_color = get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)); break; case 2: - origin_color = get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); + origin_color = get_theme_color(SNAME("axis_z_color"), EditorStringName(Editor)); break; default: origin_color = Color(); @@ -6612,13 +6613,13 @@ void fragment() { Color col; switch (i) { case 0: - col = get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); + col = get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)); break; case 1: - col = get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); + col = get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)); break; case 2: - col = get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); + col = get_theme_color(SNAME("axis_z_color"), EditorStringName(Editor)); break; default: col = Color(); @@ -7548,39 +7549,39 @@ void Node3DEditor::_add_environment_to_scene(bool p_already_added_sun) { } void Node3DEditor::_update_theme() { - tool_button[TOOL_MODE_SELECT]->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - tool_button[TOOL_MODE_MOVE]->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); - tool_button[TOOL_MODE_ROTATE]->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); - tool_button[TOOL_MODE_SCALE]->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); - tool_button[TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); - tool_button[TOOL_LOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); - tool_button[TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); - tool_button[TOOL_GROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); - tool_button[TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); - - tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))); - tool_option_button[TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); - tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); - - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon(SNAME("Panels1"), SNAME("EditorIcons"))); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons"))); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_theme_icon(SNAME("Panels2Alt"), SNAME("EditorIcons"))); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_theme_icon(SNAME("Panels3"), SNAME("EditorIcons"))); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon(SNAME("Panels3Alt"), SNAME("EditorIcons"))); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon(SNAME("Panels4"), SNAME("EditorIcons"))); - - sun_button->set_icon(get_theme_icon(SNAME("PreviewSun"), SNAME("EditorIcons"))); - environ_button->set_icon(get_theme_icon(SNAME("PreviewEnvironment"), SNAME("EditorIcons"))); - sun_environ_settings->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + tool_button[TOOL_MODE_SELECT]->set_icon(get_editor_theme_icon(SNAME("ToolSelect"))); + tool_button[TOOL_MODE_MOVE]->set_icon(get_editor_theme_icon(SNAME("ToolMove"))); + tool_button[TOOL_MODE_ROTATE]->set_icon(get_editor_theme_icon(SNAME("ToolRotate"))); + tool_button[TOOL_MODE_SCALE]->set_icon(get_editor_theme_icon(SNAME("ToolScale"))); + tool_button[TOOL_MODE_LIST_SELECT]->set_icon(get_editor_theme_icon(SNAME("ListSelect"))); + tool_button[TOOL_LOCK_SELECTED]->set_icon(get_editor_theme_icon(SNAME("Lock"))); + tool_button[TOOL_UNLOCK_SELECTED]->set_icon(get_editor_theme_icon(SNAME("Unlock"))); + tool_button[TOOL_GROUP_SELECTED]->set_icon(get_editor_theme_icon(SNAME("Group"))); + tool_button[TOOL_UNGROUP_SELECTED]->set_icon(get_editor_theme_icon(SNAME("Ungroup"))); + + tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_icon(get_editor_theme_icon(SNAME("Object"))); + tool_option_button[TOOL_OPT_USE_SNAP]->set_icon(get_editor_theme_icon(SNAME("Snap"))); + tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_editor_theme_icon(SNAME("Camera3D"))); + + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_editor_theme_icon(SNAME("Panels1"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_editor_theme_icon(SNAME("Panels2"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_editor_theme_icon(SNAME("Panels2Alt"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_editor_theme_icon(SNAME("Panels3"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_editor_theme_icon(SNAME("Panels3Alt"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_editor_theme_icon(SNAME("Panels4"))); + + sun_button->set_icon(get_editor_theme_icon(SNAME("PreviewSun"))); + environ_button->set_icon(get_editor_theme_icon(SNAME("PreviewEnvironment"))); + sun_environ_settings->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); - sun_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); - environ_sky_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); - environ_ground_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); + sun_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor)))); + environ_sky_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor)))); + environ_ground_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor)))); - context_menu_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("ContextualToolbar"), SNAME("EditorStyles"))); + context_menu_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("ContextualToolbar"), EditorStringName(EditorStyles))); } void Node3DEditor::_notification(int p_what) { diff --git a/editor/plugins/occluder_instance_3d_editor_plugin.cpp b/editor/plugins/occluder_instance_3d_editor_plugin.cpp index 9e9e602841..3a05352ecf 100644 --- a/editor/plugins/occluder_instance_3d_editor_plugin.cpp +++ b/editor/plugins/occluder_instance_3d_editor_plugin.cpp @@ -104,7 +104,7 @@ void OccluderInstance3DEditorPlugin::_bind_methods() { OccluderInstance3DEditorPlugin::OccluderInstance3DEditorPlugin() { bake = memnew(Button); bake->set_flat(true); - bake->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); + bake->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Bake"))); bake->set_text(TTR("Bake Occluders")); bake->hide(); bake->connect("pressed", Callable(this, "_bake")); diff --git a/editor/plugins/packed_scene_editor_plugin.cpp b/editor/plugins/packed_scene_editor_plugin.cpp index 3239375e1e..00fb94b6ae 100644 --- a/editor/plugins/packed_scene_editor_plugin.cpp +++ b/editor/plugins/packed_scene_editor_plugin.cpp @@ -44,7 +44,7 @@ void PackedSceneEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - open_scene_button->set_icon(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"))); + open_scene_button->set_icon(get_editor_theme_icon(SNAME("PackedScene"))); } break; } } diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 63f6643ba3..3a7805ba4c 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -43,11 +43,11 @@ void Path2DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - curve_edit->set_icon(get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); - curve_edit_curve->set_icon(get_theme_icon(SNAME("CurveCurve"), SNAME("EditorIcons"))); - curve_create->set_icon(get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); - curve_del->set_icon(get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); - curve_close->set_icon(get_theme_icon(SNAME("CurveClose"), SNAME("EditorIcons"))); + curve_edit->set_icon(get_editor_theme_icon(SNAME("CurveEdit"))); + curve_edit_curve->set_icon(get_editor_theme_icon(SNAME("CurveCurve"))); + curve_create->set_icon(get_editor_theme_icon(SNAME("CurveCreate"))); + curve_del->set_icon(get_editor_theme_icon(SNAME("CurveDelete"))); + curve_close->set_icon(get_editor_theme_icon(SNAME("CurveClose"))); } break; } } @@ -370,12 +370,12 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - const Ref<Texture2D> path_sharp_handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); - const Ref<Texture2D> path_smooth_handle = get_theme_icon(SNAME("EditorPathSmoothHandle"), SNAME("EditorIcons")); + const Ref<Texture2D> path_sharp_handle = get_editor_theme_icon(SNAME("EditorPathSharpHandle")); + const Ref<Texture2D> path_smooth_handle = get_editor_theme_icon(SNAME("EditorPathSmoothHandle")); // Both handle icons must be of the same size const Size2 handle_size = path_sharp_handle->get_size(); - const Ref<Texture2D> curve_handle = get_theme_icon(SNAME("EditorCurveHandle"), SNAME("EditorIcons")); + const Ref<Texture2D> curve_handle = get_editor_theme_icon(SNAME("EditorCurveHandle")); const Size2 curve_handle_size = curve_handle->get_size(); Ref<Curve2D> curve = node->get_curve(); @@ -417,7 +417,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } if (on_edge) { - Ref<Texture2D> add_handle = get_theme_icon(SNAME("EditorHandleAdd"), SNAME("EditorIcons")); + Ref<Texture2D> add_handle = get_editor_theme_icon(SNAME("EditorHandleAdd")); p_overlay->draw_texture(add_handle, edge_point - add_handle->get_size() * 0.5); } } diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index 3a2fcb691b..f4c36f3816 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -696,11 +696,11 @@ void Path3DEditorPlugin::_handle_option_pressed(int p_option) { void Path3DEditorPlugin::_update_theme() { // TODO: Split the EditorPlugin instance from the UI instance and connect this properly. // See the 2D path editor for inspiration. - curve_edit->set_icon(Node3DEditor::get_singleton()->get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); - curve_edit_curve->set_icon(Node3DEditor::get_singleton()->get_theme_icon(SNAME("CurveCurve"), SNAME("EditorIcons"))); - curve_create->set_icon(Node3DEditor::get_singleton()->get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); - curve_del->set_icon(Node3DEditor::get_singleton()->get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); - curve_close->set_icon(Node3DEditor::get_singleton()->get_theme_icon(SNAME("CurveClose"), SNAME("EditorIcons"))); + curve_edit->set_icon(Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("CurveEdit"))); + curve_edit_curve->set_icon(Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("CurveCurve"))); + curve_create->set_icon(Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("CurveCreate"))); + curve_del->set_icon(Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("CurveDelete"))); + curve_close->set_icon(Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("CurveClose"))); } void Path3DEditorPlugin::_notification(int p_what) { @@ -822,6 +822,6 @@ Path3DGizmoPlugin::Path3DGizmoPlugin() { Color path_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.8)); create_material("path_material", path_color); create_material("path_thin_material", Color(0.5, 0.5, 0.5)); - create_handle_material("handles", false, Node3DEditor::get_singleton()->get_theme_icon(SNAME("EditorPathSmoothHandle"), SNAME("EditorIcons"))); - create_handle_material("sec_handles", false, Node3DEditor::get_singleton()->get_theme_icon(SNAME("EditorCurveHandle"), SNAME("EditorIcons"))); + create_handle_material("handles", false, Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("EditorPathSmoothHandle"))); + create_handle_material("sec_handles", false, Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("EditorCurveHandle"))); } diff --git a/editor/plugins/physical_bone_3d_editor_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp index a8d3ab948f..c9b77b3edb 100644 --- a/editor/plugins/physical_bone_3d_editor_plugin.cpp +++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp @@ -60,7 +60,7 @@ PhysicalBone3DEditor::PhysicalBone3DEditor() { spatial_editor_hb->add_child(button_transform_joint); button_transform_joint->set_text(TTR("Move Joint")); - button_transform_joint->set_icon(Node3DEditor::get_singleton()->get_theme_icon(SNAME("PhysicalBone3D"), SNAME("EditorIcons"))); + button_transform_joint->set_icon(Node3DEditor::get_singleton()->get_editor_theme_icon(SNAME("PhysicalBone3D"))); button_transform_joint->set_toggle_mode(true); button_transform_joint->connect("toggled", callable_mp(this, &PhysicalBone3DEditor::_on_toggle_button_transform_joint)); diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index d2b3efcd65..5ed9f4946d 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -80,23 +80,23 @@ void Polygon2DEditor::_notification(int p_what) { } break; case NOTIFICATION_READY: { - button_uv->set_icon(get_theme_icon(SNAME("Uv"), SNAME("EditorIcons"))); - - uv_button[UV_MODE_CREATE]->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - uv_button[UV_MODE_CREATE_INTERNAL]->set_icon(get_theme_icon(SNAME("EditInternal"), SNAME("EditorIcons"))); - uv_button[UV_MODE_REMOVE_INTERNAL]->set_icon(get_theme_icon(SNAME("RemoveInternal"), SNAME("EditorIcons"))); - uv_button[UV_MODE_EDIT_POINT]->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - uv_button[UV_MODE_MOVE]->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); - uv_button[UV_MODE_ROTATE]->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); - uv_button[UV_MODE_SCALE]->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); - uv_button[UV_MODE_ADD_POLYGON]->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - uv_button[UV_MODE_REMOVE_POLYGON]->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); - uv_button[UV_MODE_PAINT_WEIGHT]->set_icon(get_theme_icon(SNAME("Bucket"), SNAME("EditorIcons"))); - uv_button[UV_MODE_CLEAR_WEIGHT]->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); - - b_snap_grid->set_icon(get_theme_icon(SNAME("Grid"), SNAME("EditorIcons"))); - b_snap_enable->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); - uv_icon_zoom->set_texture(get_theme_icon(SNAME("Zoom"), SNAME("EditorIcons"))); + button_uv->set_icon(get_editor_theme_icon(SNAME("Uv"))); + + uv_button[UV_MODE_CREATE]->set_icon(get_editor_theme_icon(SNAME("Edit"))); + uv_button[UV_MODE_CREATE_INTERNAL]->set_icon(get_editor_theme_icon(SNAME("EditInternal"))); + uv_button[UV_MODE_REMOVE_INTERNAL]->set_icon(get_editor_theme_icon(SNAME("RemoveInternal"))); + uv_button[UV_MODE_EDIT_POINT]->set_icon(get_editor_theme_icon(SNAME("ToolSelect"))); + uv_button[UV_MODE_MOVE]->set_icon(get_editor_theme_icon(SNAME("ToolMove"))); + uv_button[UV_MODE_ROTATE]->set_icon(get_editor_theme_icon(SNAME("ToolRotate"))); + uv_button[UV_MODE_SCALE]->set_icon(get_editor_theme_icon(SNAME("ToolScale"))); + uv_button[UV_MODE_ADD_POLYGON]->set_icon(get_editor_theme_icon(SNAME("Edit"))); + uv_button[UV_MODE_REMOVE_POLYGON]->set_icon(get_editor_theme_icon(SNAME("Close"))); + uv_button[UV_MODE_PAINT_WEIGHT]->set_icon(get_editor_theme_icon(SNAME("Bucket"))); + uv_button[UV_MODE_CLEAR_WEIGHT]->set_icon(get_editor_theme_icon(SNAME("Clear"))); + + b_snap_grid->set_icon(get_editor_theme_icon(SNAME("Grid"))); + b_snap_enable->set_icon(get_editor_theme_icon(SNAME("SnapGrid"))); + uv_icon_zoom->set_texture(get_editor_theme_icon(SNAME("Zoom"))); uv_vscroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE); uv_hscroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE); @@ -1043,7 +1043,7 @@ void Polygon2DEditor::_uv_draw() { } // All UV points are sharp, so use the sharp handle icon - Ref<Texture2D> handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); + Ref<Texture2D> handle = get_editor_theme_icon(SNAME("EditorPathSharpHandle")); Color poly_line_color = Color(0.9, 0.5, 0.5); if (polygons.size() || polygon_create.size()) { diff --git a/editor/plugins/polygon_3d_editor_plugin.cpp b/editor/plugins/polygon_3d_editor_plugin.cpp index ceff9cb5f3..451bd7a738 100644 --- a/editor/plugins/polygon_3d_editor_plugin.cpp +++ b/editor/plugins/polygon_3d_editor_plugin.cpp @@ -45,8 +45,8 @@ void Polygon3DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - button_create->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - button_edit->set_icon(get_theme_icon(SNAME("MovePoint"), SNAME("EditorIcons"))); + button_create->set_icon(get_editor_theme_icon(SNAME("Edit"))); + button_edit->set_icon(get_editor_theme_icon(SNAME("MovePoint"))); button_edit->set_pressed(true); get_tree()->connect("node_removed", callable_mp(this, &Polygon3DEditor::_node_removed)); @@ -569,7 +569,7 @@ Polygon3DEditor::Polygon3DEditor() { handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); - Ref<Texture2D> handle = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Editor3DHandle"), SNAME("EditorIcons")); + Ref<Texture2D> handle = EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Editor3DHandle")); handle_material->set_point_size(handle->get_width()); handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle); diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index b59bf3a37b..e352fd27ad 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -43,7 +43,7 @@ void ResourcePreloaderEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - load->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + load->set_icon(get_editor_theme_icon(SNAME("Folder"))); } break; } } @@ -209,11 +209,11 @@ void ResourcePreloaderEditor::_update_library() { ti->set_selectable(1, false); if (type == "PackedScene") { - ti->add_button(1, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_OPEN_SCENE, false, TTR("Open in Editor")); + ti->add_button(1, get_editor_theme_icon(SNAME("InstanceOptions")), BUTTON_OPEN_SCENE, false, TTR("Open in Editor")); } else { - ti->add_button(1, get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), BUTTON_EDIT_RESOURCE, false, TTR("Open in Editor")); + ti->add_button(1, get_editor_theme_icon(SNAME("Load")), BUTTON_EDIT_RESOURCE, false, TTR("Open in Editor")); } - ti->add_button(1, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE, false, TTR("Remove")); + ti->add_button(1, get_editor_theme_icon(SNAME("Remove")), BUTTON_REMOVE, false, TTR("Remove")); } //player->add_resource("default",resource); diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 09b0864559..10b0b214ae 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -132,7 +132,7 @@ void EditorPropertyRootMotion::_node_assign() { if (skeleton) { HashMap<int, TreeItem *> items; items.insert(-1, ti); - Ref<Texture> bone_icon = get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons")); + Ref<Texture> bone_icon = get_editor_theme_icon(SNAME("BoneAttachment3D")); Vector<int> bones_to_process = skeleton->get_parentless_bones(); while (bones_to_process.size() > 0) { int current_bone_idx = bones_to_process[0]; @@ -190,7 +190,7 @@ void EditorPropertyRootMotion::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")); + Ref<Texture2D> t = get_editor_theme_icon(SNAME("Clear")); clear->set_icon(t); } break; } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 39f4e4eb6a..2fe607a08c 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -48,6 +48,7 @@ #include "editor/editor_scale.h" #include "editor/editor_script.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/filesystem_dock.h" #include "editor/find_in_files.h" #include "editor/gui/editor_file_dialog.h" @@ -382,7 +383,7 @@ void ScriptEditorQuickOpen::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_VISIBILITY_CHANGED: { - search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + search_box->set_right_icon(search_options->get_editor_theme_icon(SNAME("Search"))); } break; case NOTIFICATION_EXIT_TREE: { @@ -663,7 +664,7 @@ void ScriptEditor::_go_to_tab(int p_idx) { } if (Object::cast_to<EditorHelp>(c)) { script_name_label->set_text(Object::cast_to<EditorHelp>(c)->get_class()); - script_icon->set_texture(get_theme_icon(SNAME("Help"), SNAME("EditorIcons"))); + script_icon->set_texture(get_editor_theme_icon(SNAME("Help"))); if (is_visible_in_tree()) { Object::cast_to<EditorHelp>(c)->set_focused(); } @@ -1611,23 +1612,25 @@ void ScriptEditor::_notification(int p_what) { case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_THEME_CHANGED: { - help_search->set_icon(get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons"))); - site_search->set_icon(get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons"))); + tab_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("ScriptEditor"), EditorStringName(EditorStyles))); + + help_search->set_icon(get_editor_theme_icon(SNAME("HelpSearch"))); + site_search->set_icon(get_editor_theme_icon(SNAME("ExternalLink"))); if (is_layout_rtl()) { - script_forward->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); - script_back->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + script_forward->set_icon(get_editor_theme_icon(SNAME("Back"))); + script_back->set_icon(get_editor_theme_icon(SNAME("Forward"))); } else { - script_forward->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); - script_back->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + script_forward->set_icon(get_editor_theme_icon(SNAME("Forward"))); + script_back->set_icon(get_editor_theme_icon(SNAME("Back"))); } - members_overview_alphabeta_sort_button->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); + members_overview_alphabeta_sort_button->set_icon(get_editor_theme_icon(SNAME("Sort"))); - filter_scripts->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - filter_methods->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + filter_scripts->set_right_icon(get_editor_theme_icon(SNAME("Search"))); + filter_methods->set_right_icon(get_editor_theme_icon(SNAME("Search"))); - filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); + filename->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); recent_scripts->reset_size(); @@ -1638,6 +1641,9 @@ void ScriptEditor::_notification(int p_what) { } break; case NOTIFICATION_READY: { + // Can't set own styles in NOTIFICATION_THEME_CHANGED, so for now this will do. + add_theme_style_override("panel", get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles"))); + get_tree()->connect("tree_changed", callable_mp(this, &ScriptEditor::_tree_changed)); InspectorDock::get_singleton()->connect("request_help", callable_mp(this, &ScriptEditor::_help_class_open)); EditorNode::get_singleton()->connect("request_help_search", callable_mp(this, &ScriptEditor::_help_search)); @@ -1957,9 +1963,9 @@ void ScriptEditor::_update_script_colors() { bool script_temperature_enabled = EDITOR_GET("text_editor/script_list/script_temperature_enabled"); int hist_size = EDITOR_GET("text_editor/script_list/script_temperature_history_size"); - Color hot_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color hot_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); hot_color.set_s(hot_color.get_s() * 0.9); - Color cold_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + Color cold_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); for (int i = 0; i < script_list->get_item_count(); i++) { int c = script_list->get_item_metadata(i); @@ -2099,7 +2105,7 @@ void ScriptEditor::_update_script_names() { EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_tab_control(i)); if (eh) { String name = eh->get_class(); - Ref<Texture2D> icon = get_theme_icon(SNAME("Help"), SNAME("EditorIcons")); + Ref<Texture2D> icon = get_editor_theme_icon(SNAME("Help")); String tooltip = vformat(TTR("%s Class Reference"), name); _ScriptEditorItemData sd; @@ -2150,7 +2156,7 @@ void ScriptEditor::_update_script_names() { } } - Color tool_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color tool_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); tool_color.set_s(tool_color.get_s() * 1.5); for (int i = 0; i < sedata_filtered.size(); i++) { script_list->add_item(sedata_filtered[i].name, sedata_filtered[i].icon); @@ -2885,7 +2891,7 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { EditorHelp *eh = Object::cast_to<EditorHelp>(cur_node); if (eh) { preview_name = eh->get_class(); - preview_icon = get_theme_icon(SNAME("Help"), SNAME("EditorIcons")); + preview_icon = get_editor_theme_icon(SNAME("Help")); } if (!preview_icon.is_null()) { @@ -4138,9 +4144,6 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { ScriptServer::edit_request_func = _open_script_request; - add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles"))); - tab_container->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditor"), SNAME("EditorStyles"))); - Ref<EditorJSONSyntaxHighlighter> json_syntax_highlighter; json_syntax_highlighter.instantiate(); register_syntax_highlighter(json_syntax_highlighter); @@ -4166,9 +4169,9 @@ void ScriptEditorPlugin::_save_last_editor(String p_editor) { void ScriptEditorPlugin::_window_visibility_changed(bool p_visible) { _focus_another_editor(); if (p_visible) { - script_editor->add_theme_style_override("panel", script_editor->get_theme_stylebox("ScriptEditorPanelFloating", "EditorStyles")); + script_editor->add_theme_style_override("panel", script_editor->get_theme_stylebox("ScriptEditorPanelFloating", EditorStringName(EditorStyles))); } else { - script_editor->add_theme_style_override("panel", script_editor->get_theme_stylebox("ScriptEditorPanel", "EditorStyles")); + script_editor->add_theme_style_override("panel", script_editor->get_theme_stylebox("ScriptEditorPanel", EditorStringName(EditorStyles))); } } diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index f8da47b45e..511e4dfd15 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -38,6 +38,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_toaster.h" #include "scene/gui/rich_text_label.h" #include "scene/gui/split_container.h" @@ -69,7 +70,7 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_n node_item->set_text(1, connection.signal.get_name()); Control *p = Object::cast_to<Control>(get_parent()); - node_item->set_icon(1, p->get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); + node_item->set_icon(1, p->get_editor_theme_icon(SNAME("Slot"))); node_item->set_selectable(1, false); node_item->set_editable(1, false); @@ -457,10 +458,10 @@ Ref<Texture2D> ScriptTextEditor::get_theme_icon() { icon_name += "Internal"; } - if (get_parent_control()->has_theme_icon(icon_name, SNAME("EditorIcons"))) { - return get_parent_control()->get_theme_icon(icon_name, SNAME("EditorIcons")); - } else if (get_parent_control()->has_theme_icon(script->get_class(), SNAME("EditorIcons"))) { - return get_parent_control()->get_theme_icon(script->get_class(), SNAME("EditorIcons")); + if (get_parent_control()->has_theme_icon(icon_name, EditorStringName(EditorIcons))) { + return get_parent_control()->get_editor_theme_icon(icon_name); + } else if (get_parent_control()->has_theme_icon(script->get_class(), EditorStringName(EditorIcons))) { + return get_parent_control()->get_editor_theme_icon(script->get_class()); } } @@ -532,7 +533,7 @@ void ScriptTextEditor::_update_warnings() { String target_path = base == connection.callable.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.callable.get_object())); warnings_panel->push_cell(); - warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); warnings_panel->add_text(vformat(TTR("Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."), connection.callable.get_method(), connection.signal.get_name(), source_path, target_path)); warnings_panel->pop(); // Color. warnings_panel->pop(); // Cell. @@ -558,7 +559,7 @@ void ScriptTextEditor::_update_warnings() { warnings_panel->push_cell(); warnings_panel->push_meta(ignore_meta); warnings_panel->push_color( - warnings_panel->get_theme_color(SNAME("accent_color"), SNAME("Editor")).lerp(warnings_panel->get_theme_color(SNAME("mono_color"), SNAME("Editor")), 0.5f)); + warnings_panel->get_theme_color(SNAME("accent_color"), EditorStringName(Editor)).lerp(warnings_panel->get_theme_color(SNAME("mono_color"), EditorStringName(Editor)), 0.5f)); warnings_panel->add_text(TTR("[Ignore]")); warnings_panel->pop(); // Color. warnings_panel->pop(); // Meta ignore. @@ -566,7 +567,7 @@ void ScriptTextEditor::_update_warnings() { warnings_panel->push_cell(); warnings_panel->push_meta(w.start_line - 1); - warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); warnings_panel->add_text(TTR("Line") + " " + itos(w.start_line)); warnings_panel->add_text(" (" + w.string_code + "):"); warnings_panel->pop(); // Color. @@ -593,7 +594,7 @@ void ScriptTextEditor::_update_errors() { errors_panel->push_cell(); errors_panel->push_meta(err.line - 1); - errors_panel->push_color(warnings_panel->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + errors_panel->push_color(warnings_panel->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); errors_panel->add_text(TTR("Line") + " " + itos(err.line) + ":"); errors_panel->pop(); // Color. errors_panel->pop(); // Meta goto. @@ -627,7 +628,7 @@ void ScriptTextEditor::_update_errors() { errors_panel->push_cell(); errors_panel->push_meta(click_meta); - errors_panel->push_color(errors_panel->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + errors_panel->push_color(errors_panel->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); errors_panel->add_text(TTR("Line") + " " + itos(err.line) + ":"); errors_panel->pop(); // Color. errors_panel->pop(); // Meta goto. @@ -1092,7 +1093,7 @@ void ScriptTextEditor::_update_connected_methods() { line_meta["method"] = method; line = functions[j].get_slice(":", 1).to_int() - 1; text_edit->set_line_gutter_metadata(line, connection_gutter, line_meta); - text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); + text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_editor_theme_icon(SNAME("Slot"))); text_edit->set_line_gutter_clickable(line, connection_gutter, true); methods_found.insert(method); break; @@ -1171,11 +1172,11 @@ void ScriptTextEditor::_update_connected_methods() { line_meta["type"] = "inherits"; line_meta["method"] = name; line_meta["base_class"] = found_base_class; - text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon(SNAME("MethodOverride"), SNAME("EditorIcons"))); + text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_editor_theme_icon(SNAME("MethodOverride"))); text_edit->set_line_gutter_clickable(line, connection_gutter, true); } else { // If method is also connected to signal, then merge icons and keep the click behavior of the slot. - text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon(SNAME("MethodOverrideAndSlot"), SNAME("EditorIcons"))); + text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_editor_theme_icon(SNAME("MethodOverrideAndSlot"))); } methods_found.insert(name); @@ -2111,16 +2112,16 @@ void ScriptTextEditor::_enable_code_editor() { editor_box->add_child(warnings_panel); warnings_panel->add_theme_font_override( - "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts"))); + "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), EditorStringName(EditorFonts))); warnings_panel->add_theme_font_size_override( - "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); + "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), EditorStringName(EditorFonts))); warnings_panel->connect("meta_clicked", callable_mp(this, &ScriptTextEditor::_warning_clicked)); editor_box->add_child(errors_panel); errors_panel->add_theme_font_override( - "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts"))); + "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), EditorStringName(EditorFonts))); errors_panel->add_theme_font_size_override( - "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); + "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), EditorStringName(EditorFonts))); errors_panel->connect("meta_clicked", callable_mp(this, &ScriptTextEditor::_error_clicked)); add_child(context_menu); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 247586fbfc..9eebf958ff 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -33,6 +33,7 @@ #include "editor/editor_command_palette.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/filesystem_dock.h" #include "editor/inspector_dock.h" @@ -74,10 +75,10 @@ void ShaderEditorPlugin::_update_shader_list() { } String _class = shader->get_class(); - if (!shader_list->has_theme_icon(_class, SNAME("EditorIcons"))) { + if (!shader_list->has_theme_icon(_class, EditorStringName(EditorIcons))) { _class = "TextFile"; } - Ref<Texture2D> icon = shader_list->get_theme_icon(_class, SNAME("EditorIcons")); + Ref<Texture2D> icon = shader_list->get_editor_theme_icon(_class); shader_list->add_item(text, icon); shader_list->set_item_tooltip(shader_list->get_item_count() - 1, path); @@ -101,7 +102,7 @@ void ShaderEditorPlugin::_update_shader_list_status() { if (se->was_compilation_successful()) { shader_list->set_item_tag_icon(i, Ref<Texture2D>()); } else { - shader_list->set_item_tag_icon(i, shader_list->get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + shader_list->set_item_tag_icon(i, shader_list->get_editor_theme_icon(SNAME("Error"))); } } } diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp index b0e532b136..11bec4f61c 100644 --- a/editor/plugins/shader_file_editor_plugin.cpp +++ b/editor/plugins/shader_file_editor_plugin.cpp @@ -37,6 +37,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/gui/item_list.h" #include "scene/gui/split_container.h" #include "servers/display_server.h" @@ -67,9 +68,9 @@ void ShaderFileEditor::_version_selected(int p_option) { Ref<Texture2D> icon; if (bytecode->get_stage_compile_error(RD::ShaderStage(i)) != String()) { - icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); + icon = get_editor_theme_icon(SNAME("ImportFail")); } else { - icon = get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons")); + icon = get_editor_theme_icon(SNAME("ImportCheck")); } stages[i]->set_icon(icon); @@ -96,7 +97,7 @@ void ShaderFileEditor::_version_selected(int p_option) { String error = bytecode->get_stage_compile_error(stage); - error_text->push_font(get_theme_font(SNAME("source"), SNAME("EditorFonts"))); + error_text->push_font(get_theme_font(SNAME("source"), EditorStringName(EditorFonts))); if (error.is_empty()) { error_text->add_text(TTR("Shader stage compiled without errors.")); @@ -112,7 +113,7 @@ void ShaderFileEditor::_update_options() { stage_hb->hide(); versions->hide(); error_text->clear(); - error_text->push_font(get_theme_font(SNAME("source"), SNAME("EditorFonts"))); + error_text->push_font(get_theme_font(SNAME("source"), EditorStringName(EditorFonts))); error_text->add_text(vformat(TTR("File structure for '%s' contains unrecoverable errors:\n\n"), shader_file->get_path().get_file())); error_text->add_text(shader_file->get_base_error()); return; @@ -155,9 +156,9 @@ void ShaderFileEditor::_update_options() { } if (failed) { - icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); + icon = get_editor_theme_icon(SNAME("ImportFail")); } else { - icon = get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons")); + icon = get_editor_theme_icon(SNAME("ImportCheck")); } versions->add_item(title, icon); diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp index 18c2b0c6e0..9b67648322 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.cpp +++ b/editor/plugins/skeleton_2d_editor_plugin.cpp @@ -98,7 +98,7 @@ Skeleton2DEditor::Skeleton2DEditor() { CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text(TTR("Skeleton2D")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Skeleton2D"), SNAME("EditorIcons"))); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Skeleton2D"))); options->get_popup()->add_item(TTR("Reset to Rest Pose"), MENU_OPTION_SET_REST); options->get_popup()->add_separator(); diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 0a3de70e2a..7aa333c198 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -36,6 +36,7 @@ #include "editor/editor_properties_vector.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "node_3d_editor_plugin.h" @@ -106,7 +107,7 @@ void BoneTransformEditor::create_editors() { void BoneTransformEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - const Color section_color = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); + const Color section_color = get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor)); section->set_bg_color(section_color); rest_section->set_bg_color(section_color); } break; @@ -671,7 +672,7 @@ void Skeleton3DEditor::update_joint_tree() { items.insert(-1, root); - Ref<Texture> bone_icon = get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons")); + Ref<Texture> bone_icon = get_editor_theme_icon(SNAME("BoneAttachment3D")); Vector<int> bones_to_process = skeleton->get_parentless_bones(); while (bones_to_process.size() > 0) { @@ -847,14 +848,14 @@ void Skeleton3DEditor::_notification(int p_what) { add_theme_constant_override("separation", 0); } break; case NOTIFICATION_THEME_CHANGED: { - skeleton_options->set_icon(get_theme_icon(SNAME("Skeleton3D"), SNAME("EditorIcons"))); - edit_mode_button->set_icon(get_theme_icon(SNAME("ToolBoneSelect"), SNAME("EditorIcons"))); - key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons"))); - key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons"))); - key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons"))); - key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); - key_insert_all_button->set_icon(get_theme_icon(SNAME("NewKey"), SNAME("EditorIcons"))); - bones_section->set_bg_color(get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + skeleton_options->set_icon(get_editor_theme_icon(SNAME("Skeleton3D"))); + edit_mode_button->set_icon(get_editor_theme_icon(SNAME("ToolBoneSelect"))); + key_loc_button->set_icon(get_editor_theme_icon(SNAME("KeyPosition"))); + key_rot_button->set_icon(get_editor_theme_icon(SNAME("KeyRotation"))); + key_scale_button->set_icon(get_editor_theme_icon(SNAME("KeyScale"))); + key_insert_button->set_icon(get_editor_theme_icon(SNAME("Key"))); + key_insert_all_button->set_icon(get_editor_theme_icon(SNAME("NewKey"))); + bones_section->set_bg_color(get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); update_joint_tree(); } break; @@ -935,7 +936,7 @@ void fragment() { } )"); handle_material->set_shader(handle_shader); - Ref<Texture2D> handle = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("EditorBoneHandle"), SNAME("EditorIcons")); + Ref<Texture2D> handle = EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("EditorBoneHandle")); handle_material->set_shader_parameter("point_size", handle->get_width()); handle_material->set_shader_parameter("texture_albedo", handle); @@ -1371,9 +1372,9 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { int bone_shape = EDITOR_GET("editors/3d_gizmos/gizmo_settings/bone_shape"); LocalVector<Color> axis_colors; - axis_colors.push_back(Node3DEditor::get_singleton()->get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); - axis_colors.push_back(Node3DEditor::get_singleton()->get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); - axis_colors.push_back(Node3DEditor::get_singleton()->get_theme_color(SNAME("axis_z_color"), SNAME("Editor"))); + axis_colors.push_back(Node3DEditor::get_singleton()->get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor))); + axis_colors.push_back(Node3DEditor::get_singleton()->get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor))); + axis_colors.push_back(Node3DEditor::get_singleton()->get_theme_color(SNAME("axis_z_color"), EditorStringName(Editor))); Ref<SurfaceTool> surface_tool(memnew(SurfaceTool)); surface_tool->begin(Mesh::PRIMITIVE_LINES); diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp index 6331209281..d081dd7c06 100644 --- a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp @@ -84,7 +84,7 @@ void SkeletonIK3DEditorPlugin::_bind_methods() { SkeletonIK3DEditorPlugin::SkeletonIK3DEditorPlugin() { play_btn = memnew(Button); - play_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); + play_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Play"))); play_btn->set_text(TTR("Play IK")); play_btn->set_toggle_mode(true); play_btn->hide(); diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index f647bded95..1363669928 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -503,12 +503,12 @@ void Sprite2DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - options->set_icon(get_theme_icon(SNAME("Sprite2D"), SNAME("EditorIcons"))); + options->set_icon(get_editor_theme_icon(SNAME("Sprite2D"))); - options->get_popup()->set_item_icon(MENU_OPTION_CONVERT_TO_MESH_2D, get_theme_icon(SNAME("MeshInstance2D"), SNAME("EditorIcons"))); - options->get_popup()->set_item_icon(MENU_OPTION_CONVERT_TO_POLYGON_2D, get_theme_icon(SNAME("Polygon2D"), SNAME("EditorIcons"))); - options->get_popup()->set_item_icon(MENU_OPTION_CREATE_COLLISION_POLY_2D, get_theme_icon(SNAME("CollisionPolygon2D"), SNAME("EditorIcons"))); - options->get_popup()->set_item_icon(MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D, get_theme_icon(SNAME("LightOccluder2D"), SNAME("EditorIcons"))); + options->get_popup()->set_item_icon(MENU_OPTION_CONVERT_TO_MESH_2D, get_editor_theme_icon(SNAME("MeshInstance2D"))); + options->get_popup()->set_item_icon(MENU_OPTION_CONVERT_TO_POLYGON_2D, get_editor_theme_icon(SNAME("Polygon2D"))); + options->get_popup()->set_item_icon(MENU_OPTION_CREATE_COLLISION_POLY_2D, get_editor_theme_icon(SNAME("CollisionPolygon2D"))); + options->get_popup()->set_item_icon(MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D, get_editor_theme_icon(SNAME("LightOccluder2D"))); } break; } } diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 720cfb5928..54b72b6b3e 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -37,6 +37,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_file_dialog.h" #include "editor/scene_tree_dock.h" @@ -132,12 +133,12 @@ void SpriteFramesEditor::_sheet_preview_draw() { return; } - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", EditorStringName(Editor)); _sheet_sort_frames(); - Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); for (int i = 0; i < frames_ordered.size(); ++i) { const int idx = frames_ordered[i].second; @@ -494,9 +495,9 @@ void SpriteFramesEditor::_toggle_show_settings() { void SpriteFramesEditor::_update_show_settings() { if (is_layout_rtl()) { - toggle_settings_button->set_icon(get_theme_icon(split_sheet_settings_vb->is_visible() ? SNAME("Back") : SNAME("Forward"), SNAME("EditorIcons"))); + toggle_settings_button->set_icon(get_editor_theme_icon(split_sheet_settings_vb->is_visible() ? SNAME("Back") : SNAME("Forward"))); } else { - toggle_settings_button->set_icon(get_theme_icon(split_sheet_settings_vb->is_visible() ? SNAME("Forward") : SNAME("Back"), SNAME("EditorIcons"))); + toggle_settings_button->set_icon(get_editor_theme_icon(split_sheet_settings_vb->is_visible() ? SNAME("Forward") : SNAME("Back"))); } } @@ -550,36 +551,36 @@ void SpriteFramesEditor::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - autoplay_icon = get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons")); - stop_icon = get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")); - pause_icon = get_theme_icon(SNAME("Pause"), SNAME("EditorIcons")); + autoplay_icon = get_editor_theme_icon(SNAME("AutoPlay")); + stop_icon = get_editor_theme_icon(SNAME("Stop")); + pause_icon = get_editor_theme_icon(SNAME("Pause")); _update_stop_icon(); - autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons"))); - anim_loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons"))); - play->set_icon(get_theme_icon(SNAME("PlayStart"), SNAME("EditorIcons"))); - play_from->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); - play_bw->set_icon(get_theme_icon(SNAME("PlayStartBackwards"), SNAME("EditorIcons"))); - play_bw_from->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons"))); - - load->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); - load_sheet->set_icon(get_theme_icon(SNAME("SpriteSheet"), SNAME("EditorIcons"))); - copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); - paste->set_icon(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons"))); - empty_before->set_icon(get_theme_icon(SNAME("InsertBefore"), SNAME("EditorIcons"))); - empty_after->set_icon(get_theme_icon(SNAME("InsertAfter"), SNAME("EditorIcons"))); - move_up->set_icon(get_theme_icon(SNAME("MoveLeft"), SNAME("EditorIcons"))); - move_down->set_icon(get_theme_icon(SNAME("MoveRight"), SNAME("EditorIcons"))); - delete_frame->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); - zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); - zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); - add_anim->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons"))); - delete_anim->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - anim_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - split_sheet_zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); - split_sheet_zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); - split_sheet_zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); + autoplay->set_icon(get_editor_theme_icon(SNAME("AutoPlay"))); + anim_loop->set_icon(get_editor_theme_icon(SNAME("Loop"))); + play->set_icon(get_editor_theme_icon(SNAME("PlayStart"))); + play_from->set_icon(get_editor_theme_icon(SNAME("Play"))); + play_bw->set_icon(get_editor_theme_icon(SNAME("PlayStartBackwards"))); + play_bw_from->set_icon(get_editor_theme_icon(SNAME("PlayBackwards"))); + + load->set_icon(get_editor_theme_icon(SNAME("Load"))); + load_sheet->set_icon(get_editor_theme_icon(SNAME("SpriteSheet"))); + copy->set_icon(get_editor_theme_icon(SNAME("ActionCopy"))); + paste->set_icon(get_editor_theme_icon(SNAME("ActionPaste"))); + empty_before->set_icon(get_editor_theme_icon(SNAME("InsertBefore"))); + empty_after->set_icon(get_editor_theme_icon(SNAME("InsertAfter"))); + move_up->set_icon(get_editor_theme_icon(SNAME("MoveLeft"))); + move_down->set_icon(get_editor_theme_icon(SNAME("MoveRight"))); + delete_frame->set_icon(get_editor_theme_icon(SNAME("Remove"))); + zoom_out->set_icon(get_editor_theme_icon(SNAME("ZoomLess"))); + zoom_reset->set_icon(get_editor_theme_icon(SNAME("ZoomReset"))); + zoom_in->set_icon(get_editor_theme_icon(SNAME("ZoomMore"))); + add_anim->set_icon(get_editor_theme_icon(SNAME("New"))); + delete_anim->set_icon(get_editor_theme_icon(SNAME("Remove"))); + anim_search_box->set_right_icon(get_editor_theme_icon(SNAME("Search"))); + split_sheet_zoom_out->set_icon(get_editor_theme_icon(SNAME("ZoomLess"))); + split_sheet_zoom_reset->set_icon(get_editor_theme_icon(SNAME("ZoomReset"))); + split_sheet_zoom_in->set_icon(get_editor_theme_icon(SNAME("ZoomMore"))); split_sheet_scroll->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); _update_show_settings(); diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index 9364b96c90..9b1c208a9f 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -57,8 +57,8 @@ void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) { void StyleBoxPreview::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - set_texture(get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons"))); - grid_preview->set_icon(get_theme_icon(SNAME("StyleBoxGrid"), SNAME("EditorIcons"))); + set_texture(get_editor_theme_icon(SNAME("Checkerboard"))); + grid_preview->set_icon(get_editor_theme_icon(SNAME("StyleBoxGrid"))); } break; case NOTIFICATION_DRAW: { _redraw(); @@ -68,7 +68,7 @@ void StyleBoxPreview::_notification(int p_what) { void StyleBoxPreview::_redraw() { if (stylebox.is_valid()) { - float grid_button_width = get_theme_icon(SNAME("StyleBoxGrid"), SNAME("EditorIcons"))->get_size().x; + float grid_button_width = get_editor_theme_icon(SNAME("StyleBoxGrid"))->get_size().x; Rect2 preview_rect = get_rect(); preview_rect = preview_rect.grow(-grid_button_width); diff --git a/editor/plugins/text_shader_editor.cpp b/editor/plugins/text_shader_editor.cpp index 932a255982..935f2250c6 100644 --- a/editor/plugins/text_shader_editor.cpp +++ b/editor/plugins/text_shader_editor.cpp @@ -34,6 +34,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/filesystem_dock.h" #include "editor/project_settings_editor.h" #include "scene/gui/split_container.h" @@ -319,8 +320,8 @@ void ShaderTextEditor::_load_theme_settings() { if (warnings_panel) { // Warnings panel. - warnings_panel->add_theme_font_override("normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts"))); - warnings_panel->add_theme_font_size_override("normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); + warnings_panel->add_theme_font_override("normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), EditorStringName(EditorFonts))); + warnings_panel->add_theme_font_size_override("normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), EditorStringName(EditorFonts))); } } @@ -586,7 +587,7 @@ void ShaderTextEditor::_update_warning_panel() { // First cell. warnings_panel->push_cell(); - warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); if (line != -1) { warnings_panel->push_meta(line - 1); warnings_panel->add_text(TTR("Line") + " " + itos(line)); @@ -717,7 +718,7 @@ void TextShaderEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { PopupMenu *popup = help_menu->get_popup(); - popup->set_item_icon(popup->get_item_index(HELP_DOCS), get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons"))); + popup->set_item_icon(popup->get_item_index(HELP_DOCS), get_editor_theme_icon(SNAME("ExternalLink"))); } break; case NOTIFICATION_APPLICATION_FOCUS_IN: { @@ -1159,7 +1160,7 @@ TextShaderEditor::TextShaderEditor() { hbc->add_child(edit_menu); hbc->add_child(goto_menu); hbc->add_child(help_menu); - hbc->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles"))); + hbc->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), EditorStringName(EditorStyles))); VSplitContainer *editor_box = memnew(VSplitContainer); main_container->add_child(editor_box); diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp index 2702e94188..1b5c2dcab1 100644 --- a/editor/plugins/texture_3d_editor_plugin.cpp +++ b/editor/plugins/texture_3d_editor_plugin.cpp @@ -43,7 +43,7 @@ void Texture3DEditor::_notification(int p_what) { } break; case NOTIFICATION_DRAW: { - Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); + Ref<Texture2D> checkerboard = get_editor_theme_icon(SNAME("Checkerboard")); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 87b207ebcd..74a03c1e97 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -31,6 +31,7 @@ #include "texture_editor_plugin.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "scene/gui/label.h" #include "scene/gui/texture_rect.h" #include "scene/resources/animated_texture.h" @@ -55,11 +56,11 @@ void TexturePreview::_notification(int p_what) { } if (metadata_label) { - Ref<Font> metadata_label_font = get_theme_font(SNAME("expression"), SNAME("EditorFonts")); + Ref<Font> metadata_label_font = get_theme_font(SNAME("expression"), EditorStringName(EditorFonts)); metadata_label->add_theme_font_override("font", metadata_label_font); } - checkerboard->set_texture(get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons"))); + checkerboard->set_texture(get_editor_theme_icon(SNAME("Checkerboard"))); } break; } } diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index a0188b08e5..20e7b5d8c4 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -54,7 +54,7 @@ void TextureLayeredEditor::_notification(int p_what) { } break; case NOTIFICATION_DRAW: { - Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); + Ref<Texture2D> checkerboard = get_editor_theme_icon(SNAME("Checkerboard")); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 124cd79126..8df7be766b 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -35,6 +35,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "scene/gui/check_box.h" #include "scene/gui/option_button.h" @@ -73,7 +74,7 @@ void TextureRegionEditor::_texture_overlay_draw() { } Transform2D mtx = _get_offset_transform(); - const Color color = get_theme_color(SNAME("mono_color"), SNAME("Editor")); + const Color color = get_theme_color(SNAME("mono_color"), EditorStringName(Editor)); if (snap_mode == SNAP_GRID) { const Color grid_color = Color(color.r, color.g, color.b, color.a * 0.15); @@ -146,7 +147,7 @@ void TextureRegionEditor::_texture_overlay_draw() { } } - Ref<Texture2D> select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); + Ref<Texture2D> select_handle = get_editor_theme_icon(SNAME("EditorHandle")); Rect2 scroll_rect(Point2(), object_texture->get_size()); @@ -264,7 +265,7 @@ void TextureRegionEditor::_draw_margin_line(Vector2 p_from, Vector2 p_to) { Vector2 dash_size = (p_to - p_from).normalized() * 10; const int dash_thickness = Math::round(2 * EDSCALE); - const Color dash_color = get_theme_color(SNAME("mono_color"), SNAME("Editor")); + const Color dash_color = get_theme_color(SNAME("mono_color"), EditorStringName(Editor)); const Color dash_bg_color = dash_color.inverted() * Color(1, 1, 1, 0.5); const int line_threshold = 200; @@ -822,12 +823,12 @@ void TextureRegionEditor::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - texture_preview->add_theme_style_override("panel", get_theme_stylebox(SNAME("TextureRegionPreviewBG"), SNAME("EditorStyles"))); - texture_overlay->add_theme_style_override("panel", get_theme_stylebox(SNAME("TextureRegionPreviewFG"), SNAME("EditorStyles"))); + texture_preview->add_theme_style_override("panel", get_theme_stylebox(SNAME("TextureRegionPreviewBG"), EditorStringName(EditorStyles))); + texture_overlay->add_theme_style_override("panel", get_theme_stylebox(SNAME("TextureRegionPreviewFG"), EditorStringName(EditorStyles))); - zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); - zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); - zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); + zoom_out->set_icon(get_editor_theme_icon(SNAME("ZoomLess"))); + zoom_reset->set_icon(get_editor_theme_icon(SNAME("ZoomReset"))); + zoom_in->set_icon(get_editor_theme_icon(SNAME("ZoomMore"))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -1226,7 +1227,7 @@ bool EditorInspectorPluginTextureRegion::parse_property(Object *p_object, const if ((p_type == Variant::RECT2 || p_type == Variant::RECT2I)) { if (((Object::cast_to<Sprite2D>(p_object) || Object::cast_to<Sprite3D>(p_object) || Object::cast_to<NinePatchRect>(p_object) || Object::cast_to<StyleBoxTexture>(p_object)) && p_path == "region_rect") || (Object::cast_to<AtlasTexture>(p_object) && p_path == "region")) { Button *button = EditorInspector::create_inspector_action_button(TTR("Edit Region")); - button->set_icon(texture_region_editor->get_theme_icon(SNAME("RegionEdit"), SNAME("EditorIcons"))); + button->set_icon(texture_region_editor->get_editor_theme_icon(SNAME("RegionEdit"))); button->connect("pressed", callable_mp(this, &EditorInspectorPluginTextureRegion::_region_edit).bind(p_object)); add_property_editor(p_path, button, true); } diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 97ab6d04f4..ffe6c01ef0 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -34,6 +34,7 @@ #include "editor/editor_node.h" #include "editor/editor_resource_picker.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_file_dialog.h" #include "editor/progress_dialog.h" @@ -84,7 +85,7 @@ void ThemeItemImportTree::_update_items_tree() { Ref<Texture2D> type_icon; if (E == "") { - type_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); + type_icon = get_editor_theme_icon(SNAME("NodeDisabled")); } else { type_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } @@ -147,7 +148,7 @@ void ThemeItemImportTree::_update_items_tree() { switch (dt) { case Theme::DATA_TYPE_COLOR: - data_type_node->set_icon(0, get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); + data_type_node->set_icon(0, get_editor_theme_icon(SNAME("Color"))); data_type_node->set_text(0, TTR("Colors")); item_list = &tree_color_items; @@ -155,7 +156,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_CONSTANT: - data_type_node->set_icon(0, get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); + data_type_node->set_icon(0, get_editor_theme_icon(SNAME("MemberConstant"))); data_type_node->set_text(0, TTR("Constants")); item_list = &tree_constant_items; @@ -163,7 +164,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_FONT: - data_type_node->set_icon(0, get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); + data_type_node->set_icon(0, get_editor_theme_icon(SNAME("Font"))); data_type_node->set_text(0, TTR("Fonts")); item_list = &tree_font_items; @@ -171,7 +172,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_FONT_SIZE: - data_type_node->set_icon(0, get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); + data_type_node->set_icon(0, get_editor_theme_icon(SNAME("FontSize"))); data_type_node->set_text(0, TTR("Font Sizes")); item_list = &tree_font_size_items; @@ -179,7 +180,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_ICON: - data_type_node->set_icon(0, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); + data_type_node->set_icon(0, get_editor_theme_icon(SNAME("ImageTexture"))); data_type_node->set_text(0, TTR("Icons")); item_list = &tree_icon_items; @@ -187,7 +188,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_STYLEBOX: - data_type_node->set_icon(0, get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); + data_type_node->set_icon(0, get_editor_theme_icon(SNAME("StyleBoxFlat"))); data_type_node->set_text(0, TTR("Styleboxes")); item_list = &tree_stylebox_items; @@ -851,49 +852,49 @@ void ThemeItemImportTree::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - select_icons_warning_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); - select_icons_warning->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + select_icons_warning_icon->set_texture(get_editor_theme_icon(SNAME("StatusWarning"))); + select_icons_warning->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); - import_items_filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + import_items_filter->set_right_icon(get_editor_theme_icon(SNAME("Search"))); // Bottom panel buttons. - import_collapse_types_button->set_icon(get_theme_icon(SNAME("CollapseTree"), SNAME("EditorIcons"))); - import_expand_types_button->set_icon(get_theme_icon(SNAME("ExpandTree"), SNAME("EditorIcons"))); + import_collapse_types_button->set_icon(get_editor_theme_icon(SNAME("CollapseTree"))); + import_expand_types_button->set_icon(get_editor_theme_icon(SNAME("ExpandTree"))); - import_select_all_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); - import_select_full_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); - import_deselect_all_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + import_select_all_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectAll"))); + import_select_full_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectFull"))); + import_deselect_all_button->set_icon(get_editor_theme_icon(SNAME("ThemeDeselectAll"))); // Side panel buttons. - select_colors_icon->set_texture(get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); - deselect_all_colors_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); - select_all_colors_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); - select_full_colors_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); - - select_constants_icon->set_texture(get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); - deselect_all_constants_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); - select_all_constants_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); - select_full_constants_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); - - select_fonts_icon->set_texture(get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); - deselect_all_fonts_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); - select_all_fonts_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); - select_full_fonts_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); - - select_font_sizes_icon->set_texture(get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); - deselect_all_font_sizes_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); - select_all_font_sizes_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); - select_full_font_sizes_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); - - select_icons_icon->set_texture(get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); - deselect_all_icons_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); - select_all_icons_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); - select_full_icons_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); - - select_styleboxes_icon->set_texture(get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); - deselect_all_styleboxes_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); - select_all_styleboxes_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); - select_full_styleboxes_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + select_colors_icon->set_texture(get_editor_theme_icon(SNAME("Color"))); + deselect_all_colors_button->set_icon(get_editor_theme_icon(SNAME("ThemeDeselectAll"))); + select_all_colors_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectAll"))); + select_full_colors_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectFull"))); + + select_constants_icon->set_texture(get_editor_theme_icon(SNAME("MemberConstant"))); + deselect_all_constants_button->set_icon(get_editor_theme_icon(SNAME("ThemeDeselectAll"))); + select_all_constants_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectAll"))); + select_full_constants_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectFull"))); + + select_fonts_icon->set_texture(get_editor_theme_icon(SNAME("Font"))); + deselect_all_fonts_button->set_icon(get_editor_theme_icon(SNAME("ThemeDeselectAll"))); + select_all_fonts_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectAll"))); + select_full_fonts_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectFull"))); + + select_font_sizes_icon->set_texture(get_editor_theme_icon(SNAME("FontSize"))); + deselect_all_font_sizes_button->set_icon(get_editor_theme_icon(SNAME("ThemeDeselectAll"))); + select_all_font_sizes_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectAll"))); + select_full_font_sizes_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectFull"))); + + select_icons_icon->set_texture(get_editor_theme_icon(SNAME("ImageTexture"))); + deselect_all_icons_button->set_icon(get_editor_theme_icon(SNAME("ThemeDeselectAll"))); + select_all_icons_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectAll"))); + select_full_icons_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectFull"))); + + select_styleboxes_icon->set_texture(get_editor_theme_icon(SNAME("StyleBoxFlat"))); + deselect_all_styleboxes_button->set_icon(get_editor_theme_icon(SNAME("ThemeDeselectAll"))); + select_all_styleboxes_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectAll"))); + select_full_styleboxes_button->set_icon(get_editor_theme_icon(SNAME("ThemeSelectFull"))); } break; } } @@ -1216,7 +1217,7 @@ void ThemeItemEditorDialog::_dialog_about_to_show() { import_default_theme_items->reset_item_tree(); import_editor_theme_items->set_edited_theme(edited_theme); - import_editor_theme_items->set_base_theme(EditorNode::get_singleton()->get_theme_base()->get_theme()); + import_editor_theme_items->set_base_theme(EditorNode::get_singleton()->get_editor_theme()); import_editor_theme_items->reset_item_tree(); import_other_theme_items->set_edited_theme(edited_theme); @@ -1237,14 +1238,14 @@ void ThemeItemEditorDialog::_update_edit_types() { for (const StringName &E : theme_types) { Ref<Texture2D> item_icon; if (E == "") { - item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); + item_icon = get_editor_theme_icon(SNAME("NodeDisabled")); } else { item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } TreeItem *list_item = edit_type_list->create_item(list_root); list_item->set_text(0, E); list_item->set_icon(0, item_icon); - list_item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TYPES_TREE_REMOVE_ITEM, false, TTR("Remove Type")); + list_item->add_button(0, get_editor_theme_icon(SNAME("Remove")), TYPES_TREE_REMOVE_ITEM, false, TTR("Remove Type")); if (E == edited_item_type) { list_item->select(0); @@ -1340,16 +1341,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *color_root = edit_items_tree->create_item(root); color_root->set_metadata(0, Theme::DATA_TYPE_COLOR); - color_root->set_icon(0, get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); + color_root->set_icon(0, get_editor_theme_icon(SNAME("Color"))); color_root->set_text(0, TTR("Colors")); - color_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Color Items")); + color_root->add_button(0, get_editor_theme_icon(SNAME("Clear")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Color Items")); names.sort_custom<StringName::AlphCompare>(); for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(color_root); item->set_text(0, E); - item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Edit")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Remove")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } has_any_items = true; @@ -1363,16 +1364,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *constant_root = edit_items_tree->create_item(root); constant_root->set_metadata(0, Theme::DATA_TYPE_CONSTANT); - constant_root->set_icon(0, get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); + constant_root->set_icon(0, get_editor_theme_icon(SNAME("MemberConstant"))); constant_root->set_text(0, TTR("Constants")); - constant_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Constant Items")); + constant_root->add_button(0, get_editor_theme_icon(SNAME("Clear")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Constant Items")); names.sort_custom<StringName::AlphCompare>(); for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(constant_root); item->set_text(0, E); - item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Edit")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Remove")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } has_any_items = true; @@ -1386,16 +1387,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *font_root = edit_items_tree->create_item(root); font_root->set_metadata(0, Theme::DATA_TYPE_FONT); - font_root->set_icon(0, get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); + font_root->set_icon(0, get_editor_theme_icon(SNAME("Font"))); font_root->set_text(0, TTR("Fonts")); - font_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Items")); + font_root->add_button(0, get_editor_theme_icon(SNAME("Clear")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Items")); names.sort_custom<StringName::AlphCompare>(); for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_root); item->set_text(0, E); - item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Edit")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Remove")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } has_any_items = true; @@ -1409,16 +1410,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *font_size_root = edit_items_tree->create_item(root); font_size_root->set_metadata(0, Theme::DATA_TYPE_FONT_SIZE); - font_size_root->set_icon(0, get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); + font_size_root->set_icon(0, get_editor_theme_icon(SNAME("FontSize"))); font_size_root->set_text(0, TTR("Font Sizes")); - font_size_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Size Items")); + font_size_root->add_button(0, get_editor_theme_icon(SNAME("Clear")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Size Items")); names.sort_custom<StringName::AlphCompare>(); for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_size_root); item->set_text(0, E); - item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Edit")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Remove")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } has_any_items = true; @@ -1432,16 +1433,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *icon_root = edit_items_tree->create_item(root); icon_root->set_metadata(0, Theme::DATA_TYPE_ICON); - icon_root->set_icon(0, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); + icon_root->set_icon(0, get_editor_theme_icon(SNAME("ImageTexture"))); icon_root->set_text(0, TTR("Icons")); - icon_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Icon Items")); + icon_root->add_button(0, get_editor_theme_icon(SNAME("Clear")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Icon Items")); names.sort_custom<StringName::AlphCompare>(); for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(icon_root); item->set_text(0, E); - item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Edit")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Remove")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } has_any_items = true; @@ -1455,16 +1456,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *stylebox_root = edit_items_tree->create_item(root); stylebox_root->set_metadata(0, Theme::DATA_TYPE_STYLEBOX); - stylebox_root->set_icon(0, get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); + stylebox_root->set_icon(0, get_editor_theme_icon(SNAME("StyleBoxFlat"))); stylebox_root->set_text(0, TTR("Styleboxes")); - stylebox_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All StyleBox Items")); + stylebox_root->add_button(0, get_editor_theme_icon(SNAME("Clear")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All StyleBox Items")); names.sort_custom<StringName::AlphCompare>(); for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(stylebox_root); item->set_text(0, E); - item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Edit")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_editor_theme_icon(SNAME("Remove")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } has_any_items = true; @@ -1872,20 +1873,20 @@ void ThemeItemEditorDialog::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - edit_items_add_color->set_icon(get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); - edit_items_add_constant->set_icon(get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); - edit_items_add_font->set_icon(get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); - edit_items_add_font_size->set_icon(get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); - edit_items_add_icon->set_icon(get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); - edit_items_add_stylebox->set_icon(get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); + edit_items_add_color->set_icon(get_editor_theme_icon(SNAME("Color"))); + edit_items_add_constant->set_icon(get_editor_theme_icon(SNAME("MemberConstant"))); + edit_items_add_font->set_icon(get_editor_theme_icon(SNAME("Font"))); + edit_items_add_font_size->set_icon(get_editor_theme_icon(SNAME("FontSize"))); + edit_items_add_icon->set_icon(get_editor_theme_icon(SNAME("ImageTexture"))); + edit_items_add_stylebox->set_icon(get_editor_theme_icon(SNAME("StyleBoxFlat"))); - edit_items_remove_class->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); - edit_items_remove_custom->set_icon(get_theme_icon(SNAME("ThemeRemoveCustomItems"), SNAME("EditorIcons"))); - edit_items_remove_all->set_icon(get_theme_icon(SNAME("ThemeRemoveAllItems"), SNAME("EditorIcons"))); + edit_items_remove_class->set_icon(get_editor_theme_icon(SNAME("Control"))); + edit_items_remove_custom->set_icon(get_editor_theme_icon(SNAME("ThemeRemoveCustomItems"))); + edit_items_remove_all->set_icon(get_editor_theme_icon(SNAME("ThemeRemoveAllItems"))); - edit_add_type_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + edit_add_type_button->set_icon(get_editor_theme_icon(SNAME("Add"))); - import_another_theme_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + import_another_theme_button->set_icon(get_editor_theme_icon(SNAME("Folder"))); } break; } } @@ -2154,7 +2155,7 @@ void ThemeTypeDialog::_update_add_type_options(const String &p_filter) { Ref<Texture2D> item_icon; if (E == "") { - item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); + item_icon = get_editor_theme_icon(SNAME("NodeDisabled")); } else { item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } @@ -2329,7 +2330,7 @@ void ThemeTypeEditor::_update_type_list() { for (const StringName &E : theme_types) { Ref<Texture2D> item_icon; if (E == "") { - item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); + item_icon = get_editor_theme_icon(SNAME("NodeDisabled")); } else { item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } @@ -2428,21 +2429,21 @@ HBoxContainer *ThemeTypeEditor::_create_property_control(Theme::DataType p_data_ item_name_edit->hide(); Button *item_rename_button = memnew(Button); - item_rename_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + item_rename_button->set_icon(get_editor_theme_icon(SNAME("Edit"))); item_rename_button->set_tooltip_text(TTR("Rename Item")); item_rename_button->set_flat(true); item_name_container->add_child(item_rename_button); item_rename_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_item_rename_cbk).bind(p_data_type, p_item_name, item_name_container)); Button *item_remove_button = memnew(Button); - item_remove_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + item_remove_button->set_icon(get_editor_theme_icon(SNAME("Remove"))); item_remove_button->set_tooltip_text(TTR("Remove Item")); item_remove_button->set_flat(true); item_name_container->add_child(item_remove_button); item_remove_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_item_remove_cbk).bind(p_data_type, p_item_name)); Button *item_rename_confirm_button = memnew(Button); - item_rename_confirm_button->set_icon(get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons"))); + item_rename_confirm_button->set_icon(get_editor_theme_icon(SNAME("ImportCheck"))); item_rename_confirm_button->set_tooltip_text(TTR("Confirm Item Rename")); item_rename_confirm_button->set_flat(true); item_name_container->add_child(item_rename_confirm_button); @@ -2450,17 +2451,17 @@ HBoxContainer *ThemeTypeEditor::_create_property_control(Theme::DataType p_data_ item_rename_confirm_button->hide(); Button *item_rename_cancel_button = memnew(Button); - item_rename_cancel_button->set_icon(get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"))); + item_rename_cancel_button->set_icon(get_editor_theme_icon(SNAME("ImportFail"))); item_rename_cancel_button->set_tooltip_text(TTR("Cancel Item Rename")); item_rename_cancel_button->set_flat(true); item_name_container->add_child(item_rename_cancel_button); item_rename_cancel_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_item_rename_canceled).bind(p_data_type, p_item_name, item_name_container)); item_rename_cancel_button->hide(); } else { - item_name->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); + item_name->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); Button *item_override_button = memnew(Button); - item_override_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + item_override_button->set_icon(get_editor_theme_icon(SNAME("Add"))); item_override_button->set_tooltip_text(TTR("Override Item")); item_override_button->set_flat(true); item_name_container->add_child(item_override_button); @@ -2670,7 +2671,7 @@ void ThemeTypeEditor::_update_type_items() { pin_leader_button->set_flat(true); pin_leader_button->set_toggle_mode(true); pin_leader_button->set_pressed(true); - pin_leader_button->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); + pin_leader_button->set_icon(get_editor_theme_icon(SNAME("Pin"))); pin_leader_button->set_tooltip_text(TTR("Unpin this StyleBox as a main style.")); item_control->add_child(pin_leader_button); pin_leader_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_on_unpin_leader_button_pressed)); @@ -2713,7 +2714,7 @@ void ThemeTypeEditor::_update_type_items() { Button *pin_leader_button = memnew(Button); pin_leader_button->set_flat(true); pin_leader_button->set_toggle_mode(true); - pin_leader_button->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); + pin_leader_button->set_icon(get_editor_theme_icon(SNAME("Pin"))); pin_leader_button->set_tooltip_text(TTR("Pin this StyleBox as a main style. Editing its properties will update the same properties in all other StyleBoxes of this type.")); item_control->add_child(pin_leader_button); pin_leader_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_on_pin_leader_button_pressed).bind(item_editor, E.key)); @@ -3313,17 +3314,17 @@ void ThemeTypeEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - add_type_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_type_button->set_icon(get_editor_theme_icon(SNAME("Add"))); - data_type_tabs->set_tab_icon(0, get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); - data_type_tabs->set_tab_icon(1, get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); - data_type_tabs->set_tab_icon(2, get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); - data_type_tabs->set_tab_icon(3, get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); - data_type_tabs->set_tab_icon(4, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); - data_type_tabs->set_tab_icon(5, get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); - data_type_tabs->set_tab_icon(6, get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(0, get_editor_theme_icon(SNAME("Color"))); + data_type_tabs->set_tab_icon(1, get_editor_theme_icon(SNAME("MemberConstant"))); + data_type_tabs->set_tab_icon(2, get_editor_theme_icon(SNAME("Font"))); + data_type_tabs->set_tab_icon(3, get_editor_theme_icon(SNAME("FontSize"))); + data_type_tabs->set_tab_icon(4, get_editor_theme_icon(SNAME("ImageTexture"))); + data_type_tabs->set_tab_icon(5, get_editor_theme_icon(SNAME("StyleBoxFlat"))); + data_type_tabs->set_tab_icon(6, get_editor_theme_icon(SNAME("Tools"))); - type_variation_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + type_variation_button->set_icon(get_editor_theme_icon(SNAME("Add"))); } break; } } @@ -3537,7 +3538,7 @@ void ThemeEditor::_preview_scene_dialog_cbk(const String &p_path) { return; } - _add_preview_tab(preview_tab, p_path.get_file(), get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"))); + _add_preview_tab(preview_tab, p_path.get_file(), get_editor_theme_icon(SNAME("PackedScene"))); preview_tab->connect("scene_invalidated", callable_mp(this, &ThemeEditor::_remove_preview_tab_invalid).bind(preview_tab)); preview_tab->connect("scene_reloaded", callable_mp(this, &ThemeEditor::_update_preview_tab).bind(preview_tab)); } @@ -3610,11 +3611,11 @@ void ThemeEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - preview_tabs->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("ThemeEditorPreviewFG"), SNAME("EditorStyles"))); - preview_tabs->add_theme_style_override("tab_unselected", get_theme_stylebox(SNAME("ThemeEditorPreviewBG"), SNAME("EditorStyles"))); + preview_tabs->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("ThemeEditorPreviewFG"), EditorStringName(EditorStyles))); + preview_tabs->add_theme_style_override("tab_unselected", get_theme_stylebox(SNAME("ThemeEditorPreviewBG"), EditorStringName(EditorStyles))); preview_tabs_content->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainerOdd"))); - add_preview_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_preview_button->set_icon(get_editor_theme_icon(SNAME("Add"))); } break; } } diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index fb8cb57d4d..61bce0a89c 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -35,6 +35,7 @@ #include "core/math/math_funcs.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "scene/gui/button.h" #include "scene/gui/check_box.h" #include "scene/gui/check_button.h" @@ -201,16 +202,22 @@ void ThemeEditorPreview::_notification(int p_what) { } connect("visibility_changed", callable_mp(this, &ThemeEditorPreview::_preview_visibility_changed)); - [[fallthrough]]; - } + } break; + + case NOTIFICATION_READY: { + List<Ref<Theme>> preview_themes; + preview_themes.push_back(ThemeDB::get_singleton()->get_default_theme()); + ThemeDB::get_singleton()->create_theme_context(preview_root, preview_themes); + } break; + case NOTIFICATION_THEME_CHANGED: { - picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); + picker_button->set_icon(get_editor_theme_icon(SNAME("ColorPick"))); theme_cache.preview_picker_overlay = get_theme_stylebox(SNAME("preview_picker_overlay"), SNAME("ThemeEditor")); theme_cache.preview_picker_overlay_color = get_theme_color(SNAME("preview_picker_overlay_color"), SNAME("ThemeEditor")); theme_cache.preview_picker_label = get_theme_stylebox(SNAME("preview_picker_label"), SNAME("ThemeEditor")); - theme_cache.preview_picker_font = get_theme_font(SNAME("status_source"), SNAME("EditorFonts")); - theme_cache.font_size = get_theme_font_size(SNAME("font_size"), SNAME("EditorFonts")); + theme_cache.preview_picker_font = get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts)); + theme_cache.font_size = get_theme_font_size(SNAME("font_size"), EditorStringName(EditorFonts)); } break; case NOTIFICATION_PROCESS: { @@ -246,9 +253,8 @@ ThemeEditorPreview::ThemeEditorPreview() { preview_container = memnew(ScrollContainer); preview_body->add_child(preview_container); - MarginContainer *preview_root = memnew(MarginContainer); + preview_root = memnew(MarginContainer); preview_container->add_child(preview_root); - preview_root->set_theme(ThemeDB::get_singleton()->get_default_theme()); preview_root->set_clip_contents(true); preview_root->set_custom_minimum_size(Size2(450, 0) * EDSCALE); preview_root->set_v_size_flags(SIZE_EXPAND_FILL); @@ -282,7 +288,7 @@ void DefaultThemeEditorPreview::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - test_color_picker_button->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); + test_color_picker_button->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor)))); } break; } } @@ -485,7 +491,7 @@ void SceneThemeEditorPreview::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - reload_scene_button->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + reload_scene_button->set_icon(get_editor_theme_icon(SNAME("Reload"))); } break; } } diff --git a/editor/plugins/theme_editor_preview.h b/editor/plugins/theme_editor_preview.h index bd9663904a..ed888e6c14 100644 --- a/editor/plugins/theme_editor_preview.h +++ b/editor/plugins/theme_editor_preview.h @@ -44,6 +44,7 @@ class ThemeEditorPreview : public VBoxContainer { GDCLASS(ThemeEditorPreview, VBoxContainer); ScrollContainer *preview_container = nullptr; + MarginContainer *preview_root = nullptr; ColorRect *preview_bg = nullptr; MarginContainer *preview_overlay = nullptr; Control *picker_overlay = nullptr; diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index fd74e6f8ca..b55be8b3f8 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -572,8 +572,8 @@ void TileAtlasView::queue_redraw() { void TileAtlasView::_update_theme_item_cache() { Control::_update_theme_item_cache(); - theme_cache.center_view_icon = get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons")); - theme_cache.checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); + theme_cache.center_view_icon = get_editor_theme_icon(SNAME("CenterView")); + theme_cache.checkerboard = get_editor_theme_icon(SNAME("Checkerboard")); } void TileAtlasView::_notification(int p_what) { diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index 0fbce2a677..26487e8dfd 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -39,6 +39,7 @@ #include "editor/editor_properties.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "scene/gui/control.h" @@ -137,9 +138,9 @@ void GenericTilePolygonEditor::_base_control_draw() { real_t grab_threshold = EDITOR_GET("editors/polygon_editor/point_grab_radius"); Color grid_color = EDITOR_GET("editors/tiles_editor/grid_color"); - const Ref<Texture2D> handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); - const Ref<Texture2D> add_handle = get_theme_icon(SNAME("EditorHandleAdd"), SNAME("EditorIcons")); - const Ref<StyleBox> focus_stylebox = get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles")); + const Ref<Texture2D> handle = get_editor_theme_icon(SNAME("EditorPathSharpHandle")); + const Ref<Texture2D> add_handle = get_editor_theme_icon(SNAME("EditorHandleAdd")); + const Ref<StyleBox> focus_stylebox = get_theme_stylebox(SNAME("Focus"), EditorStringName(EditorStyles)); // Draw the focus rectangle. if (base_control->has_focus()) { @@ -807,22 +808,22 @@ void GenericTilePolygonEditor::_notification(int p_what) { } } break; case NOTIFICATION_THEME_CHANGED: { - button_expand->set_icon(get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons"))); - button_create->set_icon(get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); - button_edit->set_icon(get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); - button_delete->set_icon(get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); - button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); - button_advanced_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - button_pixel_snap->get_popup()->set_item_icon(0, get_theme_icon(SNAME("SnapDisable"), SNAME("EditorIcons"))); - button_pixel_snap->get_popup()->set_item_icon(1, get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); - button_pixel_snap->get_popup()->set_item_icon(2, get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + button_expand->set_icon(get_editor_theme_icon(SNAME("DistractionFree"))); + button_create->set_icon(get_editor_theme_icon(SNAME("CurveCreate"))); + button_edit->set_icon(get_editor_theme_icon(SNAME("CurveEdit"))); + button_delete->set_icon(get_editor_theme_icon(SNAME("CurveDelete"))); + button_center_view->set_icon(get_editor_theme_icon(SNAME("CenterView"))); + button_advanced_menu->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); + button_pixel_snap->get_popup()->set_item_icon(0, get_editor_theme_icon(SNAME("SnapDisable"))); + button_pixel_snap->get_popup()->set_item_icon(1, get_editor_theme_icon(SNAME("Snap"))); + button_pixel_snap->get_popup()->set_item_icon(2, get_editor_theme_icon(SNAME("SnapGrid"))); button_pixel_snap->set_icon(button_pixel_snap->get_popup()->get_item_icon(current_snap_option)); PopupMenu *p = button_advanced_menu->get_popup(); - p->set_item_icon(p->get_item_index(ROTATE_RIGHT), get_theme_icon(SNAME("RotateRight"), SNAME("EditorIcons"))); - p->set_item_icon(p->get_item_index(ROTATE_LEFT), get_theme_icon(SNAME("RotateLeft"), SNAME("EditorIcons"))); - p->set_item_icon(p->get_item_index(FLIP_HORIZONTALLY), get_theme_icon(SNAME("MirrorX"), SNAME("EditorIcons"))); - p->set_item_icon(p->get_item_index(FLIP_VERTICALLY), get_theme_icon(SNAME("MirrorY"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(ROTATE_RIGHT), get_editor_theme_icon(SNAME("RotateRight"))); + p->set_item_icon(p->get_item_index(ROTATE_LEFT), get_editor_theme_icon(SNAME("RotateLeft"))); + p->set_item_icon(p->get_item_index(FLIP_HORIZONTALLY), get_editor_theme_icon(SNAME("MirrorX"))); + p->set_item_icon(p->get_item_index(FLIP_VERTICALLY), get_editor_theme_icon(SNAME("MirrorY"))); } break; } } @@ -882,10 +883,10 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() { button_advanced_menu->get_popup()->add_item(TTR("Reset to default tile shape"), RESET_TO_DEFAULT_TILE, Key::F); button_advanced_menu->get_popup()->add_item(TTR("Clear"), CLEAR_TILE, Key::C); button_advanced_menu->get_popup()->add_separator(); - button_advanced_menu->get_popup()->add_icon_item(get_theme_icon(SNAME("RotateRight"), SNAME("EditorIcons")), TTR("Rotate Right"), ROTATE_RIGHT, Key::R); - button_advanced_menu->get_popup()->add_icon_item(get_theme_icon(SNAME("RotateLeft"), SNAME("EditorIcons")), TTR("Rotate Left"), ROTATE_LEFT, Key::E); - button_advanced_menu->get_popup()->add_icon_item(get_theme_icon(SNAME("MirrorX"), SNAME("EditorIcons")), TTR("Flip Horizontally"), FLIP_HORIZONTALLY, Key::H); - button_advanced_menu->get_popup()->add_icon_item(get_theme_icon(SNAME("MirrorY"), SNAME("EditorIcons")), TTR("Flip Vertically"), FLIP_VERTICALLY, Key::V); + button_advanced_menu->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("RotateRight")), TTR("Rotate Right"), ROTATE_RIGHT, Key::R); + button_advanced_menu->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("RotateLeft")), TTR("Rotate Left"), ROTATE_LEFT, Key::E); + button_advanced_menu->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("MirrorX")), TTR("Flip Horizontally"), FLIP_HORIZONTALLY, Key::H); + button_advanced_menu->get_popup()->add_icon_item(get_editor_theme_icon(SNAME("MirrorY")), TTR("Flip Vertically"), FLIP_VERTICALLY, Key::V); button_advanced_menu->get_popup()->connect("id_pressed", callable_mp(this, &GenericTilePolygonEditor::_advanced_menu_item_pressed)); button_advanced_menu->set_focus_mode(FOCUS_ALL); toolbar->add_child(button_advanced_menu); @@ -936,7 +937,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() { root->add_child(editor_zoom_widget); button_center_view = memnew(Button); - button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); + button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("CenterView"))); button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5); button_center_view->connect("pressed", callable_mp(this, &GenericTilePolygonEditor::_center_view)); button_center_view->set_flat(true); @@ -1205,8 +1206,8 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2 Rect2 rect = p_transform.xform(Rect2(Vector2(-size / 2, -size / 2) - texture_origin, Vector2(size, size))); p_canvas_item->draw_rect(rect, value); } else { - Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); String text; // Round floating point precision to 2 digits, as tiles don't have that much space. switch (value.get_type()) { @@ -1284,9 +1285,9 @@ void TileDataDefaultEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); - tile_bool_checked = get_theme_icon(SNAME("TileChecked"), SNAME("EditorIcons")); - tile_bool_unchecked = get_theme_icon(SNAME("TileUnchecked"), SNAME("EditorIcons")); + picker_button->set_icon(get_editor_theme_icon(SNAME("ColorPick"))); + tile_bool_checked = get_editor_theme_icon(SNAME("TileChecked")); + tile_bool_unchecked = get_editor_theme_icon(SNAME("TileUnchecked")); } break; } } @@ -1334,11 +1335,11 @@ void TileDataTextureOriginEditor::draw_over_tile(CanvasItem *p_canvas_item, Tran } if (atlas_source->is_position_in_tile_texture_region(p_cell.get_atlas_coords(), p_cell.alternative_tile, Vector2())) { - Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); + Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_editor_theme_icon(SNAME("EditorPosition")); p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2()) - (position_icon->get_size() / 2), color); } else { - Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); Vector2 texture_origin = tile_data->get_texture_origin(); String text = vformat("%s", texture_origin); Vector2 string_size = font->get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size); @@ -1364,7 +1365,7 @@ void TileDataPositionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); color = selection_color; } - Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); + Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_editor_theme_icon(SNAME("EditorPosition")); p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(value)) - position_icon->get_size() / 2, color); } @@ -1382,11 +1383,11 @@ void TileDataYSortEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D TileSetSource *source = *(tile_set->get_source(p_cell.source_id)); TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source); if (atlas_source->is_position_in_tile_texture_region(p_cell.get_atlas_coords(), p_cell.alternative_tile, Vector2(0, tile_data->get_y_sort_origin()))) { - Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); + Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_editor_theme_icon(SNAME("EditorPosition")); p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(0, tile_data->get_y_sort_origin())) - position_icon->get_size() / 2, color); } else { - Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); String text = vformat("%s", tile_data->get_y_sort_origin()); Vector2 string_size = font->get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size); @@ -1733,7 +1734,7 @@ void TileDataCollisionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transfor RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform); - Ref<Texture2D> one_way_icon = get_theme_icon(SNAME("OneWayTile"), SNAME("EditorIcons")); + Ref<Texture2D> one_way_icon = get_editor_theme_icon(SNAME("OneWayTile")); for (int i = 0; i < tile_data->get_collision_polygons_count(physics_layer); i++) { Vector<Vector2> polygon = tile_data->get_collision_polygon_points(physics_layer, i); if (polygon.size() < 3) { @@ -1880,8 +1881,8 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas } // Dim terrains with wrong terrain set. - Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) { Vector2i coords = p_tile_set_atlas_source->get_tile_id(i); if (coords != hovered_coords) { @@ -2070,8 +2071,8 @@ void TileDataTerrainsEditor::forward_draw_over_alternatives(TileAtlasView *p_til } // Dim terrains with wrong terrain set. - Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)); + int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)); for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) { Vector2i coords = p_tile_set_atlas_source->get_tile_id(i); for (int j = 1; j < p_tile_set_atlas_source->get_alternative_tiles_count(coords); j++) { @@ -2776,7 +2777,7 @@ void TileDataTerrainsEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); + picker_button->set_icon(get_editor_theme_icon(SNAME("ColorPick"))); } break; } } diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index b181835f6f..fa35a03a22 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -175,7 +175,7 @@ void TileMapEditorTilesPlugin::_update_tile_set_sources_list() { // Scene collection source. TileSetScenesCollectionSource *scene_collection_source = Object::cast_to<TileSetScenesCollectionSource>(source); if (scene_collection_source) { - texture = tiles_bottom_panel->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + texture = tiles_bottom_panel->get_editor_theme_icon(SNAME("PackedScene")); if (item_text.is_empty()) { if (scene_collection_source->get_scene_tiles_count() > 0) { item_text = vformat(TTR("Scene Collection Source (ID: %d)"), source_id); @@ -393,7 +393,7 @@ void TileMapEditorTilesPlugin::_update_scenes_collection_view() { Variant udata = i; EditorResourcePreview::get_singleton()->queue_edited_resource_preview(scene, this, "_scene_thumbnail_done", udata); } else { - item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), tiles_bottom_panel->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"))); + item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), tiles_bottom_panel->get_editor_theme_icon(SNAME("PackedScene"))); } scene_tiles_list->set_item_metadata(item_index, scene_id); @@ -469,18 +469,18 @@ void TileMapEditorTilesPlugin::_scenes_list_lmb_empty_clicked(const Vector2 &p_p } void TileMapEditorTilesPlugin::_update_theme() { - source_sort_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); - select_tool_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - paint_tool_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - line_tool_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("Line"), SNAME("EditorIcons"))); - rect_tool_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("Rectangle"), SNAME("EditorIcons"))); - bucket_tool_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("Bucket"), SNAME("EditorIcons"))); - - picker_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); - erase_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons"))); - random_tile_toggle->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("RandomNumberGenerator"), SNAME("EditorIcons"))); - - missing_atlas_texture_icon = tiles_bottom_panel->get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons")); + source_sort_button->set_icon(tiles_bottom_panel->get_editor_theme_icon(SNAME("Sort"))); + select_tool_button->set_icon(tiles_bottom_panel->get_editor_theme_icon(SNAME("ToolSelect"))); + paint_tool_button->set_icon(tiles_bottom_panel->get_editor_theme_icon(SNAME("Edit"))); + line_tool_button->set_icon(tiles_bottom_panel->get_editor_theme_icon(SNAME("Line"))); + rect_tool_button->set_icon(tiles_bottom_panel->get_editor_theme_icon(SNAME("Rectangle"))); + bucket_tool_button->set_icon(tiles_bottom_panel->get_editor_theme_icon(SNAME("Bucket"))); + + picker_button->set_icon(tiles_bottom_panel->get_editor_theme_icon(SNAME("ColorPick"))); + erase_button->set_icon(tiles_bottom_panel->get_editor_theme_icon(SNAME("Eraser"))); + random_tile_toggle->set_icon(tiles_bottom_panel->get_editor_theme_icon(SNAME("RandomNumberGenerator"))); + + missing_atlas_texture_icon = tiles_bottom_panel->get_editor_theme_icon(SNAME("TileSet")); _update_tile_set_sources_list(); } @@ -3226,13 +3226,13 @@ void TileMapEditorTerrainsPlugin::_update_terrains_tree() { TreeItem *terrain_set_tree_item = terrains_tree->create_item(); String matches; if (tile_set->get_terrain_set_mode(terrain_set_index) == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) { - terrain_set_tree_item->set_icon(0, main_vbox_container->get_theme_icon(SNAME("TerrainMatchCornersAndSides"), SNAME("EditorIcons"))); + terrain_set_tree_item->set_icon(0, main_vbox_container->get_editor_theme_icon(SNAME("TerrainMatchCornersAndSides"))); matches = String(TTR("Matches Corners and Sides")); } else if (tile_set->get_terrain_set_mode(terrain_set_index) == TileSet::TERRAIN_MODE_MATCH_CORNERS) { - terrain_set_tree_item->set_icon(0, main_vbox_container->get_theme_icon(SNAME("TerrainMatchCorners"), SNAME("EditorIcons"))); + terrain_set_tree_item->set_icon(0, main_vbox_container->get_editor_theme_icon(SNAME("TerrainMatchCorners"))); matches = String(TTR("Matches Corners Only")); } else { - terrain_set_tree_item->set_icon(0, main_vbox_container->get_theme_icon(SNAME("TerrainMatchSides"), SNAME("EditorIcons"))); + terrain_set_tree_item->set_icon(0, main_vbox_container->get_editor_theme_icon(SNAME("TerrainMatchSides"))); matches = String(TTR("Matches Sides Only")); } terrain_set_tree_item->set_text(0, vformat(TTR("Terrain Set %d (%s)"), terrain_set_index, matches)); @@ -3275,13 +3275,13 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() { ERR_FAIL_INDEX(sel_terrain_id, tile_set->get_terrains_count(sel_terrain_set)); // Add the two first generic modes - int item_index = terrains_tile_list->add_icon_item(main_vbox_container->get_theme_icon(SNAME("TerrainConnect"), SNAME("EditorIcons"))); + int item_index = terrains_tile_list->add_icon_item(main_vbox_container->get_editor_theme_icon(SNAME("TerrainConnect"))); terrains_tile_list->set_item_tooltip(item_index, TTR("Connect mode: paints a terrain, then connects it with the surrounding tiles with the same terrain.")); Dictionary list_metadata_dict; list_metadata_dict["type"] = SELECTED_TYPE_CONNECT; terrains_tile_list->set_item_metadata(item_index, list_metadata_dict); - item_index = terrains_tile_list->add_icon_item(main_vbox_container->get_theme_icon(SNAME("TerrainPath"), SNAME("EditorIcons"))); + item_index = terrains_tile_list->add_icon_item(main_vbox_container->get_editor_theme_icon(SNAME("TerrainPath"))); terrains_tile_list->set_item_tooltip(item_index, TTR("Path mode: paints a terrain, thens connects it to the previous tile painted within the same stroke.")); list_metadata_dict = Dictionary(); list_metadata_dict["type"] = SELECTED_TYPE_PATH; @@ -3354,13 +3354,13 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() { } void TileMapEditorTerrainsPlugin::_update_theme() { - paint_tool_button->set_icon(main_vbox_container->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - line_tool_button->set_icon(main_vbox_container->get_theme_icon(SNAME("Line"), SNAME("EditorIcons"))); - rect_tool_button->set_icon(main_vbox_container->get_theme_icon(SNAME("Rectangle"), SNAME("EditorIcons"))); - bucket_tool_button->set_icon(main_vbox_container->get_theme_icon(SNAME("Bucket"), SNAME("EditorIcons"))); + paint_tool_button->set_icon(main_vbox_container->get_editor_theme_icon(SNAME("Edit"))); + line_tool_button->set_icon(main_vbox_container->get_editor_theme_icon(SNAME("Line"))); + rect_tool_button->set_icon(main_vbox_container->get_editor_theme_icon(SNAME("Rectangle"))); + bucket_tool_button->set_icon(main_vbox_container->get_editor_theme_icon(SNAME("Bucket"))); - picker_button->set_icon(main_vbox_container->get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); - erase_button->set_icon(main_vbox_container->get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons"))); + picker_button->set_icon(main_vbox_container->get_editor_theme_icon(SNAME("ColorPick"))); + erase_button->set_icon(main_vbox_container->get_editor_theme_icon(SNAME("Eraser"))); _update_tiles_list(); } @@ -3498,12 +3498,12 @@ void TileMapEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - missing_tile_texture = get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); - warning_pattern_texture = get_theme_icon(SNAME("WarningPattern"), SNAME("EditorIcons")); - advanced_menu_button->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); - toggle_grid_button->set_icon(get_theme_icon(SNAME("Grid"), SNAME("EditorIcons"))); + missing_tile_texture = get_editor_theme_icon(SNAME("StatusWarning")); + warning_pattern_texture = get_editor_theme_icon(SNAME("WarningPattern")); + advanced_menu_button->set_icon(get_editor_theme_icon(SNAME("Tools"))); + toggle_grid_button->set_icon(get_editor_theme_icon(SNAME("Grid"))); toggle_grid_button->set_pressed(EDITOR_GET("editors/tiles_editor/display_grid")); - toggle_highlight_selected_layer_button->set_icon(get_theme_icon(SNAME("TileMapHighlightSelected"), SNAME("EditorIcons"))); + toggle_highlight_selected_layer_button->set_icon(get_editor_theme_icon(SNAME("TileMapHighlightSelected"))); } break; case NOTIFICATION_INTERNAL_PROCESS: { diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index a9a1cd76a3..a2e4c4a784 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -36,6 +36,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_toaster.h" #include "editor/plugins/tiles/tile_set_editor.h" @@ -649,7 +650,7 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { tile_data_editors_tree->add_theme_constant_override("v_separation", 1); tile_data_editors_tree->add_theme_constant_override("h_separation", 3); - Color group_color = get_theme_color(SNAME("prop_category"), SNAME("Editor")); + Color group_color = get_theme_color(SNAME("prop_category"), EditorStringName(Editor)); // List of editors. // --- Rendering --- @@ -732,7 +733,7 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { tile_data_editors["probability"] = tile_data_probability_editor; } - Color disabled_color = get_theme_color("disabled_font_color", "Editor"); + Color disabled_color = get_theme_color("disabled_font_color", EditorStringName(Editor)); // --- Physics --- ADD_TILE_DATA_EDITOR_GROUP(TTR("Physics")); @@ -754,7 +755,7 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { if (tile_set->get_physics_layers_count() == 0) { item = tile_data_editors_tree->create_item(group); - item->set_icon(0, get_theme_icon("Info", "EditorIcons")); + item->set_icon(0, get_editor_theme_icon("Info")); item->set_icon_modulate(0, disabled_color); item->set_text(0, TTR("No physics layers")); item->set_tooltip_text(0, TTR("Create and customize physics layers in the inspector of the TileSet resource.")); @@ -782,7 +783,7 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { if (tile_set->get_navigation_layers_count() == 0) { item = tile_data_editors_tree->create_item(group); - item->set_icon(0, get_theme_icon("Info", "EditorIcons")); + item->set_icon(0, get_editor_theme_icon("Info")); item->set_icon_modulate(0, disabled_color); item->set_text(0, TTR("No navigation layers")); item->set_tooltip_text(0, TTR("Create and customize navigation layers in the inspector of the TileSet resource.")); @@ -825,7 +826,7 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { if (tile_set->get_custom_data_layers_count() == 0) { item = tile_data_editors_tree->create_item(group); - item->set_icon(0, get_theme_icon("Info", "EditorIcons")); + item->set_icon(0, get_editor_theme_icon("Info")); item->set_icon_modulate(0, disabled_color); item->set_text(0, TTR("No custom data layers")); item->set_tooltip_text(0, TTR("Create and customize custom data layers in the inspector of the TileSet resource.")); @@ -992,7 +993,7 @@ void TileSetAtlasSourceEditor::_update_atlas_view() { // Create and position the button. Button *button = memnew(Button); button->set_flat(true); - button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button->set_icon(get_editor_theme_icon(SNAME("Add"))); button->add_theme_style_override("normal", memnew(StyleBoxEmpty)); button->add_theme_style_override("hover", memnew(StyleBoxEmpty)); button->add_theme_style_override("focus", memnew(StyleBoxEmpty)); @@ -2403,16 +2404,16 @@ void TileSetAtlasSourceEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - tool_setup_atlas_source_button->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); - tool_select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - tool_paint_button->set_icon(get_theme_icon(SNAME("CanvasItem"), SNAME("EditorIcons"))); + tool_setup_atlas_source_button->set_icon(get_editor_theme_icon(SNAME("Tools"))); + tool_select_button->set_icon(get_editor_theme_icon(SNAME("ToolSelect"))); + tool_paint_button->set_icon(get_editor_theme_icon(SNAME("CanvasItem"))); - tools_settings_erase_button->set_icon(get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons"))); - tool_advanced_menu_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - outside_tiles_warning->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + tools_settings_erase_button->set_icon(get_editor_theme_icon(SNAME("Eraser"))); + tool_advanced_menu_button->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); + outside_tiles_warning->set_texture(get_editor_theme_icon(SNAME("StatusWarning"))); - resize_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); - resize_handle_disabled = get_theme_icon(SNAME("EditorHandleDisabled"), SNAME("EditorIcons")); + resize_handle = get_editor_theme_icon(SNAME("EditorHandle")); + resize_handle_disabled = get_editor_theme_icon(SNAME("EditorHandleDisabled")); } break; case NOTIFICATION_INTERNAL_PROCESS: { diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 3a21bff947..53cc59b718 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -190,7 +190,7 @@ void TileSetEditor::_update_sources_list(int force_selected_id) { // Scene collection source. TileSetScenesCollectionSource *scene_collection_source = Object::cast_to<TileSetScenesCollectionSource>(source); if (scene_collection_source) { - texture = get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + texture = get_editor_theme_icon(SNAME("PackedScene")); if (item_text.is_empty()) { if (scene_collection_source->get_scene_tiles_count() > 0) { item_text = vformat(TTR("Scene Collection Source (ID: %d)"), source_id); @@ -364,11 +364,11 @@ void TileSetEditor::_set_source_sort(int p_sort) { void TileSetEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - sources_delete_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - sources_add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - source_sort_button->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); - sources_advanced_menu_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - missing_texture_texture = get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons")); + sources_delete_button->set_icon(get_editor_theme_icon(SNAME("Remove"))); + sources_add_button->set_icon(get_editor_theme_icon(SNAME("Add"))); + source_sort_button->set_icon(get_editor_theme_icon(SNAME("Sort"))); + sources_advanced_menu_button->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); + missing_texture_texture = get_editor_theme_icon(SNAME("TileSet")); expanded_area->add_theme_style_override("panel", get_theme_stylebox("panel", "Tree")); _update_sources_list(); } break; diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp index e357e262c2..6b9250010e 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp @@ -332,7 +332,7 @@ void TileSetScenesCollectionSourceEditor::_update_scenes_list() { Variant udata = i; EditorResourcePreview::get_singleton()->queue_edited_resource_preview(scene, this, "_scene_thumbnail_done", udata); } else { - item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"))); + item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), get_editor_theme_icon(SNAME("PackedScene"))); } scene_tiles_list->set_item_metadata(item_index, scene_id); @@ -358,8 +358,8 @@ void TileSetScenesCollectionSourceEditor::_update_scenes_list() { void TileSetScenesCollectionSourceEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - scene_tile_add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - scene_tile_delete_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + scene_tile_add_button->set_icon(get_editor_theme_icon(SNAME("Add"))); + scene_tile_delete_button->set_icon(get_editor_theme_icon(SNAME("Remove"))); _update_scenes_list(); } break; diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index 7c1cf52925..904348d3bf 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -292,7 +292,7 @@ void TilesEditorUtils::draw_selection_rect(CanvasItem *p_ci, const Rect2 &p_rect real_t scale = p_ci->get_global_transform().get_scale().x * 0.5; p_ci->draw_set_transform(p_rect.position, 0, Vector2(1, 1) / scale); RS::get_singleton()->canvas_item_add_nine_patch( - p_ci->get_canvas_item(), Rect2(Vector2(), p_rect.size * scale), Rect2(), EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("TileSelection"), SNAME("EditorIcons"))->get_rid(), + p_ci->get_canvas_item(), Rect2(Vector2(), p_rect.size * scale), Rect2(), EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("TileSelection"))->get_rid(), Vector2(2, 2), Vector2(2, 2), RS::NINE_PATCH_STRETCH, RS::NINE_PATCH_STRETCH, false, p_color); p_ci->draw_set_transform_matrix(Transform2D()); } diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index a4ff9143f2..a6c98e646e 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -38,6 +38,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/filesystem_dock.h" #include "editor/plugins/script_editor_plugin.h" #include "scene/gui/separator.h" @@ -173,7 +174,7 @@ void VersionControlEditorPlugin::_update_set_up_warning(String p_new_text) { set_up_ssh_passphrase->get_text().is_empty(); if (empty_settings) { - set_up_warning_text->add_theme_color_override(SNAME("font_color"), EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + set_up_warning_text->add_theme_color_override(SNAME("font_color"), EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); set_up_warning_text->set_text(TTR("Remote settings are empty. VCS features that use the network may not work.")); } else { set_up_warning_text->set_text(""); @@ -191,7 +192,7 @@ void VersionControlEditorPlugin::_refresh_branch_list() { String current_branch = EditorVCSInterface::get_singleton()->get_current_branch_name(); for (int i = 0; i < branch_list.size(); i++) { - branch_select->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("VcsBranches"), SNAME("EditorIcons")), branch_list[i], i); + branch_select->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("VcsBranches")), branch_list[i], i); if (branch_list[i] == current_branch) { branch_select->select(i); @@ -251,7 +252,7 @@ void VersionControlEditorPlugin::_refresh_remote_list() { remote_select->set_disabled(remotes.is_empty()); for (int i = 0; i < remotes.size(); i++) { - remote_select->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons")), remotes[i], i); + remote_select->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("ArrowUp")), remotes[i], i); remote_select->set_item_metadata(i, remotes[i]); if (remotes[i] == current_remote) { @@ -421,9 +422,9 @@ void VersionControlEditorPlugin::_add_new_item(Tree *p_tree, String p_file_path, new_item->set_meta(SNAME("change_type"), p_change); new_item->set_custom_color(0, change_type_to_color[p_change]); - new_item->add_button(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("File"), SNAME("EditorIcons")), BUTTON_TYPE_OPEN, false, TTR("Open in editor")); + new_item->add_button(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("File")), BUTTON_TYPE_OPEN, false, TTR("Open in editor")); if (p_tree == unstaged_files) { - new_item->add_button(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Close"), SNAME("EditorIcons")), BUTTON_TYPE_DISCARD, false, TTR("Discard changes")); + new_item->add_button(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Close")), BUTTON_TYPE_DISCARD, false, TTR("Discard changes")); } } @@ -569,8 +570,8 @@ void VersionControlEditorPlugin::_display_diff(int p_idx) { String commit_author = meta_data[SNAME("commit_author")]; String commit_date_string = meta_data[SNAME("commit_date_string")]; - diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts"))); - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("accent_color"), SNAME("Editor"))); + diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("doc_bold"), EditorStringName(EditorFonts))); + diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("accent_color"), EditorStringName(Editor))); diff->add_text(TTR("Commit:") + " " + commit_id); diff->add_newline(); diff->add_text(TTR("Author:") + " " + commit_author); @@ -589,13 +590,13 @@ void VersionControlEditorPlugin::_display_diff(int p_idx) { for (int i = 0; i < diff_content.size(); i++) { EditorVCSInterface::DiffFile diff_file = diff_content[i]; - diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts"))); - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("accent_color"), SNAME("Editor"))); + diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("doc_bold"), EditorStringName(EditorFonts))); + diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("accent_color"), EditorStringName(Editor))); diff->add_text(TTR("File:") + " " + diff_file.new_file); diff->pop(); diff->pop(); - diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts))); for (int j = 0; j < diff_file.diff_hunks.size(); j++) { EditorVCSInterface::DiffHunk hunk = diff_file.diff_hunks[j]; @@ -678,8 +679,8 @@ void VersionControlEditorPlugin::_display_diff_split_view(List<EditorVCSInterfac EditorVCSInterface::DiffLine diff_line = parsed_diff[i]; bool has_change = diff_line.status != " "; - static const Color red = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")); - static const Color green = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor")); + static const Color red = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), EditorStringName(Editor)); + static const Color green = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), EditorStringName(Editor)); static const Color white = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("font_color"), SNAME("Label")) * Color(1, 1, 1, 0.6); if (diff_line.old_line_no >= 0) { @@ -760,9 +761,9 @@ void VersionControlEditorPlugin::_display_diff_unified_view(List<EditorVCSInterf Color color; if (diff_line.status == "+") { - color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor")); + color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), EditorStringName(Editor)); } else if (diff_line.status == "-") { - color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")); + color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), EditorStringName(Editor)); } else { color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("font_color"), SNAME("Label")); color *= Color(1, 1, 1, 0.6); @@ -855,13 +856,13 @@ void VersionControlEditorPlugin::_popup_remote_remove_confirm(int p_index) { void VersionControlEditorPlugin::_update_extra_options() { extra_options_remove_branch_list->clear(); for (int i = 0; i < branch_select->get_item_count(); i++) { - extra_options_remove_branch_list->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("VcsBranches"), SNAME("EditorIcons")), branch_select->get_item_text(branch_select->get_item_id(i))); + extra_options_remove_branch_list->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("VcsBranches")), branch_select->get_item_text(branch_select->get_item_id(i))); } extra_options_remove_branch_list->update_canvas_items(); extra_options_remove_remote_list->clear(); for (int i = 0; i < remote_select->get_item_count(); i++) { - extra_options_remove_remote_list->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons")), remote_select->get_item_text(remote_select->get_item_id(i))); + extra_options_remove_remote_list->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("ArrowUp")), remote_select->get_item_text(remote_select->get_item_id(i))); } extra_options_remove_remote_list->update_canvas_items(); } @@ -1082,7 +1083,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { set_up_ssh_public_key_input_hbc->add_child(set_up_ssh_public_key_file_dialog); Button *select_public_path_button = memnew(Button); - select_public_path_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Folder", "EditorIcons")); + select_public_path_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon("Folder")); select_public_path_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_popup_file_dialog).bind(set_up_ssh_public_key_file_dialog)); select_public_path_button->set_tooltip_text(TTR("Select SSH public key path")); set_up_ssh_public_key_input_hbc->add_child(select_public_path_button); @@ -1115,7 +1116,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { set_up_ssh_private_key_input_hbc->add_child(set_up_ssh_private_key_file_dialog); Button *select_private_path_button = memnew(Button); - select_private_path_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Folder", "EditorIcons")); + select_private_path_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon("Folder")); select_private_path_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_popup_file_dialog).bind(set_up_ssh_private_key_file_dialog)); select_private_path_button->set_tooltip_text(TTR("Select SSH private key path")); set_up_ssh_private_key_input_hbc->add_child(select_private_path_button); @@ -1160,7 +1161,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { refresh_button = memnew(Button); refresh_button->set_tooltip_text(TTR("Detect new changes")); refresh_button->set_flat(true); - refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Reload"))); refresh_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area)); refresh_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_commit_list)); refresh_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_branch_list)); @@ -1180,14 +1181,14 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { discard_all_button = memnew(Button); discard_all_button->set_tooltip_text(TTR("Discard all changes")); - discard_all_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + discard_all_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Close"))); discard_all_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_confirm_discard_all)); discard_all_button->set_flat(true); unstage_title->add_child(discard_all_button); stage_all_button = memnew(Button); stage_all_button->set_flat(true); - stage_all_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); + stage_all_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("MoveDown"))); stage_all_button->set_tooltip_text(TTR("Stage all changes")); unstage_title->add_child(stage_all_button); @@ -1217,7 +1218,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { unstage_all_button = memnew(Button); unstage_all_button->set_flat(true); - unstage_all_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + unstage_all_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("MoveUp"))); unstage_all_button->set_tooltip_text(TTR("Unstage all changes")); stage_title->add_child(unstage_all_button); @@ -1412,26 +1413,26 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { fetch_button = memnew(Button); fetch_button->set_flat(true); fetch_button->set_tooltip_text(TTR("Fetch")); - fetch_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + fetch_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Reload"))); fetch_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_fetch)); menu_bar->add_child(fetch_button); pull_button = memnew(Button); pull_button->set_flat(true); pull_button->set_tooltip_text(TTR("Pull")); - pull_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); + pull_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("MoveDown"))); pull_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_pull)); menu_bar->add_child(pull_button); push_button = memnew(Button); push_button->set_flat(true); push_button->set_tooltip_text(TTR("Push")); - push_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + push_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("MoveUp"))); push_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_push)); menu_bar->add_child(push_button); extra_options = memnew(MenuButton); - extra_options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + extra_options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("GuiTabMenuHl"))); extra_options->get_popup()->connect(SNAME("about_to_popup"), callable_mp(this, &VersionControlEditorPlugin::_update_extra_options)); extra_options->get_popup()->connect(SNAME("id_pressed"), callable_mp(this, &VersionControlEditorPlugin::_extra_option_selected)); menu_bar->add_child(extra_options); @@ -1462,19 +1463,19 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = TTR("Typechange"); change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = TTR("Unmerged"); - change_type_to_color[EditorVCSInterface::CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor")); - change_type_to_color[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor")); - change_type_to_color[EditorVCSInterface::CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor")); - change_type_to_color[EditorVCSInterface::CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")); - change_type_to_color[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("font_color"), SNAME("Editor")); - change_type_to_color[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor")); - - change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons")); - change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); - change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); - change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); - change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")); - change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); + change_type_to_color[EditorVCSInterface::CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), EditorStringName(Editor)); + change_type_to_color[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), EditorStringName(Editor)); + change_type_to_color[EditorVCSInterface::CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), EditorStringName(Editor)); + change_type_to_color[EditorVCSInterface::CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), EditorStringName(Editor)); + change_type_to_color[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("font_color"), EditorStringName(Editor)); + change_type_to_color[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), EditorStringName(Editor)); + + change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("StatusSuccess")); + change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("StatusWarning")); + change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("StatusWarning")); + change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("StatusWarning")); + change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("StatusError")); + change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("StatusWarning")); version_control_dock = memnew(VBoxContainer); version_control_dock->set_v_size_flags(Control::SIZE_EXPAND_FILL); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 330a9a36eb..b6330bdf75 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -39,6 +39,7 @@ #include "editor/editor_properties_vector.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/filesystem_dock.h" #include "editor/inspector_dock.h" @@ -348,10 +349,10 @@ void VisualShaderGraphPlugin::register_parameter_name(int p_node_id, LineEdit *p } void VisualShaderGraphPlugin::update_theme() { - vector_expanded_color[0] = editor->get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); // red - vector_expanded_color[1] = editor->get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); // green - vector_expanded_color[2] = editor->get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); // blue - vector_expanded_color[3] = editor->get_theme_color(SNAME("axis_w_color"), SNAME("Editor")); // alpha + vector_expanded_color[0] = editor->get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)); // red + vector_expanded_color[1] = editor->get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)); // green + vector_expanded_color[2] = editor->get_theme_color(SNAME("axis_z_color"), EditorStringName(Editor)); // blue + vector_expanded_color[3] = editor->get_theme_color(SNAME("axis_w_color"), EditorStringName(Editor)); // alpha } bool VisualShaderGraphPlugin::is_node_has_parameter_instances_relatively(VisualShader::Type p_type, int p_node) const { @@ -414,7 +415,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool // Visual shader specific theme for MSDF font. Ref<Theme> vstheme; vstheme.instantiate(); - Ref<Font> label_font = EditorNode::get_singleton()->get_editor_theme()->get_font("main_msdf", "EditorFonts"); + Ref<Font> label_font = EditorNode::get_singleton()->get_editor_theme()->get_font("main_msdf", EditorStringName(EditorFonts)); vstheme->set_font("font", "Label", label_font); vstheme->set_font("font", "LineEdit", label_font); vstheme->set_font("font", "Button", label_font); @@ -789,7 +790,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool name_box->connect("focus_exited", callable_mp(editor, &VisualShaderEditor::_port_name_focus_out).bind(name_box, p_id, i, false), CONNECT_DEFERRED); Button *remove_btn = memnew(Button); - remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Remove"))); remove_btn->set_tooltip_text(TTR("Remove") + " " + name_left); remove_btn->connect("pressed", callable_mp(editor, &VisualShaderEditor::_remove_input_port).bind(p_id, i), CONNECT_DEFERRED); hb->add_child(remove_btn); @@ -816,7 +817,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool if (valid_right) { if (is_group) { Button *remove_btn = memnew(Button); - remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Remove"))); remove_btn->set_tooltip_text(TTR("Remove") + " " + name_left); remove_btn->connect("pressed", callable_mp(editor, &VisualShaderEditor::_remove_output_port).bind(p_id, i), CONNECT_DEFERRED); hb->add_child(remove_btn); @@ -855,8 +856,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool if (vsnode->is_output_port_expandable(i)) { TextureButton *expand = memnew(TextureButton); expand->set_toggle_mode(true); - expand->set_texture_normal(editor->get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons"))); - expand->set_texture_pressed(editor->get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons"))); + expand->set_texture_normal(editor->get_editor_theme_icon(SNAME("GuiTreeArrowDown"))); + expand->set_texture_pressed(editor->get_editor_theme_icon(SNAME("GuiTreeArrowRight"))); expand->set_v_size_flags(Control::SIZE_SHRINK_CENTER); expand->set_pressed(vsnode->_is_output_port_expanded(i)); expand->connect("pressed", callable_mp(editor, &VisualShaderEditor::_expand_output_port).bind(p_id, i, !vsnode->_is_output_port_expanded(i)), CONNECT_DEFERRED); @@ -865,8 +866,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool if (vsnode->has_output_port_preview(i) && port_right != VisualShaderNode::PORT_TYPE_TRANSFORM && port_right != VisualShaderNode::PORT_TYPE_SAMPLER) { TextureButton *preview = memnew(TextureButton); preview->set_toggle_mode(true); - preview->set_texture_normal(editor->get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"))); - preview->set_texture_pressed(editor->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); + preview->set_texture_normal(editor->get_editor_theme_icon(SNAME("GuiVisibilityHidden"))); + preview->set_texture_pressed(editor->get_editor_theme_icon(SNAME("GuiVisibilityVisible"))); preview->set_v_size_flags(Control::SIZE_SHRINK_CENTER); register_output_port(p_id, j, preview); @@ -1002,7 +1003,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool } if (!error.is_empty()) { Label *error_label = memnew(Label); - error_label->add_theme_color_override("font_color", editor->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_label->add_theme_color_override("font_color", editor->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); error_label->set_text(error); node->add_child(error_label); } @@ -1036,8 +1037,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool } } - expression_box->add_theme_font_override("font", editor->get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); - expression_box->add_theme_font_size_override("font_size", editor->get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); + expression_box->add_theme_font_override("font", editor->get_theme_font(SNAME("expression"), EditorStringName(EditorFonts))); + expression_box->add_theme_font_size_override("font_size", editor->get_theme_font_size(SNAME("expression_size"), EditorStringName(EditorFonts))); expression_box->add_theme_color_override("font_color", text_color); expression_syntax_highlighter->set_number_color(number_color); expression_syntax_highlighter->set_symbol_color(symbol_color); @@ -1677,8 +1678,8 @@ void VisualShaderEditor::_update_options_menu() { bool is_first_item = true; - Color unsupported_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); - Color supported_color = get_theme_color(SNAME("warning_color"), SNAME("Editor")); + Color unsupported_color = get_theme_color(SNAME("error_color"), EditorStringName(Editor)); + Color supported_color = get_theme_color(SNAME("warning_color"), EditorStringName(Editor)); static bool low_driver = GLOBAL_GET("rendering/renderer/rendering_method") == "gl_compatibility"; @@ -1833,31 +1834,31 @@ void VisualShaderEditor::_update_options_menu() { } switch (options[i].return_type) { case VisualShaderNode::PORT_TYPE_SCALAR: - item->set_icon(0, get_theme_icon(SNAME("float"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("float"))); break; case VisualShaderNode::PORT_TYPE_SCALAR_INT: - item->set_icon(0, get_theme_icon(SNAME("int"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("int"))); break; case VisualShaderNode::PORT_TYPE_SCALAR_UINT: - item->set_icon(0, get_theme_icon(SNAME("uint"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("uint"))); break; case VisualShaderNode::PORT_TYPE_VECTOR_2D: - item->set_icon(0, get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("Vector2"))); break; case VisualShaderNode::PORT_TYPE_VECTOR_3D: - item->set_icon(0, get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("Vector3"))); break; case VisualShaderNode::PORT_TYPE_VECTOR_4D: - item->set_icon(0, get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("Vector4"))); break; case VisualShaderNode::PORT_TYPE_BOOLEAN: - item->set_icon(0, get_theme_icon(SNAME("bool"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("bool"))); break; case VisualShaderNode::PORT_TYPE_TRANSFORM: - item->set_icon(0, get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("Transform3D"))); break; case VisualShaderNode::PORT_TYPE_SAMPLER: - item->set_icon(0, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("ImageTexture"))); break; default: break; @@ -4085,11 +4086,11 @@ void VisualShaderEditor::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - highend_label->set_modulate(get_theme_color(SNAME("highend_color"), SNAME("Editor"))); + highend_label->set_modulate(get_theme_color(SNAME("highend_color"), EditorStringName(Editor))); - node_filter->set_right_icon(Control::get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + node_filter->set_right_icon(Control::get_editor_theme_icon(SNAME("Search"))); - preview_shader->set_icon(Control::get_theme_icon(SNAME("Shader"), SNAME("EditorIcons"))); + preview_shader->set_icon(Control::get_editor_theme_icon(SNAME("Shader"))); { Color background_color = EDITOR_GET("text_editor/theme/highlighting/background_color"); @@ -4101,7 +4102,7 @@ void VisualShaderEditor::_notification(int p_what) { Color function_color = EDITOR_GET("text_editor/theme/highlighting/function_color"); Color number_color = EDITOR_GET("text_editor/theme/highlighting/number_color"); Color members_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color"); - Color error_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); + Color error_color = get_theme_color(SNAME("error_color"), EditorStringName(Editor)); preview_text->add_theme_color_override("background_color", background_color); varying_error_label->add_theme_color_override("font_color", error_color); @@ -4114,8 +4115,8 @@ void VisualShaderEditor::_notification(int p_what) { } } - preview_text->add_theme_font_override("font", get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); - preview_text->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); + preview_text->add_theme_font_override("font", get_theme_font(SNAME("expression"), EditorStringName(EditorFonts))); + preview_text->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("expression_size"), EditorStringName(EditorFonts))); preview_text->add_theme_color_override("font_color", text_color); syntax_highlighter->set_number_color(number_color); syntax_highlighter->set_symbol_color(symbol_color); @@ -4130,12 +4131,12 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_comment_delimiter("//", "", true); error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); - error_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); - error_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); + error_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts))); + error_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), EditorStringName(EditorFonts))); error_label->add_theme_color_override("font_color", error_color); } - tools->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); + tools->set_icon(get_editor_theme_icon(SNAME("Tools"))); if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) { _update_graph(); @@ -4691,28 +4692,28 @@ void VisualShaderEditor::_update_varying_tree() { switch (varying->type) { case VisualShader::VARYING_TYPE_FLOAT: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("float"))); break; case VisualShader::VARYING_TYPE_INT: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("int"))); break; case VisualShader::VARYING_TYPE_UINT: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("uint"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("uint"))); break; case VisualShader::VARYING_TYPE_VECTOR_2D: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector2"))); break; case VisualShader::VARYING_TYPE_VECTOR_3D: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector3"))); break; case VisualShader::VARYING_TYPE_VECTOR_4D: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector4"))); break; case VisualShader::VARYING_TYPE_BOOLEAN: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("bool"))); break; case VisualShader::VARYING_TYPE_TRANSFORM: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Transform3D"))); break; default: break; @@ -6177,15 +6178,15 @@ public: editor = p_editor; input = p_input; Ref<Texture2D> type_icon[] = { - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("uint"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("float")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("int")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("uint")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector2")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector3")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector4")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("bool")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Transform3D")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("ImageTexture")), }; add_item("[None]"); @@ -6227,14 +6228,14 @@ public: varying = p_varying; Ref<Texture2D> type_icon[] = { - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("uint"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("float")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("int")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("uint")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector2")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector3")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector4")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("bool")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Transform3D")), }; bool is_getter = Ref<VisualShaderNodeVaryingGetter>(p_varying.ptr()).is_valid(); @@ -6307,16 +6308,16 @@ public: parameter_ref = p_parameter_ref; Ref<Texture2D> type_icon[] = { - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("uint"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("float")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("int")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("uint")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("bool")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector2")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector3")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector4")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Transform3D")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Color")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("ImageTexture")), }; add_item("[None]"); diff --git a/editor/plugins/voxel_gi_editor_plugin.cpp b/editor/plugins/voxel_gi_editor_plugin.cpp index af4a027f78..50c68f7d21 100644 --- a/editor/plugins/voxel_gi_editor_plugin.cpp +++ b/editor/plugins/voxel_gi_editor_plugin.cpp @@ -185,7 +185,7 @@ VoxelGIEditorPlugin::VoxelGIEditorPlugin() { bake_hb->hide(); bake = memnew(Button); bake->set_flat(true); - bake->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); + bake->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Bake"))); bake->set_text(TTR("Bake VoxelGI")); bake->connect("pressed", callable_mp(this, &VoxelGIEditorPlugin::_bake)); bake_hb->add_child(bake); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 6736bbc668..feb3d7fa14 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -44,6 +44,7 @@ #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_themes.h" #include "editor/editor_vcs_interface.h" #include "editor/gui/editor_file_dialog.h" @@ -76,21 +77,21 @@ void ProjectDialog::_set_message(const String &p_msg, MessageType p_type, InputT switch (p_type) { case MESSAGE_ERROR: { - msg->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + msg->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor))); msg->set_modulate(Color(1, 1, 1, 1)); - new_icon = get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")); + new_icon = get_editor_theme_icon(SNAME("StatusError")); } break; case MESSAGE_WARNING: { - msg->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + msg->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); msg->set_modulate(Color(1, 1, 1, 1)); - new_icon = get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); + new_icon = get_editor_theme_icon(SNAME("StatusWarning")); } break; case MESSAGE_SUCCESS: { msg->remove_theme_color_override("font_color"); msg->set_modulate(Color(1, 1, 1, 0)); - new_icon = get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons")); + new_icon = get_editor_theme_icon(SNAME("StatusSuccess")); } break; } @@ -647,11 +648,11 @@ void ProjectDialog::cancel_pressed() { project_name->clear(); _text_changed(""); - if (status_rect->get_texture() == get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))) { + if (status_rect->get_texture() == get_editor_theme_icon(SNAME("StatusError"))) { msg->show(); } - if (install_status_rect->get_texture() == get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))) { + if (install_status_rect->get_texture() == get_editor_theme_icon(SNAME("StatusError"))) { msg->show(); } } @@ -989,20 +990,20 @@ void ProjectListItemControl::_notification(int p_what) { if (icon_needs_reload) { // The project icon may not be loaded by the time the control is displayed, // so use a loading placeholder. - project_icon->set_texture(get_theme_icon(SNAME("ProjectIconLoading"), SNAME("EditorIcons"))); + project_icon->set_texture(get_editor_theme_icon(SNAME("ProjectIconLoading"))); } - project_title->add_theme_font_override("font", get_theme_font(SNAME("title"), SNAME("EditorFonts"))); - project_title->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("title_size"), SNAME("EditorFonts"))); + project_title->add_theme_font_override("font", get_theme_font(SNAME("title"), EditorStringName(EditorFonts))); + project_title->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("title_size"), EditorStringName(EditorFonts))); project_title->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("Tree"))); project_path->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("Tree"))); - project_unsupported_features->set_texture(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); + project_unsupported_features->set_texture(get_editor_theme_icon(SNAME("NodeWarning"))); - favorite_button->set_texture_normal(get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); + favorite_button->set_texture_normal(get_editor_theme_icon(SNAME("Favorites"))); if (project_is_missing) { - explore_button->set_icon(get_theme_icon(SNAME("FileBroken"), SNAME("EditorIcons"))); + explore_button->set_icon(get_editor_theme_icon(SNAME("FileBroken"))); } else { - explore_button->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); + explore_button->set_icon(get_editor_theme_icon(SNAME("Load"))); } } break; @@ -1104,12 +1105,12 @@ void ProjectListItemControl::set_is_missing(bool p_missing) { if (project_is_missing) { project_icon->set_modulate(Color(1, 1, 1, 0.5)); - explore_button->set_icon(get_theme_icon(SNAME("FileBroken"), SNAME("EditorIcons"))); + explore_button->set_icon(get_editor_theme_icon(SNAME("FileBroken"))); explore_button->set_tooltip_text(TTR("Error: Project is missing on the filesystem.")); } else { project_icon->set_modulate(Color(1, 1, 1, 1.0)); - explore_button->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); + explore_button->set_icon(get_editor_theme_icon(SNAME("Load"))); #if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED) explore_button->set_tooltip_text(TTR("Show in File Manager")); #else @@ -1276,7 +1277,7 @@ void ProjectList::_update_icons_async() { void ProjectList::_load_project_icon(int p_index) { Item &item = _projects.write[p_index]; - Ref<Texture2D> default_icon = get_theme_icon(SNAME("DefaultProjectIcon"), SNAME("EditorIcons")); + Ref<Texture2D> default_icon = get_editor_theme_icon(SNAME("DefaultProjectIcon")); Ref<Texture2D> icon; if (!item.icon.is_empty()) { Ref<Image> img; @@ -1943,28 +1944,28 @@ void ProjectManager::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - background_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); - loading_label->add_theme_font_override("font", get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); + background_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("Background"), EditorStringName(EditorStyles))); + loading_label->add_theme_font_override("font", get_theme_font(SNAME("bold"), EditorStringName(EditorFonts))); search_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("search_panel"), SNAME("ProjectManager"))); // Top bar. - search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - language_btn->set_icon(get_theme_icon(SNAME("Environment"), SNAME("EditorIcons"))); + search_box->set_right_icon(get_editor_theme_icon(SNAME("Search"))); + language_btn->set_icon(get_editor_theme_icon(SNAME("Environment"))); // Sidebar. - create_btn->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - import_btn->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); - scan_btn->set_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - open_btn->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - run_btn->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); - rename_btn->set_icon(get_theme_icon(SNAME("Rename"), SNAME("EditorIcons"))); - manage_tags_btn->set_icon(get_theme_icon("Script", "EditorIcons")); - erase_btn->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - erase_missing_btn->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); - create_tag_btn->set_icon(get_theme_icon("Add", "EditorIcons")); - - tag_error->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); - tag_edit_error->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + create_btn->set_icon(get_editor_theme_icon(SNAME("Add"))); + import_btn->set_icon(get_editor_theme_icon(SNAME("Load"))); + scan_btn->set_icon(get_editor_theme_icon(SNAME("Search"))); + open_btn->set_icon(get_editor_theme_icon(SNAME("Edit"))); + run_btn->set_icon(get_editor_theme_icon(SNAME("Play"))); + rename_btn->set_icon(get_editor_theme_icon(SNAME("Rename"))); + manage_tags_btn->set_icon(get_editor_theme_icon("Script")); + erase_btn->set_icon(get_editor_theme_icon(SNAME("Remove"))); + erase_missing_btn->set_icon(get_editor_theme_icon(SNAME("Clear"))); + create_tag_btn->set_icon(get_editor_theme_icon("Add")); + + tag_error->add_theme_color_override("font_color", get_theme_color("error_color", EditorStringName(Editor))); + tag_edit_error->add_theme_color_override("font_color", get_theme_color("error_color", EditorStringName(Editor))); create_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); import_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); @@ -2054,9 +2055,9 @@ void ProjectManager::_build_icon_type_cache(Ref<Theme> p_theme) { return; } List<StringName> tl; - p_theme->get_icon_list(SNAME("EditorIcons"), &tl); + p_theme->get_icon_list(EditorStringName(EditorIcons), &tl); for (List<StringName>::Element *E = tl.front(); E; E = E->next()) { - icon_type_cache[E->get()] = p_theme->get_icon(E->get(), SNAME("EditorIcons")); + icon_type_cache[E->get()] = p_theme->get_icon(E->get(), EditorStringName(EditorIcons)); } } @@ -2837,7 +2838,7 @@ ProjectManager::ProjectManager() { EditorColorMap::create(); Ref<Theme> theme = create_custom_theme(); - DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), SNAME("Editor"))); + DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), EditorStringName(Editor))); set_theme(theme); set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index e33f9f921d..09de9cda49 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -35,6 +35,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/export/editor_export.h" #include "scene/gui/check_button.h" @@ -501,7 +502,7 @@ void ProjectSettingsEditor::_update_action_map_editor() { List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - const Ref<Texture2D> builtin_icon = get_theme_icon(SNAME("PinPressed"), SNAME("EditorIcons")); + const Ref<Texture2D> builtin_icon = get_editor_theme_icon(SNAME("PinPressed")); for (const PropertyInfo &E : props) { const String property_name = E.name; @@ -533,11 +534,11 @@ void ProjectSettingsEditor::_update_action_map_editor() { } void ProjectSettingsEditor::_update_theme() { - search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - restart_close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + search_box->set_right_icon(get_editor_theme_icon(SNAME("Search"))); + restart_close_button->set_icon(get_editor_theme_icon(SNAME("Close"))); restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - restart_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); - restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + restart_icon->set_texture(get_editor_theme_icon(SNAME("StatusWarning"))); + restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); type_box->clear(); for (int i = 0; i < Variant::VARIANT_MAX; i++) { @@ -546,7 +547,7 @@ void ProjectSettingsEditor::_update_theme() { continue; } String type = Variant::get_type_name(Variant::Type(i)); - type_box->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i); + type_box->add_icon_item(get_editor_theme_icon(type), type, i); } } diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 737f81c157..5228db03b9 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -125,44 +125,44 @@ void PropertySelector::_update_search() { bool found = false; Ref<Texture2D> type_icons[] = { - search_options->get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("String"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Vector2i"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Rect2i"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Vector3i"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Vector4i"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Projection"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("StringName"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("RID"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Callable"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Signal"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("Array"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("PackedInt64Array"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("PackedFloat64Array"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")), - search_options->get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) + search_options->get_editor_theme_icon(SNAME("Variant")), + search_options->get_editor_theme_icon(SNAME("bool")), + search_options->get_editor_theme_icon(SNAME("int")), + search_options->get_editor_theme_icon(SNAME("float")), + search_options->get_editor_theme_icon(SNAME("String")), + search_options->get_editor_theme_icon(SNAME("Vector2")), + search_options->get_editor_theme_icon(SNAME("Vector2i")), + search_options->get_editor_theme_icon(SNAME("Rect2")), + search_options->get_editor_theme_icon(SNAME("Rect2i")), + search_options->get_editor_theme_icon(SNAME("Vector3")), + search_options->get_editor_theme_icon(SNAME("Vector3i")), + search_options->get_editor_theme_icon(SNAME("Transform2D")), + search_options->get_editor_theme_icon(SNAME("Vector4")), + search_options->get_editor_theme_icon(SNAME("Vector4i")), + search_options->get_editor_theme_icon(SNAME("Plane")), + search_options->get_editor_theme_icon(SNAME("Quaternion")), + search_options->get_editor_theme_icon(SNAME("AABB")), + search_options->get_editor_theme_icon(SNAME("Basis")), + search_options->get_editor_theme_icon(SNAME("Transform3D")), + search_options->get_editor_theme_icon(SNAME("Projection")), + search_options->get_editor_theme_icon(SNAME("Color")), + search_options->get_editor_theme_icon(SNAME("StringName")), + search_options->get_editor_theme_icon(SNAME("NodePath")), + search_options->get_editor_theme_icon(SNAME("RID")), + search_options->get_editor_theme_icon(SNAME("MiniObject")), + search_options->get_editor_theme_icon(SNAME("Callable")), + search_options->get_editor_theme_icon(SNAME("Signal")), + search_options->get_editor_theme_icon(SNAME("Dictionary")), + search_options->get_editor_theme_icon(SNAME("Array")), + search_options->get_editor_theme_icon(SNAME("PackedByteArray")), + search_options->get_editor_theme_icon(SNAME("PackedInt32Array")), + search_options->get_editor_theme_icon(SNAME("PackedInt64Array")), + search_options->get_editor_theme_icon(SNAME("PackedFloat32Array")), + search_options->get_editor_theme_icon(SNAME("PackedFloat64Array")), + search_options->get_editor_theme_icon(SNAME("PackedStringArray")), + search_options->get_editor_theme_icon(SNAME("PackedVector2Array")), + search_options->get_editor_theme_icon(SNAME("PackedVector3Array")), + search_options->get_editor_theme_icon(SNAME("PackedColorArray")) }; static_assert((sizeof(type_icons) / sizeof(type_icons[0])) == Variant::VARIANT_MAX, "Number of type icons doesn't match the number of Variant types."); @@ -177,7 +177,7 @@ void PropertySelector::_update_search() { Ref<Texture2D> icon; if (E.name == "Script Variables") { - icon = search_options->get_theme_icon(SNAME("Script"), SNAME("EditorIcons")); + icon = search_options->get_editor_theme_icon(SNAME("Script")); } else { icon = EditorNode::get_singleton()->get_class_icon(E.name); } @@ -257,7 +257,7 @@ void PropertySelector::_update_search() { script_methods = false; String rep = mi.name.replace("*", ""); if (mi.name == "*Script Methods") { - icon = search_options->get_theme_icon(SNAME("Script"), SNAME("EditorIcons")); + icon = search_options->get_editor_theme_icon(SNAME("Script")); script_methods = true; } else { icon = EditorNode::get_singleton()->get_class_icon(rep); diff --git a/editor/register_editor_types.cpp b/editor/register_editor_types.cpp index 849a6cc097..a636d8c1f2 100644 --- a/editor/register_editor_types.cpp +++ b/editor/register_editor_types.cpp @@ -41,6 +41,7 @@ #include "editor/editor_resource_preview.h" #include "editor/editor_script.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_translation_parser.h" #include "editor/editor_undo_redo_manager.h" #include "editor/export/editor_export_platform.h" @@ -133,6 +134,8 @@ void register_editor_types() { ResourceLoader::set_timestamp_on_load(true); ResourceSaver::set_timestamp_on_save(true); + EditorStringNames::create(); + GDREGISTER_CLASS(EditorPaths); GDREGISTER_CLASS(EditorPlugin); GDREGISTER_CLASS(EditorTranslationParserPlugin); @@ -289,6 +292,7 @@ void unregister_editor_types() { if (EditorPaths::get_singleton()) { EditorPaths::free(); } + EditorStringNames::free(); OS::get_singleton()->benchmark_end_measure("unregister_editor_types"); } diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 9d3cb4f2ae..050267530d 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -37,6 +37,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_themes.h" #include "editor/editor_undo_redo_manager.h" #include "modules/regex/regex.h" @@ -396,11 +397,11 @@ void RenameDialog::_update_preview(String new_text) { if (new_name == preview_node->get_name()) { // New name is identical to the old one. Don't color it as much to avoid distracting the user. - const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("default_color"), SNAME("RichTextLabel")); lbl_preview->add_theme_color_override("font_color", accent_color.lerp(text_color, 0.5)); } else { - lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor"))); + lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), EditorStringName(Editor))); } } @@ -486,7 +487,7 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * self->has_errors = true; self->lbl_preview_title->set_text(TTR("Regular Expression Error:")); - self->lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + self->lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); self->lbl_preview->set_text(vformat(TTR("At character %s"), err_str)); } diff --git a/editor/scene_create_dialog.cpp b/editor/scene_create_dialog.cpp index aac9ca3739..c97e9a81e9 100644 --- a/editor/scene_create_dialog.cpp +++ b/editor/scene_create_dialog.cpp @@ -34,6 +34,7 @@ #include "editor/create_dialog.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_validation_panel.h" #include "scene/2d/node_2d.h" #include "scene/3d/node_3d.h" @@ -48,11 +49,11 @@ void SceneCreateDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - select_node_button->set_icon(get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); - node_type_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons"))); - node_type_3d->set_icon(get_theme_icon(SNAME("Node3D"), SNAME("EditorIcons"))); - node_type_gui->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); - node_type_other->add_theme_icon_override(SNAME("icon"), get_theme_icon(SNAME("Node"), SNAME("EditorIcons"))); + select_node_button->set_icon(get_editor_theme_icon(SNAME("ClassList"))); + node_type_2d->set_icon(get_editor_theme_icon(SNAME("Node2D"))); + node_type_3d->set_icon(get_editor_theme_icon(SNAME("Node3D"))); + node_type_gui->set_icon(get_editor_theme_icon(SNAME("Control"))); + node_type_other->add_theme_icon_override(SNAME("icon"), get_editor_theme_icon(SNAME("Node"))); } break; } } @@ -114,8 +115,8 @@ void SceneCreateDialog::update_dialog() { } const StringName root_type_name = StringName(other_type_display->get_text()); - if (has_theme_icon(root_type_name, SNAME("EditorIcons"))) { - node_type_other->set_icon(get_theme_icon(root_type_name, SNAME("EditorIcons"))); + if (has_theme_icon(root_type_name, EditorStringName(EditorIcons))) { + node_type_other->set_icon(get_editor_theme_icon(root_type_name)); } else { node_type_other->set_icon(nullptr); } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index b1e30d369f..161598b50f 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -43,6 +43,7 @@ #include "editor/editor_quick_open.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_file_dialog.h" #include "editor/inspector_dock.h" @@ -1319,7 +1320,7 @@ void SceneTreeDock::_notification(int p_what) { node_shortcuts_toggle = memnew(Button); node_shortcuts_toggle->set_flat(true); - node_shortcuts_toggle->set_icon(get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); + node_shortcuts_toggle->set_icon(get_editor_theme_icon(SNAME("Favorites"))); node_shortcuts_toggle->set_toggle_mode(true); node_shortcuts_toggle->set_tooltip_text(TTR("Switch to Favorite Nodes")); node_shortcuts_toggle->set_pressed(EDITOR_GET("_use_favorites_root_selection")); @@ -1344,19 +1345,19 @@ void SceneTreeDock::_notification(int p_what) { button_2d = memnew(Button); beginner_node_shortcuts->add_child(button_2d); button_2d->set_text(TTR("2D Scene")); - button_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons"))); + button_2d->set_icon(get_editor_theme_icon(SNAME("Node2D"))); button_2d->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(TOOL_CREATE_2D_SCENE, false)); button_3d = memnew(Button); beginner_node_shortcuts->add_child(button_3d); button_3d->set_text(TTR("3D Scene")); - button_3d->set_icon(get_theme_icon(SNAME("Node3D"), SNAME("EditorIcons"))); + button_3d->set_icon(get_editor_theme_icon(SNAME("Node3D"))); button_3d->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(TOOL_CREATE_3D_SCENE, false)); button_ui = memnew(Button); beginner_node_shortcuts->add_child(button_ui); button_ui->set_text(TTR("User Interface")); - button_ui->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); + button_ui->set_icon(get_editor_theme_icon(SNAME("Control"))); button_ui->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(TOOL_CREATE_USER_INTERFACE, false)); favorite_node_shortcuts = memnew(VBoxContainer); @@ -1365,13 +1366,13 @@ void SceneTreeDock::_notification(int p_what) { button_custom = memnew(Button); node_shortcuts->add_child(button_custom); button_custom->set_text(TTR("Other Node")); - button_custom->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_custom->set_icon(get_editor_theme_icon(SNAME("Add"))); button_custom->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(TOOL_NEW, false)); button_clipboard = memnew(Button); node_shortcuts->add_child(button_clipboard); button_clipboard->set_text(TTR("Paste From Clipboard")); - button_clipboard->set_icon(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons"))); + button_clipboard->set_icon(get_editor_theme_icon(SNAME("ActionPaste"))); button_clipboard->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(TOOL_PASTE, false)); _update_create_root_dialog(); @@ -1391,37 +1392,37 @@ void SceneTreeDock::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - button_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - button_instance->set_icon(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); - button_create_script->set_icon(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons"))); - button_detach_script->set_icon(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons"))); - button_tree_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + button_add->set_icon(get_editor_theme_icon(SNAME("Add"))); + button_instance->set_icon(get_editor_theme_icon(SNAME("Instance"))); + button_create_script->set_icon(get_editor_theme_icon(SNAME("ScriptCreate"))); + button_detach_script->set_icon(get_editor_theme_icon(SNAME("ScriptRemove"))); + button_tree_menu->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); - filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + filter->set_right_icon(get_editor_theme_icon(SNAME("Search"))); PopupMenu *filter_menu = filter->get_menu(); - filter_menu->set_item_icon(filter_menu->get_item_idx_from_text(TTR("Filters")), get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - filter_menu->set_item_icon(filter_menu->get_item_index(FILTER_BY_TYPE), get_theme_icon(SNAME("Node"), SNAME("EditorIcons"))); - filter_menu->set_item_icon(filter_menu->get_item_index(FILTER_BY_GROUP), get_theme_icon(SNAME("Groups"), SNAME("EditorIcons"))); + filter_menu->set_item_icon(filter_menu->get_item_idx_from_text(TTR("Filters")), get_editor_theme_icon(SNAME("Search"))); + filter_menu->set_item_icon(filter_menu->get_item_index(FILTER_BY_TYPE), get_editor_theme_icon(SNAME("Node"))); + filter_menu->set_item_icon(filter_menu->get_item_index(FILTER_BY_GROUP), get_editor_theme_icon(SNAME("Groups"))); // These buttons are created on READY, because reasons... if (button_2d) { - button_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons"))); + button_2d->set_icon(get_editor_theme_icon(SNAME("Node2D"))); } if (button_3d) { - button_3d->set_icon(get_theme_icon(SNAME("Node3D"), SNAME("EditorIcons"))); + button_3d->set_icon(get_editor_theme_icon(SNAME("Node3D"))); } if (button_ui) { - button_ui->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); + button_ui->set_icon(get_editor_theme_icon(SNAME("Control"))); } if (button_custom) { - button_custom->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_custom->set_icon(get_editor_theme_icon(SNAME("Add"))); } if (button_clipboard) { - button_clipboard->set_icon(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons"))); + button_clipboard->set_icon(get_editor_theme_icon(SNAME("ActionPaste"))); } - menu_subresources->add_theme_constant_override("icon_max_width", get_theme_constant(SNAME("class_icon_size"), SNAME("Editor"))); + menu_subresources->add_theme_constant_override("icon_max_width", get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor))); } break; case NOTIFICATION_PROCESS: { @@ -2925,8 +2926,8 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (!EditorNode::get_singleton()->get_edited_scene()) { menu->clear(); if (profile_allow_editing) { - menu->add_icon_shortcut(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); - menu->add_icon_shortcut(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/instantiate_scene"), TOOL_INSTANTIATE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("Add")), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("Instance")), ED_GET_SHORTCUT("scene_tree/instantiate_scene"), TOOL_INSTANTIATE); } menu->reset_size(); @@ -2958,10 +2959,10 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_separator(); } - menu->add_icon_shortcut(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); - menu->add_icon_shortcut(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/instantiate_scene"), TOOL_INSTANTIATE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("Add")), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("Instance")), ED_GET_SHORTCUT("scene_tree/instantiate_scene"), TOOL_INSTANTIATE); } - menu->add_icon_shortcut(get_theme_icon(SNAME("Collapse"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("Collapse")), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE); menu->add_separator(); existing_script = selected->get_script(); @@ -2972,11 +2973,11 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { } if (profile_allow_editing) { - menu->add_icon_shortcut(get_theme_icon(SNAME("ActionCut"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/cut_node"), TOOL_CUT); - menu->add_icon_shortcut(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/copy_node"), TOOL_COPY); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionCut")), ED_GET_SHORTCUT("scene_tree/cut_node"), TOOL_CUT); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionCopy")), ED_GET_SHORTCUT("scene_tree/copy_node"), TOOL_COPY); if (selection.size() == 1 && !node_clipboard.is_empty()) { - menu->add_icon_shortcut(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/paste_node"), TOOL_PASTE); - menu->add_icon_shortcut(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/paste_node_as_sibling"), TOOL_PASTE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionPaste")), ED_GET_SHORTCUT("scene_tree/paste_node"), TOOL_PASTE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionPaste")), ED_GET_SHORTCUT("scene_tree/paste_node_as_sibling"), TOOL_PASTE); } menu->add_separator(); } @@ -2986,14 +2987,14 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (full_selection.size() == 1) { add_separator = true; - menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ScriptCreate")), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); if (existing_script.is_valid()) { - menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptExtend"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_EXTEND_SCRIPT); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ScriptExtend")), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_EXTEND_SCRIPT); } } if (existing_script.is_valid() && existing_script_removable) { add_separator = true; - menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ScriptRemove")), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); } else if (full_selection.size() > 1) { bool script_exists = false; for (Node *E : full_selection) { @@ -3005,7 +3006,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (script_exists) { add_separator = true; - menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ScriptRemove")), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); } } @@ -3019,7 +3020,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (full_selection.size() == 1) { add_separator = true; - menu->add_icon_shortcut(get_theme_icon(SNAME("Rename"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("Rename")), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME); } bool can_replace = true; @@ -3032,32 +3033,32 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (can_replace) { add_separator = true; - menu->add_icon_shortcut(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("Reload")), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); } if (scene_tree->get_selected() != edited_scene) { if (add_separator) { menu->add_separator(); } - menu->add_icon_shortcut(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); - menu->add_icon_shortcut(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN); - menu->add_icon_shortcut(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE); - menu->add_icon_shortcut(get_theme_icon(SNAME("Reparent"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT); - menu->add_icon_shortcut(get_theme_icon(SNAME("ReparentToNewNode"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/reparent_to_new_node"), TOOL_REPARENT_TO_NEW_NODE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("MoveUp")), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("MoveDown")), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("Duplicate")), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("Reparent")), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ReparentToNewNode")), ED_GET_SHORTCUT("scene_tree/reparent_to_new_node"), TOOL_REPARENT_TO_NEW_NODE); if (selection.size() == 1) { - menu->add_icon_shortcut(get_theme_icon(SNAME("NewRoot"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("NewRoot")), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT); } } } if (selection.size() == 1) { if (profile_allow_editing) { menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon(SNAME("CreateNewSceneFrom"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("CreateNewSceneFrom")), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM); } if (full_selection.size() == 1) { menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("CopyNodePath")), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); } } @@ -3076,7 +3077,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_separator(); } Node *node = full_selection[0]; - menu->add_icon_shortcut(get_theme_icon(SNAME("SceneUniqueName"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/toggle_unique_name"), TOOL_TOGGLE_SCENE_UNIQUE_NAME); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("SceneUniqueName")), ED_GET_SHORTCUT("scene_tree/toggle_unique_name"), TOOL_TOGGLE_SCENE_UNIQUE_NAME); menu->set_item_text(menu->get_item_index(TOOL_TOGGLE_SCENE_UNIQUE_NAME), node->is_unique_name_in_owner() ? TTR("Revoke Unique Name") : TTR("Access as Unique Name")); } } @@ -3091,7 +3092,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (profile_allow_editing) { menu->add_item(TTR("Clear Inheritance"), TOOL_SCENE_CLEAR_INHERITANCE); } - menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED); + menu->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED); } else if (!is_top_level) { menu->add_separator(); bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(selection[0]); @@ -3101,7 +3102,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_check_item(TTR("Load As Placeholder"), TOOL_SCENE_USE_PLACEHOLDER); menu->add_item(TTR("Make Local"), TOOL_SCENE_MAKE_LOCAL); } - menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open in Editor"), TOOL_SCENE_OPEN); + menu->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Open in Editor"), TOOL_SCENE_OPEN); if (profile_allow_editing) { menu->set_item_checked(menu->get_item_idx_from_text(TTR("Editable Children")), editable); menu->set_item_checked(menu->get_item_idx_from_text(TTR("Load As Placeholder")), placeholder); @@ -3114,15 +3115,15 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (profile_allow_editing && selection.size() > 1) { //this is not a commonly used action, it makes no sense for it to be where it was nor always present. menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon(SNAME("Rename"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("Rename")), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME); } #endif // MODULE_REGEX_ENABLED menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("Help"), SNAME("EditorIcons")), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION); + menu->add_icon_item(get_editor_theme_icon(SNAME("Help")), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION); if (profile_allow_editing) { menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), Key::KEY_DELETE), TOOL_ERASE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("Remove")), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), Key::KEY_DELETE), TOOL_ERASE); } menu->reset_size(); menu->set_position(p_menu_pos); @@ -3152,7 +3153,7 @@ void SceneTreeDock::_filter_changed(const String &p_filter) { String warning = scene_tree->get_filter_term_warning(); if (!warning.is_empty()) { - filter->add_theme_icon_override(SNAME("clear"), get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); + filter->add_theme_icon_override(SNAME("clear"), get_editor_theme_icon(SNAME("NodeWarning"))); filter->set_tooltip_text(warning); } else { filter->remove_theme_icon_override(SNAME("clear")); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index daac755529..2cca02bc7f 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -40,6 +40,7 @@ #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_file_dialog.h" #include "editor/gui/editor_validation_panel.h" @@ -111,7 +112,7 @@ void ScriptCreateDialog::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < ScriptServer::get_language_count(); i++) { - Ref<Texture2D> language_icon = get_theme_icon(ScriptServer::get_language(i)->get_type(), SNAME("EditorIcons")); + Ref<Texture2D> language_icon = get_editor_theme_icon(ScriptServer::get_language(i)->get_type()); if (language_icon.is_valid()) { language_menu->set_item_icon(i, language_icon); } @@ -134,9 +135,9 @@ void ScriptCreateDialog::_notification(int p_what) { use_templates->set_pressed(is_using_templates); } - path_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); - parent_browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); - parent_search_button->set_icon(get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); + path_button->set_icon(get_editor_theme_icon(SNAME("Folder"))); + parent_browse_button->set_icon(get_editor_theme_icon(SNAME("Folder"))); + parent_search_button->set_icon(get_editor_theme_icon(SNAME("ClassList"))); } break; } } @@ -390,6 +391,8 @@ void ScriptCreateDialog::_create_new() { if (is_built_in) { scr->set_name(internal_name->get_text()); + // Make sure the script is compiled to make its type recognizable. + scr->reload(); } else { String lpath = ProjectSettings::get_singleton()->localize_path(file_path->get_text()); scr->set_path(lpath); @@ -644,8 +647,8 @@ void ScriptCreateDialog::_update_template_menu() { } t.id = id; template_list.push_back(t); - String icon = has_theme_icon(t.inherit, SNAME("EditorIcons")) ? t.inherit : "Object"; - template_menu->set_item_icon(id, get_theme_icon(icon, SNAME("EditorIcons"))); + String icon = has_theme_icon(t.inherit, EditorStringName(EditorIcons)) ? t.inherit : "Object"; + template_menu->set_item_icon(id, get_editor_theme_icon(icon)); } } ancestor_level++; diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index 9a7b9bc84d..53ec1180a3 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -74,22 +74,22 @@ void ShaderCreateDialog::_notification(int p_what) { } void ShaderCreateDialog::_update_theme() { - Ref<Texture2D> shader_icon = gc->get_theme_icon(SNAME("Shader"), SNAME("EditorIcons")); + Ref<Texture2D> shader_icon = gc->get_editor_theme_icon(SNAME("Shader")); if (shader_icon.is_valid()) { type_menu->set_item_icon(0, shader_icon); } - Ref<Texture2D> visual_shader_icon = gc->get_theme_icon(SNAME("VisualShader"), SNAME("EditorIcons")); + Ref<Texture2D> visual_shader_icon = gc->get_editor_theme_icon(SNAME("VisualShader")); if (visual_shader_icon.is_valid()) { type_menu->set_item_icon(1, visual_shader_icon); } - Ref<Texture2D> include_icon = gc->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + Ref<Texture2D> include_icon = gc->get_editor_theme_icon(SNAME("TextFile")); if (include_icon.is_valid()) { type_menu->set_item_icon(2, include_icon); } - path_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + path_button->set_icon(get_editor_theme_icon(SNAME("Folder"))); } void ShaderCreateDialog::_update_language_info() { diff --git a/editor/window_wrapper.cpp b/editor/window_wrapper.cpp index 91d5aa8860..2570574823 100644 --- a/editor/window_wrapper.cpp +++ b/editor/window_wrapper.cpp @@ -33,6 +33,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "scene/gui/box_container.h" #include "scene/gui/label.h" #include "scene/gui/panel.h" @@ -150,7 +151,7 @@ void WindowWrapper::_notification(int p_what) { set_process_shortcut_input(true); } break; case NOTIFICATION_THEME_CHANGED: { - window_background->add_theme_style_override("panel", get_theme_stylebox("PanelForeground", "EditorStyles")); + window_background->add_theme_style_override("panel", get_theme_stylebox("PanelForeground", EditorStringName(EditorStyles))); } break; } } @@ -360,7 +361,7 @@ void ScreenSelect::_build_advanced_menu() { button->set_tooltip_text(vformat(TTR("Make this panel floating in the screen %d."), i)); if (i == current_screen) { - Color accent_color = get_theme_color("accent_color", "Editor"); + Color accent_color = get_theme_color("accent_color", EditorStringName(Editor)); button->add_theme_color_override("font_color", accent_color); } @@ -384,8 +385,8 @@ void ScreenSelect::_notification(int p_what) { connect("gui_input", callable_mp(this, &ScreenSelect::_handle_mouse_shortcut)); } break; case NOTIFICATION_THEME_CHANGED: { - set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MakeFloating", "EditorIcons")); - popup_background->add_theme_style_override("panel", get_theme_stylebox("PanelForeground", "EditorStyles")); + set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon("MakeFloating")); + popup_background->add_theme_style_override("panel", get_theme_stylebox("PanelForeground", EditorStringName(EditorStyles))); const real_t popup_height = real_t(get_theme_font_size("font_size")) * 2.0; popup->set_min_size(Size2(0, popup_height * 3)); diff --git a/main/main.cpp b/main/main.cpp index 0a9ebd4c61..7efd503f95 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -570,9 +570,15 @@ Error Main::test_setup() { ResourceLoader::load_path_remaps(); + // Initialize ThemeDB early so that scene types can register their theme items. + // Default theme will be initialized later, after modules and ScriptServer are ready. + initialize_theme_db(); + register_scene_types(); register_driver_types(); + register_scene_singletons(); + initialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE); GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SCENE); @@ -588,9 +594,7 @@ Error Main::test_setup() { register_platform_apis(); // Theme needs modules to be initialized so that sub-resources can be loaded. - initialize_theme_db(); - theme_db->initialize_theme(); - register_scene_singletons(); + theme_db->initialize_theme_noproject(); initialize_navigation_server(); @@ -2561,9 +2565,15 @@ Error Main::setup2() { OS::get_singleton()->benchmark_begin_measure("scene"); + // Initialize ThemeDB early so that scene types can register their theme items. + // Default theme will be initialized later, after modules and ScriptServer are ready. + initialize_theme_db(); + register_scene_types(); register_driver_types(); + register_scene_singletons(); + initialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE); GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SCENE); @@ -2581,11 +2591,6 @@ Error Main::setup2() { register_platform_apis(); - // Theme needs modules to be initialized so that sub-resources can be loaded. - // Default theme is initialized later, after ScriptServer is ready. - initialize_theme_db(); - register_scene_singletons(); - GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "display/mouse_cursor/custom_image", PROPERTY_HINT_FILE, "*.png,*.webp"), String()); GLOBAL_DEF_BASIC("display/mouse_cursor/custom_image_hotspot", Vector2()); GLOBAL_DEF_BASIC("display/mouse_cursor/tooltip_position_offset", Point2(10, 10)); diff --git a/methods.py b/methods.py index 97e9026fea..a6416ccdd2 100644 --- a/methods.py +++ b/methods.py @@ -776,8 +776,18 @@ def add_to_vs_project(env, sources): env.vs_srcs += [basename + ".cpp"] -def generate_vs_project(env, num_jobs, project_name="godot"): +def generate_vs_project(env, original_args, project_name="godot"): batch_file = find_visual_c_batch_file(env) + filtered_args = original_args.copy() + # Ignore the "vsproj" option to not regenerate the VS project on every build + filtered_args.pop("vsproj", None) + # The "platform" option is ignored because only the Windows platform is currently supported for VS projects + filtered_args.pop("platform", None) + # The "target" option is ignored due to the way how targets configuration is performed for VS projects (there is a separate project configuration for each target) + filtered_args.pop("target", None) + # The "progress" option is ignored as the current compilation progress indication doesn't work in VS + filtered_args.pop("progress", None) + if batch_file: class ModuleConfigs(Mapping): @@ -853,29 +863,10 @@ def generate_vs_project(env, num_jobs, project_name="godot"): "platform=windows", f"target={configuration_getter}", "progress=no", - "-j%s" % num_jobs, ] - if env["dev_build"]: - common_build_postfix.append("dev_build=yes") - - if env["dev_mode"]: - common_build_postfix.append("dev_mode=yes") - - elif env["tests"]: - common_build_postfix.append("tests=yes") - - if env["custom_modules"]: - common_build_postfix.append("custom_modules=%s" % env["custom_modules"]) - - if env["windows_subsystem"] == "console": - common_build_postfix.append("windows_subsystem=console") - - if env["precision"] == "double": - common_build_postfix.append("precision=double") - - if env["incremental_link"]: - common_build_postfix.append("incremental_link=yes") + for arg, value in filtered_args.items(): + common_build_postfix.append(f"{arg}={value}") result = " ^& ".join(common_build_prefix + [" ".join([commands] + common_build_postfix)]) return result diff --git a/misc/scripts/validate_extension_api.sh b/misc/scripts/validate_extension_api.sh index 75f03a7086..cde7a8574d 100755 --- a/misc/scripts/validate_extension_api.sh +++ b/misc/scripts/validate_extension_api.sh @@ -58,7 +58,7 @@ while read -r file; do get_expected_output "$file" # Download the reference extension_api.json - wget -qcO "$reference_file" "https://raw.githubusercontent.com/godotengine/godot-cpp/godot-$reference_tag/gdextension/extension_api.json" + wget -nv --retry-on-http-error=503 --tries=5 --timeout=60 -cO "$reference_file" "https://raw.githubusercontent.com/godotengine/godot-cpp/godot-$reference_tag/gdextension/extension_api.json" || has_problems=1 # Validate the current API against the reference "$1" --headless --validate-extension-api "$reference_file" 2>&1 | tee "$validate" | awk '!/^Validate extension JSON:/' - || true # Collect the expected and actual validation errors diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp index 91271da331..3787d0fe5e 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.cpp +++ b/modules/gltf/editor/editor_scene_importer_blend.cpp @@ -40,6 +40,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/gui/editor_file_dialog.h" #include "main/main.h" #include "scene/gui/line_edit.h" @@ -366,10 +367,10 @@ void EditorFileSystemImportFormatSupportQueryBlend::_validate_path(String p_path path_status->set_text(error); if (success) { - path_status->add_theme_color_override("font_color", path_status->get_theme_color(SNAME("success_color"), SNAME("Editor"))); + path_status->add_theme_color_override("font_color", path_status->get_theme_color(SNAME("success_color"), EditorStringName(Editor))); configure_blender_dialog->get_ok_button()->set_disabled(false); } else { - path_status->add_theme_color_override("font_color", path_status->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + path_status->add_theme_color_override("font_color", path_status->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); configure_blender_dialog->get_ok_button()->set_disabled(true); } } diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 74de40e901..984052d2ca 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -5802,10 +5802,14 @@ void GLTFDocument::_generate_scene_node(Ref<GLTFState> p_state, const GLTFNodeIn // If none of our GLTFDocumentExtension classes generated us a node, we generate one. if (!current_node) { if (gltf_node->skin >= 0 && gltf_node->mesh >= 0 && !gltf_node->children.is_empty()) { + // GLTF specifies that skinned meshes should ignore their node transforms, + // only being controlled by the skeleton, so Godot will reparent a skinned + // mesh to its skeleton. However, we still need to ensure any child nodes + // keep their place in the tree, so if there are any child nodes, the skinned + // mesh must not be the base node, so generate an empty spatial base. current_node = _generate_spatial(p_state, p_node_index); Node3D *mesh_inst = _generate_mesh_instance(p_state, p_node_index); mesh_inst->set_name(gltf_node->get_name()); - current_node->add_child(mesh_inst, true); } else if (gltf_node->mesh >= 0) { current_node = _generate_mesh_instance(p_state, p_node_index); diff --git a/modules/gridmap/editor/grid_map_editor_plugin.cpp b/modules/gridmap/editor/grid_map_editor_plugin.cpp index 0c9f8fb3e0..f96cc86142 100644 --- a/modules/gridmap/editor/grid_map_editor_plugin.cpp +++ b/modules/gridmap/editor/grid_map_editor_plugin.cpp @@ -38,6 +38,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/plugins/node_3d_editor_plugin.h" #include "scene/3d/camera_3d.h" @@ -1059,10 +1060,10 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) { } void GridMapEditor::_update_theme() { - options->set_icon(get_theme_icon(SNAME("GridMap"), SNAME("EditorIcons"))); - search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - mode_thumbnail->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); - mode_list->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); + options->set_icon(get_theme_icon(SNAME("GridMap"), EditorStringName(EditorIcons))); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), EditorStringName(EditorIcons))); + mode_thumbnail->set_icon(get_theme_icon(SNAME("FileThumbnail"), EditorStringName(EditorIcons))); + mode_list->set_icon(get_theme_icon(SNAME("FileList"), EditorStringName(EditorIcons))); } void GridMapEditor::_notification(int p_what) { diff --git a/modules/multiplayer/editor/editor_network_profiler.cpp b/modules/multiplayer/editor/editor_network_profiler.cpp index c2cb0a3d1a..a53eefc452 100644 --- a/modules/multiplayer/editor/editor_network_profiler.cpp +++ b/modules/multiplayer/editor/editor_network_profiler.cpp @@ -33,6 +33,7 @@ #include "core/os/os.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" void EditorNetworkProfiler::_bind_methods() { ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable"))); @@ -62,19 +63,19 @@ void EditorNetworkProfiler::_notification(int p_what) { void EditorNetworkProfiler::_update_theme_item_cache() { VBoxContainer::_update_theme_item_cache(); - theme_cache.node_icon = get_theme_icon(SNAME("Node"), SNAME("EditorIcons")); - theme_cache.stop_icon = get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")); - theme_cache.play_icon = get_theme_icon(SNAME("Play"), SNAME("EditorIcons")); - theme_cache.clear_icon = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")); + theme_cache.node_icon = get_theme_icon(SNAME("Node"), EditorStringName(EditorIcons)); + theme_cache.stop_icon = get_theme_icon(SNAME("Stop"), EditorStringName(EditorIcons)); + theme_cache.play_icon = get_theme_icon(SNAME("Play"), EditorStringName(EditorIcons)); + theme_cache.clear_icon = get_theme_icon(SNAME("Clear"), EditorStringName(EditorIcons)); - theme_cache.multiplayer_synchronizer_icon = get_theme_icon("MultiplayerSynchronizer", SNAME("EditorIcons")); - theme_cache.instance_options_icon = get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")); + theme_cache.multiplayer_synchronizer_icon = get_theme_icon("MultiplayerSynchronizer", EditorStringName(EditorIcons)); + theme_cache.instance_options_icon = get_theme_icon(SNAME("InstanceOptions"), EditorStringName(EditorIcons)); - theme_cache.incoming_bandwidth_icon = get_theme_icon(SNAME("ArrowDown"), SNAME("EditorIcons")); - theme_cache.outgoing_bandwidth_icon = get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons")); + theme_cache.incoming_bandwidth_icon = get_theme_icon(SNAME("ArrowDown"), EditorStringName(EditorIcons)); + theme_cache.outgoing_bandwidth_icon = get_theme_icon(SNAME("ArrowUp"), EditorStringName(EditorIcons)); - theme_cache.incoming_bandwidth_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); - theme_cache.outgoing_bandwidth_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + theme_cache.incoming_bandwidth_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); + theme_cache.outgoing_bandwidth_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); } void EditorNetworkProfiler::_refresh() { @@ -128,7 +129,7 @@ void EditorNetworkProfiler::refresh_replication_data() { const NodeInfo &cfg_info = node_data[E.value.config]; node->set_text(0, root_info.path.get_file()); - node->set_icon(0, has_theme_icon(root_info.type, SNAME("EditorIcons")) ? get_theme_icon(root_info.type, SNAME("EditorIcons")) : theme_cache.node_icon); + node->set_icon(0, has_theme_icon(root_info.type, EditorStringName(EditorIcons)) ? get_theme_icon(root_info.type, EditorStringName(EditorIcons)) : theme_cache.node_icon); node->set_tooltip_text(0, root_info.path); node->set_text(1, sync_info.path.get_file()); diff --git a/modules/multiplayer/editor/replication_editor.cpp b/modules/multiplayer/editor/replication_editor.cpp index cf1db9d43d..0051d82e99 100644 --- a/modules/multiplayer/editor/replication_editor.cpp +++ b/modules/multiplayer/editor/replication_editor.cpp @@ -35,6 +35,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/scene_tree_editor.h" #include "editor/inspector_dock.h" @@ -359,8 +360,8 @@ void ReplicationEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); - add_pick_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - pin->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); + add_pick_button->set_icon(get_theme_icon(SNAME("Add"), EditorStringName(EditorIcons))); + pin->set_icon(get_theme_icon(SNAME("Pin"), EditorStringName(EditorIcons))); } break; } } @@ -524,10 +525,10 @@ void ReplicationEditor::edit(MultiplayerSynchronizer *p_sync) { } Ref<Texture2D> ReplicationEditor::_get_class_icon(const Node *p_node) { - if (!p_node || !has_theme_icon(p_node->get_class(), "EditorIcons")) { - return get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); + if (!p_node || !has_theme_icon(p_node->get_class(), EditorStringName(EditorIcons))) { + return get_theme_icon(SNAME("ImportFail"), EditorStringName(EditorIcons)); } - return get_theme_icon(p_node->get_class(), "EditorIcons"); + return get_theme_icon(p_node->get_class(), EditorStringName(EditorIcons)); } static bool can_sync(const Variant &p_var) { @@ -571,7 +572,7 @@ void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn, bool valid = false; Variant value = node->get(subpath, &valid); if (valid && !can_sync(value)) { - item->set_icon(0, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + item->set_icon(0, get_theme_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons))); item->set_tooltip_text(0, TTR("Property of this type not supported.")); } else { item->set_icon(0, icon); @@ -579,7 +580,7 @@ void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn, } else { item->set_icon(0, icon); } - item->add_button(3, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + item->add_button(3, get_theme_icon(SNAME("Remove"), EditorStringName(EditorIcons))); item->set_text_alignment(1, HORIZONTAL_ALIGNMENT_CENTER); item->set_cell_mode(1, TreeItem::CELL_MODE_CHECK); item->set_checked(1, p_spawn); diff --git a/modules/navigation/editor/navigation_mesh_editor_plugin.cpp b/modules/navigation/editor/navigation_mesh_editor_plugin.cpp index 535091e5b6..85948e7547 100644 --- a/modules/navigation/editor/navigation_mesh_editor_plugin.cpp +++ b/modules/navigation/editor/navigation_mesh_editor_plugin.cpp @@ -35,6 +35,7 @@ #include "core/io/marshalls.h" #include "core/io/resource_saver.h" #include "editor/editor_node.h" +#include "editor/editor_string_names.h" #include "scene/3d/mesh_instance_3d.h" #include "scene/3d/navigation_region_3d.h" #include "scene/gui/box_container.h" @@ -54,8 +55,8 @@ void NavigationMeshEditor::_node_removed(Node *p_node) { void NavigationMeshEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - button_bake->set_icon(get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); - button_reset->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + button_bake->set_icon(get_theme_icon(SNAME("Bake"), EditorStringName(EditorIcons))); + button_reset->set_icon(get_theme_icon(SNAME("Reload"), EditorStringName(EditorIcons))); } break; } } diff --git a/modules/navigation/godot_navigation_server.h b/modules/navigation/godot_navigation_server.h index 40893bada6..c12605bc7a 100644 --- a/modules/navigation/godot_navigation_server.h +++ b/modules/navigation/godot_navigation_server.h @@ -56,7 +56,9 @@ void MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1) class GodotNavigationServer; +#ifndef _3D_DISABLED class NavMeshGenerator3D; +#endif // _3D_DISABLED struct SetCommand { virtual ~SetCommand() {} @@ -80,7 +82,9 @@ class GodotNavigationServer : public NavigationServer3D { LocalVector<NavMap *> active_maps; LocalVector<uint32_t> active_maps_update_id; +#ifndef _3D_DISABLED NavMeshGenerator3D *navmesh_generator_3d = nullptr; +#endif // _3D_DISABLED // Performance Monitor int pm_region_count = 0; diff --git a/modules/openxr/editor/openxr_action_editor.cpp b/modules/openxr/editor/openxr_action_editor.cpp index 586b0b0697..4b188471a0 100644 --- a/modules/openxr/editor/openxr_action_editor.cpp +++ b/modules/openxr/editor/openxr_action_editor.cpp @@ -30,6 +30,8 @@ #include "openxr_action_editor.h" +#include "editor/editor_string_names.h" + void OpenXRActionEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_do_set_name", "name"), &OpenXRActionEditor::_do_set_name); ClassDB::bind_method(D_METHOD("_do_set_localized_name", "name"), &OpenXRActionEditor::_do_set_localized_name); @@ -39,7 +41,7 @@ void OpenXRActionEditor::_bind_methods() { } void OpenXRActionEditor::_theme_changed() { - rem_action->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + rem_action->set_icon(get_theme_icon(SNAME("Remove"), EditorStringName(EditorIcons))); } void OpenXRActionEditor::_notification(int p_what) { diff --git a/modules/openxr/editor/openxr_action_set_editor.cpp b/modules/openxr/editor/openxr_action_set_editor.cpp index 6a63720257..a9fc6c4db6 100644 --- a/modules/openxr/editor/openxr_action_set_editor.cpp +++ b/modules/openxr/editor/openxr_action_set_editor.cpp @@ -30,6 +30,7 @@ #include "openxr_action_set_editor.h" +#include "editor/editor_string_names.h" #include "openxr_action_editor.h" void OpenXRActionSetEditor::_bind_methods() { @@ -45,16 +46,16 @@ void OpenXRActionSetEditor::_bind_methods() { void OpenXRActionSetEditor::_set_fold_icon() { if (is_expanded) { - fold_btn->set_icon(get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons"))); + fold_btn->set_icon(get_theme_icon(SNAME("GuiTreeArrowDown"), EditorStringName(EditorIcons))); } else { - fold_btn->set_icon(get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons"))); + fold_btn->set_icon(get_theme_icon(SNAME("GuiTreeArrowRight"), EditorStringName(EditorIcons))); } } void OpenXRActionSetEditor::_theme_changed() { _set_fold_icon(); - add_action->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - rem_action_set->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + add_action->set_icon(get_theme_icon(SNAME("Add"), EditorStringName(EditorIcons))); + rem_action_set->set_icon(get_theme_icon(SNAME("Remove"), EditorStringName(EditorIcons))); } void OpenXRActionSetEditor::_notification(int p_what) { diff --git a/modules/openxr/editor/openxr_interaction_profile_editor.cpp b/modules/openxr/editor/openxr_interaction_profile_editor.cpp index 9998bb80e3..7bccabf936 100644 --- a/modules/openxr/editor/openxr_interaction_profile_editor.cpp +++ b/modules/openxr/editor/openxr_interaction_profile_editor.cpp @@ -30,6 +30,7 @@ #include "openxr_interaction_profile_editor.h" +#include "editor/editor_string_names.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" #include "scene/gui/label.h" @@ -220,7 +221,7 @@ void OpenXRInteractionProfileEditor::_add_io_path(VBoxContainer *p_container, co path_hb->add_child(type_label); Button *path_add = memnew(Button); - path_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + path_add->set_icon(get_theme_icon(SNAME("Add"), EditorStringName(EditorIcons))); path_add->set_flat(true); path_add->connect("pressed", callable_mp(this, &OpenXRInteractionProfileEditor::select_action_for).bind(String(p_io_path->openxr_path))); path_hb->add_child(path_add); @@ -248,7 +249,7 @@ void OpenXRInteractionProfileEditor::_add_io_path(VBoxContainer *p_container, co Button *action_rem = memnew(Button); action_rem->set_flat(true); - action_rem->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + action_rem->set_icon(get_theme_icon(SNAME("Remove"), EditorStringName(EditorIcons))); action_rem->connect("pressed", callable_mp((OpenXRInteractionProfileEditor *)this, &OpenXRInteractionProfileEditor::_on_remove_pressed).bind(action->get_name_with_set(), String(p_io_path->openxr_path))); action_hb->add_child(action_rem); } diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index cbe48db494..85e98eac76 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -2383,10 +2383,8 @@ void TextServerAdvanced::_font_set_variation_coordinates(const RID &p_font_rid, ERR_FAIL_COND(!fd); MutexLock lock(fd->mutex); - if (fd->variation_coordinates != p_variation_coordinates) { - _font_clear_cache(fd); - fd->variation_coordinates = p_variation_coordinates; - } + _font_clear_cache(fd); + fd->variation_coordinates = p_variation_coordinates; } Dictionary TextServerAdvanced::_font_get_variation_coordinates(const RID &p_font_rid) const { diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index d0587bf6c0..5d4de7a0d6 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -1376,10 +1376,8 @@ void TextServerFallback::_font_set_variation_coordinates(const RID &p_font_rid, ERR_FAIL_COND(!fd); MutexLock lock(fd->mutex); - if (fd->variation_coordinates != p_variation_coordinates) { - _font_clear_cache(fd); - fd->variation_coordinates = p_variation_coordinates; - } + _font_clear_cache(fd); + fd->variation_coordinates = p_variation_coordinates; } Dictionary TextServerFallback::_font_get_variation_coordinates(const RID &p_font_rid) const { diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt index 9c1165bf8a..e115494cfd 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt @@ -907,6 +907,19 @@ class Godot(private val context: Context) : SensorEventListener { return PermissionsUtil.getGrantedPermissions(getActivity()) } + /** + * Get the list of gdextension modules to register. + */ + @Keep + private fun getGDExtensionConfigFiles(): Array<String> { + val configFiles = mutableSetOf<String>() + for (plugin in pluginRegistry.allPlugins) { + configFiles.addAll(plugin.pluginGDExtensionLibrariesPaths) + } + + return configFiles.toTypedArray() + } + @Keep private fun getCACertificates(): String { return GodotNetUtils.getCACertificates() diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java index 48aa231c7a..7f3a3ac7a3 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java +++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java @@ -57,27 +57,28 @@ import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.opengles.GL10; /** - * Base class for the Godot Android plugins. + * Base class for Godot Android plugins. * <p> - * A Godot Android plugin is a regular Android library packaged as an aar archive file with the following caveats: + * A Godot Android plugin is an Android library with the following requirements: * <p> - * - The library must have a dependency on the Godot Android library (godot-lib.aar). - * A stable version is available for each release. + * - The plugin must have a dependency on the Godot Android library: `implementation "org.godotengine:godot:<godotLibVersion>"` + * <p> + * - The plugin must include a <meta-data> tag in its Android manifest with the following format: + * <meta-data android:name="org.godotengine.plugin.v2.[PluginName]" android:value="[plugin.init.ClassFullName]" /> * <p> - * - The library must include a <meta-data> tag in its manifest file setup as follow: - * <meta-data android:name="org.godotengine.plugin.v1.[PluginName]" android:value="[plugin.init.ClassFullName]" /> * Where: + * <p> * - 'PluginName' is the name of the plugin. - * - 'plugin.init.ClassFullName' is the full name (package + class name) of the plugin class + * <p> + * - 'plugin.init.ClassFullName' is the full name (package + class name) of the plugin init class * extending {@link GodotPlugin}. + * <p> + * A Godot Android plugin can also define and provide c/c++ gdextension libraries, which will be + * automatically bundled by the aar build system. + * GDExtension ('*.gdextension') config files must be located in the project 'assets' directory and + * their paths specified by {@link GodotPlugin#getPluginGDExtensionLibrariesPaths()}. * - * A plugin can also define and provide c/c++ gdextension libraries and nativescripts for the target - * app/game to leverage. - * The shared library for the gdextension library will be automatically bundled by the aar build - * system. - * Godot '*.gdextension' resource files must however be manually defined in the project - * 'assets' directory. The recommended path for these resources in the 'assets' directory should be: - * 'godot/plugin/v1/[PluginName]/' + * @see <a href="https://docs.godotengine.org/en/stable/tutorials/platform/android/index.html">Android plugins</a> */ public abstract class GodotPlugin { private static final String TAG = GodotPlugin.class.getSimpleName(); @@ -85,6 +86,10 @@ public abstract class GodotPlugin { private final Godot godot; private final ConcurrentHashMap<String, SignalInfo> registeredSignals = new ConcurrentHashMap<>(); + /** + * Base constructor passing a {@link Godot} instance through which the plugin can access Godot's + * APIs and lifecycle events. + */ public GodotPlugin(Godot godot) { this.godot = godot; } @@ -97,7 +102,7 @@ public abstract class GodotPlugin { } /** - * Provides access to the underlying {@link Activity}. + * Provides access to the hosting {@link Activity}. */ @Nullable protected Activity getActivity() { @@ -106,33 +111,16 @@ public abstract class GodotPlugin { /** * Register the plugin with Godot native code. - * - * This method is invoked on the render thread. + * <p> + * This method is invoked by the Godot Engine on the render thread. */ public final void onRegisterPluginWithGodotNative() { registeredSignals.putAll( - registerPluginWithGodotNative(this, getPluginName(), getPluginMethods(), getPluginSignals(), - getPluginGDExtensionLibrariesPaths())); - } - - /** - * Register the plugin with Godot native code. - * - * This method must be invoked on the render thread. - */ - public static void registerPluginWithGodotNative(Object pluginObject, - GodotPluginInfoProvider pluginInfoProvider) { - registerPluginWithGodotNative(pluginObject, pluginInfoProvider.getPluginName(), - Collections.emptyList(), pluginInfoProvider.getPluginSignals(), - pluginInfoProvider.getPluginGDExtensionLibrariesPaths()); - - // Notify that registration is complete. - pluginInfoProvider.onPluginRegistered(); + registerPluginWithGodotNative(this, getPluginName(), getPluginMethods(), getPluginSignals())); } private static Map<String, SignalInfo> registerPluginWithGodotNative(Object pluginObject, - String pluginName, List<String> pluginMethods, Set<SignalInfo> pluginSignals, - Set<String> pluginGDExtensionLibrariesPaths) { + String pluginName, List<String> pluginMethods, Set<SignalInfo> pluginSignals) { nativeRegisterSingleton(pluginName, pluginObject); Set<Method> filteredMethods = new HashSet<>(); @@ -176,23 +164,18 @@ public abstract class GodotPlugin { registeredSignals.put(signalName, signalInfo); } - // Get the list of gdextension libraries to register. - if (!pluginGDExtensionLibrariesPaths.isEmpty()) { - nativeRegisterGDExtensionLibraries(pluginGDExtensionLibrariesPaths.toArray(new String[0])); - } - return registeredSignals; } /** - * Invoked once during the Godot Android initialization process after creation of the + * Invoked once during the initialization process after creation of the * {@link org.godotengine.godot.GodotRenderView} view. * <p> - * The plugin can return a non-null {@link View} layout in order to add it to the Godot view + * The plugin can return a non-null {@link View} layout which will be added to the Godot view * hierarchy. - * - * Use shouldBeOnTop() to set whether the plugin's {@link View} should be added on top or behind - * the main Godot view. + * <p> + * Use {@link GodotPlugin#shouldBeOnTop()} to specify whether the plugin's {@link View} should + * be added on top or behind the main Godot view. * * @see Activity#onCreate(Bundle) * @return the plugin's view to be included; null if no views should be included. @@ -235,44 +218,52 @@ public abstract class GodotPlugin { public boolean onMainBackPressed() { return false; } /** - * Invoked on the render thread when the Godot setup is complete. + * Invoked on the render thread when set up of the Godot engine is complete. + * <p> + * This is invoked before {@link GodotPlugin#onGodotMainLoopStarted()}. */ public void onGodotSetupCompleted() {} /** * Invoked on the render thread when the Godot main loop has started. + * + * This is invoked after {@link GodotPlugin#onGodotSetupCompleted()}. */ public void onGodotMainLoopStarted() {} /** - * Invoked once per frame on the GL thread after the frame is drawn. + * When using the OpenGL renderer, this is invoked once per frame on the GL thread after the + * frame is drawn. */ public void onGLDrawFrame(GL10 gl) {} /** - * Called on the GL thread after the surface is created and whenever the OpenGL ES surface size - * changes. + * When using the OpenGL renderer, this is called on the GL thread after the surface is created + * and whenever the OpenGL ES surface size changes. */ public void onGLSurfaceChanged(GL10 gl, int width, int height) {} /** - * Called on the GL thread when the surface is created or recreated. + * When using the OpenGL renderer, this is called on the GL thread when the surface is created + * or recreated. */ public void onGLSurfaceCreated(GL10 gl, EGLConfig config) {} /** - * Invoked once per frame on the Vulkan thread after the frame is drawn. + * When using the Vulkan renderer, this is invoked once per frame on the Vulkan thread after + * the frame is drawn. */ public void onVkDrawFrame() {} /** - * Called on the Vulkan thread after the surface is created and whenever the surface size - * changes. + * When using the Vulkan renderer, this is called on the Vulkan thread after the surface is + * created and whenever the surface size changes. */ public void onVkSurfaceChanged(Surface surface, int width, int height) {} /** - * Called on the Vulkan thread when the surface is created or recreated. + * When using the Vulkan renderer, this is called on the Vulkan thread when the surface is + * created or recreated. */ public void onVkSurfaceCreated(Surface surface) {} @@ -287,7 +278,7 @@ public abstract class GodotPlugin { /** * Returns the list of methods to be exposed to Godot. * - * @deprecated Used the {@link UsedByGodot} annotation instead. + * @deprecated Use the {@link UsedByGodot} annotation instead. */ @NonNull @Deprecated @@ -304,19 +295,19 @@ public abstract class GodotPlugin { } /** - * Returns the paths for the plugin's gdextension libraries. - * - * The paths must be relative to the 'assets' directory and point to a '*.gdextension' file. + * Returns the paths for the plugin's gdextension libraries (if any). + * <p> + * Each returned path must be relative to the 'assets' directory and point to a '*.gdextension' file. */ @NonNull - protected Set<String> getPluginGDExtensionLibrariesPaths() { + public Set<String> getPluginGDExtensionLibrariesPaths() { return Collections.emptySet(); } /** - * Returns whether the plugin's {@link View} returned in onMainCreate() should be placed on - * top of the main Godot view. - * + * Returns whether the plugin's {@link View} returned in + * {@link GodotPlugin#onMainCreate(Activity)} should be placed on top of the main Godot view. + * <p> * Returning false causes the plugin's {@link View} to be placed behind, which can be useful * when used with transparency in order to let the Godot view handle inputs. */ @@ -359,7 +350,7 @@ public abstract class GodotPlugin { } emitSignal(getGodot(), getPluginName(), signalInfo, signalArgs); } catch (IllegalArgumentException exception) { - Log.w(TAG, exception.getMessage()); + Log.w(TAG, exception); if (BuildConfig.DEBUG) { throw exception; } @@ -368,7 +359,7 @@ public abstract class GodotPlugin { /** * Emit a Godot signal. - * @param godot + * @param godot Godot instance * @param pluginName Name of the Godot plugin the signal will be emitted from. The plugin must already be registered with the Godot engine. * @param signalInfo Information about the signal to emit. * @param signalArgs Arguments used to populate the emitted signal. The arguments will be validated against the given {@link SignalInfo} parameter. @@ -397,7 +388,7 @@ public abstract class GodotPlugin { godot.runOnRenderThread(() -> nativeEmitSignal(pluginName, signalInfo.getName(), signalArgs)); } catch (IllegalArgumentException exception) { - Log.w(TAG, exception.getMessage()); + Log.w(TAG, exception); if (BuildConfig.DEBUG) { throw exception; } @@ -420,13 +411,7 @@ public abstract class GodotPlugin { private static native void nativeRegisterMethod(String p_sname, String p_name, String p_ret, String[] p_params); /** - * Used to register gdextension libraries bundled by the plugin. - * @param gdextensionPaths Paths to the libraries relative to the 'assets' directory. - */ - private static native void nativeRegisterGDExtensionLibraries(String[] gdextensionPaths); - - /** - * Used to complete registration of the {@link GodotPlugin} instance's methods. + * Used to complete registration of the {@link GodotPlugin} instance's signals. * @param pluginName Name of the plugin * @param signalName Name of the signal to register * @param signalParamTypes Signal parameters types diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java index c2428de2e1..d338b72441 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java +++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java @@ -52,7 +52,14 @@ import java.util.concurrent.ConcurrentHashMap; public final class GodotPluginRegistry { private static final String TAG = GodotPluginRegistry.class.getSimpleName(); + /** + * Prefix used for version 1 of the Godot plugin, mostly compatible with Godot 3.x + */ private static final String GODOT_PLUGIN_V1_NAME_PREFIX = "org.godotengine.plugin.v1."; + /** + * Prefix used for version 2 of the Godot plugin, compatible with Godot 4.2+ + */ + private static final String GODOT_PLUGIN_V2_NAME_PREFIX = "org.godotengine.plugin.v2."; private static GodotPluginRegistry instance; private final ConcurrentHashMap<String, GodotPlugin> registry; @@ -123,11 +130,17 @@ public final class GodotPluginRegistry { return; } - int godotPluginV1NamePrefixLength = GODOT_PLUGIN_V1_NAME_PREFIX.length(); for (String metaDataName : metaData.keySet()) { // Parse the meta-data looking for entry with the Godot plugin name prefix. - if (metaDataName.startsWith(GODOT_PLUGIN_V1_NAME_PREFIX)) { - String pluginName = metaDataName.substring(godotPluginV1NamePrefixLength).trim(); + String pluginName = null; + if (metaDataName.startsWith(GODOT_PLUGIN_V2_NAME_PREFIX)) { + pluginName = metaDataName.substring(GODOT_PLUGIN_V2_NAME_PREFIX.length()).trim(); + } else if (metaDataName.startsWith(GODOT_PLUGIN_V1_NAME_PREFIX)) { + pluginName = metaDataName.substring(GODOT_PLUGIN_V1_NAME_PREFIX.length()).trim(); + Log.w(TAG, "Godot v1 plugin are deprecated in Godot 4.2 and higher: " + pluginName); + } + + if (!TextUtils.isEmpty(pluginName)) { Log.i(TAG, "Initializing Godot plugin " + pluginName); // Retrieve the plugin class full name. @@ -149,15 +162,7 @@ public final class GodotPluginRegistry { } registry.put(pluginName, pluginHandle); Log.i(TAG, "Completed initialization for Godot plugin " + pluginHandle.getPluginName()); - } catch (ClassNotFoundException e) { - Log.w(TAG, "Unable to load Godot plugin " + pluginName, e); - } catch (IllegalAccessException e) { - Log.w(TAG, "Unable to load Godot plugin " + pluginName, e); - } catch (InstantiationException e) { - Log.w(TAG, "Unable to load Godot plugin " + pluginName, e); - } catch (NoSuchMethodException e) { - Log.w(TAG, "Unable to load Godot plugin " + pluginName, e); - } catch (InvocationTargetException e) { + } catch (Exception e) { Log.w(TAG, "Unable to load Godot plugin " + pluginName, e); } } else { @@ -165,7 +170,7 @@ public final class GodotPluginRegistry { } } } - } catch (PackageManager.NameNotFoundException e) { + } catch (Exception e) { Log.e(TAG, "Unable load Godot Android plugins from the manifest file.", e); } } diff --git a/platform/android/java_godot_wrapper.cpp b/platform/android/java_godot_wrapper.cpp index 79ba2528ba..a01a74f1fd 100644 --- a/platform/android/java_godot_wrapper.cpp +++ b/platform/android/java_godot_wrapper.cpp @@ -79,6 +79,7 @@ GodotJavaWrapper::GodotJavaWrapper(JNIEnv *p_env, jobject p_activity, jobject p_ _begin_benchmark_measure = p_env->GetMethodID(godot_class, "nativeBeginBenchmarkMeasure", "(Ljava/lang/String;)V"); _end_benchmark_measure = p_env->GetMethodID(godot_class, "nativeEndBenchmarkMeasure", "(Ljava/lang/String;)V"); _dump_benchmark = p_env->GetMethodID(godot_class, "nativeDumpBenchmark", "(Ljava/lang/String;)V"); + _get_gdextension_list_config_file = p_env->GetMethodID(godot_class, "getGDExtensionConfigFiles", "()[Ljava/lang/String;"); } GodotJavaWrapper::~GodotJavaWrapper() { @@ -264,6 +265,25 @@ Vector<String> GodotJavaWrapper::get_granted_permissions() const { return permissions_list; } +Vector<String> GodotJavaWrapper::get_gdextension_list_config_file() const { + Vector<String> config_file_list; + if (_get_gdextension_list_config_file) { + JNIEnv *env = get_jni_env(); + ERR_FAIL_NULL_V(env, config_file_list); + jobject config_file_list_object = env->CallObjectMethod(godot_instance, _get_gdextension_list_config_file); + jobjectArray *arr = reinterpret_cast<jobjectArray *>(&config_file_list_object); + + jsize len = env->GetArrayLength(*arr); + for (int i = 0; i < len; i++) { + jstring j_config_file = (jstring)env->GetObjectArrayElement(*arr, i); + String config_file = jstring_to_string(j_config_file, env); + config_file_list.push_back(config_file); + env->DeleteLocalRef(j_config_file); + } + } + return config_file_list; +} + String GodotJavaWrapper::get_ca_certificates() const { if (_get_ca_certificates) { JNIEnv *env = get_jni_env(); diff --git a/platform/android/java_godot_wrapper.h b/platform/android/java_godot_wrapper.h index ba42d5dccd..2ce756807f 100644 --- a/platform/android/java_godot_wrapper.h +++ b/platform/android/java_godot_wrapper.h @@ -59,6 +59,7 @@ private: jmethodID _request_permission = nullptr; jmethodID _request_permissions = nullptr; jmethodID _get_granted_permissions = nullptr; + jmethodID _get_gdextension_list_config_file = nullptr; jmethodID _get_ca_certificates = nullptr; jmethodID _init_input_devices = nullptr; jmethodID _vibrate = nullptr; @@ -102,6 +103,9 @@ public: void begin_benchmark_measure(const String &p_label); void end_benchmark_measure(const String &p_label); void dump_benchmark(const String &benchmark_file); + + // Return the list of gdextensions config file. + Vector<String> get_gdextension_list_config_file() const; }; #endif // JAVA_GODOT_WRAPPER_H diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index c040d8c4c6..2a8c07be83 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -39,6 +39,7 @@ #include "net_socket_android.h" #include "core/config/project_settings.h" +#include "core/extension/gdextension_manager.h" #include "drivers/unix/dir_access_unix.h" #include "drivers/unix/file_access_unix.h" #include "main/main.h" @@ -162,11 +163,39 @@ Vector<String> OS_Android::get_granted_permissions() const { Error OS_Android::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path, String *r_resolved_path) { String path = p_path; + bool so_file_exists = true; if (!FileAccess::exists(path)) { path = p_path.get_file(); + so_file_exists = false; } p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW); + if (!p_library_handle && so_file_exists) { + // The library may be on the sdcard and thus inaccessible. Try to copy it to the internal + // directory. + uint64_t so_modified_time = FileAccess::get_modified_time(p_path); + String dynamic_library_path = get_dynamic_libraries_path().path_join(String::num_uint64(so_modified_time)); + String internal_path = dynamic_library_path.path_join(p_path.get_file()); + + bool internal_so_file_exists = FileAccess::exists(internal_path); + if (!internal_so_file_exists) { + Ref<DirAccess> da_ref = DirAccess::create_for_path(p_path); + if (da_ref.is_valid()) { + Error create_dir_result = da_ref->make_dir_recursive(dynamic_library_path); + if (create_dir_result == OK || create_dir_result == ERR_ALREADY_EXISTS) { + internal_so_file_exists = da_ref->copy(path, internal_path) == OK; + } + } + } + + if (internal_so_file_exists) { + p_library_handle = dlopen(internal_path.utf8().get_data(), RTLD_NOW); + if (p_library_handle) { + path = internal_path; + } + } + } + ERR_FAIL_NULL_V_MSG(p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, dlerror())); if (r_resolved_path != nullptr) { @@ -584,6 +613,10 @@ String OS_Android::get_user_data_dir() const { return "."; } +String OS_Android::get_dynamic_libraries_path() const { + return get_cache_path().path_join("dynamic_libraries"); +} + String OS_Android::get_cache_path() const { if (!cache_dir_cache.is_empty()) { return cache_dir_cache; @@ -791,5 +824,13 @@ Error OS_Android::setup_remote_filesystem(const String &p_server_host, int p_por return err; } +void OS_Android::load_platform_gdextensions() const { + Vector<String> extension_list_config_file = godot_java->get_gdextension_list_config_file(); + for (String config_file_path : extension_list_config_file) { + GDExtensionManager::LoadStatus err = GDExtensionManager::get_singleton()->load_extension(config_file_path); + ERR_CONTINUE_MSG(err == GDExtensionManager::LOAD_STATUS_FAILED, "Error loading platform extension: " + config_file_path); + } +} + OS_Android::~OS_Android() { } diff --git a/platform/android/os_android.h b/platform/android/os_android.h index abcc412588..f88f3e0518 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -169,9 +169,15 @@ public: virtual void benchmark_end_measure(const String &p_what) override; virtual void benchmark_dump() override; + virtual void load_platform_gdextensions() const override; + virtual bool _check_internal_feature_support(const String &p_feature) override; OS_Android(GodotJavaWrapper *p_godot_java, GodotIOJavaWrapper *p_godot_io_java, bool p_use_apk_expansion); ~OS_Android(); + +private: + // Location where we relocate external dynamic libraries to make them accessible. + String get_dynamic_libraries_path() const; }; #endif // OS_ANDROID_H diff --git a/platform/android/plugin/godot_plugin_jni.cpp b/platform/android/plugin/godot_plugin_jni.cpp index 5d48c4e248..fd60ba4ae7 100644 --- a/platform/android/plugin/godot_plugin_jni.cpp +++ b/platform/android/plugin/godot_plugin_jni.cpp @@ -129,31 +129,4 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeEmitS singleton->emit_signalp(StringName(signal_name), args, count); } - -JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegisterGDExtensionLibraries(JNIEnv *env, jclass clazz, jobjectArray gdextension_paths) { - int gdextension_count = env->GetArrayLength(gdextension_paths); - if (gdextension_count == 0) { - return; - } - - // Retrieve the current list of gdextension libraries. - Array singletons; - if (ProjectSettings::get_singleton()->has_setting("gdextension/singletons")) { - singletons = GLOBAL_GET("gdextension/singletons"); - } - - // Insert the libraries provided by the plugin - for (int i = 0; i < gdextension_count; i++) { - jstring relative_path = (jstring)env->GetObjectArrayElement(gdextension_paths, i); - - String path = "res://" + jstring_to_string(relative_path, env); - if (!singletons.has(path)) { - singletons.push_back(path); - } - env->DeleteLocalRef(relative_path); - } - - // Insert the updated list back into project settings. - ProjectSettings::get_singleton()->set("gdextension/singletons", singletons); -} } diff --git a/platform/android/plugin/godot_plugin_jni.h b/platform/android/plugin/godot_plugin_jni.h index 36a992246d..baa29a79ea 100644 --- a/platform/android/plugin/godot_plugin_jni.h +++ b/platform/android/plugin/godot_plugin_jni.h @@ -39,7 +39,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegis JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegisterMethod(JNIEnv *env, jclass clazz, jstring sname, jstring name, jstring ret, jobjectArray args); JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegisterSignal(JNIEnv *env, jclass clazz, jstring j_plugin_name, jstring j_signal_name, jobjectArray j_signal_param_types); JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeEmitSignal(JNIEnv *env, jclass clazz, jstring j_plugin_name, jstring j_signal_name, jobjectArray j_signal_params); -JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegisterGDExtensionLibraries(JNIEnv *env, jclass clazz, jobjectArray gdextension_paths); } #endif // GODOT_PLUGIN_JNI_H diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index b6320fb22b..a8596c30a6 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -38,6 +38,7 @@ #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/export/editor_export.h" #include "editor/import/resource_importer_texture_settings.h" #include "editor/plugins/script_editor_plugin.h" @@ -2013,11 +2014,11 @@ Ref<ImageTexture> EditorExportPlatformIOS::get_option_icon(int p_index) const { Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); if (theme.is_valid()) { if (devices[p_index].simulator) { - icon = theme->get_icon("IOSSimulator", "EditorIcons"); + icon = theme->get_icon("IOSSimulator", EditorStringName(EditorIcons)); } else if (devices[p_index].wifi) { - icon = theme->get_icon("IOSDeviceWireless", "EditorIcons"); + icon = theme->get_icon("IOSDeviceWireless", EditorStringName(EditorIcons)); } else { - icon = theme->get_icon("IOSDeviceWired", "EditorIcons"); + icon = theme->get_icon("IOSDeviceWired", EditorStringName(EditorIcons)); } } } diff --git a/platform/ios/export/export_plugin.h b/platform/ios/export/export_plugin.h index 7de4c0b69d..27a4d73fcd 100644 --- a/platform/ios/export/export_plugin.h +++ b/platform/ios/export/export_plugin.h @@ -181,9 +181,17 @@ public: virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override { List<String> list; - list.push_back("ipa"); + if (p_preset.is_valid()) { + bool project_only = p_preset->get("application/export_project_only"); + if (project_only) { + list.push_back("xcodeproj"); + } else { + list.push_back("ipa"); + } + } return list; } + virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override; virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override; diff --git a/platform/linuxbsd/export/export_plugin.cpp b/platform/linuxbsd/export/export_plugin.cpp index 40151b1a02..9d1e058b76 100644 --- a/platform/linuxbsd/export/export_plugin.cpp +++ b/platform/linuxbsd/export/export_plugin.cpp @@ -37,6 +37,7 @@ #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/export/editor_export.h" #include "modules/modules_enabled.gen.h" // For svg. @@ -530,7 +531,7 @@ EditorExportPlatformLinuxBSD::EditorExportPlatformLinuxBSD() { Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); if (theme.is_valid()) { - stop_icon = theme->get_icon(SNAME("Stop"), SNAME("EditorIcons")); + stop_icon = theme->get_icon(SNAME("Stop"), EditorStringName(EditorIcons)); } else { stop_icon.instantiate(); } diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index 6586fe7f82..559c2c4e62 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -41,6 +41,7 @@ #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/import/resource_importer_texture_settings.h" #include "scene/resources/image_texture.h" @@ -2460,7 +2461,7 @@ EditorExportPlatformMacOS::EditorExportPlatformMacOS() { Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); if (theme.is_valid()) { - stop_icon = theme->get_icon(SNAME("Stop"), SNAME("EditorIcons")); + stop_icon = theme->get_icon(SNAME("Stop"), EditorStringName(EditorIcons)); } else { stop_icon.instantiate(); } diff --git a/platform/macos/godot_content_view.h b/platform/macos/godot_content_view.h index 0d18ac742a..c6060c96c6 100644 --- a/platform/macos/godot_content_view.h +++ b/platform/macos/godot_content_view.h @@ -47,9 +47,11 @@ @interface GodotContentLayerDelegate : NSObject <CALayerDelegate> { DisplayServer::WindowID window_id; + bool need_redraw; } - (void)setWindowID:(DisplayServer::WindowID)wid; +- (void)setNeedRedraw:(bool)redraw; @end diff --git a/platform/macos/godot_content_view.mm b/platform/macos/godot_content_view.mm index 231be83a03..8b6e1cdb79 100644 --- a/platform/macos/godot_content_view.mm +++ b/platform/macos/godot_content_view.mm @@ -40,6 +40,7 @@ - (id)init { self = [super init]; window_id = DisplayServer::INVALID_WINDOW_ID; + need_redraw = false; return self; } @@ -47,13 +48,18 @@ window_id = wid; } +- (void)setNeedRedraw:(bool)redraw { + need_redraw = redraw; +} + - (void)displayLayer:(CALayer *)layer { DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); - if (OS::get_singleton()->get_main_loop() && ds->get_is_resizing()) { + if (OS::get_singleton()->get_main_loop() && ds->get_is_resizing() && need_redraw) { Main::force_redraw(); if (!Main::is_iterating()) { // Avoid cyclic loop. Main::iteration(); } + need_redraw = false; } } @@ -93,6 +99,7 @@ } [super setFrameSize:newSize]; + [layer_delegate setNeedRedraw:true]; [self.layer setNeedsDisplay]; // Force "drawRect" call. } diff --git a/platform/web/detect.py b/platform/web/detect.py index 4015c8ff16..7b2e5646d6 100644 --- a/platform/web/detect.py +++ b/platform/web/detect.py @@ -118,6 +118,11 @@ def configure(env: "Environment"): else: env.Append(CCFLAGS=["-flto"]) env.Append(LINKFLAGS=["-flto"]) + # Workaround https://github.com/emscripten-core/emscripten/issues/19781. + cc_version = get_compiler_version(env) + cc_semver = (int(cc_version["major"]), int(cc_version["minor"]), int(cc_version["patch"])) + if cc_semver >= (3, 1, 42): + env.Append(LINKFLAGS=["-Wl,-u,scalbnf"]) # Sanitizers if env["use_ubsan"]: diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 993abd2cee..a62ccdc2aa 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -36,6 +36,7 @@ #include "core/config/project_settings.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/export/editor_export.h" #include "editor/import/resource_importer_texture_settings.h" #include "scene/resources/image_texture.h" @@ -683,7 +684,7 @@ EditorExportPlatformWeb::EditorExportPlatformWeb() { Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); if (theme.is_valid()) { - stop_icon = theme->get_icon(SNAME("Stop"), SNAME("EditorIcons")); + stop_icon = theme->get_icon(SNAME("Stop"), EditorStringName(EditorIcons)); } else { stop_icon.instantiate(); } diff --git a/platform/web/export/export_plugin.h b/platform/web/export/export_plugin.h index 2de4a4c153..887000ac45 100644 --- a/platform/web/export/export_plugin.h +++ b/platform/web/export/export_plugin.h @@ -39,6 +39,7 @@ #include "core/io/tcp_server.h" #include "core/io/zip_io.h" #include "editor/editor_node.h" +#include "editor/editor_string_names.h" #include "editor/export/editor_export_platform.h" #include "main/splash.gen.h" @@ -73,7 +74,7 @@ class EditorExportPlatformWeb : public EditorExportPlatform { icon.instantiate(); const String icon_path = String(GLOBAL_GET("application/config/icon")).strip_edges(); if (icon_path.is_empty() || ImageLoader::load_image(icon_path, icon) != OK) { - return EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("DefaultProjectIcon"), SNAME("EditorIcons"))->get_image(); + return EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("DefaultProjectIcon"), EditorStringName(EditorIcons))->get_image(); } return icon; } diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp index c4be1821bd..d2d4d78113 100644 --- a/platform/windows/export/export_plugin.cpp +++ b/platform/windows/export/export_plugin.cpp @@ -38,6 +38,7 @@ #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_scale.h" +#include "editor/editor_string_names.h" #include "editor/export/editor_export.h" #include "modules/modules_enabled.gen.h" // For svg. @@ -1020,7 +1021,7 @@ EditorExportPlatformWindows::EditorExportPlatformWindows() { Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); if (theme.is_valid()) { - stop_icon = theme->get_icon(SNAME("Stop"), SNAME("EditorIcons")); + stop_icon = theme->get_icon(SNAME("Stop"), EditorStringName(EditorIcons)); } else { stop_icon.instantiate(); } diff --git a/scene/3d/label_3d.cpp b/scene/3d/label_3d.cpp index 3d304de1df..9eec2f5345 100644 --- a/scene/3d/label_3d.cpp +++ b/scene/3d/label_3d.cpp @@ -780,42 +780,31 @@ Ref<Font> Label3D::_get_font_or_default() const { return font_override; } - // Check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_project_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); + StringName theme_name = "font"; + List<StringName> theme_types; + ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types); + + ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_null()) { + continue; + } for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - Ref<Font> f = ThemeDB::get_singleton()->get_project_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - if (f.is_valid()) { - theme_font = f; - theme_font->connect_changed(callable_mp(const_cast<Label3D *>(this), &Label3D::_font_changed)); - } - return f; + if (!theme->has_font(theme_name, E)) { + continue; } - } - } - // Lastly, fall back on the items defined in the default Theme, if they exist. - { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_default_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); - - for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - if (f.is_valid()) { - theme_font = f; - theme_font->connect_changed(callable_mp(const_cast<Label3D *>(this), &Label3D::_font_changed)); - } - return f; + Ref<Font> f = theme->get_font(theme_name, E); + if (f.is_valid()) { + theme_font = f; + theme_font->connect_changed(callable_mp(const_cast<Label3D *>(this), &Label3D::_font_changed)); } + return f; } } - // If they don't exist, use any type to return the default/empty value. - Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName()); + Ref<Font> f = global_context->get_fallback_theme()->get_font(theme_name, StringName()); if (f.is_valid()) { theme_font = f; theme_font->connect_changed(callable_mp(const_cast<Label3D *>(this), &Label3D::_font_changed)); diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 3c19766ca7..2b4d5677c4 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -654,7 +654,9 @@ void ColorPicker::_text_type_toggled() { text_is_constructor = !text_is_constructor; if (text_is_constructor) { text_type->set_text(""); - text_type->set_icon(get_theme_icon(SNAME("Script"), SNAME("EditorIcons"))); +#ifdef TOOLS_ENABLED + text_type->set_icon(get_editor_theme_icon(SNAME("Script"))); +#endif c_text->set_editable(false); c_text->set_tooltip_text(RTR("Copy this constructor in a script.")); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 63692dd064..d97ce65afc 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2465,6 +2465,11 @@ bool Control::has_theme_owner_node() const { return data.theme_owner->has_owner_node(); } +void Control::set_theme_context(ThemeContext *p_context, bool p_propagate) { + ERR_MAIN_THREAD_GUARD; + data.theme_owner->set_owner_context(p_context, p_propagate); +} + void Control::set_theme(const Ref<Theme> &p_theme) { ERR_MAIN_THREAD_GUARD; if (data.theme == p_theme) { @@ -2664,6 +2669,12 @@ int Control::get_theme_constant(const StringName &p_name, const StringName &p_th return constant; } +#ifdef TOOLS_ENABLED +Ref<Texture2D> Control::get_editor_theme_icon(const StringName &p_name) const { + return get_theme_icon(p_name, SNAME("EditorIcons")); +} +#endif + bool Control::has_theme_icon(const StringName &p_name, const StringName &p_theme_type) const { ERR_READ_THREAD_GUARD_V(false); if (!data.initialized) { @@ -3118,7 +3129,9 @@ void Control::_notification(int p_notification) { notification(NOTIFICATION_TRANSLATION_CHANGED); } #endif - notification(NOTIFICATION_THEME_CHANGED); + + // Emits NOTIFICATION_THEME_CHANGED internally. + set_theme_context(ThemeDB::get_singleton()->get_nearest_theme_context(this)); } break; case NOTIFICATION_POST_ENTER_TREE: { @@ -3128,6 +3141,7 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_EXIT_TREE: { + set_theme_context(nullptr, false); release_focus(); get_viewport()->_gui_remove_control(this); } break; @@ -3626,7 +3640,7 @@ void Control::_bind_methods() { } Control::Control() { - data.theme_owner = memnew(ThemeOwner); + data.theme_owner = memnew(ThemeOwner(this)); } Control::~Control() { diff --git a/scene/gui/control.h b/scene/gui/control.h index 7cb8fc5bf6..bad78a66d3 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -42,6 +42,7 @@ class Viewport; class Label; class Panel; class ThemeOwner; +class ThemeContext; class Control : public CanvasItem { GDCLASS(Control, CanvasItem); @@ -553,6 +554,8 @@ public: Node *get_theme_owner_node() const; bool has_theme_owner_node() const; + void set_theme_context(ThemeContext *p_context, bool p_propagate = true); + void set_theme(const Ref<Theme> &p_theme); Ref<Theme> get_theme() const; @@ -582,6 +585,9 @@ public: int get_theme_font_size(const StringName &p_name, const StringName &p_theme_type = StringName()) const; Color get_theme_color(const StringName &p_name, const StringName &p_theme_type = StringName()) const; int get_theme_constant(const StringName &p_name, const StringName &p_theme_type = StringName()) const; +#ifdef TOOLS_ENABLED + Ref<Texture2D> get_editor_theme_icon(const StringName &p_name) const; +#endif bool has_theme_icon_override(const StringName &p_name) const; bool has_theme_stylebox_override(const StringName &p_name) const; diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 23b516192e..b03d3c52d2 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1615,7 +1615,14 @@ bool ItemList::get_allow_search() const { void ItemList::set_icon_scale(real_t p_scale) { ERR_FAIL_COND(!Math::is_finite(p_scale)); + + if (icon_scale == p_scale) { + return; + } + icon_scale = p_scale; + queue_redraw(); + shape_changed = true; } real_t ItemList::get_icon_scale() const { diff --git a/scene/main/window.cpp b/scene/main/window.cpp index cffbb794c5..ba53a5e3c3 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -1269,7 +1269,9 @@ void Window::_notification(int p_what) { notification(NOTIFICATION_TRANSLATION_CHANGED); } #endif - notification(NOTIFICATION_THEME_CHANGED); + + // Emits NOTIFICATION_THEME_CHANGED internally. + set_theme_context(ThemeDB::get_singleton()->get_nearest_theme_context(this)); } break; case NOTIFICATION_READY: { @@ -1313,6 +1315,8 @@ void Window::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { + set_theme_context(nullptr, false); + if (transient) { _clear_transient(); } @@ -1889,6 +1893,11 @@ bool Window::has_theme_owner_node() const { return theme_owner->has_owner_node(); } +void Window::set_theme_context(ThemeContext *p_context, bool p_propagate) { + ERR_MAIN_THREAD_GUARD; + theme_owner->set_owner_context(p_context, p_propagate); +} + void Window::set_theme(const Ref<Theme> &p_theme) { ERR_MAIN_THREAD_GUARD; if (theme == p_theme) { @@ -2129,6 +2138,12 @@ int Window::get_theme_constant(const StringName &p_name, const StringName &p_the return constant; } +#ifdef TOOLS_ENABLED +Ref<Texture2D> Window::get_editor_theme_icon(const StringName &p_name) const { + return get_theme_icon(p_name, SNAME("EditorIcons")); +} +#endif + bool Window::has_theme_icon(const StringName &p_name, const StringName &p_theme_type) const { ERR_READ_THREAD_GUARD_V(false); if (!initialized) { @@ -2881,7 +2896,7 @@ Window::Window() { max_size_used = max_size; // Update max_size_used. } - theme_owner = memnew(ThemeOwner); + theme_owner = memnew(ThemeOwner(this)); RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED); } diff --git a/scene/main/window.h b/scene/main/window.h index d781f228d2..689fa754cb 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -39,6 +39,7 @@ class Font; class Shortcut; class StyleBox; class ThemeOwner; +class ThemeContext; class Window : public Viewport { GDCLASS(Window, Viewport) @@ -365,6 +366,8 @@ public: Node *get_theme_owner_node() const; bool has_theme_owner_node() const; + void set_theme_context(ThemeContext *p_context, bool p_propagate = true); + void set_theme(const Ref<Theme> &p_theme); Ref<Theme> get_theme() const; @@ -394,6 +397,9 @@ public: int get_theme_font_size(const StringName &p_name, const StringName &p_theme_type = StringName()) const; Color get_theme_color(const StringName &p_name, const StringName &p_theme_type = StringName()) const; int get_theme_constant(const StringName &p_name, const StringName &p_theme_type = StringName()) const; +#ifdef TOOLS_ENABLED + Ref<Texture2D> get_editor_theme_icon(const StringName &p_name) const; +#endif bool has_theme_icon_override(const StringName &p_name) const; bool has_theme_stylebox_override(const StringName &p_name) const; diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 860e48a361..c8e3741383 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -5579,8 +5579,8 @@ Variant Animation::subtract_variant(const Variant &a, const Variant &b) { Variant Animation::blend_variant(const Variant &a, const Variant &b, float c) { if (a.get_type() != b.get_type()) { if (a.is_num() && b.is_num()) { - real_t va = a; - real_t vb = b; + double va = a; + double vb = b; return va + vb * c; } return a; @@ -5591,7 +5591,7 @@ Variant Animation::blend_variant(const Variant &a, const Variant &b, float c) { return Variant(); } case Variant::INT: { - return int((a.operator int64_t()) + (b.operator int64_t()) * c + 0.5); + return int64_t((a.operator int64_t()) + (b.operator int64_t()) * c + 0.5); } case Variant::FLOAT: { return (a.operator double()) + (b.operator double()) * c; @@ -5664,8 +5664,8 @@ Variant Animation::blend_variant(const Variant &a, const Variant &b, float c) { Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float c) { if (a.get_type() != b.get_type()) { if (a.is_num() && b.is_num()) { - real_t va = a; - real_t vb = b; + double va = a; + double vb = b; return va + (vb - va) * c; } return a; @@ -5677,11 +5677,11 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float } case Variant::INT: { const int64_t va = a.operator int64_t(); - return int(va + ((b.operator int64_t()) - va) * c); + return int64_t(va + ((b.operator int64_t()) - va) * c); } case Variant::FLOAT: { - const real_t va = a.operator real_t(); - return va + ((b.operator real_t()) - va) * c; + const double va = a.operator double(); + return va + ((b.operator double()) - va) * c; } case Variant::VECTOR2: { return (a.operator Vector2()).lerp(b.operator Vector2(), c); @@ -5783,7 +5783,7 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float case Variant::PACKED_INT32_ARRAY: { const Vector<int32_t> arr_a = a; const Vector<int32_t> arr_b = b; - int32_t sz = arr_a.size(); + int sz = arr_a.size(); if (sz == 0 || arr_b.size() != sz) { return a; } else { @@ -5795,7 +5795,7 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float const int32_t *br = arr_b.ptr(); Variant va; - for (int32_t i = 0; i < sz; i++) { + for (int i = 0; i < sz; i++) { va = interpolate_variant(ar[i], br[i], c); vw[i] = va; } @@ -5806,7 +5806,7 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float case Variant::PACKED_INT64_ARRAY: { const Vector<int64_t> arr_a = a; const Vector<int64_t> arr_b = b; - int64_t sz = arr_a.size(); + int sz = arr_a.size(); if (sz == 0 || arr_b.size() != sz) { return a; } else { @@ -5818,7 +5818,7 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float const int64_t *br = arr_b.ptr(); Variant va; - for (int64_t i = 0; i < sz; i++) { + for (int i = 0; i < sz; i++) { va = interpolate_variant(ar[i], br[i], c); vw[i] = va; } diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index f5edc8d5e9..c8a98a6831 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -2779,48 +2779,25 @@ Ref<Font> FontVariation::_get_base_font_or_default() const { return base_font; } - // Check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_project_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); + StringName theme_name = "font"; + List<StringName> theme_types; + ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types); - for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - Ref<Font> f = ThemeDB::get_singleton()->get_project_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - if (f == this) { - continue; - } - if (f.is_valid()) { - theme_font = f; - theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); - } - return f; - } + ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_null()) { + continue; } - } - - // Lastly, fall back on the items defined in the default Theme, if they exist. - if (ThemeDB::get_singleton()->get_default_theme().is_valid()) { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_default_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - if (f == this) { - continue; - } - if (f.is_valid()) { - theme_font = f; - theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); - } - return f; + if (!theme->has_font(theme_name, E)) { + continue; } - } - // If they don't exist, use any type to return the default/empty value. - Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName()); - if (f != this) { + Ref<Font> f = theme->get_font(theme_name, E); + if (f == this) { + continue; + } if (f.is_valid()) { theme_font = f; theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); @@ -2829,14 +2806,21 @@ Ref<Font> FontVariation::_get_base_font_or_default() const { } } + Ref<Font> f = global_context->get_fallback_theme()->get_font(theme_name, StringName()); + if (f != this) { + if (f.is_valid()) { + theme_font = f; + theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); + } + return f; + } + return Ref<Font>(); } void FontVariation::set_variation_opentype(const Dictionary &p_coords) { - if (variation.opentype != p_coords) { - variation.opentype = p_coords; - _invalidate_rids(); - } + variation.opentype = p_coords; + _invalidate_rids(); } Dictionary FontVariation::get_variation_opentype() const { @@ -2877,10 +2861,8 @@ int FontVariation::get_variation_face_index() const { } void FontVariation::set_opentype_features(const Dictionary &p_features) { - if (opentype_features != p_features) { - opentype_features = p_features; - _invalidate_rids(); - } + opentype_features = p_features; + _invalidate_rids(); } Dictionary FontVariation::get_opentype_features() const { @@ -3135,48 +3117,25 @@ Ref<Font> SystemFont::_get_base_font_or_default() const { return base_font; } - // Check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_project_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); + StringName theme_name = "font"; + List<StringName> theme_types; + ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types); - for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - Ref<Font> f = ThemeDB::get_singleton()->get_project_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - if (f == this) { - continue; - } - if (f.is_valid()) { - theme_font = f; - theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); - } - return f; - } + ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_null()) { + continue; } - } - - // Lastly, fall back on the items defined in the default Theme, if they exist. - if (ThemeDB::get_singleton()->get_default_theme().is_valid()) { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_default_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - if (f == this) { - continue; - } - if (f.is_valid()) { - theme_font = f; - theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); - } - return f; + if (!theme->has_font(theme_name, E)) { + continue; } - } - // If they don't exist, use any type to return the default/empty value. - Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName()); - if (f != this) { + Ref<Font> f = theme->get_font(theme_name, E); + if (f == this) { + continue; + } if (f.is_valid()) { theme_font = f; theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); @@ -3185,6 +3144,15 @@ Ref<Font> SystemFont::_get_base_font_or_default() const { } } + Ref<Font> f = global_context->get_fallback_theme()->get_font(theme_name, StringName()); + if (f != this) { + if (f.is_valid()) { + theme_font = f; + theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); + } + return f; + } + return Ref<Font>(); } diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 65da0bc3c8..39b3acfe3f 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -777,6 +777,9 @@ void BaseMaterial3D::_update_shader() { if (flags[FLAG_USE_SHADOW_TO_OPACITY]) { code += ",shadow_to_opacity"; } + if (flags[FLAG_DISABLE_FOG]) { + code += ",fog_disabled"; + } if (transparency == TRANSPARENCY_ALPHA_DEPTH_PRE_PASS) { code += ",depth_prepass_alpha"; @@ -2725,6 +2728,7 @@ void BaseMaterial3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "diffuse_mode", PROPERTY_HINT_ENUM, "Burley,Lambert,Lambert Wrap,Toon"), "set_diffuse_mode", "get_diffuse_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "specular_mode", PROPERTY_HINT_ENUM, "SchlickGGX,Toon,Disabled"), "set_specular_mode", "get_specular_mode"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "disable_ambient_light"), "set_flag", "get_flag", FLAG_DISABLE_AMBIENT_LIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "disable_fog"), "set_flag", "get_flag", FLAG_DISABLE_FOG); ADD_GROUP("Vertex Color", "vertex_color"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "vertex_color_use_as_albedo"), "set_flag", "get_flag", FLAG_ALBEDO_FROM_VERTEX_COLOR); @@ -2977,6 +2981,7 @@ void BaseMaterial3D::_bind_methods() { BIND_ENUM_CONSTANT(FLAG_SUBSURFACE_MODE_SKIN); BIND_ENUM_CONSTANT(FLAG_PARTICLE_TRAILS_MODE); BIND_ENUM_CONSTANT(FLAG_ALBEDO_TEXTURE_MSDF); + BIND_ENUM_CONSTANT(FLAG_DISABLE_FOG); BIND_ENUM_CONSTANT(FLAG_MAX); BIND_ENUM_CONSTANT(DIFFUSE_BURLEY); diff --git a/scene/resources/material.h b/scene/resources/material.h index 28ceb1f119..18fbc02a12 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -256,6 +256,7 @@ public: FLAG_SUBSURFACE_MODE_SKIN, FLAG_PARTICLE_TRAILS_MODE, FLAG_ALBEDO_TEXTURE_MSDF, + FLAG_DISABLE_FOG, FLAG_MAX }; diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index a64ae07f05..6d848f5494 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -3466,32 +3466,24 @@ Ref<Font> TextMesh::_get_font_or_default() const { return font_override; } - // Check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_project_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); - - for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - return ThemeDB::get_singleton()->get_project_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - } + StringName theme_name = "font"; + List<StringName> theme_types; + ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types); + + ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_null()) { + continue; } - } - - // Lastly, fall back on the items defined in the default Theme, if they exist. - { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_default_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - return ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); + if (theme->has_font(theme_name, E)) { + return theme->get_font(theme_name, E); } } } - // If they don't exist, use any type to return the default/empty value. - return ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName()); + return global_context->get_fallback_theme()->get_font(theme_name, StringName()); } void TextMesh::set_font_size(int p_size) { diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index 7120b21190..5b375905cc 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -239,8 +239,10 @@ Ref<Resource> ResourceFormatLoaderShader::load(const String &p_path, const Strin ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot load shader: " + p_path); String str; - error = str.parse_utf8((const char *)buffer.ptr(), buffer.size()); - ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot parse shader: " + p_path); + if (buffer.size() > 0) { + error = str.parse_utf8((const char *)buffer.ptr(), buffer.size()); + ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot parse shader: " + p_path); + } Ref<Shader> shader; shader.instantiate(); diff --git a/scene/resources/shader_include.cpp b/scene/resources/shader_include.cpp index 323be6e491..0a2a686b4e 100644 --- a/scene/resources/shader_include.cpp +++ b/scene/resources/shader_include.cpp @@ -93,8 +93,10 @@ Ref<Resource> ResourceFormatLoaderShaderInclude::load(const String &p_path, cons ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot load shader include: " + p_path); String str; - error = str.parse_utf8((const char *)buffer.ptr(), buffer.size()); - ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot parse shader include: " + p_path); + if (buffer.size() > 0) { + error = str.parse_utf8((const char *)buffer.ptr(), buffer.size()); + ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot parse shader include: " + p_path); + } Ref<ShaderInclude> shader_inc; shader_inc.instantiate(); diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 799a8471b9..d2a1519d49 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -1263,11 +1263,7 @@ void Theme::get_type_dependencies(const StringName &p_base_type, const StringNam } // Continue building the chain using native class hierarchy. - StringName class_name = p_base_type; - while (class_name != StringName()) { - p_list->push_back(class_name); - class_name = ClassDB::get_parent_class_nocheck(class_name); - } + ThemeDB::get_singleton()->get_native_type_dependencies(p_base_type, p_list); } // Internal methods for getting lists as a Vector of String (compatible with public API). diff --git a/scene/theme/theme_db.cpp b/scene/theme/theme_db.cpp index 39a4f078b5..92f3dec5e2 100644 --- a/scene/theme/theme_db.cpp +++ b/scene/theme/theme_db.cpp @@ -32,6 +32,9 @@ #include "core/config/project_settings.h" #include "core/io/resource_loader.h" +#include "scene/gui/control.h" +#include "scene/main/node.h" +#include "scene/main/window.h" #include "scene/resources/font.h" #include "scene/resources/style_box.h" #include "scene/resources/texture.h" @@ -40,18 +43,18 @@ #include "servers/text_server.h" // Default engine theme creation and configuration. + void ThemeDB::initialize_theme() { + // Default theme-related project settings. + // Allow creating the default theme at a different scale to suit higher/lower base resolutions. float default_theme_scale = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "gui/theme/default_theme_scale", PROPERTY_HINT_RANGE, "0.5,8,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), 1.0); - String theme_path = GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "gui/theme/custom", PROPERTY_HINT_FILE, "*.tres,*.res,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), ""); - - String font_path = GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "gui/theme/custom_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.otf,*.ttf,*.woff,*.woff2,*.fnt,*.font,*.pfb,*.pfm", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), ""); + String project_theme_path = GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "gui/theme/custom", PROPERTY_HINT_FILE, "*.tres,*.res,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), ""); + String project_font_path = GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "gui/theme/custom_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.otf,*.ttf,*.woff,*.woff2,*.fnt,*.font,*.pfb,*.pfm", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), ""); TextServer::FontAntialiasing font_antialiasing = (TextServer::FontAntialiasing)(int)GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "gui/theme/default_font_antialiasing", PROPERTY_HINT_ENUM, "None,Grayscale,LCD Subpixel", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), 1); - TextServer::Hinting font_hinting = (TextServer::Hinting)(int)GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "gui/theme/default_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), TextServer::HINTING_LIGHT); - TextServer::SubpixelPositioning font_subpixel_positioning = (TextServer::SubpixelPositioning)(int)GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "gui/theme/default_font_subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One Half of a Pixel,One Quarter of a Pixel", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), TextServer::SUBPIXEL_POSITIONING_AUTO); const bool font_msdf = GLOBAL_DEF_RST("gui/theme/default_font_multichannel_signed_distance_field", false); @@ -60,38 +63,58 @@ void ThemeDB::initialize_theme() { GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "gui/theme/lcd_subpixel_layout", PROPERTY_HINT_ENUM, "Disabled,Horizontal RGB,Horizontal BGR,Vertical RGB,Vertical BGR"), 1); ProjectSettings::get_singleton()->set_restart_if_changed("gui/theme/lcd_subpixel_layout", false); - Ref<Font> font; - if (!font_path.is_empty()) { - font = ResourceLoader::load(font_path); - if (font.is_valid()) { - set_fallback_font(font); + // Attempt to load custom project theme and font. + + if (!project_theme_path.is_empty()) { + Ref<Theme> theme = ResourceLoader::load(project_theme_path); + if (theme.is_valid()) { + set_project_theme(theme); } else { - ERR_PRINT("Error loading custom font '" + font_path + "'"); + ERR_PRINT("Error loading custom project theme '" + project_theme_path + "'"); } } - // Always make the default theme to avoid invalid default font/icon/style in the given theme. - if (RenderingServer::get_singleton()) { - make_default_theme(default_theme_scale, font, font_subpixel_positioning, font_hinting, font_antialiasing, font_msdf, font_generate_mipmaps); - } - - if (!theme_path.is_empty()) { - Ref<Theme> theme = ResourceLoader::load(theme_path); - if (theme.is_valid()) { - set_project_theme(theme); + Ref<Font> project_font; + if (!project_font_path.is_empty()) { + project_font = ResourceLoader::load(project_font_path); + if (project_font.is_valid()) { + set_fallback_font(project_font); } else { - ERR_PRINT("Error loading custom theme '" + theme_path + "'"); + ERR_PRINT("Error loading custom project font '" + project_font_path + "'"); } } + + // Always generate the default theme to serve as a fallback for all required theme definitions. + + if (RenderingServer::get_singleton()) { + make_default_theme(default_theme_scale, project_font, font_subpixel_positioning, font_hinting, font_antialiasing, font_msdf, font_generate_mipmaps); + } + + _init_default_theme_context(); } void ThemeDB::initialize_theme_noproject() { if (RenderingServer::get_singleton()) { make_default_theme(1.0, Ref<Font>()); } + + _init_default_theme_context(); } -// Universal fallback Theme resources. +void ThemeDB::finalize_theme() { + if (!RenderingServer::get_singleton()) { + WARN_PRINT("Finalizing theme when there is no RenderingServer is an error; check the order of operations."); + } + + _finalize_theme_contexts(); + default_theme.unref(); + + fallback_font.unref(); + fallback_icon.unref(); + fallback_stylebox.unref(); +} + +// Global Theme resources. void ThemeDB::set_default_theme(const Ref<Theme> &p_default) { default_theme = p_default; @@ -176,7 +199,135 @@ Ref<StyleBox> ThemeDB::get_fallback_stylebox() { return fallback_stylebox; } +void ThemeDB::get_native_type_dependencies(const StringName &p_base_type, List<StringName> *p_list) { + ERR_FAIL_NULL(p_list); + + // TODO: It may make sense to stop at Control/Window, because their parent classes cannot be used in + // a meaningful way. + StringName class_name = p_base_type; + while (class_name != StringName()) { + p_list->push_back(class_name); + class_name = ClassDB::get_parent_class_nocheck(class_name); + } +} + +// Global theme contexts. + +ThemeContext *ThemeDB::create_theme_context(Node *p_node, List<Ref<Theme>> &p_themes) { + ERR_FAIL_COND_V(!p_node->is_inside_tree(), nullptr); + ERR_FAIL_COND_V(theme_contexts.has(p_node), nullptr); + ERR_FAIL_COND_V(p_themes.is_empty(), nullptr); + + ThemeContext *context = memnew(ThemeContext); + context->node = p_node; + context->parent = get_nearest_theme_context(p_node); + context->set_themes(p_themes); + + theme_contexts[p_node] = context; + _propagate_theme_context(p_node, context); + + p_node->connect("tree_exited", callable_mp(this, &ThemeDB::destroy_theme_context).bind(p_node)); + + return context; +} + +void ThemeDB::destroy_theme_context(Node *p_node) { + ERR_FAIL_COND(!theme_contexts.has(p_node)); + + p_node->disconnect("tree_exited", callable_mp(this, &ThemeDB::destroy_theme_context)); + + ThemeContext *context = theme_contexts[p_node]; + + theme_contexts.erase(p_node); + _propagate_theme_context(p_node, context->parent); + + memdelete(context); +} + +void ThemeDB::_propagate_theme_context(Node *p_from_node, ThemeContext *p_context) { + Control *from_control = Object::cast_to<Control>(p_from_node); + Window *from_window = from_control ? nullptr : Object::cast_to<Window>(p_from_node); + + if (from_control) { + from_control->set_theme_context(p_context); + } else if (from_window) { + from_window->set_theme_context(p_context); + } + + for (int i = 0; i < p_from_node->get_child_count(); i++) { + Node *child_node = p_from_node->get_child(i); + + // If the child is the root of another global context, stop the propagation + // in this branch. + if (theme_contexts.has(child_node)) { + theme_contexts[child_node]->parent = p_context; + continue; + } + + _propagate_theme_context(child_node, p_context); + } +} + +void ThemeDB::_init_default_theme_context() { + default_theme_context = memnew(ThemeContext); + + List<Ref<Theme>> themes; + + // Only add the project theme to the default context when running projects. + +#ifdef TOOLS_ENABLED + if (!Engine::get_singleton()->is_editor_hint()) { + themes.push_back(project_theme); + } +#else + themes.push_back(project_theme); +#endif + + themes.push_back(default_theme); + default_theme_context->set_themes(themes); +} + +void ThemeDB::_finalize_theme_contexts() { + if (default_theme_context) { + memdelete(default_theme_context); + default_theme_context = nullptr; + } + while (theme_contexts.size()) { + HashMap<Node *, ThemeContext *>::Iterator E = theme_contexts.begin(); + memdelete(E->value); + theme_contexts.remove(E); + } +} + +ThemeContext *ThemeDB::get_theme_context(Node *p_node) const { + if (!theme_contexts.has(p_node)) { + return nullptr; + } + + return theme_contexts[p_node]; +} + +ThemeContext *ThemeDB::get_default_theme_context() const { + return default_theme_context; +} + +ThemeContext *ThemeDB::get_nearest_theme_context(Node *p_for_node) const { + ERR_FAIL_COND_V(!p_for_node->is_inside_tree(), nullptr); + + Node *parent_node = p_for_node->get_parent(); + while (parent_node) { + if (theme_contexts.has(parent_node)) { + return theme_contexts[parent_node]; + } + + parent_node = parent_node->get_parent(); + } + + return nullptr; +} + // Object methods. + void ThemeDB::_bind_methods() { ClassDB::bind_method(D_METHOD("get_default_theme"), &ThemeDB::get_default_theme); ClassDB::bind_method(D_METHOD("get_project_theme"), &ThemeDB::get_project_theme); @@ -202,7 +353,8 @@ void ThemeDB::_bind_methods() { ADD_SIGNAL(MethodInfo("fallback_changed")); } -// Memory management, reference, and initialization +// Memory management, reference, and initialization. + ThemeDB *ThemeDB::singleton = nullptr; ThemeDB *ThemeDB::get_singleton() { @@ -211,13 +363,15 @@ ThemeDB *ThemeDB::get_singleton() { ThemeDB::ThemeDB() { singleton = this; - - // Universal default values, final fallback for every theme. - fallback_base_scale = 1.0; - fallback_font_size = 16; } ThemeDB::~ThemeDB() { + // For technical reasons unit tests recreate and destroy the default + // theme over and over again. Make sure that finalize_theme() also + // frees any objects that can be recreated by initialize_theme*(). + + _finalize_theme_contexts(); + default_theme.unref(); project_theme.unref(); @@ -227,3 +381,43 @@ ThemeDB::~ThemeDB() { singleton = nullptr; } + +void ThemeContext::_emit_changed() { + emit_signal(SNAME("changed")); +} + +void ThemeContext::set_themes(List<Ref<Theme>> &p_themes) { + for (const Ref<Theme> &theme : themes) { + theme->disconnect_changed(callable_mp(this, &ThemeContext::_emit_changed)); + } + + themes.clear(); + + for (const Ref<Theme> &theme : p_themes) { + if (theme.is_null()) { + continue; + } + + themes.push_back(theme); + theme->connect_changed(callable_mp(this, &ThemeContext::_emit_changed)); + } + + _emit_changed(); +} + +List<Ref<Theme>> ThemeContext::get_themes() const { + return themes; +} + +Ref<Theme> ThemeContext::get_fallback_theme() const { + // We expect all contexts to be valid and non-empty, but just in case... + if (themes.size() == 0) { + return ThemeDB::get_singleton()->get_default_theme(); + } + + return themes.back()->get(); +} + +void ThemeContext::_bind_methods() { + ADD_SIGNAL(MethodInfo("changed")); +} diff --git a/scene/theme/theme_db.h b/scene/theme/theme_db.h index f65899f5ea..40ae30ff81 100644 --- a/scene/theme/theme_db.h +++ b/scene/theme/theme_db.h @@ -35,34 +35,48 @@ #include "core/object/ref_counted.h" class Font; +class Node; class StyleBox; class Texture2D; class Theme; +class ThemeContext; class ThemeDB : public Object { GDCLASS(ThemeDB, Object); static ThemeDB *singleton; - // Universal Theme resources used when no other theme has the item. + // Global Theme resources used by the default theme context. + Ref<Theme> default_theme; Ref<Theme> project_theme; // Universal default values, final fallback for every theme. - float fallback_base_scale; + + float fallback_base_scale = 1.0; Ref<Font> fallback_font; - int fallback_font_size; + int fallback_font_size = 16; Ref<Texture2D> fallback_icon; Ref<StyleBox> fallback_stylebox; + // Global theme contexts used to scope global Theme resources. + + ThemeContext *default_theme_context = nullptr; + HashMap<Node *, ThemeContext *> theme_contexts; + + void _propagate_theme_context(Node *p_from_node, ThemeContext *p_context); + void _init_default_theme_context(); + void _finalize_theme_contexts(); + protected: static void _bind_methods(); public: void initialize_theme(); void initialize_theme_noproject(); + void finalize_theme(); - // Universal Theme resources + // Global Theme resources. void set_default_theme(const Ref<Theme> &p_default); Ref<Theme> get_default_theme(); @@ -70,7 +84,7 @@ public: void set_project_theme(const Ref<Theme> &p_project_default); Ref<Theme> get_project_theme(); - // Universal default values. + // Universal fallback values. void set_fallback_base_scale(float p_base_scale); float get_fallback_base_scale(); @@ -87,9 +101,46 @@ public: void set_fallback_stylebox(const Ref<StyleBox> &p_stylebox); Ref<StyleBox> get_fallback_stylebox(); + void get_native_type_dependencies(const StringName &p_base_type, List<StringName> *p_list); + + // Global theme contexts. + + ThemeContext *create_theme_context(Node *p_node, List<Ref<Theme>> &p_themes); + void destroy_theme_context(Node *p_node); + + ThemeContext *get_theme_context(Node *p_node) const; + ThemeContext *get_default_theme_context() const; + ThemeContext *get_nearest_theme_context(Node *p_for_node) const; + + // Memory management, reference, and initialization. + static ThemeDB *get_singleton(); ThemeDB(); ~ThemeDB(); }; +class ThemeContext : public Object { + GDCLASS(ThemeContext, Object); + + friend class ThemeDB; + + Node *node = nullptr; + ThemeContext *parent = nullptr; + + // Themes are stacked in the order of relevance, for easy iteration. + // This means that the first theme is the one you should check first, + // and the last theme is the fallback theme where every lookup ends. + List<Ref<Theme>> themes; + + void _emit_changed(); + +protected: + static void _bind_methods(); + +public: + void set_themes(List<Ref<Theme>> &p_themes); + List<Ref<Theme>> get_themes() const; + Ref<Theme> get_fallback_theme() const; +}; + #endif // THEME_DB_H diff --git a/scene/theme/theme_owner.cpp b/scene/theme/theme_owner.cpp index 40855c6a3e..1ba9a055fc 100644 --- a/scene/theme/theme_owner.cpp +++ b/scene/theme/theme_owner.cpp @@ -66,6 +66,52 @@ bool ThemeOwner::has_owner_node() const { return bool(owner_control || owner_window); } +void ThemeOwner::set_owner_context(ThemeContext *p_context, bool p_propagate) { + ThemeContext *default_context = ThemeDB::get_singleton()->get_default_theme_context(); + + if (owner_context && owner_context->is_connected("changed", callable_mp(this, &ThemeOwner::_owner_context_changed))) { + owner_context->disconnect("changed", callable_mp(this, &ThemeOwner::_owner_context_changed)); + } else if (default_context->is_connected("changed", callable_mp(this, &ThemeOwner::_owner_context_changed))) { + default_context->disconnect("changed", callable_mp(this, &ThemeOwner::_owner_context_changed)); + } + + owner_context = p_context; + + if (owner_context) { + owner_context->connect("changed", callable_mp(this, &ThemeOwner::_owner_context_changed)); + } else { + default_context->connect("changed", callable_mp(this, &ThemeOwner::_owner_context_changed)); + } + + if (p_propagate) { + _owner_context_changed(); + } +} + +void ThemeOwner::_owner_context_changed() { + if (!holder->is_inside_tree()) { + // We ignore theme changes outside of tree, because NOTIFICATION_ENTER_TREE covers everything. + return; + } + + Control *c = Object::cast_to<Control>(holder); + Window *w = c == nullptr ? Object::cast_to<Window>(holder) : nullptr; + + if (c) { + c->notification(Control::NOTIFICATION_THEME_CHANGED); + } else if (w) { + w->notification(Window::NOTIFICATION_THEME_CHANGED); + } +} + +ThemeContext *ThemeOwner::_get_active_owner_context() const { + if (owner_context) { + return owner_context; + } + + return ThemeDB::get_singleton()->get_default_theme_context(); +} + // Theme propagation. void ThemeOwner::assign_theme_on_parented(Node *p_for_node) { @@ -158,9 +204,7 @@ void ThemeOwner::get_theme_type_dependencies(const Node *p_for_node, const Strin const Window *for_w = Object::cast_to<Window>(p_for_node); ERR_FAIL_COND_MSG(!for_c && !for_w, "Only Control and Window nodes and derivatives can be polled for theming."); - Ref<Theme> default_theme = ThemeDB::get_singleton()->get_default_theme(); - Ref<Theme> project_theme = ThemeDB::get_singleton()->get_project_theme(); - + StringName type_name = p_for_node->get_class_name(); StringName type_variation; if (for_c) { type_variation = for_c->get_theme_type_variation(); @@ -168,31 +212,23 @@ void ThemeOwner::get_theme_type_dependencies(const Node *p_for_node, const Strin type_variation = for_w->get_theme_type_variation(); } - if (p_theme_type == StringName() || p_theme_type == p_for_node->get_class_name() || p_theme_type == type_variation) { - if (project_theme.is_valid() && project_theme->get_type_variation_base(type_variation) != StringName()) { - project_theme->get_type_dependencies(p_for_node->get_class_name(), type_variation, r_list); - } else { - default_theme->get_type_dependencies(p_for_node->get_class_name(), type_variation, r_list); + // If we are looking for dependencies of the current class (or a variantion of it), check themes from the context. + if (p_theme_type == StringName() || p_theme_type == type_name || p_theme_type == type_variation) { + ThemeContext *global_context = _get_active_owner_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_valid() && theme->get_type_variation_base(type_variation) != StringName()) { + theme->get_type_dependencies(type_name, type_variation, r_list); + return; + } } - } else { - default_theme->get_type_dependencies(p_theme_type, StringName(), r_list); - } -} -Node *ThemeOwner::_get_next_owner_node(Node *p_from_node) const { - Node *parent = p_from_node->get_parent(); - - Control *parent_c = Object::cast_to<Control>(parent); - if (parent_c) { - return parent_c->get_theme_owner_node(); - } else { - Window *parent_w = Object::cast_to<Window>(parent); - if (parent_w) { - return parent_w->get_theme_owner_node(); - } + // If nothing was found, get the native dependencies for the current class. + ThemeDB::get_singleton()->get_native_type_dependencies(type_name, r_list); + return; } - return nullptr; + // Otherwise, get the native dependencies for the provided theme type. + ThemeDB::get_singleton()->get_native_type_dependencies(p_theme_type, r_list); } Variant ThemeOwner::get_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, List<StringName> p_theme_types) { @@ -215,24 +251,20 @@ Variant ThemeOwner::get_theme_item_in_types(Theme::DataType p_data_type, const S owner_node = _get_next_owner_node(owner_node); } - // Secondly, check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - for (const StringName &E : p_theme_types) { - if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(p_data_type, p_name, E)) { - return ThemeDB::get_singleton()->get_project_theme()->get_theme_item(p_data_type, p_name, E); + // Second, check global themes from the appropriate context. + ThemeContext *global_context = _get_active_owner_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_valid()) { + for (const StringName &E : p_theme_types) { + if (theme->has_theme_item(p_data_type, p_name, E)) { + return theme->get_theme_item(p_data_type, p_name, E); + } } } } - // Lastly, fall back on the items defined in the default Theme, if they exist. - for (const StringName &E : p_theme_types) { - if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(p_data_type, p_name, E)) { - return ThemeDB::get_singleton()->get_default_theme()->get_theme_item(p_data_type, p_name, E); - } - } - - // If they don't exist, use any type to return the default/empty value. - return ThemeDB::get_singleton()->get_default_theme()->get_theme_item(p_data_type, p_name, p_theme_types[0]); + // Finally, if no match exists, use any type to return the default/empty value. + return global_context->get_fallback_theme()->get_theme_item(p_data_type, p_name, StringName()); } bool ThemeOwner::has_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, List<StringName> p_theme_types) { @@ -255,22 +287,19 @@ bool ThemeOwner::has_theme_item_in_types(Theme::DataType p_data_type, const Stri owner_node = _get_next_owner_node(owner_node); } - // Secondly, check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - for (const StringName &E : p_theme_types) { - if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(p_data_type, p_name, E)) { - return true; + // Second, check global themes from the appropriate context. + ThemeContext *global_context = _get_active_owner_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_valid()) { + for (const StringName &E : p_theme_types) { + if (theme->has_theme_item(p_data_type, p_name, E)) { + return true; + } } } } - // Lastly, fall back on the items defined in the default Theme, if they exist. - for (const StringName &E : p_theme_types) { - if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(p_data_type, p_name, E)) { - return true; - } - } - + // Finally, if no match exists, return false. return false; } @@ -290,17 +319,17 @@ float ThemeOwner::get_theme_default_base_scale() { owner_node = _get_next_owner_node(owner_node); } - // Secondly, check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - if (ThemeDB::get_singleton()->get_project_theme()->has_default_base_scale()) { - return ThemeDB::get_singleton()->get_project_theme()->get_default_base_scale(); + // Second, check global themes from the appropriate context. + ThemeContext *global_context = _get_active_owner_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_valid()) { + if (theme->has_default_base_scale()) { + return theme->get_default_base_scale(); + } } } - // Lastly, fall back on the default Theme. - if (ThemeDB::get_singleton()->get_default_theme()->has_default_base_scale()) { - return ThemeDB::get_singleton()->get_default_theme()->get_default_base_scale(); - } + // Finally, if no match exists, return the universal default. return ThemeDB::get_singleton()->get_fallback_base_scale(); } @@ -320,17 +349,17 @@ Ref<Font> ThemeOwner::get_theme_default_font() { owner_node = _get_next_owner_node(owner_node); } - // Secondly, check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - if (ThemeDB::get_singleton()->get_project_theme()->has_default_font()) { - return ThemeDB::get_singleton()->get_project_theme()->get_default_font(); + // Second, check global themes from the appropriate context. + ThemeContext *global_context = _get_active_owner_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_valid()) { + if (theme->has_default_font()) { + return theme->get_default_font(); + } } } - // Lastly, fall back on the default Theme. - if (ThemeDB::get_singleton()->get_default_theme()->has_default_font()) { - return ThemeDB::get_singleton()->get_default_theme()->get_default_font(); - } + // Finally, if no match exists, return the universal default. return ThemeDB::get_singleton()->get_fallback_font(); } @@ -350,17 +379,17 @@ int ThemeOwner::get_theme_default_font_size() { owner_node = _get_next_owner_node(owner_node); } - // Secondly, check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - if (ThemeDB::get_singleton()->get_project_theme()->has_default_font_size()) { - return ThemeDB::get_singleton()->get_project_theme()->get_default_font_size(); + // Second, check global themes from the appropriate context. + ThemeContext *global_context = _get_active_owner_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_valid()) { + if (theme->has_default_font_size()) { + return theme->get_default_font_size(); + } } } - // Lastly, fall back on the default Theme. - if (ThemeDB::get_singleton()->get_default_theme()->has_default_font_size()) { - return ThemeDB::get_singleton()->get_default_theme()->get_default_font_size(); - } + // Finally, if no match exists, return the universal default. return ThemeDB::get_singleton()->get_fallback_font_size(); } @@ -377,3 +406,19 @@ Ref<Theme> ThemeOwner::_get_owner_node_theme(Node *p_owner_node) const { return Ref<Theme>(); } + +Node *ThemeOwner::_get_next_owner_node(Node *p_from_node) const { + Node *parent = p_from_node->get_parent(); + + Control *parent_c = Object::cast_to<Control>(parent); + if (parent_c) { + return parent_c->get_theme_owner_node(); + } else { + Window *parent_w = Object::cast_to<Window>(parent); + if (parent_w) { + return parent_w->get_theme_owner_node(); + } + } + + return nullptr; +} diff --git a/scene/theme/theme_owner.h b/scene/theme/theme_owner.h index 7ebd53fde8..4923ccb00b 100644 --- a/scene/theme/theme_owner.h +++ b/scene/theme/theme_owner.h @@ -36,11 +36,18 @@ class Control; class Node; +class ThemeContext; class Window; class ThemeOwner : public Object { + Node *holder = nullptr; + Control *owner_control = nullptr; Window *owner_window = nullptr; + ThemeContext *owner_context = nullptr; + + void _owner_context_changed(); + ThemeContext *_get_active_owner_context() const; Node *_get_next_owner_node(Node *p_from_node) const; Ref<Theme> _get_owner_node_theme(Node *p_owner_node) const; @@ -52,6 +59,8 @@ public: Node *get_owner_node() const; bool has_owner_node() const; + void set_owner_context(ThemeContext *p_context, bool p_propagate = true); + // Theme propagation. void assign_theme_on_parented(Node *p_for_node); @@ -69,7 +78,7 @@ public: Ref<Font> get_theme_default_font(); int get_theme_default_font_size(); - ThemeOwner() {} + ThemeOwner(Node *p_holder) { holder = p_holder; } ~ThemeOwner() {} }; diff --git a/servers/rendering/renderer_rd/cluster_builder_rd.cpp b/servers/rendering/renderer_rd/cluster_builder_rd.cpp index f99a5254bb..7554e478bb 100644 --- a/servers/rendering/renderer_rd/cluster_builder_rd.cpp +++ b/servers/rendering/renderer_rd/cluster_builder_rd.cpp @@ -95,7 +95,7 @@ ClusterBuilderSharedDataRD::ClusterBuilderSharedDataRD() { 0, 0, -1, 0.7236073, -0.5257253, -0.4472195, -0.276388, -0.8506492, -0.4472199, -0.8944262, 0, -0.4472156, -0.276388, 0.8506492, -0.4472199, 0.7236073, 0.5257253, -0.4472195, 0.276388, -0.8506492, 0.4472199, -0.7236073, -0.5257253, 0.4472195, -0.7236073, 0.5257253, 0.4472195, 0.276388, 0.8506492, 0.4472199, 0.8944262, 0, 0.4472156, 0, 0, 1, -0.1624555, -0.4999952, -0.8506544, 0.4253227, -0.3090114, -0.8506542, 0.2628688, -0.8090116, -0.5257377, 0.8506479, 0, -0.5257359, 0.4253227, 0.3090114, -0.8506542, -0.5257298, 0, -0.8506517, -0.6881894, -0.4999969, -0.5257362, -0.1624555, 0.4999952, -0.8506544, -0.6881894, 0.4999969, -0.5257362, 0.2628688, 0.8090116, -0.5257377, 0.9510579, -0.3090126, 0, 0.9510579, 0.3090126, 0, 0, -1, 0, 0.5877856, -0.8090167, 0, -0.9510579, -0.3090126, 0, -0.5877856, -0.8090167, 0, -0.5877856, 0.8090167, 0, -0.9510579, 0.3090126, 0, 0.5877856, 0.8090167, 0, 0, 1, 0, 0.6881894, -0.4999969, 0.5257362, -0.2628688, -0.8090116, 0.5257377, -0.8506479, 0, 0.5257359, -0.2628688, 0.8090116, 0.5257377, 0.6881894, 0.4999969, 0.5257362, 0.1624555, -0.4999952, 0.8506544, 0.5257298, 0, 0.8506517, -0.4253227, -0.3090114, 0.8506542, -0.4253227, 0.3090114, 0.8506542, 0.1624555, 0.4999952, 0.8506544 }; static const uint32_t icosphere_triangle_count = 80; - static const uint32_t icosphere_triangle_indices[icosphere_triangle_count * 3] = { + static const uint16_t icosphere_triangle_indices[icosphere_triangle_count * 3] = { 0, 13, 12, 1, 13, 15, 0, 12, 17, 0, 17, 19, 0, 19, 16, 1, 15, 22, 2, 14, 24, 3, 18, 26, 4, 20, 28, 5, 21, 30, 1, 22, 25, 2, 24, 27, 3, 26, 29, 4, 28, 31, 5, 30, 23, 6, 32, 37, 7, 33, 39, 8, 34, 40, 9, 35, 41, 10, 36, 38, 38, 41, 11, 38, 36, 41, 36, 9, 41, 41, 40, 11, 41, 35, 40, 35, 8, 40, 40, 39, 11, 40, 34, 39, 34, 7, 39, 39, 37, 11, 39, 33, 37, 33, 6, 37, 37, 38, 11, 37, 32, 38, 32, 10, 38, 23, 36, 10, 23, 30, 36, 30, 9, 36, 31, 35, 9, 31, 28, 35, 28, 8, 35, 29, 34, 8, 29, 26, 34, 26, 7, 34, 27, 33, 7, 27, 24, 33, 24, 6, 33, 25, 32, 6, 25, 22, 32, 22, 10, 32, 30, 31, 9, 30, 21, 31, 21, 4, 31, 28, 29, 8, 28, 20, 29, 20, 3, 29, 26, 27, 7, 26, 18, 27, 18, 2, 27, 24, 25, 6, 24, 14, 25, 14, 1, 25, 22, 23, 10, 22, 15, 23, 15, 5, 23, 16, 21, 5, 16, 19, 21, 19, 4, 21, 19, 20, 4, 19, 17, 20, 17, 3, 20, 17, 18, 3, 17, 12, 18, 12, 2, 18, 15, 16, 5, 15, 13, 16, 13, 0, 16, 12, 14, 2, 12, 13, 14, 13, 1, 14 }; @@ -106,10 +106,10 @@ ClusterBuilderSharedDataRD::ClusterBuilderSharedDataRD() { sphere_vertex_buffer = RD::get_singleton()->vertex_buffer_create(vertex_data.size(), vertex_data); Vector<uint8_t> index_data; - index_data.resize(sizeof(uint32_t) * icosphere_triangle_count * 3); + index_data.resize(sizeof(uint16_t) * icosphere_triangle_count * 3); memcpy(index_data.ptrw(), icosphere_triangle_indices, index_data.size()); - sphere_index_buffer = RD::get_singleton()->index_buffer_create(icosphere_triangle_count * 3, RD::INDEX_BUFFER_FORMAT_UINT32, index_data); + sphere_index_buffer = RD::get_singleton()->index_buffer_create(icosphere_triangle_count * 3, RD::INDEX_BUFFER_FORMAT_UINT16, index_data); Vector<RID> buffers; buffers.push_back(sphere_vertex_buffer); @@ -139,7 +139,7 @@ ClusterBuilderSharedDataRD::ClusterBuilderSharedDataRD() { 0, 1, -1, 0.1950903, 0.9807853, -1, 0.3826835, 0.9238795, -1, 0.5555703, 0.8314696, -1, 0.7071068, 0.7071068, -1, 0.8314697, 0.5555702, -1, 0.9238795, 0.3826834, -1, 0.9807853, 0.1950903, -1, 1, 0, -1, 0.9807853, -0.1950902, -1, 0.9238796, -0.3826833, -1, 0.8314697, -0.5555702, -1, 0.7071068, -0.7071068, -1, 0.5555702, -0.8314697, -1, 0.3826833, -0.9238796, -1, 0.1950901, -0.9807853, -1, -3.25841e-7, -1, -1, -0.1950907, -0.9807852, -1, -0.3826839, -0.9238793, -1, -0.5555707, -0.8314693, -1, -0.7071073, -0.7071063, -1, -0.83147, -0.5555697, -1, -0.9238799, -0.3826827, -1, 0, 0, 0, -0.9807854, -0.1950894, -1, -1, 9.65599e-7, -1, -0.9807851, 0.1950913, -1, -0.9238791, 0.3826845, -1, -0.8314689, 0.5555713, -1, -0.7071059, 0.7071077, -1, -0.5555691, 0.8314704, -1, -0.3826821, 0.9238801, -1, -0.1950888, 0.9807856, -1 }; static const uint32_t cone_triangle_count = 62; - static const uint32_t cone_triangle_indices[cone_triangle_count * 3] = { + static const uint16_t cone_triangle_indices[cone_triangle_count * 3] = { 0, 23, 1, 1, 23, 2, 2, 23, 3, 3, 23, 4, 4, 23, 5, 5, 23, 6, 6, 23, 7, 7, 23, 8, 8, 23, 9, 9, 23, 10, 10, 23, 11, 11, 23, 12, 12, 23, 13, 13, 23, 14, 14, 23, 15, 15, 23, 16, 16, 23, 17, 17, 23, 18, 18, 23, 19, 19, 23, 20, 20, 23, 21, 21, 23, 22, 22, 23, 24, 24, 23, 25, 25, 23, 26, 26, 23, 27, 27, 23, 28, 28, 23, 29, 29, 23, 30, 30, 23, 31, 31, 23, 32, 32, 23, 0, 7, 15, 24, 32, 0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 3, 6, 7, 3, 7, 8, 9, 9, 10, 7, 10, 11, 7, 11, 12, 15, 12, 13, 15, 13, 14, 15, 15, 16, 17, 17, 18, 19, 19, 20, 24, 20, 21, 24, 21, 22, 24, 24, 25, 26, 26, 27, 28, 28, 29, 30, 30, 31, 32, 32, 1, 3, 15, 17, 24, 17, 19, 24, 24, 26, 32, 26, 28, 32, 28, 30, 32, 32, 3, 7, 7, 11, 15, 32, 7, 24 }; @@ -150,10 +150,10 @@ ClusterBuilderSharedDataRD::ClusterBuilderSharedDataRD() { cone_vertex_buffer = RD::get_singleton()->vertex_buffer_create(vertex_data.size(), vertex_data); Vector<uint8_t> index_data; - index_data.resize(sizeof(uint32_t) * cone_triangle_count * 3); + index_data.resize(sizeof(uint16_t) * cone_triangle_count * 3); memcpy(index_data.ptrw(), cone_triangle_indices, index_data.size()); - cone_index_buffer = RD::get_singleton()->index_buffer_create(cone_triangle_count * 3, RD::INDEX_BUFFER_FORMAT_UINT32, index_data); + cone_index_buffer = RD::get_singleton()->index_buffer_create(cone_triangle_count * 3, RD::INDEX_BUFFER_FORMAT_UINT16, index_data); Vector<RID> buffers; buffers.push_back(cone_vertex_buffer); @@ -193,7 +193,7 @@ ClusterBuilderSharedDataRD::ClusterBuilderSharedDataRD() { -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1 }; static const uint32_t box_triangle_count = 12; - static const uint32_t box_triangle_indices[box_triangle_count * 3] = { + static const uint16_t box_triangle_indices[box_triangle_count * 3] = { 1, 2, 0, 3, 6, 2, 7, 4, 6, 5, 0, 4, 6, 0, 2, 3, 5, 7, 1, 3, 2, 3, 7, 6, 7, 5, 4, 5, 1, 0, 6, 4, 0, 3, 1, 5 }; @@ -204,10 +204,10 @@ ClusterBuilderSharedDataRD::ClusterBuilderSharedDataRD() { box_vertex_buffer = RD::get_singleton()->vertex_buffer_create(vertex_data.size(), vertex_data); Vector<uint8_t> index_data; - index_data.resize(sizeof(uint32_t) * box_triangle_count * 3); + index_data.resize(sizeof(uint16_t) * box_triangle_count * 3); memcpy(index_data.ptrw(), box_triangle_indices, index_data.size()); - box_index_buffer = RD::get_singleton()->index_buffer_create(box_triangle_count * 3, RD::INDEX_BUFFER_FORMAT_UINT32, index_data); + box_index_buffer = RD::get_singleton()->index_buffer_create(box_triangle_count * 3, RD::INDEX_BUFFER_FORMAT_UINT16, index_data); Vector<RID> buffers; buffers.push_back(box_vertex_buffer); diff --git a/servers/rendering/renderer_rd/effects/debug_effects.cpp b/servers/rendering/renderer_rd/effects/debug_effects.cpp index 3d26a9a8df..357d035ae9 100644 --- a/servers/rendering/renderer_rd/effects/debug_effects.cpp +++ b/servers/rendering/renderer_rd/effects/debug_effects.cpp @@ -85,7 +85,7 @@ void DebugEffects::_create_frustum_arrays() { } if (frustum.index_buffer.is_null()) { - uint32_t indices[6 * 2 * 3] = { + uint16_t indices[6 * 2 * 3] = { // Far 0, 1, 2, // FLT, FLB, FRT 1, 3, 2, // FLB, FRB, FRT @@ -111,19 +111,19 @@ void DebugEffects::_create_frustum_arrays() { data.resize(6 * 2 * 3 * 4); { uint8_t *w = data.ptrw(); - int *p32 = (int *)w; + uint16_t *p16 = (uint16_t *)w; for (int i = 0; i < 6 * 2 * 3; i++) { - *p32 = indices[i]; - p32++; + *p16 = indices[i]; + p16++; } } - frustum.index_buffer = RD::get_singleton()->index_buffer_create(6 * 2 * 3, RenderingDevice::INDEX_BUFFER_FORMAT_UINT32, data); + frustum.index_buffer = RD::get_singleton()->index_buffer_create(6 * 2 * 3, RenderingDevice::INDEX_BUFFER_FORMAT_UINT16, data); frustum.index_array = RD::get_singleton()->index_array_create(frustum.index_buffer, 0, 6 * 2 * 3); } if (frustum.lines_buffer.is_null()) { - uint32_t indices[12 * 2] = { + uint16_t indices[12 * 2] = { 0, 1, // FLT - FLB 1, 3, // FLB - FRB 3, 2, // FRB - FRT @@ -145,14 +145,14 @@ void DebugEffects::_create_frustum_arrays() { data.resize(12 * 2 * 4); { uint8_t *w = data.ptrw(); - int *p32 = (int *)w; + uint16_t *p16 = (uint16_t *)w; for (int i = 0; i < 12 * 2; i++) { - *p32 = indices[i]; - p32++; + *p16 = indices[i]; + p16++; } } - frustum.lines_buffer = RD::get_singleton()->index_buffer_create(12 * 2, RenderingDevice::INDEX_BUFFER_FORMAT_UINT32, data); + frustum.lines_buffer = RD::get_singleton()->index_buffer_create(12 * 2, RenderingDevice::INDEX_BUFFER_FORMAT_UINT16, data); frustum.lines_array = RD::get_singleton()->index_array_create(frustum.lines_buffer, 0, 12 * 2); } } diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp index 12f8f6a366..509072bbec 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp @@ -707,6 +707,7 @@ void SceneShaderForwardClustered::init(const String p_defines) { actions.render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n"; actions.render_mode_defines["unshaded"] = "#define MODE_UNSHADED\n"; actions.render_mode_defines["debug_shadow_splits"] = "#define DEBUG_DRAW_PSSM_SPLITS\n"; + actions.render_mode_defines["fog_disabled"] = "#define FOG_DISABLED\n"; actions.base_texture_binding_index = 1; actions.texture_layout_set = RenderForwardClustered::MATERIAL_UNIFORM_SET; diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp index 32d2289f75..ffbe7f7e59 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp @@ -610,6 +610,7 @@ void SceneShaderForwardMobile::init(const String p_defines) { actions.render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n"; actions.render_mode_defines["unshaded"] = "#define MODE_UNSHADED\n"; actions.render_mode_defines["debug_shadow_splits"] = "#define DEBUG_DRAW_PSSM_SPLITS\n"; + actions.render_mode_defines["fog_disabled"] = "#define FOG_DISABLED\n"; actions.base_texture_binding_index = 1; actions.texture_layout_set = RenderForwardMobile::MATERIAL_UNIFORM_SET; diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index d8c035a51c..b1ad7e16ed 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -2587,18 +2587,18 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() { { // default index buffer Vector<uint8_t> pv; - pv.resize(6 * 4); + pv.resize(6 * 2); { uint8_t *w = pv.ptrw(); - int *p32 = (int *)w; - p32[0] = 0; - p32[1] = 1; - p32[2] = 2; - p32[3] = 0; - p32[4] = 2; - p32[5] = 3; + uint16_t *p16 = (uint16_t *)w; + p16[0] = 0; + p16[1] = 1; + p16[2] = 2; + p16[3] = 0; + p16[4] = 2; + p16[5] = 3; } - shader.quad_index_buffer = RD::get_singleton()->index_buffer_create(6, RenderingDevice::INDEX_BUFFER_FORMAT_UINT32, pv); + shader.quad_index_buffer = RD::get_singleton()->index_buffer_create(6, RenderingDevice::INDEX_BUFFER_FORMAT_UINT16, pv); shader.quad_index_array = RD::get_singleton()->index_array_create(shader.quad_index_buffer, 0, 6); } diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index 4ccd2aa322..7eb8cbd02f 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -126,18 +126,18 @@ void RendererCompositorRD::initialize() { //create index array for copy shader Vector<uint8_t> pv; - pv.resize(6 * 4); + pv.resize(6 * 2); { uint8_t *w = pv.ptrw(); - int *p32 = (int *)w; - p32[0] = 0; - p32[1] = 1; - p32[2] = 2; - p32[3] = 0; - p32[4] = 2; - p32[5] = 3; + uint16_t *p16 = (uint16_t *)w; + p16[0] = 0; + p16[1] = 1; + p16[2] = 2; + p16[3] = 0; + p16[4] = 2; + p16[5] = 3; } - blit.index_buffer = RD::get_singleton()->index_buffer_create(6, RenderingDevice::INDEX_BUFFER_FORMAT_UINT32, pv); + blit.index_buffer = RD::get_singleton()->index_buffer_create(6, RenderingDevice::INDEX_BUFFER_FORMAT_UINT16, pv); blit.array = RD::get_singleton()->index_array_create(blit.index_buffer, 0, 6); blit.sampler = RD::get_singleton()->sampler_create(RD::SamplerState()); diff --git a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl index 8f3c704afe..cfba408fe1 100644 --- a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl @@ -802,7 +802,9 @@ void fragment_shader(in SceneData scene_data) { float clearcoat_roughness = 0.0; float anisotropy = 0.0; vec2 anisotropy_flow = vec2(1.0, 0.0); +#ifndef FOG_DISABLED vec4 fog = vec4(0.0); +#endif // !FOG_DISABLED #if defined(CUSTOM_RADIANCE_USED) vec4 custom_radiance = vec4(0.0); #endif @@ -962,6 +964,7 @@ void fragment_shader(in SceneData scene_data) { /////////////////////// FOG ////////////////////// #ifndef MODE_RENDER_DEPTH +#ifndef FOG_DISABLED #ifndef CUSTOM_FOG_USED // fog must be processed as early as possible and then packed. // to maximize VGPR usage @@ -997,6 +1000,7 @@ void fragment_shader(in SceneData scene_data) { uint fog_rg = packHalf2x16(fog.rg); uint fog_ba = packHalf2x16(fog.ba); +#endif //!FOG_DISABLED #endif //!MODE_RENDER_DEPTH /////////////////////// DECALS //////////////////////////////// @@ -2250,8 +2254,10 @@ void fragment_shader(in SceneData scene_data) { diffuse_light *= 1.0 - metallic; ambient_light *= 1.0 - metallic; +#ifndef FOG_DISABLED //restore fog fog = vec4(unpackHalf2x16(fog_rg), unpackHalf2x16(fog_ba)); +#endif //!FOG_DISABLED #ifdef MODE_SEPARATE_SPECULAR @@ -2268,8 +2274,10 @@ void fragment_shader(in SceneData scene_data) { specular_buffer = vec4(specular_light, metallic); #endif +#ifndef FOG_DISABLED diffuse_buffer.rgb = mix(diffuse_buffer.rgb, fog.rgb, fog.a); specular_buffer.rgb = mix(specular_buffer.rgb, vec3(0.0), fog.a); +#endif //!FOG_DISABLED #else //MODE_SEPARATE_SPECULAR @@ -2280,8 +2288,10 @@ void fragment_shader(in SceneData scene_data) { //frag_color = vec4(1.0); #endif //USE_NO_SHADING +#ifndef FOG_DISABLED // Draw "fixed" fog before volumetric fog to ensure volumetric fog can appear in front of the sky. frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a); +#endif //!FOG_DISABLED #endif //MODE_SEPARATE_SPECULAR diff --git a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl index 0283482d76..cdf81bb6ec 100644 --- a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl @@ -694,7 +694,9 @@ void main() { float clearcoat_roughness = 0.0; float anisotropy = 0.0; vec2 anisotropy_flow = vec2(1.0, 0.0); +#ifndef FOG_DISABLED vec4 fog = vec4(0.0); +#endif // !FOG_DISABLED #if defined(CUSTOM_RADIANCE_USED) vec4 custom_radiance = vec4(0.0); #endif @@ -860,6 +862,7 @@ void main() { /////////////////////// FOG ////////////////////// #ifndef MODE_RENDER_DEPTH +#ifndef FOG_DISABLED #ifndef CUSTOM_FOG_USED // fog must be processed as early as possible and then packed. // to maximize VGPR usage @@ -874,6 +877,7 @@ void main() { uint fog_rg = packHalf2x16(fog.rg); uint fog_ba = packHalf2x16(fog.ba); +#endif //!FOG_DISABLED #endif //!MODE_RENDER_DEPTH /////////////////////// DECALS //////////////////////////////// @@ -1744,8 +1748,10 @@ void main() { diffuse_light *= 1.0 - metallic; ambient_light *= 1.0 - metallic; +#ifndef FOG_DISABLED //restore fog fog = vec4(unpackHalf2x16(fog_rg), unpackHalf2x16(fog_ba)); +#endif // !FOG_DISABLED #ifdef MODE_MULTIPLE_RENDER_TARGETS @@ -1762,8 +1768,10 @@ void main() { specular_buffer = vec4(specular_light, metallic); #endif // MODE_UNSHADED +#ifndef FOG_DISABLED diffuse_buffer.rgb = mix(diffuse_buffer.rgb, fog.rgb, fog.a); specular_buffer.rgb = mix(specular_buffer.rgb, vec3(0.0), fog.a); +#endif // !FOG_DISABLED #else //MODE_MULTIPLE_RENDER_TARGETS @@ -1773,8 +1781,10 @@ void main() { frag_color = vec4(emission + ambient_light + diffuse_light + specular_light, alpha); #endif // MODE_UNSHADED +#ifndef FOG_DISABLED // Draw "fixed" fog before volumetric fog to ensure volumetric fog can appear in front of the sky. frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a); +#endif // !FOG_DISABLED // On mobile we use a UNORM buffer with 10bpp which results in a range from 0.0 - 1.0 resulting in HDR breaking // We divide by sc_luminance_multiplier to support a range from 0.0 - 2.0 both increasing precision on bright and darker images diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp index fda341bbc9..5c4fa1a47c 100644 --- a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp @@ -1191,18 +1191,18 @@ MaterialStorage::MaterialStorage() { // buffers { //create index array for copy shaders Vector<uint8_t> pv; - pv.resize(6 * 4); + pv.resize(6 * 2); { uint8_t *w = pv.ptrw(); - int *p32 = (int *)w; - p32[0] = 0; - p32[1] = 1; - p32[2] = 2; - p32[3] = 0; - p32[4] = 2; - p32[5] = 3; + uint16_t *p16 = (uint16_t *)w; + p16[0] = 0; + p16[1] = 1; + p16[2] = 2; + p16[3] = 0; + p16[4] = 2; + p16[5] = 3; } - quad_index_buffer = RD::get_singleton()->index_buffer_create(6, RenderingDevice::INDEX_BUFFER_FORMAT_UINT32, pv); + quad_index_buffer = RD::get_singleton()->index_buffer_create(6, RenderingDevice::INDEX_BUFFER_FORMAT_UINT16, pv); quad_index_array = RD::get_singleton()->index_array_create(quad_index_buffer, 0, 6); } diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp index c256d37344..728089f516 100644 --- a/servers/rendering/shader_types.cpp +++ b/servers/rendering/shader_types.cpp @@ -227,6 +227,7 @@ ShaderTypes::ShaderTypes() { shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("alpha_to_coverage") }); shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("alpha_to_coverage_and_one") }); shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("debug_shadow_splits") }); + shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("fog_disabled") }); } /************ CANVAS ITEM **************************/ diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index 659fb003d3..c10ad6e13d 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -805,6 +805,22 @@ TEST_CASE("[String] sprintf") { REQUIRE(error == false); CHECK(output == String("fish +99.990000 frog")); + // Real with sign (negative zero). + format = "fish %+f frog"; + args.clear(); + args.push_back(-0.0); + output = format.sprintf(args, &error); + REQUIRE(error == false); + CHECK(output == String("fish -0.000000 frog")); + + // Real with sign (positive zero). + format = "fish %+f frog"; + args.clear(); + args.push_back(0.0); + output = format.sprintf(args, &error); + REQUIRE(error == false); + CHECK(output == String("fish +0.000000 frog")); + // Real with 1 decimal. format = "fish %.1f frog"; args.clear(); diff --git a/tests/scene/test_viewport.h b/tests/scene/test_viewport.h index dd4786977e..0c53668c6d 100644 --- a/tests/scene/test_viewport.h +++ b/tests/scene/test_viewport.h @@ -43,8 +43,8 @@ namespace TestViewport { -class NotificationControl : public Control { - GDCLASS(NotificationControl, Control); +class NotificationControlViewport : public Control { + GDCLASS(NotificationControlViewport, Control); protected: void _notification(int p_what) { @@ -63,11 +63,11 @@ public: bool mouse_over = false; }; -// `NotificationControl`-derived class that additionally +// `NotificationControlViewport`-derived class that additionally // - allows start Dragging // - stores mouse information of last event -class DragStart : public NotificationControl { - GDCLASS(DragStart, NotificationControl); +class DragStart : public NotificationControlViewport { + GDCLASS(DragStart, NotificationControlViewport); public: MouseButton last_mouse_button; @@ -93,9 +93,9 @@ public: } }; -// `NotificationControl`-derived class that acts as a Drag and Drop target. -class DragTarget : public NotificationControl { - GDCLASS(DragTarget, NotificationControl); +// `NotificationControlViewport`-derived class that acts as a Drag and Drop target. +class DragTarget : public NotificationControlViewport { + GDCLASS(DragTarget, NotificationControlViewport); public: Variant drag_data; diff --git a/tests/scene/test_window.h b/tests/scene/test_window.h index e0c55101de..592cccfd7e 100644 --- a/tests/scene/test_window.h +++ b/tests/scene/test_window.h @@ -38,8 +38,8 @@ namespace TestWindow { -class NotificationControl : public Control { - GDCLASS(NotificationControl, Control); +class NotificationControlWindow : public Control { + GDCLASS(NotificationControlWindow, Control); protected: void _notification(int p_what) { @@ -69,7 +69,7 @@ TEST_CASE("[SceneTree][Window]") { w->set_content_scale_size(Size2i(200, 200)); w->set_content_scale_mode(Window::CONTENT_SCALE_MODE_CANVAS_ITEMS); w->set_content_scale_aspect(Window::CONTENT_SCALE_ASPECT_KEEP); - NotificationControl *c = memnew(NotificationControl); + NotificationControlWindow *c = memnew(NotificationControlWindow); w->add_child(c); c->set_size(Size2i(100, 100)); c->set_position(Size2i(-50, -50)); diff --git a/tests/servers/test_text_server.h b/tests/servers/test_text_server.h index eef5b850ca..0f23929e1e 100644 --- a/tests/servers/test_text_server.h +++ b/tests/servers/test_text_server.h @@ -70,7 +70,7 @@ TEST_SUITE("[TextServer]") { ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size); ts->font_set_allow_system_fallback(font1, false); RID font2 = ts->create_font(); - ts->font_set_data_ptr(font2, _font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size); + ts->font_set_data_ptr(font2, _font_NotoSansThai_Regular, _font_NotoSansThai_Regular_size); ts->font_set_allow_system_fallback(font2, false); Array font; @@ -177,7 +177,7 @@ TEST_SUITE("[TextServer]") { ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size); ts->font_set_allow_system_fallback(font1, false); RID font2 = ts->create_font(); - ts->font_set_data_ptr(font2, _font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size); + ts->font_set_data_ptr(font2, _font_NotoSansThai_Regular, _font_NotoSansThai_Regular_size); ts->font_set_allow_system_fallback(font2, false); RID font3 = ts->create_font(); ts->font_set_data_ptr(font3, _font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size); @@ -511,7 +511,7 @@ TEST_SUITE("[TextServer]") { RID font1 = ts->create_font(); ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size); RID font2 = ts->create_font(); - ts->font_set_data_ptr(font2, _font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size); + ts->font_set_data_ptr(font2, _font_NotoSansThai_Regular, _font_NotoSansThai_Regular_size); Array font; font.push_back(font1); diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 6cc7aad48e..3a80fc8c00 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -212,7 +212,6 @@ struct GodotTestCaseListener : public doctest::IReporter { PhysicsServer2D *physics_server_2d = nullptr; NavigationServer3D *navigation_server_3d = nullptr; NavigationServer2D *navigation_server_2d = nullptr; - ThemeDB *theme_db = nullptr; void test_case_start(const doctest::TestCaseData &p_in) override { reinitialize(); @@ -238,6 +237,12 @@ struct GodotTestCaseListener : public doctest::IReporter { RenderingServerDefault::get_singleton()->init(); RenderingServerDefault::get_singleton()->set_render_loop_enabled(false); + // ThemeDB requires RenderingServer to initialize the default theme. + // So we have to do this for each test case. Also make sure there is + // no residual theme from something else. + ThemeDB::get_singleton()->finalize_theme(); + ThemeDB::get_singleton()->initialize_theme_noproject(); + physics_server_3d = PhysicsServer3DManager::get_singleton()->new_default_server(); physics_server_3d->init(); @@ -252,9 +257,6 @@ struct GodotTestCaseListener : public doctest::IReporter { memnew(InputMap); InputMap::get_singleton()->load_default(); - theme_db = memnew(ThemeDB); - theme_db->initialize_theme_noproject(); - memnew(SceneTree); SceneTree::get_singleton()->initialize(); if (!DisplayServer::get_singleton()->has_feature(DisplayServer::Feature::FEATURE_SUBWINDOWS)) { @@ -294,11 +296,6 @@ struct GodotTestCaseListener : public doctest::IReporter { memdelete(SceneTree::get_singleton()); } - if (theme_db) { - memdelete(theme_db); - theme_db = nullptr; - } - if (navigation_server_3d) { memdelete(navigation_server_3d); navigation_server_3d = nullptr; @@ -326,6 +323,10 @@ struct GodotTestCaseListener : public doctest::IReporter { } if (RenderingServer::get_singleton()) { + // ThemeDB requires RenderingServer to finalize the default theme. + // So we have to do this for each test case. + ThemeDB::get_singleton()->finalize_theme(); + RenderingServer::get_singleton()->sync(); RenderingServer::get_singleton()->global_shader_parameters_clear(); RenderingServer::get_singleton()->finish(); diff --git a/thirdparty/README.md b/thirdparty/README.md index ff8f1d5591..e8cef36f9a 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -154,25 +154,68 @@ Files extracted from upstream source: ## fonts -- `NotoSans*.woff2`, `NotoNaskhArabicUI_*.woff2`: - * Upstream: https://github.com/googlefonts/noto-fonts - * Version: v2017-10-24-phase3-second-cleanup - * License: OFL-1.1 - * Comment: Use UI font variant if available, because it has tight vertical metrics and - good for UI. -- `JetBrainsMono_Regular.woff2`: - * Upstream: https://github.com/JetBrains/JetBrainsMono - * Version: 2.242 - * License: OFL-1.1 - `DroidSans*.woff2`: * Upstream: https://android.googlesource.com/platform/frameworks/base/+/master/data/fonts/ * Version: ? (pre-2014 commit when DroidSansJapanese.ttf was obsoleted) * License: Apache 2.0 +- `JetBrainsMono_Regular.woff2`: + * Upstream: https://github.com/JetBrains/JetBrainsMono + * Version: 2.304 (cd5227bd1f61dff3bbd6c814ceaf7ffd95e947d9, 2023) + * License: OFL-1.1 +- `NotoNaskhArabicUI*.woff2`: + * Upstream: https://github.com/notofonts/arabic + * Version: 2.014 (133ccaebf922ca080a7eef22998611ac3c242df9, 2022) + * License: OFL-1.1 +- `NotoSans*.woff2`: + * Upstream: https://github.com/notofonts/latin-greek-cyrillic + * Version: 2.012 (9ea0c8d37bff0c0067b03777f40aa04f2bf78f99, 2023) + * License: OFL-1.1 +- `NotoSansBengali*.woff2`: + * Upstream: https://github.com/notofonts/bengali + * Version: 2.003 (020a5701f6fc6a363d5eccbae45e37714c0ad686, 2022) + * License: OFL-1.1 +- `NotoSansDevanagari*.woff2`: + * Upstream: https://github.com/notofonts/devanagari + * Version: 2.004 (f8f27e49da0ec9e5e38ecf3628671f05b24dd955, 2023) + * License: OFL-1.1 +- `NotoSansGeorgian*.woff2`: + * Upstream: https://github.com/notofonts/georgian + * Version: 2.002 (243ec9aa1d4ec58cc42120d30faac1a102fbfeb9, 2022) + * License: OFL-1.1 +- `NotoSansHebrew*.woff2`: + * Upstream: https://github.com/notofonts/hebrew + * Version: 2.003 (caa7ab0614fb5b37cc003d9bf3d7d3e765331110, 2022) + * License: OFL-1.1 +- `NotoSansMalayalam*.woff2`: + * Upstream: https://github.com/notofonts/malayalam + * Version: 2.104 (0fd65e553a6af3dc1c09ed39dfe8933e01c17b32, 2023) + * License: OFL-1.1 +- `NotoSansOriya*.woff2`: + * Upstream: https://github.com/notofonts/oriya + * Version: 2.005 (9377f242b247df12d0bf4cecd93b9c4b18036fbd, 2023) + * License: OFL-1.1 +- `NotoSansSinhala*.woff2`: + * Upstream: https://github.com/notofonts/sinhala + * Version: 2.006 (66e5a2ed9797e575222d6e7c5b3710c7bf68be79, 2022) + * License: OFL-1.1 +- `NotoSansTamil*.woff2`: + * Upstream: https://github.com/notofonts/tamil + * Version: 2.004 (f34a08d1ae3fa810581f63410296d971bdcd62dc, 2023) + * License: OFL-1.1 +- `NotoSansTelugu*.woff2`: + * Upstream: https://github.com/notofonts/telugu + * Version: 2.004 (68a6a8170cba5b2e9b45029ef36994961e8f614c, 2023) + * License: OFL-1.1 +- `NotoSansThai*.woff2`: + * Upstream: https://github.com/notofonts/thai + * Version: 2.001 (09af528011390f35abf15cf86068dae208f512c4, 2022) + * License: OFL-1.1 - `OpenSans_SemiBold.woff2`: * Upstream: https://fonts.google.com/specimen/Open+Sans * Version: 1.10 (downloaded from Google Fonts in February 2021) * License: Apache 2.0 -- All fonts are converted from the `.ttf` sources using `https://github.com/google/woff2` tool. +- All fonts are converted from the unhinted `.ttf` sources using `https://github.com/google/woff2` tool. +- Comment: Use UI font variant if available, because it has tight vertical metrics and good for UI. ## freetype @@ -250,7 +293,7 @@ Files extracted from upstream source: ## harfbuzz - Upstream: https://github.com/harfbuzz/harfbuzz -- Version: 8.0.0 (b4305532a7746422e0b615eee6304119c1092fd8, 2023) +- Version: 8.1.1 (1d665c2b521512cdd56964138fc601debd1f1177, 2023) - License: MIT Files extracted from upstream source: diff --git a/thirdparty/fonts/JetBrainsMono_Regular.woff2 b/thirdparty/fonts/JetBrainsMono_Regular.woff2 Binary files differindex 490104645b..dc698ffb83 100644 --- a/thirdparty/fonts/JetBrainsMono_Regular.woff2 +++ b/thirdparty/fonts/JetBrainsMono_Regular.woff2 diff --git a/thirdparty/fonts/NotoNaskhArabicUI_Bold.woff2 b/thirdparty/fonts/NotoNaskhArabicUI_Bold.woff2 Binary files differindex 72358d6eb1..e9a834ac69 100644 --- a/thirdparty/fonts/NotoNaskhArabicUI_Bold.woff2 +++ b/thirdparty/fonts/NotoNaskhArabicUI_Bold.woff2 diff --git a/thirdparty/fonts/NotoNaskhArabicUI_Regular.woff2 b/thirdparty/fonts/NotoNaskhArabicUI_Regular.woff2 Binary files differindex 1195d4174e..b0c0aaf766 100644 --- a/thirdparty/fonts/NotoNaskhArabicUI_Regular.woff2 +++ b/thirdparty/fonts/NotoNaskhArabicUI_Regular.woff2 diff --git a/thirdparty/fonts/NotoSansBengaliUI_Bold.woff2 b/thirdparty/fonts/NotoSansBengaliUI_Bold.woff2 Binary files differindex 03adf85fdc..c0087a2453 100644 --- a/thirdparty/fonts/NotoSansBengaliUI_Bold.woff2 +++ b/thirdparty/fonts/NotoSansBengaliUI_Bold.woff2 diff --git a/thirdparty/fonts/NotoSansBengaliUI_Regular.woff2 b/thirdparty/fonts/NotoSansBengaliUI_Regular.woff2 Binary files differindex a6a3ffa3a7..219792295a 100644 --- a/thirdparty/fonts/NotoSansBengaliUI_Regular.woff2 +++ b/thirdparty/fonts/NotoSansBengaliUI_Regular.woff2 diff --git a/thirdparty/fonts/NotoSansDevanagariUI_Bold.woff2 b/thirdparty/fonts/NotoSansDevanagariUI_Bold.woff2 Binary files differindex 6c835712cb..d3d34ff8e1 100644 --- a/thirdparty/fonts/NotoSansDevanagariUI_Bold.woff2 +++ b/thirdparty/fonts/NotoSansDevanagariUI_Bold.woff2 diff --git a/thirdparty/fonts/NotoSansDevanagariUI_Regular.woff2 b/thirdparty/fonts/NotoSansDevanagariUI_Regular.woff2 Binary files differindex 486896e6e9..333562f449 100644 --- a/thirdparty/fonts/NotoSansDevanagariUI_Regular.woff2 +++ b/thirdparty/fonts/NotoSansDevanagariUI_Regular.woff2 diff --git a/thirdparty/fonts/NotoSansGeorgian_Bold.woff2 b/thirdparty/fonts/NotoSansGeorgian_Bold.woff2 Binary files differindex 104afa150c..c5e25ffe22 100644 --- a/thirdparty/fonts/NotoSansGeorgian_Bold.woff2 +++ b/thirdparty/fonts/NotoSansGeorgian_Bold.woff2 diff --git a/thirdparty/fonts/NotoSansGeorgian_Regular.woff2 b/thirdparty/fonts/NotoSansGeorgian_Regular.woff2 Binary files differindex 0a7b9e878b..64ff0e84d8 100644 --- a/thirdparty/fonts/NotoSansGeorgian_Regular.woff2 +++ b/thirdparty/fonts/NotoSansGeorgian_Regular.woff2 diff --git a/thirdparty/fonts/NotoSansHebrew_Bold.woff2 b/thirdparty/fonts/NotoSansHebrew_Bold.woff2 Binary files differindex 96c5ae1349..01768b6416 100644 --- a/thirdparty/fonts/NotoSansHebrew_Bold.woff2 +++ b/thirdparty/fonts/NotoSansHebrew_Bold.woff2 diff --git a/thirdparty/fonts/NotoSansHebrew_Regular.woff2 b/thirdparty/fonts/NotoSansHebrew_Regular.woff2 Binary files differindex 17eadedc6f..980b7d3bf8 100644 --- a/thirdparty/fonts/NotoSansHebrew_Regular.woff2 +++ b/thirdparty/fonts/NotoSansHebrew_Regular.woff2 diff --git a/thirdparty/fonts/NotoSansMalayalamUI_Bold.woff2 b/thirdparty/fonts/NotoSansMalayalamUI_Bold.woff2 Binary files differindex 5f6bacb0c3..8757bf3584 100644 --- a/thirdparty/fonts/NotoSansMalayalamUI_Bold.woff2 +++ b/thirdparty/fonts/NotoSansMalayalamUI_Bold.woff2 diff --git a/thirdparty/fonts/NotoSansMalayalamUI_Regular.woff2 b/thirdparty/fonts/NotoSansMalayalamUI_Regular.woff2 Binary files differindex c54a82a874..cd266fafd3 100644 --- a/thirdparty/fonts/NotoSansMalayalamUI_Regular.woff2 +++ b/thirdparty/fonts/NotoSansMalayalamUI_Regular.woff2 diff --git a/thirdparty/fonts/NotoSansOriyaUI_Bold.woff2 b/thirdparty/fonts/NotoSansOriyaUI_Bold.woff2 Binary files differdeleted file mode 100644 index b7e34302e2..0000000000 --- a/thirdparty/fonts/NotoSansOriyaUI_Bold.woff2 +++ /dev/null diff --git a/thirdparty/fonts/NotoSansOriyaUI_Regular.woff2 b/thirdparty/fonts/NotoSansOriyaUI_Regular.woff2 Binary files differdeleted file mode 100644 index e64090cd77..0000000000 --- a/thirdparty/fonts/NotoSansOriyaUI_Regular.woff2 +++ /dev/null diff --git a/thirdparty/fonts/NotoSansOriya_Bold.woff2 b/thirdparty/fonts/NotoSansOriya_Bold.woff2 Binary files differnew file mode 100644 index 0000000000..333abfaae0 --- /dev/null +++ b/thirdparty/fonts/NotoSansOriya_Bold.woff2 diff --git a/thirdparty/fonts/NotoSansOriya_Regular.woff2 b/thirdparty/fonts/NotoSansOriya_Regular.woff2 Binary files differnew file mode 100644 index 0000000000..c9b7c4a74e --- /dev/null +++ b/thirdparty/fonts/NotoSansOriya_Regular.woff2 diff --git a/thirdparty/fonts/NotoSansSinhalaUI_Bold.woff2 b/thirdparty/fonts/NotoSansSinhalaUI_Bold.woff2 Binary files differindex 01dbd1bc8f..7facb291bd 100644 --- a/thirdparty/fonts/NotoSansSinhalaUI_Bold.woff2 +++ b/thirdparty/fonts/NotoSansSinhalaUI_Bold.woff2 diff --git a/thirdparty/fonts/NotoSansSinhalaUI_Regular.woff2 b/thirdparty/fonts/NotoSansSinhalaUI_Regular.woff2 Binary files differindex 504c9d0809..8059db385f 100644 --- a/thirdparty/fonts/NotoSansSinhalaUI_Regular.woff2 +++ b/thirdparty/fonts/NotoSansSinhalaUI_Regular.woff2 diff --git a/thirdparty/fonts/NotoSansTamilUI_Bold.woff2 b/thirdparty/fonts/NotoSansTamilUI_Bold.woff2 Binary files differindex 96967b0cce..ed428dedbd 100644 --- a/thirdparty/fonts/NotoSansTamilUI_Bold.woff2 +++ b/thirdparty/fonts/NotoSansTamilUI_Bold.woff2 diff --git a/thirdparty/fonts/NotoSansTamilUI_Regular.woff2 b/thirdparty/fonts/NotoSansTamilUI_Regular.woff2 Binary files differindex e9b2bee582..d32dc96ae6 100644 --- a/thirdparty/fonts/NotoSansTamilUI_Regular.woff2 +++ b/thirdparty/fonts/NotoSansTamilUI_Regular.woff2 diff --git a/thirdparty/fonts/NotoSansTeluguUI_Bold.woff2 b/thirdparty/fonts/NotoSansTeluguUI_Bold.woff2 Binary files differindex 2885bf991d..4de7b9f28d 100644 --- a/thirdparty/fonts/NotoSansTeluguUI_Bold.woff2 +++ b/thirdparty/fonts/NotoSansTeluguUI_Bold.woff2 diff --git a/thirdparty/fonts/NotoSansTeluguUI_Regular.woff2 b/thirdparty/fonts/NotoSansTeluguUI_Regular.woff2 Binary files differindex ac5e66d8f6..0d9fe71d3a 100644 --- a/thirdparty/fonts/NotoSansTeluguUI_Regular.woff2 +++ b/thirdparty/fonts/NotoSansTeluguUI_Regular.woff2 diff --git a/thirdparty/fonts/NotoSansThaiUI_Bold.woff2 b/thirdparty/fonts/NotoSansThaiUI_Bold.woff2 Binary files differdeleted file mode 100644 index 202995c066..0000000000 --- a/thirdparty/fonts/NotoSansThaiUI_Bold.woff2 +++ /dev/null diff --git a/thirdparty/fonts/NotoSansThaiUI_Regular.woff2 b/thirdparty/fonts/NotoSansThaiUI_Regular.woff2 Binary files differdeleted file mode 100644 index 2fb284f21f..0000000000 --- a/thirdparty/fonts/NotoSansThaiUI_Regular.woff2 +++ /dev/null diff --git a/thirdparty/fonts/NotoSansThai_Bold.woff2 b/thirdparty/fonts/NotoSansThai_Bold.woff2 Binary files differnew file mode 100644 index 0000000000..68dc6c1392 --- /dev/null +++ b/thirdparty/fonts/NotoSansThai_Bold.woff2 diff --git a/thirdparty/fonts/NotoSansThai_Regular.woff2 b/thirdparty/fonts/NotoSansThai_Regular.woff2 Binary files differnew file mode 100644 index 0000000000..ae29cbdb10 --- /dev/null +++ b/thirdparty/fonts/NotoSansThai_Regular.woff2 diff --git a/thirdparty/fonts/NotoSans_Bold.woff2 b/thirdparty/fonts/NotoSans_Bold.woff2 Binary files differindex 36a5b89999..09a3297a6a 100644 --- a/thirdparty/fonts/NotoSans_Bold.woff2 +++ b/thirdparty/fonts/NotoSans_Bold.woff2 diff --git a/thirdparty/fonts/NotoSans_Regular.woff2 b/thirdparty/fonts/NotoSans_Regular.woff2 Binary files differindex d449eed8d7..59c252ede1 100644 --- a/thirdparty/fonts/NotoSans_Regular.woff2 +++ b/thirdparty/fonts/NotoSans_Regular.woff2 diff --git a/thirdparty/harfbuzz/src/OT/Layout/GDEF/GDEF.hh b/thirdparty/harfbuzz/src/OT/Layout/GDEF/GDEF.hh index d995ba0d4c..4f85d3ce5e 100644 --- a/thirdparty/harfbuzz/src/OT/Layout/GDEF/GDEF.hh +++ b/thirdparty/harfbuzz/src/OT/Layout/GDEF/GDEF.hh @@ -439,6 +439,16 @@ struct MarkGlyphSetsFormat1 bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; } + template <typename set_t> + void collect_coverage (hb_vector_t<set_t> &sets) const + { + for (const auto &offset : coverage) + { + const auto &cov = this+offset; + cov.collect_coverage (sets.push ()); + } + } + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); @@ -492,6 +502,15 @@ struct MarkGlyphSets } } + template <typename set_t> + void collect_coverage (hb_vector_t<set_t> &sets) const + { + switch (u.format) { + case 1: u.format1.collect_coverage (sets); return; + default:return; + } + } + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); @@ -856,6 +875,10 @@ struct GDEF hb_blob_destroy (table.get_blob ()); table = hb_blob_get_empty (); } + +#ifndef HB_NO_GDEF_CACHE + table->get_mark_glyph_sets ().collect_coverage (mark_glyph_set_digests); +#endif } ~accelerator_t () { table.destroy (); } @@ -879,8 +902,18 @@ struct GDEF } + bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const + { + return +#ifndef HB_NO_GDEF_CACHE + mark_glyph_set_digests[set_index].may_have (glyph_id) && +#endif + table->mark_set_covers (set_index, glyph_id); + } + hb_blob_ptr_t<GDEF> table; #ifndef HB_NO_GDEF_CACHE + hb_vector_t<hb_set_digest_t> mark_glyph_set_digests; mutable hb_cache_t<21, 3, 8> glyph_props_cache; #endif }; diff --git a/thirdparty/harfbuzz/src/OT/Layout/GPOS/CursivePosFormat1.hh b/thirdparty/harfbuzz/src/OT/Layout/GPOS/CursivePosFormat1.hh index a459124dfe..54852aae75 100644 --- a/thirdparty/harfbuzz/src/OT/Layout/GPOS/CursivePosFormat1.hh +++ b/thirdparty/harfbuzz/src/OT/Layout/GPOS/CursivePosFormat1.hh @@ -91,7 +91,13 @@ struct CursivePosFormat1 bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (coverage.sanitize (c, this) && entryExitRecord.sanitize (c, this)); + if (unlikely (!coverage.sanitize (c, this))) + return_trace (false); + + if (c->lazy_some_gpos) + return_trace (entryExitRecord.sanitize_shallow (c)); + else + return_trace (entryExitRecord.sanitize (c, this)); } bool intersects (const hb_set_t *glyphs) const @@ -119,10 +125,11 @@ struct CursivePosFormat1 hb_buffer_t *buffer = c->buffer; const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (buffer->cur().codepoint)]; - if (!this_record.entryAnchor) return_trace (false); + if (!this_record.entryAnchor || + unlikely (!this_record.entryAnchor.sanitize (&c->sanitizer, this))) return_trace (false); hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; - skippy_iter.reset_fast (buffer->idx, 1); + skippy_iter.reset_fast (buffer->idx); unsigned unsafe_from; if (unlikely (!skippy_iter.prev (&unsafe_from))) { @@ -131,7 +138,8 @@ struct CursivePosFormat1 } const EntryExitRecord &prev_record = entryExitRecord[(this+coverage).get_coverage (buffer->info[skippy_iter.idx].codepoint)]; - if (!prev_record.exitAnchor) + if (!prev_record.exitAnchor || + unlikely (!prev_record.exitAnchor.sanitize (&c->sanitizer, this))) { buffer->unsafe_to_concat_from_outbuffer (skippy_iter.idx, buffer->idx + 1); return_trace (false); @@ -200,8 +208,8 @@ struct CursivePosFormat1 * Arabic. */ unsigned int child = i; unsigned int parent = j; - hb_position_t x_offset = entry_x - exit_x; - hb_position_t y_offset = entry_y - exit_y; + hb_position_t x_offset = roundf (entry_x - exit_x); + hb_position_t y_offset = roundf (entry_y - exit_y); if (!(c->lookup_props & LookupFlag::RightToLeft)) { unsigned int k = child; diff --git a/thirdparty/harfbuzz/src/OT/Layout/GPOS/MarkMarkPosFormat1.hh b/thirdparty/harfbuzz/src/OT/Layout/GPOS/MarkMarkPosFormat1.hh index 9dae5ce5da..72535f4c98 100644 --- a/thirdparty/harfbuzz/src/OT/Layout/GPOS/MarkMarkPosFormat1.hh +++ b/thirdparty/harfbuzz/src/OT/Layout/GPOS/MarkMarkPosFormat1.hh @@ -100,7 +100,7 @@ struct MarkMarkPosFormat1_2 /* now we search backwards for a suitable mark glyph until a non-mark glyph */ hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; - skippy_iter.reset_fast (buffer->idx, 1); + skippy_iter.reset_fast (buffer->idx); skippy_iter.set_lookup_props (c->lookup_props & ~(uint32_t)LookupFlag::IgnoreFlags); unsigned unsafe_from; if (unlikely (!skippy_iter.prev (&unsafe_from))) diff --git a/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairPosFormat1.hh b/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairPosFormat1.hh index 714b4bec72..e4a2006fb9 100644 --- a/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairPosFormat1.hh +++ b/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairPosFormat1.hh @@ -110,7 +110,7 @@ struct PairPosFormat1_3 if (likely (index == NOT_COVERED)) return_trace (false); hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; - skippy_iter.reset_fast (buffer->idx, 1); + skippy_iter.reset_fast (buffer->idx); unsigned unsafe_to; if (unlikely (!skippy_iter.next (&unsafe_to))) { diff --git a/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairPosFormat2.hh b/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairPosFormat2.hh index 05e6c0fa54..1bde9e755e 100644 --- a/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairPosFormat2.hh +++ b/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairPosFormat2.hh @@ -131,7 +131,7 @@ struct PairPosFormat2_4 if (likely (index == NOT_COVERED)) return_trace (false); hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; - skippy_iter.reset_fast (buffer->idx, 1); + skippy_iter.reset_fast (buffer->idx); unsigned unsafe_to; if (unlikely (!skippy_iter.next (&unsafe_to))) { diff --git a/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairValueRecord.hh b/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairValueRecord.hh index 3222477764..72bf0e99b5 100644 --- a/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairValueRecord.hh +++ b/thirdparty/harfbuzz/src/OT/Layout/GPOS/PairValueRecord.hh @@ -22,7 +22,7 @@ struct PairValueRecord ValueRecord values; /* Positioning data for the first glyph * followed by for second glyph */ public: - DEFINE_SIZE_ARRAY (Types::size, values); + DEFINE_SIZE_ARRAY (Types::HBGlyphID::static_size, values); int cmp (hb_codepoint_t k) const { return secondGlyph.cmp (k); } diff --git a/thirdparty/harfbuzz/src/OT/Layout/GSUB/Ligature.hh b/thirdparty/harfbuzz/src/OT/Layout/GSUB/Ligature.hh index db3fc55f77..402ed12ae2 100644 --- a/thirdparty/harfbuzz/src/OT/Layout/GSUB/Ligature.hh +++ b/thirdparty/harfbuzz/src/OT/Layout/GSUB/Ligature.hh @@ -19,7 +19,6 @@ struct Ligature * in writing direction */ public: DEFINE_SIZE_ARRAY (Types::size + 2, component); - DEFINE_SIZE_MAX (65536 * Types::HBGlyphID::static_size); bool sanitize (hb_sanitize_context_t *c) const { diff --git a/thirdparty/harfbuzz/src/OT/Layout/GSUB/LigatureSet.hh b/thirdparty/harfbuzz/src/OT/Layout/GSUB/LigatureSet.hh index 0ba262e901..08665438c4 100644 --- a/thirdparty/harfbuzz/src/OT/Layout/GSUB/LigatureSet.hh +++ b/thirdparty/harfbuzz/src/OT/Layout/GSUB/LigatureSet.hh @@ -72,19 +72,14 @@ struct LigatureSet ; } - static bool match_always (hb_glyph_info_t &info HB_UNUSED, unsigned value HB_UNUSED, const void *data HB_UNUSED) - { - return true; - } - bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); unsigned int num_ligs = ligature.len; -#ifndef HB_NO_OT_LIGATURES_FAST_PATH - if (HB_OPTIMIZE_SIZE_VAL || num_ligs <= 2) +#ifndef HB_NO_OT_RULESETS_FAST_PATH + if (HB_OPTIMIZE_SIZE_VAL || num_ligs <= 4) #endif { slow: @@ -97,10 +92,12 @@ struct LigatureSet } /* This version is optimized for speed by matching the first component - * of the ligature here, instead of calling into the ligation code. */ + * of the ligature here, instead of calling into the ligation code. + * + * This is replicated in ChainRuleSet and RuleSet. */ hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; - skippy_iter.reset (c->buffer->idx, 1); + skippy_iter.reset (c->buffer->idx); skippy_iter.set_match_func (match_always, nullptr); skippy_iter.set_glyph_data ((HBUINT16 *) nullptr); unsigned unsafe_to; @@ -118,6 +115,8 @@ struct LigatureSet goto slow; } } + else + goto slow; bool unsafe_to_concat = false; @@ -125,7 +124,7 @@ struct LigatureSet { const auto &lig = this+ligature.arrayZ[i]; if (unlikely (lig.component.lenP1 <= 1) || - lig.component[1] == first) + lig.component.arrayZ[0] == first) { if (lig.apply (c)) { diff --git a/thirdparty/harfbuzz/src/graph/classdef-graph.hh b/thirdparty/harfbuzz/src/graph/classdef-graph.hh index 4ae0c13acc..c1432883ff 100644 --- a/thirdparty/harfbuzz/src/graph/classdef-graph.hh +++ b/thirdparty/harfbuzz/src/graph/classdef-graph.hh @@ -72,7 +72,7 @@ struct ClassDef : public OT::ClassDef class_def_link->width = SmallTypes::size; class_def_link->objidx = class_def_prime_id; class_def_link->position = link_position; - class_def_prime_vertex.parents.push (parent_id); + class_def_prime_vertex.add_parent (parent_id); return true; } diff --git a/thirdparty/harfbuzz/src/graph/coverage-graph.hh b/thirdparty/harfbuzz/src/graph/coverage-graph.hh index bd6e91a1f2..4f44e076d1 100644 --- a/thirdparty/harfbuzz/src/graph/coverage-graph.hh +++ b/thirdparty/harfbuzz/src/graph/coverage-graph.hh @@ -96,7 +96,7 @@ struct Coverage : public OT::Layout::Common::Coverage coverage_link->width = SmallTypes::size; coverage_link->objidx = coverage_prime_id; coverage_link->position = link_position; - coverage_prime_vertex.parents.push (parent_id); + coverage_prime_vertex.add_parent (parent_id); return (Coverage*) coverage_prime_vertex.obj.head; } diff --git a/thirdparty/harfbuzz/src/graph/graph.hh b/thirdparty/harfbuzz/src/graph/graph.hh index 53d0bc94e1..0680958190 100644 --- a/thirdparty/harfbuzz/src/graph/graph.hh +++ b/thirdparty/harfbuzz/src/graph/graph.hh @@ -43,12 +43,28 @@ struct graph_t { hb_serialize_context_t::object_t obj; int64_t distance = 0 ; - int64_t space = 0 ; - hb_vector_t<unsigned> parents; + unsigned space = 0 ; unsigned start = 0; unsigned end = 0; unsigned priority = 0; - + private: + unsigned incoming_edges_ = 0; + unsigned single_parent = (unsigned) -1; + hb_hashmap_t<unsigned, unsigned> parents; + public: + + auto parents_iter () const HB_AUTO_RETURN + ( + hb_concat ( + hb_iter (&single_parent, single_parent != (unsigned) -1), + parents.keys_ref () + ) + ) + + bool in_error () const + { + return parents.in_error (); + } bool link_positions_valid (unsigned num_objects, bool removed_nil) { @@ -143,7 +159,9 @@ struct graph_t hb_swap (a.obj, b.obj); hb_swap (a.distance, b.distance); hb_swap (a.space, b.space); + hb_swap (a.single_parent, b.single_parent); hb_swap (a.parents, b.parents); + hb_swap (a.incoming_edges_, b.incoming_edges_); hb_swap (a.start, b.start); hb_swap (a.end, b.end); hb_swap (a.priority, b.priority); @@ -154,6 +172,7 @@ struct graph_t { hb_hashmap_t<unsigned, unsigned> result; + result.alloc (obj.real_links.length); for (const auto& l : obj.real_links) { result.set (l.position, l.objidx); } @@ -163,22 +182,76 @@ struct graph_t bool is_shared () const { - return parents.length > 1; + return parents.get_population () > 1; } unsigned incoming_edges () const { - return parents.length; + if (HB_DEBUG_SUBSET_REPACK) + { + assert (incoming_edges_ == (single_parent != (unsigned) -1) + + (parents.values_ref () | hb_reduce (hb_add, 0))); + } + return incoming_edges_; + } + + void reset_parents () + { + incoming_edges_ = 0; + single_parent = (unsigned) -1; + parents.reset (); + } + + void add_parent (unsigned parent_index) + { + assert (parent_index != (unsigned) -1); + if (incoming_edges_ == 0) + { + single_parent = parent_index; + incoming_edges_ = 1; + return; + } + else if (single_parent != (unsigned) -1) + { + assert (incoming_edges_ == 1); + if (!parents.set (single_parent, 1)) + return; + single_parent = (unsigned) -1; + } + + unsigned *v; + if (parents.has (parent_index, &v)) + { + (*v)++; + incoming_edges_++; + } + else if (parents.set (parent_index, 1)) + incoming_edges_++; } void remove_parent (unsigned parent_index) { - unsigned count = parents.length; - for (unsigned i = 0; i < count; i++) + if (parent_index == single_parent) { - if (parents.arrayZ[i] != parent_index) continue; - parents.remove_unordered (i); - break; + single_parent = (unsigned) -1; + incoming_edges_--; + return; + } + + unsigned *v; + if (parents.has (parent_index, &v)) + { + incoming_edges_--; + if (*v > 1) + (*v)--; + else + parents.del (parent_index); + + if (incoming_edges_ == 1) + { + single_parent = *parents.keys (); + parents.reset (); + } } } @@ -199,20 +272,46 @@ struct graph_t } } - void remap_parents (const hb_vector_t<unsigned>& id_map) + bool remap_parents (const hb_vector_t<unsigned>& id_map) { - unsigned count = parents.length; - for (unsigned i = 0; i < count; i++) - parents.arrayZ[i] = id_map[parents.arrayZ[i]]; + if (single_parent != (unsigned) -1) + { + assert (single_parent < id_map.length); + single_parent = id_map[single_parent]; + return true; + } + + hb_hashmap_t<unsigned, unsigned> new_parents; + new_parents.alloc (parents.get_population ()); + for (auto _ : parents) + { + assert (_.first < id_map.length); + assert (!new_parents.has (id_map[_.first])); + new_parents.set (id_map[_.first], _.second); + } + + if (new_parents.in_error ()) + return false; + + parents = std::move (new_parents); + return true; } void remap_parent (unsigned old_index, unsigned new_index) { - unsigned count = parents.length; - for (unsigned i = 0; i < count; i++) + if (single_parent != (unsigned) -1) + { + if (single_parent == old_index) + single_parent = new_index; + return; + } + + const unsigned *pv; + if (parents.has (old_index, &pv)) { - if (parents.arrayZ[i] == old_index) - parents.arrayZ[i] = new_index; + unsigned v = *pv; + parents.set (new_index, v); + parents.del (old_index); } } @@ -419,7 +518,7 @@ struct graph_t link->width = 2; link->objidx = child_id; link->position = (char*) offset - (char*) v.obj.head; - vertices_[child_id].parents.push (parent_id); + vertices_[child_id].add_parent (parent_id); } /* @@ -465,7 +564,7 @@ struct graph_t { unsigned next_id = queue.pop_minimum().second; - hb_swap (sorted_graph[new_id], vertices_[next_id]); + sorted_graph[new_id] = std::move (vertices_[next_id]); const vertex_t& next = sorted_graph[new_id]; if (unlikely (!check_success(new_id >= 0))) { @@ -493,8 +592,8 @@ struct graph_t check_success (!queue.in_error ()); check_success (!sorted_graph.in_error ()); - remap_all_obj_indices (id_map, &sorted_graph); - hb_swap (vertices_, sorted_graph); + check_success (remap_all_obj_indices (id_map, &sorted_graph)); + vertices_ = std::move (sorted_graph); if (!check_success (new_id == -1)) print_orphaned_nodes (); @@ -605,7 +704,7 @@ struct graph_t { unsigned child_idx = index_for_offset (node_idx, offset); auto& child = vertices_[child_idx]; - for (unsigned p : child.parents) + for (unsigned p : child.parents_iter ()) { if (p != node_idx) { return duplicate (node_idx, child_idx); @@ -688,12 +787,15 @@ struct graph_t subgraph.set (root_idx, wide_parents (root_idx, parents)); find_subgraph (root_idx, subgraph); } + if (subgraph.in_error ()) + return false; unsigned original_root_idx = root_idx (); hb_map_t index_map; bool made_changes = false; for (auto entry : subgraph.iter ()) { + assert (entry.first < vertices_.length); const auto& node = vertices_[entry.first]; unsigned subgraph_incoming_edges = entry.second; @@ -749,10 +851,10 @@ struct graph_t { for (const auto& link : vertices_[node_idx].obj.all_links ()) { - const uint32_t *v; + hb_codepoint_t *v; if (subgraph.has (link.objidx, &v)) { - subgraph.set (link.objidx, *v + 1); + (*v)++; continue; } subgraph.set (link.objidx, 1); @@ -824,7 +926,7 @@ struct graph_t new_link->position = (const char*) new_offset - (const char*) new_v.obj.head; auto& child = vertices_[child_id]; - child.parents.push (new_parent_idx); + child.add_parent (new_parent_idx); old_v.remove_real_link (child_id, old_offset); child.remove_parent (old_parent_idx); @@ -868,18 +970,18 @@ struct graph_t clone->obj.tail = child.obj.tail; clone->distance = child.distance; clone->space = child.space; - clone->parents.reset (); + clone->reset_parents (); unsigned clone_idx = vertices_.length - 2; for (const auto& l : child.obj.real_links) { clone->obj.real_links.push (l); - vertices_[l.objidx].parents.push (clone_idx); + vertices_[l.objidx].add_parent (clone_idx); } for (const auto& l : child.obj.virtual_links) { clone->obj.virtual_links.push (l); - vertices_[l.objidx].parents.push (clone_idx); + vertices_[l.objidx].add_parent (clone_idx); } check_success (!clone->obj.real_links.in_error ()); @@ -1008,13 +1110,13 @@ struct graph_t { update_parents(); - if (root().parents) + if (root().incoming_edges ()) // Root cannot have parents. return false; for (unsigned i = 0; i < root_idx (); i++) { - if (!vertices_[i].parents) + if (!vertices_[i].incoming_edges ()) return false; } return true; @@ -1078,14 +1180,14 @@ struct graph_t parents_invalid = true; update_parents(); - if (root().parents) { + if (root().incoming_edges ()) { DEBUG_MSG (SUBSET_REPACK, nullptr, "Root node has incoming edges."); } for (unsigned i = 0; i < root_idx (); i++) { const auto& v = vertices_[i]; - if (!v.parents) + if (!v.incoming_edges ()) DEBUG_MSG (SUBSET_REPACK, nullptr, "Node %u is orphaned.", i); } } @@ -1117,6 +1219,8 @@ struct graph_t unsigned space_for (unsigned index, unsigned* root = nullptr) const { + loop: + assert (index < vertices_.length); const auto& node = vertices_[index]; if (node.space) { @@ -1125,14 +1229,15 @@ struct graph_t return node.space; } - if (!node.parents) + if (!node.incoming_edges ()) { if (root) *root = index; return 0; } - return space_for (node.parents[0], root); + index = *node.parents_iter (); + goto loop; } void err_other_error () { this->successful = false; } @@ -1156,12 +1261,8 @@ struct graph_t unsigned wide_parents (unsigned node_idx, hb_set_t& parents) const { unsigned count = 0; - hb_set_t visited; - for (unsigned p : vertices_[node_idx].parents) + for (unsigned p : vertices_[node_idx].parents_iter ()) { - if (visited.has (p)) continue; - visited.add (p); - // Only real links can be wide for (const auto& l : vertices_[p].obj.real_links) { @@ -1191,20 +1292,18 @@ struct graph_t unsigned count = vertices_.length; for (unsigned i = 0; i < count; i++) - vertices_.arrayZ[i].parents.reset (); + vertices_.arrayZ[i].reset_parents (); for (unsigned p = 0; p < count; p++) { for (auto& l : vertices_.arrayZ[p].obj.all_links ()) - { - vertices_[l.objidx].parents.push (p); - } + vertices_[l.objidx].add_parent (p); } for (unsigned i = 0; i < count; i++) // parents arrays must be accurate or downstream operations like cycle detection // and sorting won't work correctly. - check_success (!vertices_.arrayZ[i].parents.in_error ()); + check_success (!vertices_.arrayZ[i].in_error ()); parents_invalid = false; } @@ -1248,12 +1347,8 @@ struct graph_t // (such as a fibonacci queue) with a fast decrease priority. unsigned count = vertices_.length; for (unsigned i = 0; i < count; i++) - { - if (i == vertices_.length - 1) - vertices_.arrayZ[i].distance = 0; - else - vertices_.arrayZ[i].distance = hb_int_max (int64_t); - } + vertices_.arrayZ[i].distance = hb_int_max (int64_t); + vertices_.tail ().distance = 0; hb_priority_queue_t queue; queue.insert (0, vertices_.length - 1); @@ -1273,15 +1368,15 @@ struct graph_t { if (visited[link.objidx]) continue; - const auto& child = vertices_[link.objidx].obj; + const auto& child = vertices_.arrayZ[link.objidx].obj; unsigned link_width = link.width ? link.width : 4; // treat virtual offsets as 32 bits wide int64_t child_weight = (child.tail - child.head) + - ((int64_t) 1 << (link_width * 8)) * (vertices_[link.objidx].space + 1); + ((int64_t) 1 << (link_width * 8)) * (vertices_.arrayZ[link.objidx].space + 1); int64_t child_distance = next_distance + child_weight; - if (child_distance < vertices_[link.objidx].distance) + if (child_distance < vertices_.arrayZ[link.objidx].distance) { - vertices_[link.objidx].distance = child_distance; + vertices_.arrayZ[link.objidx].distance = child_distance; queue.insert (child_distance, link.objidx); } } @@ -1309,7 +1404,7 @@ struct graph_t unsigned old_idx = link.objidx; link.objidx = new_idx; vertices_[old_idx].remove_parent (parent_idx); - vertices_[new_idx].parents.push (parent_idx); + vertices_[new_idx].add_parent (parent_idx); } /* @@ -1337,18 +1432,20 @@ struct graph_t /* * Updates all objidx's in all links using the provided mapping. */ - void remap_all_obj_indices (const hb_vector_t<unsigned>& id_map, + bool remap_all_obj_indices (const hb_vector_t<unsigned>& id_map, hb_vector_t<vertex_t>* sorted_graph) const { unsigned count = sorted_graph->length; for (unsigned i = 0; i < count; i++) { - (*sorted_graph)[i].remap_parents (id_map); + if (!(*sorted_graph)[i].remap_parents (id_map)) + return false; for (auto& link : sorted_graph->arrayZ[i].obj.all_links_writer ()) { link.objidx = id_map[link.objidx]; } } + return true; } /* @@ -1379,7 +1476,7 @@ struct graph_t for (const auto& l : v.obj.all_links ()) find_connected_nodes (l.objidx, targets, visited, connected); - for (unsigned p : v.parents) + for (unsigned p : v.parents_iter ()) find_connected_nodes (p, targets, visited, connected); } diff --git a/thirdparty/harfbuzz/src/graph/gsubgpos-graph.hh b/thirdparty/harfbuzz/src/graph/gsubgpos-graph.hh index 78d5096325..303517f687 100644 --- a/thirdparty/harfbuzz/src/graph/gsubgpos-graph.hh +++ b/thirdparty/harfbuzz/src/graph/gsubgpos-graph.hh @@ -225,7 +225,7 @@ struct Lookup : public OT::Lookup if (is_ext) { unsigned ext_id = create_extension_subtable (c, subtable_id, type); - c.graph.vertices_[subtable_id].parents.push (ext_id); + c.graph.vertices_[subtable_id].add_parent (ext_id); subtable_id = ext_id; } @@ -234,7 +234,7 @@ struct Lookup : public OT::Lookup link->objidx = subtable_id; link->position = (char*) &new_lookup->subTable[offset_index++] - (char*) new_lookup; - c.graph.vertices_[subtable_id].parents.push (this_index); + c.graph.vertices_[subtable_id].add_parent (this_index); } } @@ -315,7 +315,7 @@ struct Lookup : public OT::Lookup // Make extension point at the subtable. auto& ext_vertex = c.graph.vertices_[ext_index]; auto& subtable_vertex = c.graph.vertices_[subtable_index]; - ext_vertex.parents.push (lookup_index); + ext_vertex.add_parent (lookup_index); subtable_vertex.remap_parent (lookup_index, ext_index); return true; diff --git a/thirdparty/harfbuzz/src/graph/pairpos-graph.hh b/thirdparty/harfbuzz/src/graph/pairpos-graph.hh index f655b71558..ad158cc9e8 100644 --- a/thirdparty/harfbuzz/src/graph/pairpos-graph.hh +++ b/thirdparty/harfbuzz/src/graph/pairpos-graph.hh @@ -419,7 +419,7 @@ struct PairPosFormat2 : public OT::Layout::GPOS_impl::PairPosFormat2_4<SmallType class_def_link->width = SmallTypes::size; class_def_link->objidx = class_def_2_id; class_def_link->position = 10; - graph.vertices_[class_def_2_id].parents.push (pair_pos_prime_id); + graph.vertices_[class_def_2_id].add_parent (pair_pos_prime_id); graph.duplicate (pair_pos_prime_id, class_def_2_id); return pair_pos_prime_id; diff --git a/thirdparty/harfbuzz/src/hb-aat-layout-trak-table.hh b/thirdparty/harfbuzz/src/hb-aat-layout-trak-table.hh index 2ba9355b06..c72c0865d3 100644 --- a/thirdparty/harfbuzz/src/hb-aat-layout-trak-table.hh +++ b/thirdparty/harfbuzz/src/hb-aat-layout-trak-table.hh @@ -111,13 +111,13 @@ struct TrackData break; } } - if (!trackTableEntry) return 0.; + if (!trackTableEntry) return 0; /* * Choose size. */ unsigned int sizes = nSizes; - if (!sizes) return 0.; + if (!sizes) return 0; if (sizes == 1) return trackTableEntry->get_value (base, 0, sizes); hb_array_t<const F16DOT16> size_table ((base+sizeTable).arrayZ, sizes); diff --git a/thirdparty/harfbuzz/src/hb-algs.hh b/thirdparty/harfbuzz/src/hb-algs.hh index 374965d56e..6cabc7fb02 100644 --- a/thirdparty/harfbuzz/src/hb-algs.hh +++ b/thirdparty/harfbuzz/src/hb-algs.hh @@ -283,8 +283,8 @@ HB_FUNCOBJ (hb_bool); // Compression function for Merkle-Damgard construction. // This function is generated using the framework provided. #define mix(h) ( \ - (h) ^= (h) >> 23, \ - (h) *= 0x2127599bf4325c37ULL, \ + (void) ((h) ^= (h) >> 23), \ + (void) ((h) *= 0x2127599bf4325c37ULL), \ (h) ^= (h) >> 47) static inline uint64_t fasthash64(const void *buf, size_t len, uint64_t seed) @@ -362,10 +362,10 @@ struct // https://github.com/harfbuzz/harfbuzz/pull/4228#issuecomment-1565079537 template <typename T, hb_enable_if (std::is_integral<T>::value && sizeof (T) <= sizeof (uint32_t))> constexpr auto - impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, v * 2654435761u /* Knuh's multiplicative hash */) + impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, (uint32_t) v * 2654435761u /* Knuh's multiplicative hash */) template <typename T, hb_enable_if (std::is_integral<T>::value && sizeof (T) > sizeof (uint32_t))> constexpr auto - impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, (v ^ (v >> 32)) * 2654435761u /* Knuth's multiplicative hash */) + impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, (uint32_t) (v ^ (v >> 32)) * 2654435761u /* Knuth's multiplicative hash */) template <typename T> constexpr auto impl (const T& v, hb_priority<0>) const HB_RETURN (uint32_t, std::hash<hb_decay<decltype (hb_deref (v))>>{} (hb_deref (v))) diff --git a/thirdparty/harfbuzz/src/hb-bimap.hh b/thirdparty/harfbuzz/src/hb-bimap.hh index 4006fc4ebd..64dbf2e869 100644 --- a/thirdparty/harfbuzz/src/hb-bimap.hh +++ b/thirdparty/harfbuzz/src/hb-bimap.hh @@ -143,6 +143,7 @@ struct hb_inc_bimap_t hb_codepoint_t skip (unsigned count) { hb_codepoint_t start = back_map.length; + back_map.alloc (back_map.length + count); for (unsigned i = 0; i < count; i++) back_map.push (HB_MAP_VALUE_INVALID); return start; diff --git a/thirdparty/harfbuzz/src/hb-bit-page.hh b/thirdparty/harfbuzz/src/hb-bit-page.hh index e578d2643f..e1826e12a5 100644 --- a/thirdparty/harfbuzz/src/hb-bit-page.hh +++ b/thirdparty/harfbuzz/src/hb-bit-page.hh @@ -89,14 +89,17 @@ struct hb_vector_size_t struct hb_bit_page_t { - void init0 () { v.init0 (); } - void init1 () { v.init1 (); } + void init0 () { v.init0 (); population = 0; } + void init1 () { v.init1 (); population = PAGE_BITS; } + + void dirty () { population = UINT_MAX; } static inline constexpr unsigned len () { return ARRAY_LENGTH_CONST (v); } bool is_empty () const { + if (has_population ()) return !population; return + hb_iter (v) | hb_none @@ -107,8 +110,8 @@ struct hb_bit_page_t return hb_bytes_t ((const char *) &v, sizeof (v)).hash (); } - void add (hb_codepoint_t g) { elt (g) |= mask (g); } - void del (hb_codepoint_t g) { elt (g) &= ~mask (g); } + void add (hb_codepoint_t g) { elt (g) |= mask (g); dirty (); } + void del (hb_codepoint_t g) { elt (g) &= ~mask (g); dirty (); } void set (hb_codepoint_t g, bool value) { if (value) add (g); else del (g); } bool get (hb_codepoint_t g) const { return elt (g) & mask (g); } @@ -120,20 +123,21 @@ struct hb_bit_page_t *la |= (mask (b) << 1) - mask(a); else { - *la |= ~(mask (a) - 1); + *la |= ~(mask (a) - 1llu); la++; hb_memset (la, 0xff, (char *) lb - (char *) la); - *lb |= ((mask (b) << 1) - 1); + *lb |= ((mask (b) << 1) - 1llu); } + dirty (); } void del_range (hb_codepoint_t a, hb_codepoint_t b) { elt_t *la = &elt (a); elt_t *lb = &elt (b); if (la == lb) - *la &= ~((mask (b) << 1) - mask(a)); + *la &= ~((mask (b) << 1llu) - mask(a)); else { *la &= mask (a) - 1; @@ -141,8 +145,9 @@ struct hb_bit_page_t hb_memset (la, 0, (char *) lb - (char *) la); - *lb &= ~((mask (b) << 1) - 1); + *lb &= ~((mask (b) << 1) - 1llu); } + dirty (); } void set_range (hb_codepoint_t a, hb_codepoint_t b, bool v) { if (v) add_range (a, b); else del_range (a, b); } @@ -222,18 +227,25 @@ struct hb_bit_page_t } bool is_subset (const hb_bit_page_t &larger_page) const { + if (has_population () && larger_page.has_population () && + population > larger_page.population) + return false; + for (unsigned i = 0; i < len (); i++) if (~larger_page.v[i] & v[i]) return false; return true; } + bool has_population () const { return population != UINT_MAX; } unsigned int get_population () const { - return + if (has_population ()) return population; + population = + hb_iter (v) | hb_reduce ([] (unsigned pop, const elt_t &_) { return pop + hb_popcount (_); }, 0u) ; + return population; } bool next (hb_codepoint_t *codepoint) const @@ -329,9 +341,9 @@ struct hb_bit_page_t const elt_t& elt (hb_codepoint_t g) const { return v[(g & MASK) / ELT_BITS]; } static constexpr elt_t mask (hb_codepoint_t g) { return elt_t (1) << (g & ELT_MASK); } + mutable unsigned population; vector_t v; }; -static_assert (hb_bit_page_t::PAGE_BITS == sizeof (hb_bit_page_t) * 8, ""); #endif /* HB_BIT_PAGE_HH */ diff --git a/thirdparty/harfbuzz/src/hb-bit-set.hh b/thirdparty/harfbuzz/src/hb-bit-set.hh index a84d751fb3..9e60cb934a 100644 --- a/thirdparty/harfbuzz/src/hb-bit-set.hh +++ b/thirdparty/harfbuzz/src/hb-bit-set.hh @@ -30,7 +30,6 @@ #include "hb.hh" #include "hb-bit-page.hh" -#include "hb-machinery.hh" struct hb_bit_set_t @@ -183,6 +182,16 @@ struct hb_bit_set_t return true; } + /* Duplicated here from hb-machinery.hh to avoid including it. */ + template<typename Type> + static inline const Type& StructAtOffsetUnaligned(const void *P, unsigned int offset) + { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" + return * reinterpret_cast<const Type*> ((const char *) P + offset); +#pragma GCC diagnostic pop + } + template <typename T> void set_array (bool v, const T *array, unsigned int count, unsigned int stride=sizeof(T)) { @@ -553,6 +562,7 @@ struct hb_bit_set_t count--; page_map.arrayZ[count] = page_map.arrayZ[a]; page_at (count).v = op (page_at (a).v, other.page_at (b).v); + page_at (count).dirty (); } else if (page_map.arrayZ[a - 1].major > other.page_map.arrayZ[b - 1].major) { @@ -571,7 +581,7 @@ struct hb_bit_set_t count--; page_map.arrayZ[count].major = other.page_map.arrayZ[b].major; page_map.arrayZ[count].index = next_page++; - page_at (count).v = other.page_at (b).v; + page_at (count) = other.page_at (b); } } } @@ -589,7 +599,7 @@ struct hb_bit_set_t count--; page_map.arrayZ[count].major = other.page_map.arrayZ[b].major; page_map.arrayZ[count].index = next_page++; - page_at (count).v = other.page_at (b).v; + page_at (count) = other.page_at (b); } assert (!count); resize (newCount); diff --git a/thirdparty/harfbuzz/src/hb-buffer.cc b/thirdparty/harfbuzz/src/hb-buffer.cc index ace2a104fd..749ef9bd49 100644 --- a/thirdparty/harfbuzz/src/hb-buffer.cc +++ b/thirdparty/harfbuzz/src/hb-buffer.cc @@ -499,12 +499,12 @@ hb_buffer_t::set_masks (hb_mask_t value, unsigned int cluster_start, unsigned int cluster_end) { - hb_mask_t not_mask = ~mask; - value &= mask; - if (!mask) return; + hb_mask_t not_mask = ~mask; + value &= mask; + unsigned int count = len; for (unsigned int i = 0; i < count; i++) if (cluster_start <= info[i].cluster && info[i].cluster < cluster_end) diff --git a/thirdparty/harfbuzz/src/hb-buffer.hh b/thirdparty/harfbuzz/src/hb-buffer.hh index 4d48b7f167..f04ad58f11 100644 --- a/thirdparty/harfbuzz/src/hb-buffer.hh +++ b/thirdparty/harfbuzz/src/hb-buffer.hh @@ -464,13 +464,16 @@ struct hb_buffer_t start, end, true); } +#ifndef HB_OPTIMIZE_SIZE + HB_ALWAYS_INLINE +#endif void unsafe_to_concat (unsigned int start = 0, unsigned int end = -1) { if (likely ((flags & HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT) == 0)) return; _set_glyph_flags (HB_GLYPH_FLAG_UNSAFE_TO_CONCAT, start, end, - true); + false); } void unsafe_to_break_from_outbuffer (unsigned int start = 0, unsigned int end = -1) { @@ -478,6 +481,9 @@ struct hb_buffer_t start, end, true, true); } +#ifndef HB_OPTIMIZE_SIZE + HB_ALWAYS_INLINE +#endif void unsafe_to_concat_from_outbuffer (unsigned int start = 0, unsigned int end = -1) { if (likely ((flags & HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT) == 0)) diff --git a/thirdparty/harfbuzz/src/hb-config.hh b/thirdparty/harfbuzz/src/hb-config.hh index 335c6976f6..816c55c7d3 100644 --- a/thirdparty/harfbuzz/src/hb-config.hh +++ b/thirdparty/harfbuzz/src/hb-config.hh @@ -183,7 +183,7 @@ #endif #ifdef HB_OPTIMIZE_SIZE_MORE -#define HB_NO_OT_LIGATURES_FAST_PATH +#define HB_NO_OT_RULESETS_FAST_PATH #endif #ifdef HB_MINIMIZE_MEMORY_USAGE diff --git a/thirdparty/harfbuzz/src/hb-kern.hh b/thirdparty/harfbuzz/src/hb-kern.hh index 9ac744c9dd..0462a0ea8e 100644 --- a/thirdparty/harfbuzz/src/hb-kern.hh +++ b/thirdparty/harfbuzz/src/hb-kern.hh @@ -70,7 +70,7 @@ struct hb_kern_machine_t continue; } - skippy_iter.reset (idx, 1); + skippy_iter.reset (idx); unsigned unsafe_to; if (!skippy_iter.next (&unsafe_to)) { diff --git a/thirdparty/harfbuzz/src/hb-machinery.hh b/thirdparty/harfbuzz/src/hb-machinery.hh index cde1e99d6f..ecff94f1b6 100644 --- a/thirdparty/harfbuzz/src/hb-machinery.hh +++ b/thirdparty/harfbuzz/src/hb-machinery.hh @@ -131,10 +131,6 @@ static inline Type& StructAfter(TObject &X) unsigned int get_size () const { return (size - (array).min_size + (array).get_size ()); } \ DEFINE_SIZE_ARRAY(size, array) -#define DEFINE_SIZE_MAX(size) \ - DEFINE_INSTANCE_ASSERTION (sizeof (*this) <= (size)) \ - static constexpr unsigned max_size = (size) - /* diff --git a/thirdparty/harfbuzz/src/hb-map.hh b/thirdparty/harfbuzz/src/hb-map.hh index e8abeec636..42604ef7c2 100644 --- a/thirdparty/harfbuzz/src/hb-map.hh +++ b/thirdparty/harfbuzz/src/hb-map.hh @@ -78,6 +78,10 @@ struct hb_hashmap_t hash (0), value () {} + // Needed for https://github.com/harfbuzz/harfbuzz/issues/4138 + K& get_key () { return key; } + V& get_value () { return value; } + bool is_used () const { return is_used_; } void set_used (bool is_used) { is_used_ = is_used; } void set_real (bool is_real) { is_real_ = is_real; } @@ -405,23 +409,21 @@ struct hb_hashmap_t auto keys_ref () const HB_AUTO_RETURN ( + iter_items () - | hb_map (&item_t::key) + | hb_map (&item_t::get_key) ) auto keys () const HB_AUTO_RETURN ( - + iter_items () - | hb_map (&item_t::key) + + keys_ref () | hb_map (hb_ridentity) ) auto values_ref () const HB_AUTO_RETURN ( + iter_items () - | hb_map (&item_t::value) + | hb_map (&item_t::get_value) ) auto values () const HB_AUTO_RETURN ( - + iter_items () - | hb_map (&item_t::value) + + values_ref () | hb_map (hb_ridentity) ) diff --git a/thirdparty/harfbuzz/src/hb-null.hh b/thirdparty/harfbuzz/src/hb-null.hh index 2982516283..6796906ba8 100644 --- a/thirdparty/harfbuzz/src/hb-null.hh +++ b/thirdparty/harfbuzz/src/hb-null.hh @@ -37,7 +37,7 @@ /* Global nul-content Null pool. Enlarge as necessary. */ -#define HB_NULL_POOL_SIZE 520 +#define HB_NULL_POOL_SIZE 640 template <typename T, typename> struct _hb_has_min_size : hb_false_type {}; @@ -49,15 +49,6 @@ using hb_has_min_size = _hb_has_min_size<T, void>; #define hb_has_min_size(T) hb_has_min_size<T>::value template <typename T, typename> -struct _hb_has_max_size : hb_false_type {}; -template <typename T> -struct _hb_has_max_size<T, hb_void_t<decltype (T::max_size)>> - : hb_true_type {}; -template <typename T> -using hb_has_max_size = _hb_has_max_size<T, void>; -#define hb_has_max_size(T) hb_has_max_size<T>::value - -template <typename T, typename> struct _hb_has_null_size : hb_false_type {}; template <typename T> struct _hb_has_null_size<T, hb_void_t<decltype (T::null_size)>> diff --git a/thirdparty/harfbuzz/src/hb-open-type.hh b/thirdparty/harfbuzz/src/hb-open-type.hh index 6d464a3535..d3fdd1caf5 100644 --- a/thirdparty/harfbuzz/src/hb-open-type.hh +++ b/thirdparty/harfbuzz/src/hb-open-type.hh @@ -718,30 +718,6 @@ struct ArrayOf return_trace (out); } - /* Special-case ArrayOf Offset16To structs with a maximum size. */ - template <typename T = Type, - typename Base = void, - hb_enable_if (hb_has_max_size (typename T::target_t) && - sizeof (T) == 2)> - HB_ALWAYS_INLINE - bool sanitize (hb_sanitize_context_t *c, const Base *base) const - { - TRACE_SANITIZE (this); - - if (unlikely (!sanitize_shallow (c))) return_trace (false); - - unsigned max_len = 65536 + Type::target_t::max_size; - - if (unlikely (c->check_range_fast (base, max_len))) - return_trace (true); - - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (unlikely (!c->dispatch (arrayZ[i], base))) - return_trace (false); - return_trace (true); - } - template <typename ...Ts> HB_ALWAYS_INLINE bool sanitize (hb_sanitize_context_t *c, Ts&&... ds) const diff --git a/thirdparty/harfbuzz/src/hb-ot-cff-common.hh b/thirdparty/harfbuzz/src/hb-ot-cff-common.hh index a2f90c8f5e..923a32b26f 100644 --- a/thirdparty/harfbuzz/src/hb-ot-cff-common.hh +++ b/thirdparty/harfbuzz/src/hb-ot-cff-common.hh @@ -94,10 +94,10 @@ struct CFFIndex for (const auto &_ : +it) { unsigned len = _.length; + if (!len) + continue; if (len <= 1) { - if (!len) - continue; *ret++ = *_.arrayZ; continue; } diff --git a/thirdparty/harfbuzz/src/hb-ot-cff1-table.hh b/thirdparty/harfbuzz/src/hb-ot-cff1-table.hh index 3d658ac626..1e81dcb5e3 100644 --- a/thirdparty/harfbuzz/src/hb-ot-cff1-table.hh +++ b/thirdparty/harfbuzz/src/hb-ot-cff1-table.hh @@ -1061,6 +1061,8 @@ struct cff1 template <typename PRIVOPSET, typename PRIVDICTVAL> struct accelerator_templ_t { + static constexpr hb_tag_t tableTag = cff1::tableTag; + accelerator_templ_t (hb_face_t *face) { if (!face) return; diff --git a/thirdparty/harfbuzz/src/hb-ot-cff2-table.hh b/thirdparty/harfbuzz/src/hb-ot-cff2-table.hh index 9913cdad0c..af24bb9986 100644 --- a/thirdparty/harfbuzz/src/hb-ot-cff2-table.hh +++ b/thirdparty/harfbuzz/src/hb-ot-cff2-table.hh @@ -390,6 +390,8 @@ struct cff2 template <typename PRIVOPSET, typename PRIVDICTVAL> struct accelerator_templ_t { + static constexpr hb_tag_t tableTag = cff2::tableTag; + accelerator_templ_t (hb_face_t *face) { if (!face) return; diff --git a/thirdparty/harfbuzz/src/hb-ot-hmtx-table.hh b/thirdparty/harfbuzz/src/hb-ot-hmtx-table.hh index fed6ca1c7a..89640b43f1 100644 --- a/thirdparty/harfbuzz/src/hb-ot-hmtx-table.hh +++ b/thirdparty/harfbuzz/src/hb-ot-hmtx-table.hh @@ -179,6 +179,7 @@ struct hmtxvmtx lm.advance = mtx.first; lm.sb = mtx.second; } + // TODO(beyond-64k): This assumes that maxp.numGlyphs is 0xFFFF. else if (gid < 0x10000u) short_metrics[gid] = mtx.second; else @@ -199,6 +200,8 @@ struct hmtxvmtx /* Determine num_long_metrics to encode. */ auto& plan = c->plan; + // TODO Don't consider retaingid holes here. + num_long_metrics = hb_min (plan->num_output_glyphs (), 0xFFFFu); unsigned int last_advance = get_new_gid_advance_unscaled (plan, mtx_map, num_long_metrics - 1, _mtx); while (num_long_metrics > 1 && diff --git a/thirdparty/harfbuzz/src/hb-ot-layout-common.hh b/thirdparty/harfbuzz/src/hb-ot-layout-common.hh index b3af128e02..0831e4499e 100644 --- a/thirdparty/harfbuzz/src/hb-ot-layout-common.hh +++ b/thirdparty/harfbuzz/src/hb-ot-layout-common.hh @@ -1937,13 +1937,22 @@ struct ClassDefFormat2_4 { /* Match if there's any glyph that is not listed! */ hb_codepoint_t g = HB_SET_VALUE_INVALID; - for (auto &range : rangeRecord) + hb_codepoint_t last = HB_SET_VALUE_INVALID; + auto it = hb_iter (rangeRecord); + for (auto &range : it) { + if (it->first == last + 1) + { + it++; + continue; + } + if (!glyphs->next (&g)) break; if (g < range.first) return true; g = range.last; + last = g; } if (g != HB_SET_VALUE_INVALID && glyphs->next (&g)) return true; @@ -2928,9 +2937,29 @@ struct ConditionFormat1 const hb_map_t *index_map = &c->plan->axes_index_map; if (index_map->is_empty ()) return_trace (true); - if (!index_map->has (axisIndex)) + const hb_map_t& axes_old_index_tag_map = c->plan->axes_old_index_tag_map; + hb_codepoint_t *axis_tag; + if (!axes_old_index_tag_map.has (axisIndex, &axis_tag) || + !index_map->has (axisIndex)) return_trace (false); + const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location = c->plan->axes_location; + Triple axis_limit{-1.f, 0.f, 1.f}; + Triple *normalized_limit; + if (normalized_axes_location.has (*axis_tag, &normalized_limit)) + axis_limit = *normalized_limit; + + const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances = c->plan->axes_triple_distances; + TripleDistances axis_triple_distances{1.f, 1.f}; + TripleDistances *triple_dists; + if (axes_triple_distances.has (*axis_tag, &triple_dists)) + axis_triple_distances = *triple_dists; + + float normalized_min = renormalizeValue (filterRangeMinValue.to_float (), axis_limit, axis_triple_distances, false); + float normalized_max = renormalizeValue (filterRangeMaxValue.to_float (), axis_limit, axis_triple_distances, false); + out->filterRangeMinValue.set_float (normalized_min); + out->filterRangeMaxValue.set_float (normalized_max); + return_trace (c->serializer->check_assign (out->axisIndex, index_map->get (axisIndex), HB_SERIALIZE_ERROR_INT_OVERFLOW)); } @@ -2946,15 +2975,16 @@ struct ConditionFormat1 hb_tag_t axis_tag = c->axes_index_tag_map->get (axisIndex); Triple axis_range (-1.f, 0.f, 1.f); - if (c->axes_location->has (axis_tag)) - axis_range = c->axes_location->get (axis_tag); + Triple *axis_limit; + if (c->axes_location->has (axis_tag, &axis_limit)) + axis_range = *axis_limit; - int axis_min_val = axis_range.minimum; - int axis_default_val = axis_range.middle; - int axis_max_val = axis_range.maximum; + float axis_min_val = axis_range.minimum; + float axis_default_val = axis_range.middle; + float axis_max_val = axis_range.maximum; - int16_t filter_min_val = filterRangeMinValue.to_int (); - int16_t filter_max_val = filterRangeMaxValue.to_int (); + float filter_min_val = filterRangeMinValue.to_float (); + float filter_max_val = filterRangeMaxValue.to_float (); if (axis_default_val < filter_min_val || axis_default_val > filter_max_val) @@ -2974,7 +3004,9 @@ struct ConditionFormat1 { // add axisIndex->value into the hashmap so we can check if the record is // unique with variations - hb_codepoint_t val = (filter_max_val << 16) + filter_min_val; + int16_t int_filter_max_val = filterRangeMaxValue.to_int (); + int16_t int_filter_min_val = filterRangeMinValue.to_int (); + hb_codepoint_t val = (int_filter_max_val << 16) + int_filter_min_val; condition_map->set (axisIndex, val); return KEEP_COND_WITH_VAR; diff --git a/thirdparty/harfbuzz/src/hb-ot-layout-gsubgpos.hh b/thirdparty/harfbuzz/src/hb-ot-layout-gsubgpos.hh index e10adb78be..662ec9d3e8 100644 --- a/thirdparty/harfbuzz/src/hb-ot-layout-gsubgpos.hh +++ b/thirdparty/harfbuzz/src/hb-ot-layout-gsubgpos.hh @@ -402,16 +402,6 @@ struct hb_ot_apply_context_t : { struct matcher_t { - matcher_t () : - lookup_props (0), - mask (-1), - ignore_zwnj (false), - ignore_zwj (false), - per_syllable (false), - syllable {0}, - match_func (nullptr), - match_data (nullptr) {} - typedef bool (*match_func_t) (hb_glyph_info_t &info, unsigned value, const void *data); void set_ignore_zwnj (bool ignore_zwnj_) { ignore_zwnj = ignore_zwnj_; } @@ -470,14 +460,14 @@ struct hb_ot_apply_context_t : } protected: - unsigned int lookup_props; - hb_mask_t mask; - bool ignore_zwnj; - bool ignore_zwj; - bool per_syllable; - uint8_t syllable; - match_func_t match_func; - const void *match_data; + unsigned int lookup_props = 0; + hb_mask_t mask = -1; + bool ignore_zwnj = false; + bool ignore_zwj = false; + bool per_syllable = false; + uint8_t syllable = 0; + match_func_t match_func = nullptr; + const void *match_data = nullptr; }; struct skipping_iterator_t @@ -528,11 +518,9 @@ struct hb_ot_apply_context_t : #ifndef HB_OPTIMIZE_SIZE HB_ALWAYS_INLINE #endif - void reset (unsigned int start_index_, - unsigned int num_items_) + void reset (unsigned int start_index_) { idx = start_index_; - num_items = num_items_; end = c->buffer->len; matcher.set_syllable (start_index_ == c->buffer->idx ? c->buffer->cur().syllable () : 0); } @@ -540,17 +528,14 @@ struct hb_ot_apply_context_t : #ifndef HB_OPTIMIZE_SIZE HB_ALWAYS_INLINE #endif - void reset_fast (unsigned int start_index_, - unsigned int num_items_) + void reset_fast (unsigned int start_index_) { // Doesn't set end or syllable. Used by GPOS which doesn't care / change. idx = start_index_; - num_items = num_items_; } void reject () { - num_items++; backup_glyph_data (); } @@ -593,12 +578,7 @@ struct hb_ot_apply_context_t : #endif bool next (unsigned *unsafe_to = nullptr) { - assert (num_items > 0); - /* The alternate condition below is faster at string boundaries, - * but produces subpar "unsafe-to-concat" values. */ - signed stop = (signed) end - (signed) num_items; - if (c->buffer->flags & HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT) - stop = (signed) end - 1; + const signed stop = (signed) end - 1; while ((signed) idx < stop) { idx++; @@ -606,7 +586,6 @@ struct hb_ot_apply_context_t : { case MATCH: { - num_items--; advance_glyph_data (); return true; } @@ -629,12 +608,7 @@ struct hb_ot_apply_context_t : #endif bool prev (unsigned *unsafe_from = nullptr) { - assert (num_items > 0); - /* The alternate condition below is faster at string boundaries, - * but produces subpar "unsafe-to-concat" values. */ - unsigned stop = num_items - 1; - if (c->buffer->flags & HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT) - stop = 1 - 1; + const unsigned stop = 0; while (idx > stop) { idx--; @@ -642,7 +616,6 @@ struct hb_ot_apply_context_t : { case MATCH: { - num_items--; advance_glyph_data (); return true; } @@ -661,6 +634,7 @@ struct hb_ot_apply_context_t : return false; } + HB_ALWAYS_INLINE hb_codepoint_t get_glyph_data () { @@ -671,6 +645,7 @@ struct hb_ot_apply_context_t : #endif return 0; } + HB_ALWAYS_INLINE void advance_glyph_data () { @@ -699,7 +674,6 @@ struct hb_ot_apply_context_t : const HBUINT24 *match_glyph_data24; #endif - unsigned int num_items; unsigned int end; }; @@ -826,7 +800,7 @@ struct hb_ot_apply_context_t : * match_props has the set index. */ if (match_props & LookupFlag::UseMarkFilteringSet) - return gdef.mark_set_covers (match_props >> 16, glyph); + return gdef_accel.mark_set_covers (match_props >> 16, glyph); /* The second byte of match_props has the meaning * "ignore marks of attachment type different than @@ -1198,6 +1172,10 @@ static inline void collect_array (hb_collect_glyphs_context_t *c HB_UNUSED, } +static inline bool match_always (hb_glyph_info_t &info HB_UNUSED, unsigned value HB_UNUSED, const void *data HB_UNUSED) +{ + return true; +} static inline bool match_glyph (hb_glyph_info_t &info, unsigned value, const void *data HB_UNUSED) { return info.codepoint == value; @@ -1218,6 +1196,28 @@ static inline bool match_class_cached (hb_glyph_info_t &info, unsigned value, co info.syllable() = klass; return klass == value; } +static inline bool match_class_cached1 (hb_glyph_info_t &info, unsigned value, const void *data) +{ + unsigned klass = info.syllable() & 0x0F; + if (klass < 15) + return klass == value; + const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); + klass = class_def.get_class (info.codepoint); + if (likely (klass < 15)) + info.syllable() = (info.syllable() & 0xF0) | klass; + return klass == value; +} +static inline bool match_class_cached2 (hb_glyph_info_t &info, unsigned value, const void *data) +{ + unsigned klass = (info.syllable() & 0xF0) >> 4; + if (klass < 15) + return klass == value; + const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); + klass = class_def.get_class (info.codepoint); + if (likely (klass < 15)) + info.syllable() = (info.syllable() & 0x0F) | (klass << 4); + return klass == value; +} static inline bool match_coverage (hb_glyph_info_t &info, unsigned value, const void *data) { Offset16To<Coverage> coverage; @@ -1265,7 +1265,7 @@ static bool match_input (hb_ot_apply_context_t *c, hb_buffer_t *buffer = c->buffer; hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; - skippy_iter.reset (buffer->idx, count - 1); + skippy_iter.reset (buffer->idx); skippy_iter.set_match_func (match_func, match_data); skippy_iter.set_glyph_data (input); @@ -1505,7 +1505,7 @@ static bool match_backtrack (hb_ot_apply_context_t *c, TRACE_APPLY (nullptr); hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context; - skippy_iter.reset (c->buffer->backtrack_len (), count); + skippy_iter.reset (c->buffer->backtrack_len ()); skippy_iter.set_match_func (match_func, match_data); skippy_iter.set_glyph_data (backtrack); @@ -1538,7 +1538,7 @@ static bool match_lookahead (hb_ot_apply_context_t *c, TRACE_APPLY (nullptr); hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context; - skippy_iter.reset (start_index - 1, count); + skippy_iter.reset (start_index - 1); skippy_iter.set_match_func (match_func, match_data); skippy_iter.set_glyph_data (lookahead); @@ -1913,12 +1913,13 @@ static inline bool context_would_apply_lookup (hb_would_apply_context_t *c, } template <typename HBUINT> -static inline bool context_apply_lookup (hb_ot_apply_context_t *c, - unsigned int inputCount, /* Including the first glyph (not matched) */ - const HBUINT input[], /* Array of input values--start with second glyph */ - unsigned int lookupCount, - const LookupRecord lookupRecord[], - const ContextApplyLookupContext &lookup_context) +HB_ALWAYS_INLINE +static bool context_apply_lookup (hb_ot_apply_context_t *c, + unsigned int inputCount, /* Including the first glyph (not matched) */ + const HBUINT input[], /* Array of input values--start with second glyph */ + unsigned int lookupCount, + const LookupRecord lookupRecord[], + const ContextApplyLookupContext &lookup_context) { unsigned match_end = 0; unsigned match_positions[HB_MAX_CONTEXT_LENGTH]; @@ -1944,6 +1945,9 @@ static inline bool context_apply_lookup (hb_ot_apply_context_t *c, template <typename Types> struct Rule { + template <typename T> + friend struct RuleSet; + bool intersects (const hb_set_t *glyphs, ContextClosureLookupContext &lookup_context) const { return context_intersects (glyphs, @@ -2065,7 +2069,6 @@ struct Rule * design order */ public: DEFINE_SIZE_ARRAY (4, inputZ); - DEFINE_SIZE_MAX (65536 * (Types::HBUINT::static_size + LookupRecord::static_size)); }; template <typename Types> @@ -2131,13 +2134,105 @@ struct RuleSet const ContextApplyLookupContext &lookup_context) const { TRACE_APPLY (this); - return_trace ( - + hb_iter (rule) - | hb_map (hb_add (this)) - | hb_map ([&] (const Rule &_) { return _.apply (c, lookup_context); }) - | hb_any - ) - ; + + unsigned num_rules = rule.len; + +#ifndef HB_NO_OT_RULESETS_FAST_PATH + if (HB_OPTIMIZE_SIZE_VAL || num_rules <= 4) +#endif + { + slow: + return_trace ( + + hb_iter (rule) + | hb_map (hb_add (this)) + | hb_map ([&] (const Rule &_) { return _.apply (c, lookup_context); }) + | hb_any + ) + ; + } + + /* This version is optimized for speed by matching the first & second + * components of the rule here, instead of calling into the matching code. + * + * Replicated from LigatureSet::apply(). */ + + hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; + skippy_iter.reset (c->buffer->idx); + skippy_iter.set_match_func (match_always, nullptr); + skippy_iter.set_glyph_data ((HBUINT16 *) nullptr); + unsigned unsafe_to = (unsigned) -1, unsafe_to1 = 0, unsafe_to2 = 0; + hb_glyph_info_t *first = nullptr, *second = nullptr; + bool matched = skippy_iter.next (); + if (likely (matched)) + { + first = &c->buffer->info[skippy_iter.idx]; + unsafe_to = skippy_iter.idx + 1; + + if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx])) + { + /* Can't use the fast path if eg. the next char is a default-ignorable + * or other skippable. */ + goto slow; + } + } + else + { + /* Failed to match a next glyph. Only try applying rules that have + * no further input. */ + return_trace ( + + hb_iter (rule) + | hb_map (hb_add (this)) + | hb_filter ([&] (const Rule &_) { return _.inputCount <= 1; }) + | hb_map ([&] (const Rule &_) { return _.apply (c, lookup_context); }) + | hb_any + ) + ; + } + matched = skippy_iter.next (); + if (likely (matched && !skippy_iter.may_skip (c->buffer->info[skippy_iter.idx]))) + { + second = &c->buffer->info[skippy_iter.idx]; + unsafe_to2 = skippy_iter.idx + 1; + } + + auto match_input = lookup_context.funcs.match; + auto *input_data = lookup_context.match_data; + for (unsigned int i = 0; i < num_rules; i++) + { + const auto &r = this+rule.arrayZ[i]; + + const auto &input = r.inputZ; + + if (r.inputCount <= 1 || + (!match_input || + match_input (*first, input.arrayZ[0], input_data))) + { + if (!second || + (r.inputCount <= 2 || + (!match_input || + match_input (*second, input.arrayZ[1], input_data))) + ) + { + if (r.apply (c, lookup_context)) + { + if (unsafe_to != (unsigned) -1) + c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to); + return_trace (true); + } + } + else + unsafe_to = unsafe_to2; + } + else + { + if (unsafe_to == (unsigned) -1) + unsafe_to = unsafe_to1; + } + } + if (likely (unsafe_to != (unsigned) -1)) + c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to); + + return_trace (false); } bool subset (hb_subset_context_t *c, @@ -2516,11 +2611,7 @@ struct ContextFormat2_5 if (cached && c->buffer->cur().syllable() < 255) index = c->buffer->cur().syllable (); else - { index = class_def.get_class (c->buffer->cur().codepoint); - if (cached && index < 255) - c->buffer->cur().syllable() = index; - } const RuleSet &rule_set = this+ruleSet[index]; return_trace (rule_set.apply (c, lookup_context)); } @@ -2914,16 +3005,17 @@ static inline bool chain_context_would_apply_lookup (hb_would_apply_context_t *c } template <typename HBUINT> -static inline bool chain_context_apply_lookup (hb_ot_apply_context_t *c, - unsigned int backtrackCount, - const HBUINT backtrack[], - unsigned int inputCount, /* Including the first glyph (not matched) */ - const HBUINT input[], /* Array of input values--start with second glyph */ - unsigned int lookaheadCount, - const HBUINT lookahead[], - unsigned int lookupCount, - const LookupRecord lookupRecord[], - const ChainContextApplyLookupContext &lookup_context) +HB_ALWAYS_INLINE +static bool chain_context_apply_lookup (hb_ot_apply_context_t *c, + unsigned int backtrackCount, + const HBUINT backtrack[], + unsigned int inputCount, /* Including the first glyph (not matched) */ + const HBUINT input[], /* Array of input values--start with second glyph */ + unsigned int lookaheadCount, + const HBUINT lookahead[], + unsigned int lookupCount, + const LookupRecord lookupRecord[], + const ChainContextApplyLookupContext &lookup_context) { unsigned end_index = c->buffer->idx; unsigned match_end = 0; @@ -2962,6 +3054,9 @@ static inline bool chain_context_apply_lookup (hb_ot_apply_context_t *c, template <typename Types> struct ChainRule { + template <typename T> + friend struct ChainRuleSet; + bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const { const auto &input = StructAfter<decltype (inputX)> (backtrack); @@ -3148,7 +3243,6 @@ struct ChainRule * design order) */ public: DEFINE_SIZE_MIN (8); - DEFINE_SIZE_MAX (65536 * (3 * Types::HBUINT::static_size + LookupRecord::static_size)); }; template <typename Types> @@ -3211,13 +3305,119 @@ struct ChainRuleSet const ChainContextApplyLookupContext &lookup_context) const { TRACE_APPLY (this); - return_trace ( - + hb_iter (rule) - | hb_map (hb_add (this)) - | hb_map ([&] (const ChainRule &_) { return _.apply (c, lookup_context); }) - | hb_any - ) - ; + + unsigned num_rules = rule.len; + +#ifndef HB_NO_OT_RULESETS_FAST_PATH + if (HB_OPTIMIZE_SIZE_VAL || num_rules <= 4) +#endif + { + slow: + return_trace ( + + hb_iter (rule) + | hb_map (hb_add (this)) + | hb_map ([&] (const ChainRule &_) { return _.apply (c, lookup_context); }) + | hb_any + ) + ; + } + + /* This version is optimized for speed by matching the first & second + * components of the rule here, instead of calling into the matching code. + * + * Replicated from LigatureSet::apply(). */ + + hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; + skippy_iter.reset (c->buffer->idx); + skippy_iter.set_match_func (match_always, nullptr); + skippy_iter.set_glyph_data ((HBUINT16 *) nullptr); + unsigned unsafe_to = (unsigned) -1, unsafe_to1 = 0, unsafe_to2 = 0; + hb_glyph_info_t *first = nullptr, *second = nullptr; + bool matched = skippy_iter.next (); + if (likely (matched)) + { + first = &c->buffer->info[skippy_iter.idx]; + unsafe_to1 = skippy_iter.idx + 1; + + if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx])) + { + /* Can't use the fast path if eg. the next char is a default-ignorable + * or other skippable. */ + goto slow; + } + } + else + { + /* Failed to match a next glyph. Only try applying rules that have + * no further input and lookahead. */ + return_trace ( + + hb_iter (rule) + | hb_map (hb_add (this)) + | hb_filter ([&] (const ChainRule &_) + { + const auto &input = StructAfter<decltype (_.inputX)> (_.backtrack); + const auto &lookahead = StructAfter<decltype (_.lookaheadX)> (input); + return input.lenP1 <= 1 && lookahead.len == 0; + }) + | hb_map ([&] (const ChainRule &_) { return _.apply (c, lookup_context); }) + | hb_any + ) + ; + } + matched = skippy_iter.next (); + if (likely (matched && !skippy_iter.may_skip (c->buffer->info[skippy_iter.idx]))) + { + second = &c->buffer->info[skippy_iter.idx]; + unsafe_to2 = skippy_iter.idx + 1; + } + + auto match_input = lookup_context.funcs.match[1]; + auto match_lookahead = lookup_context.funcs.match[2]; + auto *input_data = lookup_context.match_data[1]; + auto *lookahead_data = lookup_context.match_data[2]; + for (unsigned int i = 0; i < num_rules; i++) + { + const auto &r = this+rule.arrayZ[i]; + + const auto &input = StructAfter<decltype (r.inputX)> (r.backtrack); + const auto &lookahead = StructAfter<decltype (r.lookaheadX)> (input); + + unsigned lenP1 = hb_max ((unsigned) input.lenP1, 1u); + if (lenP1 > 1 ? + (!match_input || + match_input (*first, input.arrayZ[0], input_data)) + : + (!lookahead.len || !match_lookahead || + match_lookahead (*first, lookahead.arrayZ[0], lookahead_data))) + { + if (!second || + (lenP1 > 2 ? + (!match_input || + match_input (*second, input.arrayZ[1], input_data)) + : + (lookahead.len <= 2 - lenP1 || !match_lookahead || + match_lookahead (*second, lookahead.arrayZ[2 - lenP1], lookahead_data)))) + { + if (r.apply (c, lookup_context)) + { + if (unsafe_to != (unsigned) -1) + c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to); + return_trace (true); + } + } + else + unsafe_to = unsafe_to2; + } + else + { + if (unsafe_to == (unsigned) -1) + unsafe_to = unsafe_to1; + } + } + if (likely (unsafe_to != (unsigned) -1)) + c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to); + + return_trace (false); } bool subset (hb_subset_context_t *c, @@ -3616,26 +3816,22 @@ struct ChainContextFormat2_5 const ClassDef &input_class_def = this+inputClassDef; const ClassDef &lookahead_class_def = this+lookaheadClassDef; - /* For ChainContextFormat2_5 we cache the LookaheadClassDef instead of InputClassDef. - * The reason is that most heavy fonts want to identify a glyph in context and apply - * a lookup to it. In this scenario, the length of the input sequence is one, whereas - * the lookahead / backtrack are typically longer. The one glyph in input sequence is - * looked-up below and no input glyph is looked up in individual rules, whereas the - * lookahead and backtrack glyphs are tried. Since we match lookahead before backtrack, - * we should cache lookahead. This decisions showed a 20% improvement in shaping of - * the Gulzar font. - */ - + /* match_class_caches1 is slightly faster. Use it for lookahead, + * which is typically longer. */ struct ChainContextApplyLookupContext lookup_context = { - {{cached && &backtrack_class_def == &lookahead_class_def ? match_class_cached : match_class, - cached && &input_class_def == &lookahead_class_def ? match_class_cached : match_class, - cached ? match_class_cached : match_class}}, + {{cached && &backtrack_class_def == &lookahead_class_def ? match_class_cached1 : match_class, + cached ? match_class_cached2 : match_class, + cached ? match_class_cached1 : match_class}}, {&backtrack_class_def, &input_class_def, &lookahead_class_def} }; - index = input_class_def.get_class (c->buffer->cur().codepoint); + // Note: Corresponds to match_class_cached2 + if (cached && ((c->buffer->cur().syllable() & 0xF0) >> 4) < 15) + index = (c->buffer->cur().syllable () & 0xF0) >> 4; + else + index = input_class_def.get_class (c->buffer->cur().codepoint); const ChainRuleSet &rule_set = this+ruleSet[index]; return_trace (rule_set.apply (c, lookup_context)); } @@ -4139,6 +4335,9 @@ struct hb_ot_layout_lookup_accelerator_t bool may_have (hb_codepoint_t g) const { return digest.may_have (g); } +#ifndef HB_OPTIMIZE_SIZE + HB_ALWAYS_INLINE +#endif bool apply (hb_ot_apply_context_t *c, unsigned subtables_count, bool use_cache) const { #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE diff --git a/thirdparty/harfbuzz/src/hb-ot-layout.cc b/thirdparty/harfbuzz/src/hb-ot-layout.cc index 020b8a6c82..5ce36693a8 100644 --- a/thirdparty/harfbuzz/src/hb-ot-layout.cc +++ b/thirdparty/harfbuzz/src/hb-ot-layout.cc @@ -1241,7 +1241,7 @@ script_collect_features (hb_collect_features_context_t *c, * terminated by %HB_TAG_NONE * @features: (nullable) (array zero-terminated=1): The array of features to collect, * terminated by %HB_TAG_NONE - * @feature_indexes: (out): The array of feature indexes found for the query + * @feature_indexes: (out): The set of feature indexes found for the query * * Fetches a list of all feature indexes in the specified face's GSUB table * or GPOS table, underneath the specified scripts, languages, and features. @@ -1282,6 +1282,44 @@ hb_ot_layout_collect_features (hb_face_t *face, } } +/** + * hb_ot_layout_collect_features_map: + * @face: #hb_face_t to work upon + * @table_tag: #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS + * @script_index: The index of the requested script tag + * @language_index: The index of the requested language tag + * @feature_map: (out): The map of feature tag to feature index. + * + * Fetches the mapping from feature tags to feature indexes for + * the specified script and language. + * + * Since: 8.1.0 + **/ +void +hb_ot_layout_collect_features_map (hb_face_t *face, + hb_tag_t table_tag, + unsigned script_index, + unsigned language_index, + hb_map_t *feature_map /* OUT */) +{ + const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); + const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index); + + unsigned int count = l.get_feature_indexes (0, nullptr, nullptr); + feature_map->alloc (count); + + for (unsigned int i = 0; i < count; i++) + { + unsigned feature_index = 0; + unsigned feature_count = 1; + l.get_feature_indexes (i, &feature_count, &feature_index); + if (!feature_count) + break; + hb_tag_t feature_tag = g.get_feature_tag (feature_index); + feature_map->set (feature_tag, feature_index); + } +} + /** * hb_ot_layout_collect_lookups: diff --git a/thirdparty/harfbuzz/src/hb-ot-layout.h b/thirdparty/harfbuzz/src/hb-ot-layout.h index b0fae3707f..386b98d580 100644 --- a/thirdparty/harfbuzz/src/hb-ot-layout.h +++ b/thirdparty/harfbuzz/src/hb-ot-layout.h @@ -325,6 +325,13 @@ hb_ot_layout_collect_features (hb_face_t *face, hb_set_t *feature_indexes /* OUT */); HB_EXTERN void +hb_ot_layout_collect_features_map (hb_face_t *face, + hb_tag_t table_tag, + unsigned script_index, + unsigned language_index, + hb_map_t *feature_map /* OUT */); + +HB_EXTERN void hb_ot_layout_collect_lookups (hb_face_t *face, hb_tag_t table_tag, const hb_tag_t *scripts, diff --git a/thirdparty/harfbuzz/src/hb-ot-map.cc b/thirdparty/harfbuzz/src/hb-ot-map.cc index bacd56ef3f..fac73eb34e 100644 --- a/thirdparty/harfbuzz/src/hb-ot-map.cc +++ b/thirdparty/harfbuzz/src/hb-ot-map.cc @@ -239,6 +239,13 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, feature_infos.shrink (j + 1); } + hb_map_t feature_indices[2]; + for (unsigned int table_index = 0; table_index < 2; table_index++) + hb_ot_layout_collect_features_map (face, + table_tags[table_index], + script_index[table_index], + language_index[table_index], + &feature_indices[table_index]); /* Allocate bits now */ static_assert ((!(HB_GLYPH_FLAG_DEFINED & (HB_GLYPH_FLAG_DEFINED + 1))), ""); @@ -261,7 +268,6 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, if (!info->max_value || next_bit + bits_needed >= global_bit_shift) continue; /* Feature disabled, or not enough bits. */ - bool found = false; unsigned int feature_index[2]; for (unsigned int table_index = 0; table_index < 2; table_index++) @@ -269,12 +275,14 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, if (required_feature_tag[table_index] == info->tag) required_feature_stage[table_index] = info->stage[table_index]; - found |= (bool) hb_ot_layout_language_find_feature (face, - table_tags[table_index], - script_index[table_index], - language_index[table_index], - info->tag, - &feature_index[table_index]); + hb_codepoint_t *index; + if (feature_indices[table_index].has (info->tag, &index)) + { + feature_index[table_index] = *index; + found = true; + } + else + feature_index[table_index] = HB_OT_LAYOUT_NO_FEATURE_INDEX; } if (!found && (info->flags & F_GLOBAL_SEARCH)) { diff --git a/thirdparty/harfbuzz/src/hb-ot-shape.cc b/thirdparty/harfbuzz/src/hb-ot-shape.cc index d84313f190..9c1c2a950e 100644 --- a/thirdparty/harfbuzz/src/hb-ot-shape.cc +++ b/thirdparty/harfbuzz/src/hb-ot-shape.cc @@ -476,9 +476,18 @@ hb_set_unicode_props (hb_buffer_t *buffer) { _hb_glyph_info_set_unicode_props (&info[i], buffer); + unsigned gen_cat = _hb_glyph_info_get_general_category (&info[i]); + if (FLAG_UNSAFE (gen_cat) & + (FLAG (HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER) | + FLAG (HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER) | + FLAG (HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER) | + FLAG (HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER) | + FLAG (HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR))) + continue; + /* Marks are already set as continuation by the above line. * Handle Emoji_Modifier and ZWJ-continuation. */ - if (unlikely (_hb_glyph_info_get_general_category (&info[i]) == HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL && + if (unlikely (gen_cat == HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL && hb_in_range<hb_codepoint_t> (info[i].codepoint, 0x1F3FBu, 0x1F3FFu))) { _hb_glyph_info_set_continuation (&info[i]); @@ -756,6 +765,14 @@ hb_ot_shape_setup_masks_fraction (const hb_ot_shape_context_t *c) _hb_glyph_info_get_general_category (&info[end]) == HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER) end++; + if (start == i || end == i + 1) + { + if (start == i) + buffer->unsafe_to_concat (start, start + 1); + if (end == i + 1) + buffer->unsafe_to_concat (end - 1, end); + continue; + } buffer->unsafe_to_break (start, end); diff --git a/thirdparty/harfbuzz/src/hb-ot-shaper-use-machine.hh b/thirdparty/harfbuzz/src/hb-ot-shaper-use-machine.hh index 7249c33356..80a9b09d8e 100644 --- a/thirdparty/harfbuzz/src/hb-ot-shaper-use-machine.hh +++ b/thirdparty/harfbuzz/src/hb-ot-shaper-use-machine.hh @@ -1,32 +1,31 @@ - #line 1 "hb-ot-shaper-use-machine.rl" /* - * Copyright © 2015 Mozilla Foundation. - * Copyright © 2015 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Mozilla Author(s): Jonathan Kew - * Google Author(s): Behdad Esfahbod - */ +* Copyright © 2015 Mozilla Foundation. +* Copyright © 2015 Google, Inc. +* +* This is part of HarfBuzz, a text shaping library. +* +* Permission is hereby granted, without written agreement and without +* license or royalty fees, to use, copy, modify, and distribute this +* software and its documentation for any purpose, provided that the +* above copyright notice and the following two paragraphs appear in +* all copies of this software. +* +* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR +* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN +* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +* DAMAGE. +* +* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, +* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS +* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO +* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +* +* Mozilla Author(s): Jonathan Kew +* Google Author(s): Behdad Esfahbod +*/ #ifndef HB_OT_SHAPER_USE_MACHINE_HH #define HB_OT_SHAPER_USE_MACHINE_HH @@ -41,15 +40,15 @@ #define USE(Cat) use_syllable_machine_ex_##Cat enum use_syllable_type_t { - use_virama_terminated_cluster, - use_sakot_terminated_cluster, - use_standard_cluster, - use_number_joiner_terminated_cluster, - use_numeral_cluster, - use_symbol_cluster, - use_hieroglyph_cluster, - use_broken_cluster, - use_non_cluster, + use_virama_terminated_cluster, + use_sakot_terminated_cluster, + use_standard_cluster, + use_number_joiner_terminated_cluster, + use_numeral_cluster, + use_symbol_cluster, + use_hieroglyph_cluster, + use_broken_cluster, + use_non_cluster, }; @@ -99,724 +98,592 @@ enum use_syllable_type_t { #line 96 "hb-ot-shaper-use-machine.hh" static const unsigned char _use_syllable_machine_trans_keys[] = { - 0u, 53u, 11u, 53u, 11u, 53u, 1u, 53u, 14u, 48u, 14u, 47u, 14u, 47u, 14u, 47u, - 14u, 46u, 14u, 46u, 14u, 14u, 14u, 48u, 14u, 48u, 14u, 48u, 1u, 14u, 14u, 48u, - 14u, 53u, 14u, 53u, 14u, 53u, 14u, 53u, 12u, 53u, 14u, 53u, 12u, 53u, 12u, 53u, - 12u, 53u, 11u, 53u, 1u, 14u, 1u, 48u, 11u, 53u, 14u, 42u, 14u, 42u, 11u, 53u, - 11u, 53u, 1u, 53u, 14u, 48u, 14u, 47u, 14u, 47u, 14u, 47u, 14u, 46u, 14u, 46u, - 14u, 14u, 14u, 48u, 14u, 48u, 14u, 48u, 1u, 14u, 14u, 48u, 14u, 53u, 14u, 53u, - 14u, 53u, 14u, 53u, 12u, 53u, 14u, 53u, 12u, 53u, 12u, 53u, 12u, 53u, 11u, 53u, - 1u, 14u, 1u, 14u, 1u, 48u, 13u, 14u, 4u, 14u, 11u, 53u, 11u, 53u, 1u, 53u, - 14u, 48u, 14u, 47u, 14u, 47u, 14u, 47u, 14u, 46u, 14u, 46u, 14u, 14u, 14u, 48u, - 14u, 48u, 14u, 48u, 1u, 14u, 14u, 48u, 14u, 53u, 14u, 53u, 14u, 53u, 14u, 53u, - 12u, 53u, 14u, 53u, 12u, 53u, 12u, 53u, 12u, 53u, 11u, 53u, 1u, 14u, 1u, 14u, - 1u, 48u, 11u, 53u, 11u, 53u, 1u, 53u, 14u, 48u, 14u, 47u, 14u, 47u, 14u, 47u, - 14u, 46u, 14u, 46u, 14u, 14u, 14u, 48u, 14u, 48u, 14u, 48u, 1u, 14u, 14u, 48u, - 14u, 53u, 14u, 53u, 14u, 53u, 14u, 53u, 12u, 53u, 14u, 53u, 12u, 53u, 12u, 53u, - 12u, 53u, 11u, 53u, 1u, 14u, 1u, 48u, 4u, 14u, 13u, 14u, 1u, 53u, 11u, 53u, - 14u, 42u, 14u, 42u, 1u, 5u, 14u, 52u, 14u, 52u, 14u, 51u, 0 + 0u, 39u, 5u, 39u, 5u, 39u, 1u, 39u, + 8u, 34u, 8u, 33u, 8u, 33u, 8u, 33u, + 8u, 32u, 8u, 32u, 8u, 8u, 8u, 34u, + 8u, 34u, 8u, 34u, 1u, 8u, 8u, 34u, + 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, + 6u, 39u, 8u, 39u, 6u, 39u, 6u, 39u, + 6u, 39u, 5u, 39u, 1u, 8u, 1u, 34u, + 8u, 28u, 8u, 28u, 5u, 39u, 1u, 39u, + 8u, 34u, 8u, 33u, 8u, 33u, 8u, 33u, + 8u, 32u, 8u, 32u, 8u, 8u, 8u, 34u, + 8u, 34u, 8u, 34u, 1u, 8u, 8u, 34u, + 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, + 6u, 39u, 8u, 39u, 6u, 39u, 6u, 39u, + 6u, 39u, 5u, 39u, 1u, 8u, 1u, 8u, + 1u, 34u, 7u, 8u, 3u, 8u, 5u, 39u, + 5u, 39u, 1u, 39u, 8u, 34u, 8u, 33u, + 8u, 33u, 8u, 33u, 8u, 32u, 8u, 32u, + 8u, 8u, 8u, 34u, 8u, 34u, 8u, 34u, + 1u, 8u, 8u, 34u, 8u, 39u, 8u, 39u, + 8u, 39u, 8u, 39u, 6u, 39u, 8u, 39u, + 6u, 39u, 6u, 39u, 6u, 39u, 5u, 39u, + 1u, 8u, 1u, 8u, 1u, 34u, 5u, 39u, + 1u, 39u, 8u, 34u, 8u, 33u, 8u, 33u, + 8u, 33u, 8u, 32u, 8u, 32u, 8u, 8u, + 8u, 34u, 8u, 34u, 8u, 34u, 1u, 8u, + 8u, 34u, 8u, 39u, 8u, 39u, 8u, 39u, + 8u, 39u, 6u, 39u, 8u, 39u, 6u, 39u, + 6u, 39u, 6u, 39u, 5u, 39u, 1u, 8u, + 1u, 34u, 3u, 8u, 7u, 8u, 1u, 39u, + 8u, 28u, 8u, 28u, 1u, 4u, 8u, 38u, + 8u, 38u, 8u, 37u, 0u }; -static const char _use_syllable_machine_key_spans[] = { - 54, 43, 43, 53, 35, 34, 34, 34, - 33, 33, 1, 35, 35, 35, 14, 35, - 40, 40, 40, 40, 42, 40, 42, 42, - 42, 43, 14, 48, 43, 29, 29, 43, - 43, 53, 35, 34, 34, 34, 33, 33, - 1, 35, 35, 35, 14, 35, 40, 40, - 40, 40, 42, 40, 42, 42, 42, 43, - 14, 14, 48, 2, 11, 43, 43, 53, - 35, 34, 34, 34, 33, 33, 1, 35, - 35, 35, 14, 35, 40, 40, 40, 40, - 42, 40, 42, 42, 42, 43, 14, 14, - 48, 43, 43, 53, 35, 34, 34, 34, - 33, 33, 1, 35, 35, 35, 14, 35, - 40, 40, 40, 40, 42, 40, 42, 42, - 42, 43, 14, 48, 11, 2, 53, 43, - 29, 29, 5, 39, 39, 38 +static const signed char _use_syllable_machine_char_class[] = { + 0, 1, 2, 2, 3, 4, 2, 2, + 2, 2, 2, 5, 6, 7, 8, 2, + 2, 2, 9, 2, 2, 2, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 2, 24, 25, 26, + 2, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 0 }; static const short _use_syllable_machine_index_offsets[] = { - 0, 55, 99, 143, 197, 233, 268, 303, - 338, 372, 406, 408, 444, 480, 516, 531, - 567, 608, 649, 690, 731, 774, 815, 858, - 901, 944, 988, 1003, 1052, 1096, 1126, 1156, - 1200, 1244, 1298, 1334, 1369, 1404, 1439, 1473, - 1507, 1509, 1545, 1581, 1617, 1632, 1668, 1709, - 1750, 1791, 1832, 1875, 1916, 1959, 2002, 2045, - 2089, 2104, 2119, 2168, 2171, 2183, 2227, 2271, - 2325, 2361, 2396, 2431, 2466, 2500, 2534, 2536, - 2572, 2608, 2644, 2659, 2695, 2736, 2777, 2818, - 2859, 2902, 2943, 2986, 3029, 3072, 3116, 3131, - 3146, 3195, 3239, 3283, 3337, 3373, 3408, 3443, - 3478, 3512, 3546, 3548, 3584, 3620, 3656, 3671, - 3707, 3748, 3789, 3830, 3871, 3914, 3955, 3998, - 4041, 4084, 4128, 4143, 4192, 4204, 4207, 4261, - 4305, 4335, 4365, 4371, 4411, 4451 + 0, 40, 75, 110, 149, 176, 202, 228, + 254, 279, 304, 305, 332, 359, 386, 394, + 421, 453, 485, 517, 549, 583, 615, 649, + 683, 717, 752, 760, 794, 815, 836, 871, + 910, 937, 963, 989, 1015, 1040, 1065, 1066, + 1093, 1120, 1147, 1155, 1182, 1214, 1246, 1278, + 1310, 1344, 1376, 1410, 1444, 1478, 1513, 1521, + 1529, 1563, 1565, 1571, 1606, 1641, 1680, 1707, + 1733, 1759, 1785, 1810, 1835, 1836, 1863, 1890, + 1917, 1925, 1952, 1984, 2016, 2048, 2080, 2114, + 2146, 2180, 2214, 2248, 2283, 2291, 2299, 2333, + 2368, 2407, 2434, 2460, 2486, 2512, 2537, 2562, + 2563, 2590, 2617, 2644, 2652, 2679, 2711, 2743, + 2775, 2807, 2841, 2873, 2907, 2941, 2975, 3010, + 3018, 3052, 3058, 3060, 3099, 3120, 3141, 3145, + 3176, 3207, 0 +}; + +static const short _use_syllable_machine_indicies[] = { + 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 6, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 30, 34, 3, 35, 3, 36, + 38, 39, 37, 40, 37, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 38, 50, + 51, 52, 53, 54, 55, 56, 57, 58, + 37, 59, 60, 61, 62, 59, 37, 37, + 37, 37, 63, 38, 39, 37, 40, 37, + 41, 42, 43, 44, 45, 46, 47, 48, + 49, 38, 50, 51, 52, 53, 54, 55, + 56, 37, 37, 37, 59, 60, 61, 62, + 59, 37, 37, 37, 37, 63, 38, 37, + 37, 37, 37, 37, 37, 40, 37, 37, + 42, 43, 44, 45, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 54, 55, 56, + 37, 37, 37, 37, 60, 61, 62, 64, + 37, 37, 37, 37, 42, 40, 37, 37, + 42, 43, 44, 45, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 54, 55, 56, + 37, 37, 37, 37, 60, 61, 62, 64, + 40, 37, 37, 37, 43, 44, 45, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 60, + 61, 62, 40, 37, 37, 37, 37, 44, + 45, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 60, 61, 62, 40, 37, 37, 37, + 37, 37, 45, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 60, 61, 62, 40, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 60, 61, 40, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 61, + 40, 40, 37, 37, 37, 43, 44, 45, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 54, 55, 56, 37, 37, 37, 37, + 60, 61, 62, 64, 40, 37, 37, 37, + 43, 44, 45, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 55, 56, 37, + 37, 37, 37, 60, 61, 62, 64, 40, + 37, 37, 37, 43, 44, 45, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 56, 37, 37, 37, 37, 60, 61, + 62, 64, 65, 37, 37, 37, 37, 37, + 37, 40, 40, 37, 37, 37, 43, 44, + 45, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 60, 61, 62, 64, 40, 37, 41, + 42, 43, 44, 45, 37, 37, 37, 37, + 37, 37, 51, 52, 53, 54, 55, 56, + 37, 37, 37, 37, 60, 61, 62, 64, + 37, 37, 37, 37, 42, 40, 37, 37, + 42, 43, 44, 45, 37, 37, 37, 37, + 37, 37, 51, 52, 53, 54, 55, 56, + 37, 37, 37, 37, 60, 61, 62, 64, + 37, 37, 37, 37, 42, 40, 37, 37, + 42, 43, 44, 45, 37, 37, 37, 37, + 37, 37, 37, 52, 53, 54, 55, 56, + 37, 37, 37, 37, 60, 61, 62, 64, + 37, 37, 37, 37, 42, 40, 37, 37, + 42, 43, 44, 45, 37, 37, 37, 37, + 37, 37, 37, 37, 53, 54, 55, 56, + 37, 37, 37, 37, 60, 61, 62, 64, + 37, 37, 37, 37, 42, 66, 37, 40, + 37, 41, 42, 43, 44, 45, 37, 47, + 48, 37, 37, 37, 51, 52, 53, 54, + 55, 56, 37, 37, 37, 37, 60, 61, + 62, 64, 37, 37, 37, 37, 42, 40, + 37, 37, 42, 43, 44, 45, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 54, + 55, 56, 37, 37, 37, 37, 60, 61, + 62, 64, 37, 37, 37, 37, 42, 66, + 37, 40, 37, 41, 42, 43, 44, 45, + 37, 37, 48, 37, 37, 37, 51, 52, + 53, 54, 55, 56, 37, 37, 37, 37, + 60, 61, 62, 64, 37, 37, 37, 37, + 42, 66, 37, 40, 37, 41, 42, 43, + 44, 45, 37, 37, 37, 37, 37, 37, + 51, 52, 53, 54, 55, 56, 37, 37, + 37, 37, 60, 61, 62, 64, 37, 37, + 37, 37, 42, 66, 37, 40, 37, 41, + 42, 43, 44, 45, 46, 47, 48, 37, + 37, 37, 51, 52, 53, 54, 55, 56, + 37, 37, 37, 37, 60, 61, 62, 64, + 37, 37, 37, 37, 42, 38, 39, 37, + 40, 37, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 37, 50, 51, 52, 53, + 54, 55, 56, 37, 37, 37, 59, 60, + 61, 62, 59, 37, 37, 37, 37, 63, + 38, 37, 37, 37, 37, 37, 37, 40, + 38, 37, 37, 37, 37, 37, 37, 40, + 37, 37, 42, 43, 44, 45, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 54, + 55, 56, 37, 37, 37, 37, 60, 61, + 62, 64, 40, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 57, 58, 40, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 58, 2, 68, 67, 69, + 67, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 2, 79, 80, 81, 82, 83, + 84, 85, 67, 67, 67, 86, 87, 88, + 89, 90, 67, 67, 67, 67, 91, 2, + 67, 67, 67, 67, 67, 67, 69, 67, + 67, 71, 72, 73, 74, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 83, 84, + 85, 67, 67, 67, 67, 87, 88, 89, + 92, 67, 67, 67, 67, 71, 69, 67, + 67, 71, 72, 73, 74, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 83, 84, + 85, 67, 67, 67, 67, 87, 88, 89, + 92, 69, 67, 67, 67, 72, 73, 74, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 87, 88, 89, 69, 67, 67, 67, 67, + 73, 74, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 87, 88, 89, 69, 67, 67, + 67, 67, 67, 74, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 87, 88, 89, 69, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 87, 88, + 69, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 88, 69, 69, 67, 67, 67, 72, 73, + 74, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 83, 84, 85, 67, 67, 67, + 67, 87, 88, 89, 92, 69, 67, 67, + 67, 72, 73, 74, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 84, 85, + 67, 67, 67, 67, 87, 88, 89, 92, + 69, 67, 67, 67, 72, 73, 74, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 85, 67, 67, 67, 67, 87, + 88, 89, 92, 94, 93, 93, 93, 93, + 93, 93, 95, 69, 67, 67, 67, 72, + 73, 74, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 87, 88, 89, 92, 69, 67, + 70, 71, 72, 73, 74, 67, 67, 67, + 67, 67, 67, 80, 81, 82, 83, 84, + 85, 67, 67, 67, 67, 87, 88, 89, + 92, 67, 67, 67, 67, 71, 69, 67, + 67, 71, 72, 73, 74, 67, 67, 67, + 67, 67, 67, 80, 81, 82, 83, 84, + 85, 67, 67, 67, 67, 87, 88, 89, + 92, 67, 67, 67, 67, 71, 69, 67, + 67, 71, 72, 73, 74, 67, 67, 67, + 67, 67, 67, 67, 81, 82, 83, 84, + 85, 67, 67, 67, 67, 87, 88, 89, + 92, 67, 67, 67, 67, 71, 69, 67, + 67, 71, 72, 73, 74, 67, 67, 67, + 67, 67, 67, 67, 67, 82, 83, 84, + 85, 67, 67, 67, 67, 87, 88, 89, + 92, 67, 67, 67, 67, 71, 96, 67, + 69, 67, 70, 71, 72, 73, 74, 67, + 76, 77, 67, 67, 67, 80, 81, 82, + 83, 84, 85, 67, 67, 67, 67, 87, + 88, 89, 92, 67, 67, 67, 67, 71, + 69, 67, 67, 71, 72, 73, 74, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 83, 84, 85, 67, 67, 67, 67, 87, + 88, 89, 92, 67, 67, 67, 67, 71, + 96, 67, 69, 67, 70, 71, 72, 73, + 74, 67, 67, 77, 67, 67, 67, 80, + 81, 82, 83, 84, 85, 67, 67, 67, + 67, 87, 88, 89, 92, 67, 67, 67, + 67, 71, 96, 67, 69, 67, 70, 71, + 72, 73, 74, 67, 67, 67, 67, 67, + 67, 80, 81, 82, 83, 84, 85, 67, + 67, 67, 67, 87, 88, 89, 92, 67, + 67, 67, 67, 71, 96, 67, 69, 67, + 70, 71, 72, 73, 74, 75, 76, 77, + 67, 67, 67, 80, 81, 82, 83, 84, + 85, 67, 67, 67, 67, 87, 88, 89, + 92, 67, 67, 67, 67, 71, 2, 68, + 67, 69, 67, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 67, 79, 80, 81, + 82, 83, 84, 85, 67, 67, 67, 86, + 87, 88, 89, 90, 67, 67, 67, 67, + 91, 2, 97, 97, 97, 97, 97, 97, + 98, 2, 93, 93, 93, 93, 93, 93, + 95, 2, 67, 67, 67, 67, 67, 67, + 69, 67, 67, 71, 72, 73, 74, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 83, 84, 85, 67, 67, 67, 67, 87, + 88, 89, 92, 100, 101, 4, 102, 102, + 102, 102, 103, 104, 105, 67, 69, 67, + 106, 107, 108, 109, 110, 111, 112, 113, + 114, 104, 115, 116, 117, 118, 119, 120, + 121, 57, 58, 67, 122, 123, 124, 125, + 126, 67, 67, 67, 67, 127, 104, 105, + 67, 69, 67, 106, 107, 108, 109, 110, + 111, 112, 113, 114, 104, 115, 116, 117, + 118, 119, 120, 121, 67, 67, 67, 122, + 123, 124, 125, 126, 67, 67, 67, 67, + 127, 104, 67, 67, 67, 67, 67, 67, + 69, 67, 67, 107, 108, 109, 110, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 119, 120, 121, 67, 67, 67, 67, 123, + 124, 125, 128, 67, 67, 67, 67, 107, + 69, 67, 67, 107, 108, 109, 110, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 119, 120, 121, 67, 67, 67, 67, 123, + 124, 125, 128, 69, 67, 67, 67, 108, + 109, 110, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 123, 124, 125, 69, 67, 67, + 67, 67, 109, 110, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 123, 124, 125, 69, + 67, 67, 67, 67, 67, 110, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 123, 124, + 125, 69, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 123, 124, 69, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 124, 69, 69, 67, 67, 67, + 108, 109, 110, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 119, 120, 121, 67, + 67, 67, 67, 123, 124, 125, 128, 69, + 67, 67, 67, 108, 109, 110, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 120, 121, 67, 67, 67, 67, 123, 124, + 125, 128, 69, 67, 67, 67, 108, 109, + 110, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 121, 67, 67, 67, + 67, 123, 124, 125, 128, 129, 93, 93, + 93, 93, 93, 93, 95, 69, 67, 67, + 67, 108, 109, 110, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 123, 124, 125, 128, + 69, 67, 106, 107, 108, 109, 110, 67, + 67, 67, 67, 67, 67, 116, 117, 118, + 119, 120, 121, 67, 67, 67, 67, 123, + 124, 125, 128, 67, 67, 67, 67, 107, + 69, 67, 67, 107, 108, 109, 110, 67, + 67, 67, 67, 67, 67, 116, 117, 118, + 119, 120, 121, 67, 67, 67, 67, 123, + 124, 125, 128, 67, 67, 67, 67, 107, + 69, 67, 67, 107, 108, 109, 110, 67, + 67, 67, 67, 67, 67, 67, 117, 118, + 119, 120, 121, 67, 67, 67, 67, 123, + 124, 125, 128, 67, 67, 67, 67, 107, + 69, 67, 67, 107, 108, 109, 110, 67, + 67, 67, 67, 67, 67, 67, 67, 118, + 119, 120, 121, 67, 67, 67, 67, 123, + 124, 125, 128, 67, 67, 67, 67, 107, + 130, 67, 69, 67, 106, 107, 108, 109, + 110, 67, 112, 113, 67, 67, 67, 116, + 117, 118, 119, 120, 121, 67, 67, 67, + 67, 123, 124, 125, 128, 67, 67, 67, + 67, 107, 69, 67, 67, 107, 108, 109, + 110, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 119, 120, 121, 67, 67, 67, + 67, 123, 124, 125, 128, 67, 67, 67, + 67, 107, 130, 67, 69, 67, 106, 107, + 108, 109, 110, 67, 67, 113, 67, 67, + 67, 116, 117, 118, 119, 120, 121, 67, + 67, 67, 67, 123, 124, 125, 128, 67, + 67, 67, 67, 107, 130, 67, 69, 67, + 106, 107, 108, 109, 110, 67, 67, 67, + 67, 67, 67, 116, 117, 118, 119, 120, + 121, 67, 67, 67, 67, 123, 124, 125, + 128, 67, 67, 67, 67, 107, 130, 67, + 69, 67, 106, 107, 108, 109, 110, 111, + 112, 113, 67, 67, 67, 116, 117, 118, + 119, 120, 121, 67, 67, 67, 67, 123, + 124, 125, 128, 67, 67, 67, 67, 107, + 104, 105, 67, 69, 67, 106, 107, 108, + 109, 110, 111, 112, 113, 114, 67, 115, + 116, 117, 118, 119, 120, 121, 67, 67, + 67, 122, 123, 124, 125, 126, 67, 67, + 67, 67, 127, 104, 97, 97, 97, 97, + 97, 97, 98, 104, 93, 93, 93, 93, + 93, 93, 95, 104, 67, 67, 67, 67, + 67, 67, 69, 67, 67, 107, 108, 109, + 110, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 119, 120, 121, 67, 67, 67, + 67, 123, 124, 125, 128, 6, 7, 131, + 9, 131, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 6, 20, 21, 22, 23, + 24, 25, 26, 131, 131, 131, 30, 31, + 32, 33, 30, 131, 131, 131, 131, 36, + 6, 131, 131, 131, 131, 131, 131, 9, + 131, 131, 12, 13, 14, 15, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 24, + 25, 26, 131, 131, 131, 131, 31, 32, + 33, 132, 131, 131, 131, 131, 12, 9, + 131, 131, 12, 13, 14, 15, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 24, + 25, 26, 131, 131, 131, 131, 31, 32, + 33, 132, 9, 131, 131, 131, 13, 14, + 15, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 31, 32, 33, 9, 131, 131, 131, + 131, 14, 15, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 31, 32, 33, 9, 131, + 131, 131, 131, 131, 15, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 31, 32, 33, + 9, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 31, + 32, 9, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 32, 9, 9, 131, 131, 131, 13, + 14, 15, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 24, 25, 26, 131, 131, + 131, 131, 31, 32, 33, 132, 9, 131, + 131, 131, 13, 14, 15, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 25, + 26, 131, 131, 131, 131, 31, 32, 33, + 132, 9, 131, 131, 131, 13, 14, 15, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 26, 131, 131, 131, 131, + 31, 32, 33, 132, 133, 131, 131, 131, + 131, 131, 131, 9, 9, 131, 131, 131, + 13, 14, 15, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 31, 32, 33, 132, 9, + 131, 11, 12, 13, 14, 15, 131, 131, + 131, 131, 131, 131, 21, 22, 23, 24, + 25, 26, 131, 131, 131, 131, 31, 32, + 33, 132, 131, 131, 131, 131, 12, 9, + 131, 131, 12, 13, 14, 15, 131, 131, + 131, 131, 131, 131, 21, 22, 23, 24, + 25, 26, 131, 131, 131, 131, 31, 32, + 33, 132, 131, 131, 131, 131, 12, 9, + 131, 131, 12, 13, 14, 15, 131, 131, + 131, 131, 131, 131, 131, 22, 23, 24, + 25, 26, 131, 131, 131, 131, 31, 32, + 33, 132, 131, 131, 131, 131, 12, 9, + 131, 131, 12, 13, 14, 15, 131, 131, + 131, 131, 131, 131, 131, 131, 23, 24, + 25, 26, 131, 131, 131, 131, 31, 32, + 33, 132, 131, 131, 131, 131, 12, 134, + 131, 9, 131, 11, 12, 13, 14, 15, + 131, 17, 18, 131, 131, 131, 21, 22, + 23, 24, 25, 26, 131, 131, 131, 131, + 31, 32, 33, 132, 131, 131, 131, 131, + 12, 9, 131, 131, 12, 13, 14, 15, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 24, 25, 26, 131, 131, 131, 131, + 31, 32, 33, 132, 131, 131, 131, 131, + 12, 134, 131, 9, 131, 11, 12, 13, + 14, 15, 131, 131, 18, 131, 131, 131, + 21, 22, 23, 24, 25, 26, 131, 131, + 131, 131, 31, 32, 33, 132, 131, 131, + 131, 131, 12, 134, 131, 9, 131, 11, + 12, 13, 14, 15, 131, 131, 131, 131, + 131, 131, 21, 22, 23, 24, 25, 26, + 131, 131, 131, 131, 31, 32, 33, 132, + 131, 131, 131, 131, 12, 134, 131, 9, + 131, 11, 12, 13, 14, 15, 16, 17, + 18, 131, 131, 131, 21, 22, 23, 24, + 25, 26, 131, 131, 131, 131, 31, 32, + 33, 132, 131, 131, 131, 131, 12, 6, + 7, 131, 9, 131, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 131, 20, 21, + 22, 23, 24, 25, 26, 131, 131, 131, + 30, 31, 32, 33, 30, 131, 131, 131, + 131, 36, 6, 131, 131, 131, 131, 131, + 131, 9, 6, 131, 131, 131, 131, 131, + 131, 9, 131, 131, 12, 13, 14, 15, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 24, 25, 26, 131, 131, 131, 131, + 31, 32, 33, 132, 135, 131, 131, 131, + 131, 9, 8, 9, 2, 131, 131, 2, + 6, 7, 8, 9, 131, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 6, 20, + 21, 22, 23, 24, 25, 26, 27, 28, + 131, 30, 31, 32, 33, 30, 131, 131, + 131, 131, 36, 9, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 27, 28, + 9, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 28, 2, 136, 136, + 2, 138, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 139, 137, 34, + 138, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 34, 139, 137, 139, 138, + 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 34, 137, 35, 0 }; -static const unsigned char _use_syllable_machine_indicies[] = { - 0, 1, 2, 2, 3, 4, 2, 2, - 2, 2, 2, 5, 6, 7, 8, 2, - 2, 2, 9, 2, 2, 2, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 2, 24, 25, 26, - 2, 27, 28, 29, 30, 31, 32, 33, - 30, 34, 2, 35, 2, 36, 2, 38, - 39, 37, 40, 37, 37, 37, 37, 37, - 37, 37, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, - 37, 55, 56, 57, 37, 58, 59, 37, - 60, 61, 62, 63, 60, 37, 37, 37, - 37, 64, 37, 38, 39, 37, 40, 37, - 37, 37, 37, 37, 37, 37, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 51, - 51, 52, 53, 54, 37, 55, 56, 57, - 37, 37, 37, 37, 60, 61, 62, 63, - 60, 37, 37, 37, 37, 64, 37, 38, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 40, 37, 37, 37, - 37, 37, 37, 37, 37, 42, 43, 44, - 45, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 55, 56, 57, 37, 37, - 37, 37, 37, 61, 62, 63, 65, 37, - 37, 37, 37, 42, 37, 40, 37, 37, - 37, 37, 37, 37, 37, 37, 42, 43, - 44, 45, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 55, 56, 57, 37, - 37, 37, 37, 37, 61, 62, 63, 65, - 37, 40, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 43, 44, 45, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 61, 62, 63, 37, 40, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 44, - 45, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 61, 62, 63, 37, 40, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 45, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 61, 62, - 63, 37, 40, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 61, 62, 37, 40, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 62, 37, 40, 37, - 40, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 43, 44, 45, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 55, - 56, 57, 37, 37, 37, 37, 37, 61, - 62, 63, 65, 37, 40, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 43, 44, - 45, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 56, 57, 37, 37, - 37, 37, 37, 61, 62, 63, 65, 37, - 40, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 43, 44, 45, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 57, 37, 37, 37, 37, 37, 61, - 62, 63, 65, 37, 66, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 40, 37, 40, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 43, 44, 45, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 61, 62, 63, 65, 37, 40, - 37, 37, 37, 37, 37, 37, 37, 41, - 42, 43, 44, 45, 37, 37, 37, 37, - 37, 37, 52, 53, 54, 37, 55, 56, - 57, 37, 37, 37, 37, 37, 61, 62, - 63, 65, 37, 37, 37, 37, 42, 37, - 40, 37, 37, 37, 37, 37, 37, 37, - 37, 42, 43, 44, 45, 37, 37, 37, - 37, 37, 37, 52, 53, 54, 37, 55, - 56, 57, 37, 37, 37, 37, 37, 61, - 62, 63, 65, 37, 37, 37, 37, 42, - 37, 40, 37, 37, 37, 37, 37, 37, - 37, 37, 42, 43, 44, 45, 37, 37, - 37, 37, 37, 37, 37, 53, 54, 37, - 55, 56, 57, 37, 37, 37, 37, 37, - 61, 62, 63, 65, 37, 37, 37, 37, - 42, 37, 40, 37, 37, 37, 37, 37, - 37, 37, 37, 42, 43, 44, 45, 37, - 37, 37, 37, 37, 37, 37, 37, 54, - 37, 55, 56, 57, 37, 37, 37, 37, - 37, 61, 62, 63, 65, 37, 37, 37, - 37, 42, 37, 67, 37, 40, 37, 37, - 37, 37, 37, 37, 37, 41, 42, 43, - 44, 45, 37, 47, 48, 37, 37, 37, - 52, 53, 54, 37, 55, 56, 57, 37, - 37, 37, 37, 37, 61, 62, 63, 65, - 37, 37, 37, 37, 42, 37, 40, 37, - 37, 37, 37, 37, 37, 37, 37, 42, - 43, 44, 45, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 55, 56, 57, - 37, 37, 37, 37, 37, 61, 62, 63, - 65, 37, 37, 37, 37, 42, 37, 67, - 37, 40, 37, 37, 37, 37, 37, 37, - 37, 41, 42, 43, 44, 45, 37, 37, - 48, 37, 37, 37, 52, 53, 54, 37, - 55, 56, 57, 37, 37, 37, 37, 37, - 61, 62, 63, 65, 37, 37, 37, 37, - 42, 37, 67, 37, 40, 37, 37, 37, - 37, 37, 37, 37, 41, 42, 43, 44, - 45, 37, 37, 37, 37, 37, 37, 52, - 53, 54, 37, 55, 56, 57, 37, 37, - 37, 37, 37, 61, 62, 63, 65, 37, - 37, 37, 37, 42, 37, 67, 37, 40, - 37, 37, 37, 37, 37, 37, 37, 41, - 42, 43, 44, 45, 46, 47, 48, 37, - 37, 37, 52, 53, 54, 37, 55, 56, - 57, 37, 37, 37, 37, 37, 61, 62, - 63, 65, 37, 37, 37, 37, 42, 37, - 38, 39, 37, 40, 37, 37, 37, 37, - 37, 37, 37, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 37, 51, 52, 53, - 54, 37, 55, 56, 57, 37, 37, 37, - 37, 60, 61, 62, 63, 60, 37, 37, - 37, 37, 64, 37, 38, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 40, 37, 38, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 40, 37, 37, 37, 37, 37, 37, 37, - 37, 42, 43, 44, 45, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 55, - 56, 57, 37, 37, 37, 37, 37, 61, - 62, 63, 65, 37, 38, 39, 37, 40, - 37, 37, 37, 37, 37, 37, 37, 41, - 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 37, 55, 56, - 57, 37, 37, 37, 37, 60, 61, 62, - 63, 60, 37, 37, 37, 37, 64, 37, - 40, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 58, 59, 37, 40, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 59, 37, 69, 70, 68, 71, - 68, 68, 68, 68, 68, 68, 68, 72, - 73, 74, 75, 76, 77, 78, 79, 80, - 1, 81, 82, 83, 84, 68, 85, 86, - 87, 68, 68, 68, 68, 88, 89, 90, - 91, 92, 68, 68, 68, 68, 93, 68, - 69, 70, 68, 71, 68, 68, 68, 68, - 68, 68, 68, 72, 73, 74, 75, 76, - 77, 78, 79, 80, 81, 81, 82, 83, - 84, 68, 85, 86, 87, 68, 68, 68, - 68, 88, 89, 90, 91, 92, 68, 68, - 68, 68, 93, 68, 69, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 71, 68, 68, 68, 68, 68, 68, - 68, 68, 73, 74, 75, 76, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 85, 86, 87, 68, 68, 68, 68, 68, - 89, 90, 91, 94, 68, 68, 68, 68, - 73, 68, 71, 68, 68, 68, 68, 68, - 68, 68, 68, 73, 74, 75, 76, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 85, 86, 87, 68, 68, 68, 68, - 68, 89, 90, 91, 94, 68, 71, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 74, 75, 76, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 89, 90, 91, - 68, 71, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 75, 76, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 89, 90, 91, 68, 71, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 76, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 89, 90, 91, 68, 71, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 89, 90, - 68, 71, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 90, 68, 71, 68, 71, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 74, - 75, 76, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 85, 86, 87, 68, - 68, 68, 68, 68, 89, 90, 91, 94, - 68, 71, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 74, 75, 76, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 86, 87, 68, 68, 68, 68, 68, - 89, 90, 91, 94, 68, 71, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 74, - 75, 76, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 87, 68, - 68, 68, 68, 68, 89, 90, 91, 94, - 68, 96, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 97, 95, - 71, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 74, 75, 76, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 89, - 90, 91, 94, 68, 71, 68, 68, 68, - 68, 68, 68, 68, 72, 73, 74, 75, - 76, 68, 68, 68, 68, 68, 68, 82, - 83, 84, 68, 85, 86, 87, 68, 68, - 68, 68, 68, 89, 90, 91, 94, 68, - 68, 68, 68, 73, 68, 71, 68, 68, - 68, 68, 68, 68, 68, 68, 73, 74, - 75, 76, 68, 68, 68, 68, 68, 68, - 82, 83, 84, 68, 85, 86, 87, 68, - 68, 68, 68, 68, 89, 90, 91, 94, - 68, 68, 68, 68, 73, 68, 71, 68, - 68, 68, 68, 68, 68, 68, 68, 73, - 74, 75, 76, 68, 68, 68, 68, 68, - 68, 68, 83, 84, 68, 85, 86, 87, - 68, 68, 68, 68, 68, 89, 90, 91, - 94, 68, 68, 68, 68, 73, 68, 71, - 68, 68, 68, 68, 68, 68, 68, 68, - 73, 74, 75, 76, 68, 68, 68, 68, - 68, 68, 68, 68, 84, 68, 85, 86, - 87, 68, 68, 68, 68, 68, 89, 90, - 91, 94, 68, 68, 68, 68, 73, 68, - 98, 68, 71, 68, 68, 68, 68, 68, - 68, 68, 72, 73, 74, 75, 76, 68, - 78, 79, 68, 68, 68, 82, 83, 84, - 68, 85, 86, 87, 68, 68, 68, 68, - 68, 89, 90, 91, 94, 68, 68, 68, - 68, 73, 68, 71, 68, 68, 68, 68, - 68, 68, 68, 68, 73, 74, 75, 76, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 85, 86, 87, 68, 68, 68, - 68, 68, 89, 90, 91, 94, 68, 68, - 68, 68, 73, 68, 98, 68, 71, 68, - 68, 68, 68, 68, 68, 68, 72, 73, - 74, 75, 76, 68, 68, 79, 68, 68, - 68, 82, 83, 84, 68, 85, 86, 87, - 68, 68, 68, 68, 68, 89, 90, 91, - 94, 68, 68, 68, 68, 73, 68, 98, - 68, 71, 68, 68, 68, 68, 68, 68, - 68, 72, 73, 74, 75, 76, 68, 68, - 68, 68, 68, 68, 82, 83, 84, 68, - 85, 86, 87, 68, 68, 68, 68, 68, - 89, 90, 91, 94, 68, 68, 68, 68, - 73, 68, 98, 68, 71, 68, 68, 68, - 68, 68, 68, 68, 72, 73, 74, 75, - 76, 77, 78, 79, 68, 68, 68, 82, - 83, 84, 68, 85, 86, 87, 68, 68, - 68, 68, 68, 89, 90, 91, 94, 68, - 68, 68, 68, 73, 68, 69, 70, 68, - 71, 68, 68, 68, 68, 68, 68, 68, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 68, 81, 82, 83, 84, 68, 85, - 86, 87, 68, 68, 68, 68, 88, 89, - 90, 91, 92, 68, 68, 68, 68, 93, - 68, 69, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 100, 99, - 69, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 97, 95, 69, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 71, 68, 68, 68, - 68, 68, 68, 68, 68, 73, 74, 75, - 76, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 85, 86, 87, 68, 68, - 68, 68, 68, 89, 90, 91, 94, 68, - 102, 103, 101, 3, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 105, 104, 106, - 107, 68, 71, 68, 68, 68, 68, 68, - 68, 68, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, - 68, 122, 123, 124, 68, 58, 59, 68, - 125, 126, 127, 128, 129, 68, 68, 68, - 68, 130, 68, 106, 107, 68, 71, 68, - 68, 68, 68, 68, 68, 68, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 118, - 118, 119, 120, 121, 68, 122, 123, 124, - 68, 68, 68, 68, 125, 126, 127, 128, - 129, 68, 68, 68, 68, 130, 68, 106, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 71, 68, 68, 68, - 68, 68, 68, 68, 68, 109, 110, 111, - 112, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 122, 123, 124, 68, 68, - 68, 68, 68, 126, 127, 128, 131, 68, - 68, 68, 68, 109, 68, 71, 68, 68, - 68, 68, 68, 68, 68, 68, 109, 110, - 111, 112, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 122, 123, 124, 68, - 68, 68, 68, 68, 126, 127, 128, 131, - 68, 71, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 110, 111, 112, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 126, 127, 128, 68, 71, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 111, - 112, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 126, 127, 128, 68, 71, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 112, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 126, 127, - 128, 68, 71, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 126, 127, 68, 71, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 127, 68, 71, 68, - 71, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 110, 111, 112, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 122, - 123, 124, 68, 68, 68, 68, 68, 126, - 127, 128, 131, 68, 71, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 110, 111, - 112, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 123, 124, 68, 68, - 68, 68, 68, 126, 127, 128, 131, 68, - 71, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 110, 111, 112, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 124, 68, 68, 68, 68, 68, 126, - 127, 128, 131, 68, 132, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 97, 95, 71, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 110, 111, 112, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 126, 127, 128, 131, 68, 71, - 68, 68, 68, 68, 68, 68, 68, 108, - 109, 110, 111, 112, 68, 68, 68, 68, - 68, 68, 119, 120, 121, 68, 122, 123, - 124, 68, 68, 68, 68, 68, 126, 127, - 128, 131, 68, 68, 68, 68, 109, 68, - 71, 68, 68, 68, 68, 68, 68, 68, - 68, 109, 110, 111, 112, 68, 68, 68, - 68, 68, 68, 119, 120, 121, 68, 122, - 123, 124, 68, 68, 68, 68, 68, 126, - 127, 128, 131, 68, 68, 68, 68, 109, - 68, 71, 68, 68, 68, 68, 68, 68, - 68, 68, 109, 110, 111, 112, 68, 68, - 68, 68, 68, 68, 68, 120, 121, 68, - 122, 123, 124, 68, 68, 68, 68, 68, - 126, 127, 128, 131, 68, 68, 68, 68, - 109, 68, 71, 68, 68, 68, 68, 68, - 68, 68, 68, 109, 110, 111, 112, 68, - 68, 68, 68, 68, 68, 68, 68, 121, - 68, 122, 123, 124, 68, 68, 68, 68, - 68, 126, 127, 128, 131, 68, 68, 68, - 68, 109, 68, 133, 68, 71, 68, 68, - 68, 68, 68, 68, 68, 108, 109, 110, - 111, 112, 68, 114, 115, 68, 68, 68, - 119, 120, 121, 68, 122, 123, 124, 68, - 68, 68, 68, 68, 126, 127, 128, 131, - 68, 68, 68, 68, 109, 68, 71, 68, - 68, 68, 68, 68, 68, 68, 68, 109, - 110, 111, 112, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 122, 123, 124, - 68, 68, 68, 68, 68, 126, 127, 128, - 131, 68, 68, 68, 68, 109, 68, 133, - 68, 71, 68, 68, 68, 68, 68, 68, - 68, 108, 109, 110, 111, 112, 68, 68, - 115, 68, 68, 68, 119, 120, 121, 68, - 122, 123, 124, 68, 68, 68, 68, 68, - 126, 127, 128, 131, 68, 68, 68, 68, - 109, 68, 133, 68, 71, 68, 68, 68, - 68, 68, 68, 68, 108, 109, 110, 111, - 112, 68, 68, 68, 68, 68, 68, 119, - 120, 121, 68, 122, 123, 124, 68, 68, - 68, 68, 68, 126, 127, 128, 131, 68, - 68, 68, 68, 109, 68, 133, 68, 71, - 68, 68, 68, 68, 68, 68, 68, 108, - 109, 110, 111, 112, 113, 114, 115, 68, - 68, 68, 119, 120, 121, 68, 122, 123, - 124, 68, 68, 68, 68, 68, 126, 127, - 128, 131, 68, 68, 68, 68, 109, 68, - 106, 107, 68, 71, 68, 68, 68, 68, - 68, 68, 68, 108, 109, 110, 111, 112, - 113, 114, 115, 116, 68, 118, 119, 120, - 121, 68, 122, 123, 124, 68, 68, 68, - 68, 125, 126, 127, 128, 129, 68, 68, - 68, 68, 130, 68, 106, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 100, 99, 106, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 97, 95, 106, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 71, - 68, 68, 68, 68, 68, 68, 68, 68, - 109, 110, 111, 112, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 122, 123, - 124, 68, 68, 68, 68, 68, 126, 127, - 128, 131, 68, 106, 107, 68, 71, 68, - 68, 68, 68, 68, 68, 68, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 68, 122, 123, 124, - 68, 68, 68, 68, 125, 126, 127, 128, - 129, 68, 68, 68, 68, 130, 68, 5, - 6, 134, 8, 134, 134, 134, 134, 134, - 134, 134, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 20, 20, 21, 22, 23, - 134, 24, 25, 26, 134, 134, 134, 134, - 30, 31, 32, 33, 30, 134, 134, 134, - 134, 36, 134, 5, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 8, 134, 134, 134, 134, 134, 134, 134, - 134, 11, 12, 13, 14, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 24, - 25, 26, 134, 134, 134, 134, 134, 31, - 32, 33, 135, 134, 134, 134, 134, 11, - 134, 8, 134, 134, 134, 134, 134, 134, - 134, 134, 11, 12, 13, 14, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 24, 25, 26, 134, 134, 134, 134, 134, - 31, 32, 33, 135, 134, 8, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 12, - 13, 14, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 31, 32, 33, 134, - 8, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 13, 14, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 31, - 32, 33, 134, 8, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 14, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 31, 32, 33, 134, 8, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 31, 32, 134, - 8, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 32, 134, 8, 134, 8, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 12, 13, - 14, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 24, 25, 26, 134, 134, - 134, 134, 134, 31, 32, 33, 135, 134, - 8, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 12, 13, 14, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 25, 26, 134, 134, 134, 134, 134, 31, - 32, 33, 135, 134, 8, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 12, 13, - 14, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 26, 134, 134, - 134, 134, 134, 31, 32, 33, 135, 134, - 136, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 8, 134, 8, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 12, 13, 14, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 31, 32, - 33, 135, 134, 8, 134, 134, 134, 134, - 134, 134, 134, 10, 11, 12, 13, 14, - 134, 134, 134, 134, 134, 134, 21, 22, - 23, 134, 24, 25, 26, 134, 134, 134, - 134, 134, 31, 32, 33, 135, 134, 134, - 134, 134, 11, 134, 8, 134, 134, 134, - 134, 134, 134, 134, 134, 11, 12, 13, - 14, 134, 134, 134, 134, 134, 134, 21, - 22, 23, 134, 24, 25, 26, 134, 134, - 134, 134, 134, 31, 32, 33, 135, 134, - 134, 134, 134, 11, 134, 8, 134, 134, - 134, 134, 134, 134, 134, 134, 11, 12, - 13, 14, 134, 134, 134, 134, 134, 134, - 134, 22, 23, 134, 24, 25, 26, 134, - 134, 134, 134, 134, 31, 32, 33, 135, - 134, 134, 134, 134, 11, 134, 8, 134, - 134, 134, 134, 134, 134, 134, 134, 11, - 12, 13, 14, 134, 134, 134, 134, 134, - 134, 134, 134, 23, 134, 24, 25, 26, - 134, 134, 134, 134, 134, 31, 32, 33, - 135, 134, 134, 134, 134, 11, 134, 137, - 134, 8, 134, 134, 134, 134, 134, 134, - 134, 10, 11, 12, 13, 14, 134, 16, - 17, 134, 134, 134, 21, 22, 23, 134, - 24, 25, 26, 134, 134, 134, 134, 134, - 31, 32, 33, 135, 134, 134, 134, 134, - 11, 134, 8, 134, 134, 134, 134, 134, - 134, 134, 134, 11, 12, 13, 14, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 24, 25, 26, 134, 134, 134, 134, - 134, 31, 32, 33, 135, 134, 134, 134, - 134, 11, 134, 137, 134, 8, 134, 134, - 134, 134, 134, 134, 134, 10, 11, 12, - 13, 14, 134, 134, 17, 134, 134, 134, - 21, 22, 23, 134, 24, 25, 26, 134, - 134, 134, 134, 134, 31, 32, 33, 135, - 134, 134, 134, 134, 11, 134, 137, 134, - 8, 134, 134, 134, 134, 134, 134, 134, - 10, 11, 12, 13, 14, 134, 134, 134, - 134, 134, 134, 21, 22, 23, 134, 24, - 25, 26, 134, 134, 134, 134, 134, 31, - 32, 33, 135, 134, 134, 134, 134, 11, - 134, 137, 134, 8, 134, 134, 134, 134, - 134, 134, 134, 10, 11, 12, 13, 14, - 15, 16, 17, 134, 134, 134, 21, 22, - 23, 134, 24, 25, 26, 134, 134, 134, - 134, 134, 31, 32, 33, 135, 134, 134, - 134, 134, 11, 134, 5, 6, 134, 8, - 134, 134, 134, 134, 134, 134, 134, 10, - 11, 12, 13, 14, 15, 16, 17, 18, - 134, 20, 21, 22, 23, 134, 24, 25, - 26, 134, 134, 134, 134, 30, 31, 32, - 33, 30, 134, 134, 134, 134, 36, 134, - 5, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 8, 134, 5, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 8, 134, 134, 134, - 134, 134, 134, 134, 134, 11, 12, 13, - 14, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 24, 25, 26, 134, 134, - 134, 134, 134, 31, 32, 33, 135, 134, - 138, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 8, 134, 7, 8, 134, 1, - 134, 134, 134, 1, 134, 134, 134, 134, - 134, 5, 6, 7, 8, 134, 134, 134, - 134, 134, 134, 134, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 134, 24, 25, 26, 134, 27, - 28, 134, 30, 31, 32, 33, 30, 134, - 134, 134, 134, 36, 134, 5, 6, 134, - 8, 134, 134, 134, 134, 134, 134, 134, - 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 134, 24, - 25, 26, 134, 134, 134, 134, 30, 31, - 32, 33, 30, 134, 134, 134, 134, 36, - 134, 8, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 27, 28, 134, 8, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 28, 134, 1, 139, 139, - 139, 1, 139, 141, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 142, - 140, 34, 140, 141, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 34, 142, - 140, 142, 140, 141, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 34, 140, - 35, 140, 0 +static const short _use_syllable_machine_index_defaults[] = { + 3, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 93, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 97, 93, + 67, 99, 102, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, + 93, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 97, 93, 67, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 136, 137, + 137, 137, 0 }; -static const char _use_syllable_machine_trans_targs[] = { - 1, 31, 0, 59, 61, 90, 91, 116, - 0, 118, 104, 92, 93, 94, 95, 108, - 110, 111, 112, 119, 113, 105, 106, 107, - 99, 100, 101, 120, 121, 122, 114, 96, - 97, 98, 123, 125, 115, 0, 2, 3, - 0, 16, 4, 5, 6, 7, 20, 22, - 23, 24, 28, 25, 17, 18, 19, 11, - 12, 13, 29, 30, 26, 8, 9, 10, - 27, 14, 15, 21, 0, 32, 33, 0, - 46, 34, 35, 36, 37, 50, 52, 53, - 54, 55, 47, 48, 49, 41, 42, 43, - 56, 38, 39, 40, 57, 58, 44, 0, - 45, 0, 51, 0, 0, 0, 60, 0, - 0, 0, 62, 63, 76, 64, 65, 66, - 67, 80, 82, 83, 84, 89, 85, 77, - 78, 79, 71, 72, 73, 86, 68, 69, - 70, 87, 88, 74, 75, 81, 0, 102, - 103, 109, 117, 0, 0, 0, 124 +static const signed char _use_syllable_machine_cond_targs[] = { + 0, 1, 30, 0, 57, 59, 87, 88, + 113, 0, 115, 101, 89, 90, 91, 92, + 105, 107, 108, 109, 110, 102, 103, 104, + 96, 97, 98, 116, 117, 118, 111, 93, + 94, 95, 119, 121, 112, 0, 2, 3, + 0, 16, 4, 5, 6, 7, 20, 22, + 23, 24, 25, 17, 18, 19, 11, 12, + 13, 28, 29, 26, 8, 9, 10, 27, + 14, 15, 21, 0, 31, 0, 44, 32, + 33, 34, 35, 48, 50, 51, 52, 53, + 45, 46, 47, 39, 40, 41, 54, 36, + 37, 38, 55, 56, 42, 0, 43, 0, + 49, 0, 0, 0, 58, 0, 0, 0, + 60, 61, 74, 62, 63, 64, 65, 78, + 80, 81, 82, 83, 75, 76, 77, 69, + 70, 71, 84, 66, 67, 68, 85, 86, + 72, 73, 79, 0, 99, 100, 106, 114, + 0, 0, 0, 120, 0 }; -static const char _use_syllable_machine_trans_actions[] = { - 0, 0, 3, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 5, 0, 0, - 6, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 0, 0, 8, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 9, - 0, 10, 0, 11, 12, 13, 0, 14, - 15, 16, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 17, 0, - 0, 0, 0, 18, 19, 20, 0 +static const signed char _use_syllable_machine_cond_actions[] = { + 0, 0, 0, 3, 0, 0, 0, 0, + 0, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 5, 0, 0, + 6, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 0, 8, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 10, + 0, 11, 12, 13, 0, 14, 15, 16, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 17, 0, 0, 0, 0, + 18, 19, 20, 0, 0 }; -static const char _use_syllable_machine_to_state_actions[] = { - 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 +static const signed char _use_syllable_machine_to_state_actions[] = { + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 }; -static const char _use_syllable_machine_from_state_actions[] = { - 2, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 +static const signed char _use_syllable_machine_from_state_actions[] = { + 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 }; static const short _use_syllable_machine_eof_trans[] = { - 0, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 69, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 96, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, - 100, 96, 69, 102, 105, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 96, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 100, 96, - 69, 69, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 140, 141, 141, 141 + 1, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 94, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 98, 94, + 68, 100, 103, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, + 94, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 98, 94, 68, 132, + 132, 132, 132, 132, 132, 132, 132, 132, + 132, 132, 132, 132, 132, 132, 132, 132, + 132, 132, 132, 132, 132, 132, 132, 132, + 132, 132, 132, 132, 132, 132, 137, 138, + 138, 138, 0 }; static const int use_syllable_machine_start = 0; @@ -834,65 +701,65 @@ static const int use_syllable_machine_en_main = 0; #define found_syllable(syllable_type) \ - HB_STMT_START { \ - if (0) fprintf (stderr, "syllable %u..%u %s\n", (*ts).second.first, (*te).second.first, #syllable_type); \ - for (unsigned i = (*ts).second.first; i < (*te).second.first; ++i) \ - info[i].syllable() = (syllable_serial << 4) | syllable_type; \ - syllable_serial++; \ - if (syllable_serial == 16) syllable_serial = 1; \ - } HB_STMT_END +HB_STMT_START { \ + if (0) fprintf (stderr, "syllable %u..%u %s\n", (*ts).second.first, (*te).second.first, #syllable_type); \ + for (unsigned i = (*ts).second.first; i < (*te).second.first; ++i) \ + info[i].syllable() = (syllable_serial << 4) | syllable_type; \ + syllable_serial++; \ + if (syllable_serial == 16) syllable_serial = 1; \ + } HB_STMT_END template <typename Iter> struct machine_index_t : - hb_iter_with_fallback_t<machine_index_t<Iter>, - typename Iter::item_t> +hb_iter_with_fallback_t<machine_index_t<Iter>, +typename Iter::item_t> { - machine_index_t (const Iter& it) : it (it) {} - machine_index_t (const machine_index_t& o) : hb_iter_with_fallback_t<machine_index_t<Iter>, - typename Iter::item_t> (), - it (o.it), is_null (o.is_null) {} - - static constexpr bool is_random_access_iterator = Iter::is_random_access_iterator; - static constexpr bool is_sorted_iterator = Iter::is_sorted_iterator; - - typename Iter::item_t __item__ () const { return *it; } - typename Iter::item_t __item_at__ (unsigned i) const { return it[i]; } - unsigned __len__ () const { return it.len (); } - void __next__ () { ++it; } - void __forward__ (unsigned n) { it += n; } - void __prev__ () { --it; } - void __rewind__ (unsigned n) { it -= n; } - - void operator = (unsigned n) - { - assert (n == 0); - is_null = true; - } - explicit operator bool () { return !is_null; } - - void operator = (const machine_index_t& o) - { - is_null = o.is_null; - unsigned index = (*it).first; - unsigned n = (*o.it).first; - if (index < n) it += n - index; else if (index > n) it -= index - n; - } - bool operator == (const machine_index_t& o) const - { return is_null ? o.is_null : !o.is_null && (*it).first == (*o.it).first; } - bool operator != (const machine_index_t& o) const { return !(*this == o); } - - private: - Iter it; - bool is_null = false; + machine_index_t (const Iter& it) : it (it) {} + machine_index_t (const machine_index_t& o) : hb_iter_with_fallback_t<machine_index_t<Iter>, + typename Iter::item_t> (), + it (o.it), is_null (o.is_null) {} + + static constexpr bool is_random_access_iterator = Iter::is_random_access_iterator; + static constexpr bool is_sorted_iterator = Iter::is_sorted_iterator; + + typename Iter::item_t __item__ () const { return *it; } + typename Iter::item_t __item_at__ (unsigned i) const { return it[i]; } + unsigned __len__ () const { return it.len (); } + void __next__ () { ++it; } + void __forward__ (unsigned n) { it += n; } + void __prev__ () { --it; } + void __rewind__ (unsigned n) { it -= n; } + + void operator = (unsigned n) + { + assert (n == 0); + is_null = true; + } + explicit operator bool () { return !is_null; } + + void operator = (const machine_index_t& o) + { + is_null = o.is_null; + unsigned index = (*it).first; + unsigned n = (*o.it).first; + if (index < n) it += n - index; else if (index > n) it -= index - n; + } + bool operator == (const machine_index_t& o) const + { return is_null ? o.is_null : !o.is_null && (*it).first == (*o.it).first; } + bool operator != (const machine_index_t& o) const { return !(*this == o); } + + private: + Iter it; + bool is_null = false; }; struct { - template <typename Iter, - hb_requires (hb_is_iterable (Iter))> - machine_index_t<hb_iter_type<Iter>> - operator () (Iter&& it) const - { return machine_index_t<hb_iter_type<Iter>> (hb_iter (it)); } + template <typename Iter, + hb_requires (hb_is_iterable (Iter))> + machine_index_t<hb_iter_type<Iter>> + operator () (Iter&& it) const + { return machine_index_t<hb_iter_type<Iter>> (hb_iter (it)); } } HB_FUNCOBJ (machine_index); @@ -905,172 +772,352 @@ not_ccs_default_ignorable (const hb_glyph_info_t &i) static inline void find_syllables_use (hb_buffer_t *buffer) { - hb_glyph_info_t *info = buffer->info; - auto p = - + hb_iter (info, buffer->len) - | hb_enumerate - | hb_filter ([] (const hb_glyph_info_t &i) { return not_ccs_default_ignorable (i); }, - hb_second) - | hb_filter ([&] (const hb_pair_t<unsigned, const hb_glyph_info_t &> p) - { - if (p.second.use_category() == USE(ZWNJ)) - for (unsigned i = p.first + 1; i < buffer->len; ++i) - if (not_ccs_default_ignorable (info[i])) - return !_hb_glyph_info_is_unicode_mark (&info[i]); - return true; - }) - | hb_enumerate - | machine_index - ; - auto pe = p + p.len (); - auto eof = +pe; - auto ts = +p; - auto te = +p; - unsigned int act HB_UNUSED; - int cs; - -#line 922 "hb-ot-shaper-use-machine.hh" + hb_glyph_info_t *info = buffer->info; + auto p = + + hb_iter (info, buffer->len) + | hb_enumerate + | hb_filter ([] (const hb_glyph_info_t &i) { return not_ccs_default_ignorable (i); }, + hb_second) + | hb_filter ([&] (const hb_pair_t<unsigned, const hb_glyph_info_t &> p) { - cs = use_syllable_machine_start; - ts = 0; - te = 0; - act = 0; - } + if (p.second.use_category() == USE(ZWNJ)) + for (unsigned i = p.first + 1; i < buffer->len; ++i) + if (not_ccs_default_ignorable (info[i])) + return !_hb_glyph_info_is_unicode_mark (&info[i]); + return true; + }) + | hb_enumerate + | machine_index + ; + auto pe = p + p.len (); + auto eof = +pe; + auto ts = +p; + auto te = +p; + unsigned int act HB_UNUSED; + int cs; +#line 792 "hb-ot-shaper-use-machine.hh" + { + cs = (int)use_syllable_machine_start; + ts = 0; + te = 0; + } + #line 282 "hb-ot-shaper-use-machine.rl" + + unsigned int syllable_serial = 1; - unsigned int syllable_serial = 1; - -#line 931 "hb-ot-shaper-use-machine.hh" +#line 801 "hb-ot-shaper-use-machine.hh" { - int _slen; - int _trans; - const unsigned char *_keys; - const unsigned char *_inds; - if ( p == pe ) - goto _test_eof; -_resume: - switch ( _use_syllable_machine_from_state_actions[cs] ) { - case 2: + unsigned int _trans = 0; + const unsigned char * _keys; + const short * _inds; + int _ic; + _resume: {} + if ( p == pe && p != eof ) + goto _out; + switch ( _use_syllable_machine_from_state_actions[cs] ) { + case 2: { + { #line 1 "NONE" - {ts = p;} - break; -#line 943 "hb-ot-shaper-use-machine.hh" - } - - _keys = _use_syllable_machine_trans_keys + (cs<<1); - _inds = _use_syllable_machine_indicies + _use_syllable_machine_index_offsets[cs]; + {ts = p;}} + +#line 815 "hb-ot-shaper-use-machine.hh" - _slen = _use_syllable_machine_key_spans[cs]; - _trans = _inds[ _slen > 0 && _keys[0] <=( (*p).second.second.use_category()) && - ( (*p).second.second.use_category()) <= _keys[1] ? - ( (*p).second.second.use_category()) - _keys[0] : _slen ]; - -_eof_trans: - cs = _use_syllable_machine_trans_targs[_trans]; - - if ( _use_syllable_machine_trans_actions[_trans] == 0 ) - goto _again; - - switch ( _use_syllable_machine_trans_actions[_trans] ) { - case 12: + + break; + } + } + + if ( p == eof ) { + if ( _use_syllable_machine_eof_trans[cs] > 0 ) { + _trans = (unsigned int)_use_syllable_machine_eof_trans[cs] - 1; + } + } + else { + _keys = ( _use_syllable_machine_trans_keys + ((cs<<1))); + _inds = ( _use_syllable_machine_indicies + (_use_syllable_machine_index_offsets[cs])); + + if ( ((*p).second.second.use_category()) <= 53 ) { + _ic = (int)_use_syllable_machine_char_class[(int)((*p).second.second.use_category()) - 0]; + if ( _ic <= (int)(*( _keys+1)) && _ic >= (int)(*( _keys)) ) + _trans = (unsigned int)(*( _inds + (int)( _ic - (int)(*( _keys)) ) )); + else + _trans = (unsigned int)_use_syllable_machine_index_defaults[cs]; + } + else { + _trans = (unsigned int)_use_syllable_machine_index_defaults[cs]; + } + + } + cs = (int)_use_syllable_machine_cond_targs[_trans]; + + if ( _use_syllable_machine_cond_actions[_trans] != 0 ) { + + switch ( _use_syllable_machine_cond_actions[_trans] ) { + case 12: { + { +#line 170 "hb-ot-shaper-use-machine.rl" + {te = p+1;{ #line 170 "hb-ot-shaper-use-machine.rl" - {te = p+1;{ found_syllable (use_virama_terminated_cluster); }} - break; - case 10: + found_syllable (use_virama_terminated_cluster); } + }} + +#line 855 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 10: { + { +#line 171 "hb-ot-shaper-use-machine.rl" + {te = p+1;{ #line 171 "hb-ot-shaper-use-machine.rl" - {te = p+1;{ found_syllable (use_sakot_terminated_cluster); }} - break; - case 8: + found_syllable (use_sakot_terminated_cluster); } + }} + +#line 867 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 8: { + { +#line 172 "hb-ot-shaper-use-machine.rl" + {te = p+1;{ #line 172 "hb-ot-shaper-use-machine.rl" - {te = p+1;{ found_syllable (use_standard_cluster); }} - break; - case 16: + found_syllable (use_standard_cluster); } + }} + +#line 879 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 16: { + { +#line 173 "hb-ot-shaper-use-machine.rl" + {te = p+1;{ #line 173 "hb-ot-shaper-use-machine.rl" - {te = p+1;{ found_syllable (use_number_joiner_terminated_cluster); }} - break; - case 14: + found_syllable (use_number_joiner_terminated_cluster); } + }} + +#line 891 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 14: { + { +#line 174 "hb-ot-shaper-use-machine.rl" + {te = p+1;{ #line 174 "hb-ot-shaper-use-machine.rl" - {te = p+1;{ found_syllable (use_numeral_cluster); }} - break; - case 6: + found_syllable (use_numeral_cluster); } + }} + +#line 903 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 6: { + { +#line 175 "hb-ot-shaper-use-machine.rl" + {te = p+1;{ #line 175 "hb-ot-shaper-use-machine.rl" - {te = p+1;{ found_syllable (use_symbol_cluster); }} - break; - case 20: + found_syllable (use_symbol_cluster); } + }} + +#line 915 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 20: { + { #line 176 "hb-ot-shaper-use-machine.rl" - {te = p+1;{ found_syllable (use_hieroglyph_cluster); }} - break; - case 4: + {te = p+1;{ +#line 176 "hb-ot-shaper-use-machine.rl" + found_syllable (use_hieroglyph_cluster); } + }} + +#line 927 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 4: { + { #line 177 "hb-ot-shaper-use-machine.rl" - {te = p+1;{ found_syllable (use_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} - break; - case 3: + {te = p+1;{ +#line 177 "hb-ot-shaper-use-machine.rl" + found_syllable (use_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; } + }} + +#line 939 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 3: { + { #line 178 "hb-ot-shaper-use-machine.rl" - {te = p+1;{ found_syllable (use_non_cluster); }} - break; - case 11: + {te = p+1;{ +#line 178 "hb-ot-shaper-use-machine.rl" + found_syllable (use_non_cluster); } + }} + +#line 951 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 11: { + { #line 170 "hb-ot-shaper-use-machine.rl" - {te = p;p--;{ found_syllable (use_virama_terminated_cluster); }} - break; - case 9: + {te = p;p = p - 1;{ +#line 170 "hb-ot-shaper-use-machine.rl" + found_syllable (use_virama_terminated_cluster); } + }} + +#line 963 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 9: { + { #line 171 "hb-ot-shaper-use-machine.rl" - {te = p;p--;{ found_syllable (use_sakot_terminated_cluster); }} - break; - case 7: + {te = p;p = p - 1;{ +#line 171 "hb-ot-shaper-use-machine.rl" + found_syllable (use_sakot_terminated_cluster); } + }} + +#line 975 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 7: { + { #line 172 "hb-ot-shaper-use-machine.rl" - {te = p;p--;{ found_syllable (use_standard_cluster); }} - break; - case 15: + {te = p;p = p - 1;{ +#line 172 "hb-ot-shaper-use-machine.rl" + found_syllable (use_standard_cluster); } + }} + +#line 987 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 15: { + { #line 173 "hb-ot-shaper-use-machine.rl" - {te = p;p--;{ found_syllable (use_number_joiner_terminated_cluster); }} - break; - case 13: + {te = p;p = p - 1;{ +#line 173 "hb-ot-shaper-use-machine.rl" + found_syllable (use_number_joiner_terminated_cluster); } + }} + +#line 999 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 13: { + { +#line 174 "hb-ot-shaper-use-machine.rl" + {te = p;p = p - 1;{ #line 174 "hb-ot-shaper-use-machine.rl" - {te = p;p--;{ found_syllable (use_numeral_cluster); }} - break; - case 5: + found_syllable (use_numeral_cluster); } + }} + +#line 1011 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 5: { + { +#line 175 "hb-ot-shaper-use-machine.rl" + {te = p;p = p - 1;{ #line 175 "hb-ot-shaper-use-machine.rl" - {te = p;p--;{ found_syllable (use_symbol_cluster); }} - break; - case 19: + found_syllable (use_symbol_cluster); } + }} + +#line 1023 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 19: { + { +#line 176 "hb-ot-shaper-use-machine.rl" + {te = p;p = p - 1;{ #line 176 "hb-ot-shaper-use-machine.rl" - {te = p;p--;{ found_syllable (use_hieroglyph_cluster); }} - break; - case 17: + found_syllable (use_hieroglyph_cluster); } + }} + +#line 1035 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 17: { + { +#line 177 "hb-ot-shaper-use-machine.rl" + {te = p;p = p - 1;{ #line 177 "hb-ot-shaper-use-machine.rl" - {te = p;p--;{ found_syllable (use_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} - break; - case 18: + found_syllable (use_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; } + }} + +#line 1047 "hb-ot-shaper-use-machine.hh" + + + break; + } + case 18: { + { #line 178 "hb-ot-shaper-use-machine.rl" - {te = p;p--;{ found_syllable (use_non_cluster); }} - break; -#line 1014 "hb-ot-shaper-use-machine.hh" - } + {te = p;p = p - 1;{ +#line 178 "hb-ot-shaper-use-machine.rl" + found_syllable (use_non_cluster); } + }} + +#line 1059 "hb-ot-shaper-use-machine.hh" -_again: - switch ( _use_syllable_machine_to_state_actions[cs] ) { - case 1: + + break; + } + } + + } + + if ( p == eof ) { + if ( cs >= 0 ) + goto _out; + } + else { + switch ( _use_syllable_machine_to_state_actions[cs] ) { + case 1: { + { #line 1 "NONE" - {ts = 0;} - break; -#line 1021 "hb-ot-shaper-use-machine.hh" - } + {ts = 0;}} + +#line 1078 "hb-ot-shaper-use-machine.hh" - if ( ++p != pe ) - goto _resume; - _test_eof: {} - if ( p == eof ) - { - if ( _use_syllable_machine_eof_trans[cs] > 0 ) { - _trans = _use_syllable_machine_eof_trans[cs] - 1; - goto _eof_trans; - } + + break; + } + } + + p += 1; + goto _resume; + } + _out: {} } - - } - + #line 287 "hb-ot-shaper-use-machine.rl" } diff --git a/thirdparty/harfbuzz/src/hb-ot-var-avar-table.hh b/thirdparty/harfbuzz/src/hb-ot-var-avar-table.hh index 3449b30499..f3754aa6b8 100644 --- a/thirdparty/harfbuzz/src/hb-ot-var-avar-table.hh +++ b/thirdparty/harfbuzz/src/hb-ot-var-avar-table.hh @@ -72,6 +72,65 @@ struct AxisValueMap return_trace (c->check_struct (this)); } + void set_mapping (float from_coord, float to_coord) + { + coords[0].set_float (from_coord); + coords[1].set_float (to_coord); + } + + bool is_outside_axis_range (const Triple& axis_range) const + { + float from_coord = coords[0].to_float (); + return !axis_range.contains (from_coord); + } + + bool must_include () const + { + float from_coord = coords[0].to_float (); + float to_coord = coords[1].to_float (); + return (from_coord == -1.f && to_coord == -1.f) || + (from_coord == 0.f && to_coord == 0.f) || + (from_coord == 1.f && to_coord == 1.f); + } + + void instantiate (const Triple& axis_range, + const Triple& unmapped_range, + const TripleDistances& triple_distances) + { + float from_coord = coords[0].to_float (); + float to_coord = coords[1].to_float (); + + from_coord = renormalizeValue (from_coord, unmapped_range, triple_distances); + to_coord = renormalizeValue (to_coord, axis_range, triple_distances); + + coords[0].set_float (from_coord); + coords[1].set_float (to_coord); + } + + HB_INTERNAL static int cmp (const void *pa, const void *pb) + { + const AxisValueMap *a = (const AxisValueMap *) pa; + const AxisValueMap *b = (const AxisValueMap *) pb; + + int a_from = a->coords[0].to_int (); + int b_from = b->coords[0].to_int (); + if (a_from != b_from) + return a_from - b_from; + + /* this should never be reached. according to the spec, all of the axis + * value map records for a given axis must have different fromCoord values + * */ + int a_to = a->coords[1].to_int (); + int b_to = b->coords[1].to_int (); + return a_to - b_to; + } + + bool serialize (hb_serialize_context_t *c) const + { + TRACE_SERIALIZE (this); + return_trace (c->embed (this)); + } + public: F2DOT14 coords[2]; // F2DOT14 fromCoord; /* A normalized coordinate value obtained using @@ -122,6 +181,78 @@ struct SegmentMaps : Array16Of<AxisValueMap> int unmap (int value) const { return map (value, 1, 0); } + Triple unmap_axis_range (const Triple& axis_range) const + { + F2DOT14 val, unmapped_val; + + val.set_float (axis_range.minimum); + unmapped_val.set_int (unmap (val.to_int ())); + float unmapped_min = unmapped_val.to_float (); + + val.set_float (axis_range.middle); + unmapped_val.set_int (unmap (val.to_int ())); + float unmapped_middle = unmapped_val.to_float (); + + val.set_float (axis_range.maximum); + unmapped_val.set_int (unmap (val.to_int ())); + float unmapped_max = unmapped_val.to_float (); + + return Triple{unmapped_min, unmapped_middle, unmapped_max}; + } + + bool subset (hb_subset_context_t *c, hb_tag_t axis_tag) const + { + TRACE_SUBSET (this); + /* avar mapped normalized axis range*/ + Triple *axis_range; + if (!c->plan->axes_location.has (axis_tag, &axis_range)) + return c->serializer->embed (*this); + + TripleDistances *axis_triple_distances; + if (!c->plan->axes_triple_distances.has (axis_tag, &axis_triple_distances)) + return_trace (false); + + auto *out = c->serializer->start_embed (this); + if (unlikely (!c->serializer->extend_min (out))) return_trace (false); + + Triple unmapped_range = unmap_axis_range (*axis_range); + + /* create a vector of retained mappings and sort */ + hb_vector_t<AxisValueMap> value_mappings; + for (const auto& _ : as_array ()) + { + if (_.is_outside_axis_range (unmapped_range)) + continue; + AxisValueMap mapping; + mapping = _; + mapping.instantiate (*axis_range, unmapped_range, *axis_triple_distances); + /* (-1, -1), (0, 0), (1, 1) mappings will be added later, so avoid + * duplicates here */ + if (mapping.must_include ()) + continue; + value_mappings.push (std::move (mapping)); + } + + AxisValueMap m; + m.set_mapping (-1.f, -1.f); + value_mappings.push (m); + + m.set_mapping (0.f, 0.f); + value_mappings.push (m); + + m.set_mapping (1.f, 1.f); + value_mappings.push (m); + + value_mappings.qsort (); + + for (const auto& _ : value_mappings) + { + if (!_.serialize (c->serializer)) + return_trace (false); + } + return_trace (c->serializer->check_assign (out->len, value_mappings.length, HB_SERIALIZE_ERROR_INT_OVERFLOW)); + } + public: DEFINE_SIZE_ARRAY (2, *this); }; @@ -225,6 +356,39 @@ struct avar } } + bool subset (hb_subset_context_t *c) const + { + TRACE_SUBSET (this); + unsigned retained_axis_count = c->plan->axes_index_map.get_population (); + if (!retained_axis_count) //all axes are pinned/dropped + return_trace (false); + + avar *out = c->serializer->allocate_min<avar> (); + if (unlikely (!out)) return_trace (false); + + out->version.major = 1; + out->version.minor = 0; + if (!c->serializer->check_assign (out->axisCount, retained_axis_count, HB_SERIALIZE_ERROR_INT_OVERFLOW)) + return_trace (false); + + const hb_map_t& axes_index_map = c->plan->axes_index_map; + const SegmentMaps *map = &firstAxisSegmentMaps; + unsigned count = axisCount; + for (unsigned int i = 0; i < count; i++) + { + if (axes_index_map.has (i)) + { + hb_tag_t *axis_tag; + if (!c->plan->axes_old_index_tag_map.has (i, &axis_tag)) + return_trace (false); + if (!map->subset (c, *axis_tag)) + return_trace (false); + } + map = &StructAfter<SegmentMaps> (*map); + } + return_trace (true); + } + protected: FixedVersion<>version; /* Version of the avar table * initially set to 0x00010000u */ diff --git a/thirdparty/harfbuzz/src/hb-ot-var-common.hh b/thirdparty/harfbuzz/src/hb-ot-var-common.hh index 44ec64bc03..9e813f6d2d 100644 --- a/thirdparty/harfbuzz/src/hb-ot-var-common.hh +++ b/thirdparty/harfbuzz/src/hb-ot-var-common.hh @@ -60,18 +60,21 @@ struct DeltaSetIndexMapFormat01 entryFormat = ((width-1)<<4)|(inner_bit_count-1); mapCount = output_map.length; - HBUINT8 *p = c->allocate_size<HBUINT8> (width * output_map.length, false); + HBUINT8 *p = c->allocate_size<HBUINT8> (width * output_map.length); if (unlikely (!p)) return_trace (false); for (unsigned int i = 0; i < output_map.length; i++) { - unsigned int v = output_map[i]; - unsigned int outer = v >> 16; - unsigned int inner = v & 0xFFFF; - unsigned int u = (outer << inner_bit_count) | inner; - for (unsigned int w = width; w > 0;) + unsigned int v = output_map.arrayZ[i]; + if (v) { - p[--w] = u; - u >>= 8; + unsigned int outer = v >> 16; + unsigned int inner = v & 0xFFFF; + unsigned int u = (outer << inner_bit_count) | inner; + for (unsigned int w = width; w > 0;) + { + p[--w] = u; + u >>= 8; + } } p += width; } @@ -421,25 +424,6 @@ struct TupleVariationHeader DEFINE_SIZE_MIN (4); }; -/* not using hb_bytes_t: avoid potential build issues with some compilers */ -struct byte_data_t -{ - hb_bytes_t bytes; - - byte_data_t () = default; - byte_data_t (const char *p_, unsigned len_) : bytes (hb_bytes_t (p_, len_)) {} - - void fini () { bytes.fini (); } - - bool operator == (const byte_data_t& o) const - { return bytes.arrayZ == o.bytes.arrayZ && bytes.length == o.bytes.length; } - - explicit operator bool () const { return bytes.length; } - - void copy (hb_serialize_context_t *c) const - { c->embed (bytes.arrayZ, bytes.length); } -}; - enum packed_delta_flag_t { DELTAS_ARE_ZERO = 0x80, @@ -505,6 +489,7 @@ struct tuple_delta_t else { if (!o.indices.arrayZ[i]) continue; + indices.arrayZ[i] = true; deltas_x[i] = o.deltas_x[i]; if (deltas_y && o.deltas_y) deltas_y[i] = o.deltas_y[i]; @@ -530,7 +515,8 @@ struct tuple_delta_t return *this; } - hb_vector_t<tuple_delta_t> change_tuple_var_axis_limit (hb_tag_t axis_tag, Triple axis_limit) const + hb_vector_t<tuple_delta_t> change_tuple_var_axis_limit (hb_tag_t axis_tag, Triple axis_limit, + TripleDistances axis_triple_distances) const { hb_vector_t<tuple_delta_t> out; Triple *tent; @@ -550,7 +536,7 @@ struct tuple_delta_t return out; } - result_t solutions = rebase_tent (*tent, axis_limit); + result_t solutions = rebase_tent (*tent, axis_limit, axis_triple_distances); for (auto t : solutions) { tuple_delta_t new_var = *this; @@ -715,6 +701,8 @@ struct tuple_delta_t } if (j != rounded_deltas.length) return false; + /* reset i because we reuse rounded_deltas for deltas_y */ + i = 0; encoded_len += encode_delta_run (i, compiled_deltas.as_array ().sub_array (encoded_len), rounded_deltas); } return compiled_deltas.resize (encoded_len); @@ -755,14 +743,14 @@ struct tuple_delta_t while (run_length >= 64) { - *it++ = (DELTAS_ARE_ZERO | 63); + *it++ = char (DELTAS_ARE_ZERO | 63); run_length -= 64; encoded_len++; } if (run_length) { - *it++ = (DELTAS_ARE_ZERO | (run_length - 1)); + *it++ = char (DELTAS_ARE_ZERO | (run_length - 1)); encoded_len++; } return encoded_len; @@ -870,6 +858,7 @@ struct tuple_delta_t if (run_length) { *it++ = (DELTAS_ARE_WORDS | (run_length - 1)); + encoded_len++; while (start < i) { int16_t delta_val = deltas[start++]; @@ -917,7 +906,7 @@ struct TupleVariationData private: /* referenced point set->compiled point data map */ - hb_hashmap_t<const hb_vector_t<bool>*, byte_data_t> point_data_map; + hb_hashmap_t<const hb_vector_t<bool>*, hb_bytes_t> point_data_map; /* referenced point set-> count map, used in finding shared points */ hb_hashmap_t<const hb_vector_t<bool>*, unsigned> point_set_count_map; @@ -1003,16 +992,21 @@ struct TupleVariationData return true; } - void change_tuple_variations_axis_limits (const hb_hashmap_t<hb_tag_t, Triple> *normalized_axes_location) + void change_tuple_variations_axis_limits (const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location, + const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances) { - for (auto _ : *normalized_axes_location) + for (auto _ : normalized_axes_location) { hb_tag_t axis_tag = _.first; Triple axis_limit = _.second; + TripleDistances axis_triple_distances{1.f, 1.f}; + if (axes_triple_distances.has (axis_tag)) + axis_triple_distances = axes_triple_distances.get (axis_tag); + hb_vector_t<tuple_delta_t> new_vars; for (const tuple_delta_t& var : tuple_vars) { - hb_vector_t<tuple_delta_t> out = var.change_tuple_var_axis_limit (axis_tag, axis_limit); + hb_vector_t<tuple_delta_t> out = var.change_tuple_var_axis_limit (axis_tag, axis_limit, axis_triple_distances); if (!out) continue; unsigned new_len = new_vars.length + out.length; @@ -1054,7 +1048,7 @@ struct TupleVariationData tuple_vars = std::move (new_vars); } - byte_data_t compile_point_set (const hb_vector_t<bool> &point_indices) + hb_bytes_t compile_point_set (const hb_vector_t<bool> &point_indices) { unsigned num_points = 0; for (bool i : point_indices) @@ -1066,15 +1060,15 @@ struct TupleVariationData if (num_points == indices_length) { char *p = (char *) hb_calloc (1, sizeof (char)); - if (unlikely (!p)) return byte_data_t (); + if (unlikely (!p)) return hb_bytes_t (); - return byte_data_t (p, 1); + return hb_bytes_t (p, 1); } /* allocate enough memories: 2 bytes for count + 3 bytes for each point */ unsigned num_bytes = 2 + 3 *num_points; char *p = (char *) hb_calloc (num_bytes, sizeof (char)); - if (unlikely (!p)) return byte_data_t (); + if (unlikely (!p)) return hb_bytes_t (); unsigned pos = 0; /* binary data starts with the total number of reference points */ @@ -1137,10 +1131,10 @@ struct TupleVariationData else p[header_pos] = (run_length - 1) | 0x80; } - return byte_data_t (p, pos); + return hb_bytes_t (p, pos); } - /* compile all point set and store byte data in a point_set->byte_data_t hashmap, + /* compile all point set and store byte data in a point_set->hb_bytes_t hashmap, * also update point_set->count map, which will be used in finding shared * point set*/ bool compile_all_point_sets () @@ -1157,8 +1151,8 @@ struct TupleVariationData continue; } - byte_data_t compiled_data = compile_point_set (*points_set); - if (unlikely (compiled_data == byte_data_t ())) + hb_bytes_t compiled_data = compile_point_set (*points_set); + if (unlikely (compiled_data == hb_bytes_t ())) return false; if (!point_data_map.set (points_set, compiled_data) || @@ -1169,19 +1163,19 @@ struct TupleVariationData } /* find shared points set which saves most bytes */ - byte_data_t find_shared_points () + hb_bytes_t find_shared_points () { unsigned max_saved_bytes = 0; - byte_data_t res{}; + hb_bytes_t res{}; for (const auto& _ : point_data_map.iter ()) { const hb_vector_t<bool>* points_set = _.first; - unsigned data_length = _.second.bytes.length; + unsigned data_length = _.second.length; unsigned *count; if (unlikely (!point_set_count_map.has (points_set, &count) || *count <= 1)) - return byte_data_t (); + return hb_bytes_t (); unsigned saved_bytes = data_length * ((*count) -1); if (saved_bytes > max_saved_bytes) @@ -1193,9 +1187,10 @@ struct TupleVariationData return res; } - void instantiate (const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location) + void instantiate (const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location, + const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances) { - change_tuple_variations_axis_limits (&normalized_axes_location); + change_tuple_variations_axis_limits (normalized_axes_location, axes_triple_distances); merge_tuple_variations (); } @@ -1209,14 +1204,14 @@ struct TupleVariationData for (auto& tuple: tuple_vars) { const hb_vector_t<bool>* points_set = &(tuple.indices); - byte_data_t *points_data; + hb_bytes_t *points_data; if (unlikely (!point_data_map.has (points_set, &points_data))) return false; if (!tuple.compile_deltas ()) return false; - if (!tuple.compile_tuple_var_header (axes_index_map, points_data->bytes.length, axes_old_index_tag_map)) + if (!tuple.compile_tuple_var_header (axes_index_map, points_data->length, axes_old_index_tag_map)) return false; } return true; @@ -1227,8 +1222,7 @@ struct TupleVariationData TRACE_SERIALIZE (this); for (const auto& tuple: tuple_vars) { - byte_data_t compiled_bytes {tuple.compiled_tuple_header.arrayZ, tuple.compiled_tuple_header.length}; - compiled_bytes.copy (c); + tuple.compiled_tuple_header.as_array ().copy (c); if (c->in_error ()) return_trace (false); total_header_len += tuple.compiled_tuple_header.length; } @@ -1241,13 +1235,12 @@ struct TupleVariationData for (const auto& tuple: tuple_vars) { const hb_vector_t<bool>* points_set = &(tuple.indices); - byte_data_t *point_data; + hb_bytes_t *point_data; if (!point_data_map.has (points_set, &point_data)) return_trace (false); point_data->copy (c); - byte_data_t compiled_bytes {tuple.compiled_deltas.arrayZ, tuple.compiled_deltas.length}; - compiled_bytes.copy (c); + tuple.compiled_deltas.as_array ().copy (c); if (c->in_error ()) return_trace (false); } return_trace (true); diff --git a/thirdparty/harfbuzz/src/hb-ot-var-cvar-table.hh b/thirdparty/harfbuzz/src/hb-ot-var-cvar-table.hh index de54339301..fee39eff38 100644 --- a/thirdparty/harfbuzz/src/hb-ot-var-cvar-table.hh +++ b/thirdparty/harfbuzz/src/hb-ot-var-cvar-table.hh @@ -161,13 +161,14 @@ struct cvar const hb_tag_t cvt = HB_TAG('c','v','t',' '); hb_blob_t *cvt_blob = hb_face_reference_table (c->plan->source, cvt); unsigned point_count = hb_blob_get_length (cvt_blob) / FWORD::static_size; + hb_blob_destroy (cvt_blob); if (!decompile_tuple_variations (axis_count, point_count, false, &(c->plan->axes_old_index_tag_map), tuple_variations)) return_trace (false); - tuple_variations.instantiate (c->plan->axes_location); + tuple_variations.instantiate (c->plan->axes_location, c->plan->axes_triple_distances); if (!tuple_variations.compile_bytes (c->plan->axes_index_map, c->plan->axes_old_index_tag_map)) return_trace (false); diff --git a/thirdparty/harfbuzz/src/hb-ot-var-fvar-table.hh b/thirdparty/harfbuzz/src/hb-ot-var-fvar-table.hh index d8e789cb44..4c4957bd71 100644 --- a/thirdparty/harfbuzz/src/hb-ot-var-fvar-table.hh +++ b/thirdparty/harfbuzz/src/hb-ot-var-fvar-table.hh @@ -99,16 +99,16 @@ struct InstanceRecord for (unsigned i = 0 ; i < axis_count; i++) { uint32_t *axis_tag; + Triple *axis_limit; // only keep instances whose coordinates == pinned axis location - if (!c->plan->axes_old_index_tag_map.has (i, &axis_tag)) continue; - if (axes_location->has (*axis_tag)) + if (!c->plan->axes_old_index_tag_map.has (i, &axis_tag)) return_trace (false); + if (axes_location->has (*axis_tag, &axis_limit)) { - Triple axis_limit = axes_location->get (*axis_tag); - if (!axis_coord_pinned_or_within_axis_range (coords, i, axis_limit)) + if (!axis_coord_pinned_or_within_axis_range (coords, i, *axis_limit)) return_trace (false); //skip pinned axis - if (axis_limit.is_point ()) + if (axis_limit->is_point ()) continue; } @@ -228,6 +228,30 @@ struct AxisRecord return defaultValue.to_float (); } + TripleDistances get_triple_distances () const + { + float min, default_, max; + get_coordinates (min, default_, max); + return TripleDistances (min, default_, max); + } + + bool subset (hb_subset_context_t *c) const + { + TRACE_SUBSET (this); + auto *out = c->serializer->embed (this); + if (unlikely (!out)) return_trace (false); + + const hb_hashmap_t<hb_tag_t, Triple>& user_axes_location = c->plan->user_axes_location; + Triple *axis_limit; + if (user_axes_location.has (axisTag, &axis_limit)) + { + out->minValue.set_float (axis_limit->minimum); + out->defaultValue.set_float (axis_limit->middle); + out->maxValue.set_float (axis_limit->maximum); + } + return_trace (true); + } + public: Tag axisTag; /* Tag identifying the design variation for the axis. */ protected: @@ -416,21 +440,25 @@ struct fvar for (unsigned i = 0 ; i < (unsigned)axisCount; i++) { if (!c->plan->axes_index_map.has (i)) continue; - if (unlikely (!c->serializer->embed (axes_records[i]))) + if (unlikely (!axes_records[i].subset (c))) return_trace (false); } if (!c->serializer->check_assign (out->firstAxis, get_size (), HB_SERIALIZE_ERROR_INT_OVERFLOW)) return_trace (false); + unsigned num_retained_instances = 0; for (unsigned i = 0 ; i < (unsigned)instanceCount; i++) { const InstanceRecord *instance = get_instance (i); auto snap = c->serializer->snapshot (); if (!instance->subset (c, axisCount, has_postscript_nameid)) c->serializer->revert (snap); + else + num_retained_instances++; } - return_trace (true); + + return_trace (c->serializer->check_assign (out->instanceCount, num_retained_instances, HB_SERIALIZE_ERROR_INT_OVERFLOW)); } public: diff --git a/thirdparty/harfbuzz/src/hb-ot-var-hvar-table.hh b/thirdparty/harfbuzz/src/hb-ot-var-hvar-table.hh index 943d376bdf..490f883fcc 100644 --- a/thirdparty/harfbuzz/src/hb-ot-var-hvar-table.hh +++ b/thirdparty/harfbuzz/src/hb-ot-var-hvar-table.hh @@ -45,7 +45,8 @@ struct index_map_subset_plan_t void init (const DeltaSetIndexMap &index_map, hb_inc_bimap_t &outer_map, hb_vector_t<hb_set_t *> &inner_sets, - const hb_subset_plan_t *plan) + const hb_subset_plan_t *plan, + bool bypass_empty = true) { map_count = 0; outer_bit_count = 0; @@ -53,11 +54,10 @@ struct index_map_subset_plan_t max_inners.init (); output_map.init (); - if (&index_map == &Null (DeltaSetIndexMap)) return; + if (bypass_empty && !index_map.get_map_count ()) return; unsigned int last_val = (unsigned int)-1; hb_codepoint_t last_gid = HB_CODEPOINT_INVALID; - hb_codepoint_t num_gid = (hb_codepoint_t) hb_min (index_map.get_map_count (), plan->num_output_glyphs ()); outer_bit_count = (index_map.get_width () * 8) - index_map.get_inner_bit_count (); max_inners.resize (inner_sets.length); @@ -68,24 +68,17 @@ struct index_map_subset_plan_t unsigned count = new_to_old_gid_list.length; for (unsigned j = count; j; j--) { - hb_codepoint_t gid = new_to_old_gid_list[j - 1].first; - if (gid >= num_gid) continue; - - hb_codepoint_t old_gid = new_to_old_gid_list[j - 1].second; + hb_codepoint_t gid = new_to_old_gid_list.arrayZ[j - 1].first; + hb_codepoint_t old_gid = new_to_old_gid_list.arrayZ[j - 1].second; unsigned int v = index_map.map (old_gid); if (last_gid == HB_CODEPOINT_INVALID) { - if (gid + 1 != num_gid) - { - last_gid = gid + 1; - break; - } last_val = v; last_gid = gid; continue; } - if (v != last_val || gid + 1 != last_gid) + if (v != last_val) break; last_gid = gid; @@ -120,8 +113,6 @@ struct index_map_subset_plan_t const hb_vector_t<hb_inc_bimap_t> &inner_maps, const hb_subset_plan_t *plan) { - if (input_map == &Null (DeltaSetIndexMap)) return; - for (unsigned int i = 0; i < max_inners.length; i++) { if (inner_maps[i].get_population () == 0) continue; @@ -129,18 +120,17 @@ struct index_map_subset_plan_t if (bit_count > inner_bit_count) inner_bit_count = bit_count; } - output_map.resize (map_count); - for (hb_codepoint_t gid = 0; gid < output_map.length; gid++) + if (unlikely (!output_map.resize (map_count))) return; + for (const auto &_ : plan->new_to_old_gid_list) { - hb_codepoint_t old_gid; - if (plan->old_gid_for_new_gid (gid, &old_gid)) - { - uint32_t v = input_map->map (old_gid); - unsigned int outer = v >> 16; - output_map[gid] = (outer_map[outer] << 16) | (inner_maps[outer][v & 0xFFFF]); - } - else - output_map[gid] = 0; /* Map unused glyph to outer/inner=0/0 */ + hb_codepoint_t new_gid = _.first; + hb_codepoint_t old_gid = _.second; + + if (unlikely (new_gid >= map_count)) break; + + uint32_t v = input_map->map (old_gid); + unsigned int outer = v >> 16; + output_map.arrayZ[new_gid] = (outer_map[outer] << 16) | (inner_maps[outer][v & 0xFFFF]); } } @@ -184,7 +174,7 @@ struct hvarvvar_subset_plan_t if (unlikely (!index_map_plans.length || !inner_sets.length || !inner_maps.length)) return; bool retain_adv_map = false; - index_map_plans[0].init (*index_maps[0], outer_map, inner_sets, plan); + index_map_plans[0].init (*index_maps[0], outer_map, inner_sets, plan, false); if (index_maps[0] == &Null (DeltaSetIndexMap)) { retain_adv_map = plan->flags & HB_SUBSET_FLAGS_RETAIN_GIDS; @@ -201,13 +191,10 @@ struct hvarvvar_subset_plan_t if (retain_adv_map) { - unsigned num_glyphs = plan->num_output_glyphs (); - for (hb_codepoint_t gid = 0; gid < num_glyphs; gid++) + for (const auto &_ : plan->new_to_old_gid_list) { - if (inner_sets[0]->has (gid)) - inner_maps[0].add (gid); - else - inner_maps[0].skip (); + hb_codepoint_t old_gid = _.second; + inner_maps[0].add (old_gid); } } else diff --git a/thirdparty/harfbuzz/src/hb-priority-queue.hh b/thirdparty/harfbuzz/src/hb-priority-queue.hh index bf1b282d3d..baac7e1e69 100644 --- a/thirdparty/harfbuzz/src/hb-priority-queue.hh +++ b/thirdparty/harfbuzz/src/hb-priority-queue.hh @@ -54,6 +54,9 @@ struct hb_priority_queue_t bool in_error () const { return heap.in_error (); } +#ifndef HB_OPTIMIZE_SIZE + HB_ALWAYS_INLINE +#endif void insert (int64_t priority, unsigned value) { heap.push (item_t (priority, value)); @@ -61,6 +64,9 @@ struct hb_priority_queue_t bubble_up (heap.length - 1); } +#ifndef HB_OPTIMIZE_SIZE + HB_ALWAYS_INLINE +#endif item_t pop_minimum () { assert (!is_empty ()); @@ -106,8 +112,10 @@ struct hb_priority_queue_t return 2 * index + 2; } + HB_ALWAYS_INLINE void bubble_down (unsigned index) { + repeat: assert (index < heap.length); unsigned left = left_child (index); @@ -123,19 +131,21 @@ struct hb_priority_queue_t && (!has_right || heap.arrayZ[index].first <= heap.arrayZ[right].first)) return; + unsigned child; if (!has_right || heap.arrayZ[left].first < heap.arrayZ[right].first) - { - swap (index, left); - bubble_down (left); - return; - } + child = left; + else + child = right; - swap (index, right); - bubble_down (right); + swap (index, child); + index = child; + goto repeat; } + HB_ALWAYS_INLINE void bubble_up (unsigned index) { + repeat: assert (index < heap.length); if (index == 0) return; @@ -145,7 +155,8 @@ struct hb_priority_queue_t return; swap (index, parent_index); - bubble_up (parent_index); + index = parent_index; + goto repeat; } void swap (unsigned a, unsigned b) diff --git a/thirdparty/harfbuzz/src/hb-sanitize.hh b/thirdparty/harfbuzz/src/hb-sanitize.hh index 2d338c51c8..efb5adde5f 100644 --- a/thirdparty/harfbuzz/src/hb-sanitize.hh +++ b/thirdparty/harfbuzz/src/hb-sanitize.hh @@ -258,7 +258,8 @@ struct hb_sanitize_context_t : this->max_ops = -1; return false; } - return (this->max_ops -= (int) count) > 0; + this->max_ops -= (int) count; + return true; } #ifndef HB_OPTIMIZE_SIZE @@ -381,6 +382,9 @@ struct hb_sanitize_context_t : } template <typename Type> +#ifndef HB_OPTIMIZE_SIZE + HB_ALWAYS_INLINE +#endif bool check_struct (const Type *obj) const { if (sizeof (uintptr_t) == sizeof (uint32_t)) diff --git a/thirdparty/harfbuzz/src/hb-serialize.hh b/thirdparty/harfbuzz/src/hb-serialize.hh index f852f07ba6..15eccb6a09 100644 --- a/thirdparty/harfbuzz/src/hb-serialize.hh +++ b/thirdparty/harfbuzz/src/hb-serialize.hh @@ -266,7 +266,7 @@ struct hb_serialize_context_t propagate_error (std::forward<Ts> (os)...); } /* To be called around main operation. */ - template <typename Type> + template <typename Type=char> __attribute__((returns_nonnull)) Type *start_serialize () { diff --git a/thirdparty/harfbuzz/src/hb-subset-cff-common.hh b/thirdparty/harfbuzz/src/hb-subset-cff-common.hh index f54792648d..462e99cf8c 100644 --- a/thirdparty/harfbuzz/src/hb-subset-cff-common.hh +++ b/thirdparty/harfbuzz/src/hb-subset-cff-common.hh @@ -773,7 +773,7 @@ struct subr_subsetter_t } } - /* Doing this here one by one instead of compacting all at the en + /* Doing this here one by one instead of compacting all at the end * has massive peak-memory saving. * * The compacting both saves memory and makes further operations diff --git a/thirdparty/harfbuzz/src/hb-subset-cff1.cc b/thirdparty/harfbuzz/src/hb-subset-cff1.cc index e80d18d097..872cba6672 100644 --- a/thirdparty/harfbuzz/src/hb-subset-cff1.cc +++ b/thirdparty/harfbuzz/src/hb-subset-cff1.cc @@ -551,14 +551,12 @@ struct cff1_subset_plan sid = sidmap.add (sid); if (sid != last_sid + 1) - { subset_charset_ranges.push (code_pair_t {sid, glyph}); - if (glyph == old_glyph && skip) - { - glyph = hb_min (_.first - 1, glyph_to_sid_map->arrayZ[old_glyph].glyph); - sid += glyph - old_glyph; - } + if (glyph == old_glyph && skip) + { + glyph = hb_min (_.first - 1, glyph_to_sid_map->arrayZ[old_glyph].glyph); + sid += glyph - old_glyph; } last_sid = sid; } diff --git a/thirdparty/harfbuzz/src/hb-subset-cff1.hh b/thirdparty/harfbuzz/src/hb-subset-cff1.hh deleted file mode 100644 index aaf5def1ed..0000000000 --- a/thirdparty/harfbuzz/src/hb-subset-cff1.hh +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2018 Adobe Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Adobe Author(s): Michiharu Ariza - */ - -#ifndef HB_SUBSET_CFF1_HH -#define HB_SUBSET_CFF1_HH - -#include "hb.hh" - -#include "hb-subset-plan.hh" - -HB_INTERNAL bool -hb_subset_cff1 (hb_subset_context_t *c); - -#endif /* HB_SUBSET_CFF1_HH */ diff --git a/thirdparty/harfbuzz/src/hb-subset-cff2.hh b/thirdparty/harfbuzz/src/hb-subset-cff2.hh deleted file mode 100644 index f10556ddd7..0000000000 --- a/thirdparty/harfbuzz/src/hb-subset-cff2.hh +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2018 Adobe Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Adobe Author(s): Michiharu Ariza - */ - -#ifndef HB_SUBSET_CFF2_HH -#define HB_SUBSET_CFF2_HH - -#include "hb.hh" - -#include "hb-subset-plan.hh" - -HB_INTERNAL bool -hb_subset_cff2 (hb_subset_context_t *c); - -#endif /* HB_SUBSET_CFF2_HH */ diff --git a/thirdparty/harfbuzz/src/hb-subset-input.cc b/thirdparty/harfbuzz/src/hb-subset-input.cc index e6b23df704..93f961f2d8 100644 --- a/thirdparty/harfbuzz/src/hb-subset-input.cc +++ b/thirdparty/harfbuzz/src/hb-subset-input.cc @@ -69,7 +69,6 @@ hb_subset_input_t::hb_subset_input_t () sets.drop_tables->add_array (default_drop_tables, ARRAY_LENGTH (default_drop_tables)); hb_tag_t default_no_subset_tables[] = { - HB_TAG ('a', 'v', 'a', 'r'), HB_TAG ('g', 'a', 's', 'p'), HB_TAG ('f', 'p', 'g', 'm'), HB_TAG ('p', 'r', 'e', 'p'), diff --git a/thirdparty/harfbuzz/src/hb-subset-instancer-solver.cc b/thirdparty/harfbuzz/src/hb-subset-instancer-solver.cc index c698d944ce..4cb3f8a485 100644 --- a/thirdparty/harfbuzz/src/hb-subset-instancer-solver.cc +++ b/thirdparty/harfbuzz/src/hb-subset-instancer-solver.cc @@ -253,9 +253,8 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) * axisDef axisMax */ float newUpper = peak + (1 - gain) * (upper - peak); - // I feel like the first condition is always true because - // outGain >= gain. - if (axisMax <= newUpper && newUpper <= axisDef + (axisMax - axisDef) * 2) + assert (axisMax <= newUpper); // Because outGain >= gain + if (newUpper <= axisDef + (axisMax - axisDef) * 2) { upper = newUpper; if (!negative && axisDef + (axisMax - axisDef) * MAX_F2DOT14 < upper) @@ -362,38 +361,47 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) return out; } -/* Normalizes value based on a min/default/max triple. */ -static inline float normalizeValue (float v, const Triple &triple, bool extrapolate = false) +static inline TripleDistances _reverse_triple_distances (const TripleDistances &v) +{ return TripleDistances (v.positive, v.negative); } + +float renormalizeValue (float v, const Triple &triple, + const TripleDistances &triple_distances, bool extrapolate) { - /* - >>> normalizeValue(400, (100, 400, 900)) - 0.0 - >>> normalizeValue(100, (100, 400, 900)) - -1.0 - >>> normalizeValue(650, (100, 400, 900)) - 0.5 - */ float lower = triple.minimum, def = triple.middle, upper = triple.maximum; assert (lower <= def && def <= upper); if (!extrapolate) v = hb_max (hb_min (v, upper), lower); - if ((v == def) || (lower == upper)) + if (v == def) return 0.f; - if ((v < def && lower != def) || (v > def && upper == def)) + if (def < 0.f) + return -renormalizeValue (-v, _reverse_negate (triple), + _reverse_triple_distances (triple_distances), extrapolate); + + /* default >= 0 and v != default */ + if (v > def) + return (v - def) / (upper - def); + + /* v < def */ + if (lower >= 0.f) return (v - def) / (def - lower); + + /* lower < 0 and v < default */ + float total_distance = triple_distances.negative * (-lower) + triple_distances.positive * def; + + float v_distance; + if (v >= 0.f) + v_distance = (def - v) * triple_distances.positive; else - { - assert ((v > def && upper != def) || - (v < def && lower == def)); - return (v - def) / (upper - def); - } + v_distance = (-v) * triple_distances.negative + triple_distances.positive * def; + + return (-v_distance) /total_distance; } result_t -rebase_tent (Triple tent, Triple axisLimit) +rebase_tent (Triple tent, Triple axisLimit, TripleDistances axis_triple_distances) { assert (-1.f <= axisLimit.minimum && axisLimit.minimum <= axisLimit.middle && axisLimit.middle <= axisLimit.maximum && axisLimit.maximum <= +1.f); assert (-2.f <= tent.minimum && tent.minimum <= tent.middle && tent.middle <= tent.maximum && tent.maximum <= +2.f); @@ -401,7 +409,7 @@ rebase_tent (Triple tent, Triple axisLimit) result_t sols = _solve (tent, axisLimit); - auto n = [&axisLimit] (float v) { return normalizeValue (v, axisLimit, true); }; + auto n = [&axisLimit, &axis_triple_distances] (float v) { return renormalizeValue (v, axisLimit, axis_triple_distances); }; result_t out; for (auto &p : sols) diff --git a/thirdparty/harfbuzz/src/hb-subset-instancer-solver.hh b/thirdparty/harfbuzz/src/hb-subset-instancer-solver.hh index b1f8594937..563fccbb59 100644 --- a/thirdparty/harfbuzz/src/hb-subset-instancer-solver.hh +++ b/thirdparty/harfbuzz/src/hb-subset-instancer-solver.hh @@ -27,6 +27,21 @@ #include "hb.hh" +/* pre-normalized distances */ +struct TripleDistances +{ + TripleDistances (): negative (1.f), positive (1.f) {} + TripleDistances (float neg_, float pos_): negative (neg_), positive (pos_) {} + TripleDistances (float min, float default_, float max) + { + negative = default_ - min; + positive = max - default_; + } + + float negative; + float positive; +}; + struct Triple { Triple () : @@ -66,6 +81,7 @@ struct Triple { return current; } + float minimum; float middle; float maximum; @@ -74,6 +90,12 @@ struct Triple { using result_item_t = hb_pair_t<float, Triple>; using result_t = hb_vector_t<result_item_t>; +/* renormalize a normalized value v to the range of an axis, + * considering the prenormalized distances as well as the new axis limits. + * Ported from fonttools */ +HB_INTERNAL float renormalizeValue (float v, const Triple &triple, + const TripleDistances &triple_distances, + bool extrapolate = true); /* Given a tuple (lower,peak,upper) "tent" and new axis limits * (axisMin,axisDefault,axisMax), solves how to represent the tent * under the new axis configuration. All values are in normalized @@ -85,6 +107,6 @@ using result_t = hb_vector_t<result_item_t>; * If tent value is Triple{}, that is a special deltaset that should * be always-enabled (called "gain"). */ -HB_INTERNAL result_t rebase_tent (Triple tent, Triple axisLimit); +HB_INTERNAL result_t rebase_tent (Triple tent, Triple axisLimit, TripleDistances axis_triple_distances); #endif /* HB_SUBSET_INSTANCER_SOLVER_HH */ diff --git a/thirdparty/harfbuzz/src/hb-subset-plan-member-list.hh b/thirdparty/harfbuzz/src/hb-subset-plan-member-list.hh index be29e67ecb..8e61055f4a 100644 --- a/thirdparty/harfbuzz/src/hb-subset-plan-member-list.hh +++ b/thirdparty/harfbuzz/src/hb-subset-plan-member-list.hh @@ -105,6 +105,8 @@ HB_SUBSET_PLAN_MEMBER (hb_vector_t<int>, normalized_coords) //user specified axes range map HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<hb_tag_t, Triple>), user_axes_location) +//axis->TripleDistances map (distances in the pre-normalized space) +HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<hb_tag_t, TripleDistances>), axes_triple_distances) //retained old axis index -> new axis index mapping in fvar axis array HB_SUBSET_PLAN_MEMBER (hb_map_t, axes_index_map) diff --git a/thirdparty/harfbuzz/src/hb-subset-plan.cc b/thirdparty/harfbuzz/src/hb-subset-plan.cc index 9a00de3e60..a2090b727c 100644 --- a/thirdparty/harfbuzz/src/hb-subset-plan.cc +++ b/thirdparty/harfbuzz/src/hb-subset-plan.cc @@ -605,11 +605,14 @@ _populate_unicodes_to_retain (const hb_set_t *unicodes, /* Add gids which where requested, but not mapped in cmap */ unsigned num_glyphs = plan->source->get_num_glyphs (); - for (hb_codepoint_t gid : *glyphs) + hb_codepoint_t first = HB_SET_VALUE_INVALID, last = HB_SET_VALUE_INVALID; + for (; glyphs->next_range (&first, &last); ) { - if (gid >= num_glyphs) + if (first >= num_glyphs) break; - plan->_glyphset_gsub.add (gid); + if (last >= num_glyphs) + last = num_glyphs - 1; + plan->_glyphset_gsub.add_range (first, last); } } @@ -927,12 +930,14 @@ _normalize_axes_location (hb_face_t *face, hb_subset_plan_t *plan) new_axis_idx++; } - if (plan->user_axes_location.has (axis_tag)) + Triple *axis_range; + if (plan->user_axes_location.has (axis_tag, &axis_range)) { - Triple axis_range = plan->user_axes_location.get (axis_tag); - int normalized_min = axis.normalize_axis_value (axis_range.minimum); - int normalized_default = axis.normalize_axis_value (axis_range.middle); - int normalized_max = axis.normalize_axis_value (axis_range.maximum); + plan->axes_triple_distances.set (axis_tag, axis.get_triple_distances ()); + + int normalized_min = axis.normalize_axis_value (axis_range->minimum); + int normalized_default = axis.normalize_axis_value (axis_range->middle); + int normalized_max = axis.normalize_axis_value (axis_range->maximum); if (has_avar && old_axis_idx < avar_axis_count) { @@ -940,9 +945,9 @@ _normalize_axes_location (hb_face_t *face, hb_subset_plan_t *plan) normalized_default = seg_maps->map (normalized_default); normalized_max = seg_maps->map (normalized_max); } - plan->axes_location.set (axis_tag, Triple (static_cast<float> (normalized_min), - static_cast<float> (normalized_default), - static_cast<float> (normalized_max))); + plan->axes_location.set (axis_tag, Triple (static_cast<float> (normalized_min / 16384.f), + static_cast<float> (normalized_default / 16384.f), + static_cast<float> (normalized_max / 16384.f))); if (normalized_default != 0) plan->pinned_at_default = false; diff --git a/thirdparty/harfbuzz/src/hb-subset.cc b/thirdparty/harfbuzz/src/hb-subset.cc index 8e8a5eb0bd..1f97dbed29 100644 --- a/thirdparty/harfbuzz/src/hb-subset.cc +++ b/thirdparty/harfbuzz/src/hb-subset.cc @@ -50,6 +50,7 @@ #include "hb-ot-name-table.hh" #include "hb-ot-layout-gsub-table.hh" #include "hb-ot-layout-gpos-table.hh" +#include "hb-ot-var-avar-table.hh" #include "hb-ot-var-cvar-table.hh" #include "hb-ot-var-fvar-table.hh" #include "hb-ot-var-gvar-table.hh" @@ -273,7 +274,7 @@ _try_subset (const TableType *table, hb_vector_t<char>* buf, hb_subset_context_t* c /* OUT */) { - c->serializer->start_serialize<TableType> (); + c->serializer->start_serialize (); if (c->serializer->in_error ()) return false; bool needed = table->subset (c); @@ -516,10 +517,11 @@ _subset_table (hb_subset_plan_t *plan, case HB_OT_TAG_fvar: if (plan->user_axes_location.is_empty ()) return _passthrough (plan, tag); return _subset<const OT::fvar> (plan, buf); + case HB_OT_TAG_avar: + if (plan->user_axes_location.is_empty ()) return _passthrough (plan, tag); + return _subset<const OT::avar> (plan, buf); case HB_OT_TAG_STAT: - /*TODO(qxliu): change the condition as we support more complex - * instancing operation*/ - if (plan->all_axes_pinned) return _subset<const OT::STAT> (plan, buf); + if (!plan->user_axes_location.is_empty ()) return _subset<const OT::STAT> (plan, buf); else return _passthrough (plan, tag); case HB_TAG ('c', 'v', 't', ' '): diff --git a/thirdparty/harfbuzz/src/hb-uniscribe.cc b/thirdparty/harfbuzz/src/hb-uniscribe.cc index 9648e02663..1b8ac367e1 100644 --- a/thirdparty/harfbuzz/src/hb-uniscribe.cc +++ b/thirdparty/harfbuzz/src/hb-uniscribe.cc @@ -699,7 +699,7 @@ retry: script_tags, &item_count); if (unlikely (FAILED (hr))) - FAIL ("ScriptItemizeOpenType() failed: 0x%08lx", hr); + FAIL ("ScriptItemizeOpenType() failed: 0x%08lx", (unsigned long) hr); #undef MAX_ITEMS @@ -785,7 +785,7 @@ retry: } if (unlikely (FAILED (hr))) { - FAIL ("ScriptShapeOpenType() failed: 0x%08lx", hr); + FAIL ("ScriptShapeOpenType() failed: 0x%08lx", (unsigned long) hr); } for (unsigned int j = chars_offset; j < chars_offset + item_chars_len; j++) @@ -811,7 +811,7 @@ retry: offsets + glyphs_offset, nullptr); if (unlikely (FAILED (hr))) - FAIL ("ScriptPlaceOpenType() failed: 0x%08lx", hr); + FAIL ("ScriptPlaceOpenType() failed: 0x%08lx", (unsigned long) hr); if (DEBUG_ENABLED (UNISCRIBE)) fprintf (stderr, "Item %d RTL %d LayoutRTL %d LogicalOrder %d ScriptTag %c%c%c%c\n", diff --git a/thirdparty/harfbuzz/src/hb-version.h b/thirdparty/harfbuzz/src/hb-version.h index 9b27acf598..773395fb25 100644 --- a/thirdparty/harfbuzz/src/hb-version.h +++ b/thirdparty/harfbuzz/src/hb-version.h @@ -47,20 +47,20 @@ HB_BEGIN_DECLS * * The minor component of the library version available at compile-time. */ -#define HB_VERSION_MINOR 0 +#define HB_VERSION_MINOR 1 /** * HB_VERSION_MICRO: * * The micro component of the library version available at compile-time. */ -#define HB_VERSION_MICRO 0 +#define HB_VERSION_MICRO 1 /** * HB_VERSION_STRING: * * A string literal containing the library version available at compile-time. */ -#define HB_VERSION_STRING "8.0.0" +#define HB_VERSION_STRING "8.1.1" /** * HB_VERSION_ATLEAST: diff --git a/thirdparty/harfbuzz/src/hb.hh b/thirdparty/harfbuzz/src/hb.hh index 49119b8f82..972608d6a3 100644 --- a/thirdparty/harfbuzz/src/hb.hh +++ b/thirdparty/harfbuzz/src/hb.hh @@ -64,6 +64,7 @@ #pragma GCC diagnostic error "-Wbitwise-instead-of-logical" #pragma GCC diagnostic error "-Wcast-align" #pragma GCC diagnostic error "-Wcast-function-type" +#pragma GCC diagnostic error "-Wconstant-conversion" #pragma GCC diagnostic error "-Wcomma" #pragma GCC diagnostic error "-Wdelete-non-virtual-dtor" #pragma GCC diagnostic error "-Wembedded-directive" |