diff options
author | Yuri Sizov <yuris@humnom.net> | 2023-05-23 14:40:13 +0200 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-05-23 15:20:42 +0200 |
commit | edf47f1ee438a06729bf25c20851568f2875245f (patch) | |
tree | 07a17f478fc066c4f61149728af06da03a234b85 /editor/plugins/visual_shader_editor_plugin.cpp | |
parent | d5c1b9f883adbb54900c145eafcaa789d0fd563c (diff) | |
download | redot-engine-edf47f1ee438a06729bf25c20851568f2875245f.tar.gz |
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 <yokomeshi@gmail.com>
Diffstat (limited to 'editor/plugins/visual_shader_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 754533ab31..db9c7098a6 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<InputEvent> &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<VisualShaderNodePluginDefault> default_plugin; default_plugin.instantiate(); default_plugin->set_editor(this); |