From edf47f1ee438a06729bf25c20851568f2875245f Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Tue, 23 May 2023 14:40:13 +0200 Subject: [PATCH] Delay initialization of the visual shader editor UI This makes sure that the theme is ready to be used before the methods is called. Also add missing icons (and update some existing). Co-authored-by: Samuel Wilson --- editor/editor_themes.cpp | 25 +++++++++------- editor/icons/Projection.svg | 1 + editor/icons/Transform3D.svg | 2 +- editor/icons/Vector4.svg | 2 +- editor/icons/Vector4i.svg | 2 +- editor/icons/uint.svg | 1 + .../plugins/visual_shader_editor_plugin.cpp | 30 ++++++++++--------- editor/property_selector.cpp | 2 +- 8 files changed, 36 insertions(+), 29 deletions(-) create mode 100644 editor/icons/Projection.svg create mode 100644 editor/icons/uint.svg diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 3cdd78dc7ff..aa98eb61033 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -136,22 +136,25 @@ void EditorColorMap::create() { // Variant types add_conversion_color_pair("#41ecad", "#25e3a0"); // Variant add_conversion_color_pair("#6f91f0", "#6d8eeb"); // bool - add_conversion_color_pair("#5abbef", "#4fb2e9"); // int + add_conversion_color_pair("#5abbef", "#4fb2e9"); // int/uint add_conversion_color_pair("#35d4f4", "#27ccf0"); // float add_conversion_color_pair("#4593ec", "#4690e7"); // String - add_conversion_color_pair("#ac73f1", "#ad76ee"); // Vector2 - add_conversion_color_pair("#f1738f", "#ee758e"); // Rect2 - add_conversion_color_pair("#de66f0", "#dc6aed"); // Vector3 - add_conversion_color_pair("#b9ec41", "#96ce1a"); // Transform2D - add_conversion_color_pair("#f74949", "#f77070"); // Plane - add_conversion_color_pair("#ec418e", "#ec69a3"); // Quaternion add_conversion_color_pair("#ee5677", "#ee7991"); // AABB + add_conversion_color_pair("#e0e0e0", "#5a5a5a"); // Array add_conversion_color_pair("#e1ec41", "#b2bb19"); // Basis - add_conversion_color_pair("#f68f45", "#f49047"); // Transform3D - add_conversion_color_pair("#417aec", "#6993ec"); // NodePath - add_conversion_color_pair("#41ec80", "#2ce573"); // RID - add_conversion_color_pair("#55f3e3", "#12d5c3"); // Object add_conversion_color_pair("#54ed9e", "#57e99f"); // Dictionary + add_conversion_color_pair("#417aec", "#6993ec"); // NodePath + add_conversion_color_pair("#55f3e3", "#12d5c3"); // Object + add_conversion_color_pair("#f74949", "#f77070"); // Plane + add_conversion_color_pair("#44bd44", "#46b946"); // Projection + add_conversion_color_pair("#ec418e", "#ec69a3"); // Quaternion + add_conversion_color_pair("#f1738f", "#ee758e"); // Rect2 + add_conversion_color_pair("#41ec80", "#2ce573"); // RID + add_conversion_color_pair("#b9ec41", "#96ce1a"); // Transform2D + add_conversion_color_pair("#f68f45", "#f49047"); // Transform3D + add_conversion_color_pair("#ac73f1", "#ad76ee"); // Vector2 + add_conversion_color_pair("#de66f0", "#dc6aed"); // Vector3 + add_conversion_color_pair("#f066bd", "#ed6abd"); // Vector4 // Visual shaders add_conversion_color_pair("#77ce57", "#67c046"); // Vector funcs diff --git a/editor/icons/Projection.svg b/editor/icons/Projection.svg new file mode 100644 index 00000000000..c6c9fed6792 --- /dev/null +++ b/editor/icons/Projection.svg @@ -0,0 +1 @@ + diff --git a/editor/icons/Transform3D.svg b/editor/icons/Transform3D.svg index a940120702a..10d2769d973 100644 --- a/editor/icons/Transform3D.svg +++ b/editor/icons/Transform3D.svg @@ -1 +1 @@ - + diff --git a/editor/icons/Vector4.svg b/editor/icons/Vector4.svg index 2797df4443a..7befa5c78ab 100644 --- a/editor/icons/Vector4.svg +++ b/editor/icons/Vector4.svg @@ -1 +1 @@ - + diff --git a/editor/icons/Vector4i.svg b/editor/icons/Vector4i.svg index ddab1f1747d..d86cba253bc 100644 --- a/editor/icons/Vector4i.svg +++ b/editor/icons/Vector4i.svg @@ -1 +1 @@ - + diff --git a/editor/icons/uint.svg b/editor/icons/uint.svg new file mode 100644 index 00000000000..7dd5a92925a --- /dev/null +++ b/editor/icons/uint.svg @@ -0,0 +1 @@ + diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 754533ab318..db9c7098a6c 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1845,31 +1845,31 @@ void VisualShaderEditor::_update_options_menu() { } switch (options[i].return_type) { case VisualShaderNode::PORT_TYPE_SCALAR: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons"))); + item->set_icon(0, get_theme_icon(SNAME("float"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_SCALAR_INT: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons"))); + item->set_icon(0, get_theme_icon(SNAME("int"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_SCALAR_UINT: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("uint"), SNAME("EditorIcons"))); + item->set_icon(0, get_theme_icon(SNAME("uint"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_VECTOR_2D: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons"))); + item->set_icon(0, get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_VECTOR_3D: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons"))); + item->set_icon(0, get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_VECTOR_4D: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons"))); + item->set_icon(0, get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_BOOLEAN: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons"))); + item->set_icon(0, get_theme_icon(SNAME("bool"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_TRANSFORM: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons"))); + item->set_icon(0, get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_SAMPLER: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); + item->set_icon(0, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); break; default: break; @@ -4051,6 +4051,10 @@ void VisualShaderEditor::_sbox_input(const Ref &p_ie) { void VisualShaderEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_POSTINITIALIZE: { + _update_options_menu(); + } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning"))); graph->set_warped_panning(bool(EDITOR_GET("editors/panning/warped_mouse_panning"))); @@ -4077,8 +4081,8 @@ void VisualShaderEditor::_notification(int p_what) { graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning"))); graph->set_warped_panning(bool(EDITOR_GET("editors/panning/warped_mouse_panning"))); - [[fallthrough]]; - } + } break; + case NOTIFICATION_THEME_CHANGED: { highend_label->set_modulate(get_theme_color(SNAME("highend_color"), SNAME("Editor"))); @@ -4130,7 +4134,7 @@ void VisualShaderEditor::_notification(int p_what) { error_label->add_theme_color_override("font_color", error_color); } - tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); + tools->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) { _update_graph(); @@ -6130,8 +6134,6 @@ VisualShaderEditor::VisualShaderEditor() { ///////////////////////////////////////////////////////////////////// - _update_options_menu(); - Ref default_plugin; default_plugin.instantiate(); default_plugin->set_editor(this); diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 011aef5e83a..737f81c1576 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -144,7 +144,7 @@ void PropertySelector::_update_search() { 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("Variant"), SNAME("EditorIcons")), // Projection, needs icon. + 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")),