Merge pull request #77394 from YuriSizov/editor-vshaders-delay-init

Delay initialization of the visual shader editor UI
This commit is contained in:
Rémi Verschelde 2023-05-23 19:15:13 +02:00
commit 59a35194bf
No known key found for this signature in database
GPG key ID: C3336907360768E1
8 changed files with 36 additions and 29 deletions

View file

@ -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

View file

@ -0,0 +1 @@
<svg height="12" viewBox="0 0 16 12" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m0 2v8h2v-2c.772 0 1.468-.3 2-.779v2.779h2v-3c0-.552.448-1 1-1h1v-2h-1c-.781 0-1.486.306-2.02.795-.107-1.56-1.393-2.795-2.98-2.795zm8 4v2c0 1 1 2 2 2h1c1 0 2-1 2-2v-2c0-1-1-2-2-2h-1c-1 0-2 1-2 2zm6-4v2h2v-2zm-12 2c.552 0 1 .448 1 1s-.448 1-1 1zm8 2h1v2h-1zm4 0v3c0 .552-.448 1-1 1h-1v2h1c1.657 0 3-1.343 3-3v-3z" fill="#44bd44"/><path d="m7 4c-1.657 0-3 1.343-3 3v3h2v-3c0-.552.448-1 1-1h1v-2z" fill="#fff" fill-opacity=".39216"/></svg>

After

Width:  |  Height:  |  Size: 529 B

View file

@ -1 +1 @@
<svg height="12" viewBox="0 0 16 12" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m0 2 2 4-2 4h2l.9082-2.1816 1.0918 2.1816h2l-2-4 2-4h-2l-.9082 2.1816-1.0918-2.1816zm6 8h2v-2h1v-2h-1v-1c.0000096-.55228.44772-.99999 1-1h1v-2h-1c-1.6569 0-3 1.3431-3 3zm4-6v6h2v-2l1 1 1-1v2h2v-6h-2l-1 2-1-2z" fill="#f68f45"/><path d="m9 2a3 3 0 0 0 -3 3v5h2v-2h1v-2h-1v-1a1 1 0 0 1 1-1h1v-2z" fill="#fff" fill-opacity=".39216"/></svg>
<svg height="12" viewBox="0 0 16 12" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m4 4h3.349c0 .549-.451 1.267-1 1.267v1c.549 0 1 .326 1 .874 0 .549-.451.859-1 .859h-1v2h1c1.07 0 2.063-.573 2.598-1.5s.535-1.806 0-2.733c-.104-.18-.227-.348-.366-.502.139-.153.261-.32.366-.498.262-.457.398-.64.398-.767h.004v-2h-9.349v2h2v6h2zm6 6h2c1.428 0 2.751-.764 3.465-2 .713-1.236.713-2.764 0-4-.714-1.236-2.037-2-3.465-2h-2zm2-6c.714 0 1.376.382 1.732 1 .357.618.357 1.382 0 2-.356.618-1.018 1-1.732 1z" fill="#f68f45"/><path d="m6.00006 2v2h1.349c0 .549-.451 1.267-1 1.267v1c.549 0 1 .326 1 .874 0 .549-.451.859-1 .859h-1v2h1c1.07 0 2.062-.573 2.598-1.5.535-.927.535-1.806 0-2.733-.104-.18-.227-.348-.366-.502.139-.153.261-.32.366-.498.262-.457.398-.64.398-.767h.004v-2z" fill="#fff" fill-opacity=".39216"/></svg>

Before

Width:  |  Height:  |  Size: 428 B

After

Width:  |  Height:  |  Size: 814 B

View file

@ -1 +1 @@
<svg viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg"><path d="M1 4v6h2a3 3 0 0 0 3-3V4H4v3a1 1 0 0 1-1 1V4zm5 3a3 3 0 0 0 3 3h1V8H9a1 1 0 0 1 0-2h1V4H9a3 3 0 0 0-3 3z" fill="#de66f0"/><path d="m12.467 1.523-1.526 5.694 3.02-.015.044 3.795h1.98V5.116h-2.373l.943-3.595z" fill="#eba2f6"/></svg>
<svg clip-rule="evenodd" fill-rule="evenodd" height="12" stroke-linejoin="round" stroke-miterlimit="2" viewBox="0 0 16 12" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m11 3v5h3v3h2v-9h-2v4h-1v-3zm-10 1v6h2c1.646 0 3-1.354 3-3v-3h-2v3c0 .549-.451 1-1 1v-4zm5 3c0 1.646 1.354 3 3 3h1v-2h-1c-.549 0-1-.451-1-1s.451-1 1-1h1v-2h-1c-1.646 0-3 1.354-3 3z" fill="#f066bd"/><path d="m11 3v5h3v3h2v-9h-2v4h-1v-3z" fill="#fff" fill-opacity=".39216"/></svg>

Before

Width:  |  Height:  |  Size: 300 B

After

Width:  |  Height:  |  Size: 457 B

View file

@ -1 +1 @@
<svg viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg"><path d="m1 4v6h2c1.6568542 0 3-1.3431458 3-3v-3h-2v3c0 .5522847-.4477153 1-1 1v-4z" fill="#de66f0"/><path d="m8.482 1.523-1.526 5.694 3.02-.015.043997 3.795h1.980003v-5.881h-2.373l.943-3.595z" fill="#eba2f6"/><path d="m13 2v2h2v-2zm0 4v4.000001h2v-4.000001z" fill="#5abbef"/></svg>
<svg height="12" viewBox="0 0 16 12" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7 3v5h3v3h2v-9h-2v4h-1v-3zm-6 1v6h2c1.657 0 3-1.343 3-3v-3h-2v3c0 .552-.448 1-1 1v-4z" fill="#f066bd"/><path d="m7 3v5h3v3h2v-9h-2v4h-1v-3z" fill="#fff" fill-opacity=".39216"/><path d="m13 2v2h2v-2zm0 4v4h2v-4z" fill="#5abbef"/></svg>

Before

Width:  |  Height:  |  Size: 343 B

After

Width:  |  Height:  |  Size: 328 B

1
editor/icons/uint.svg Normal file
View file

@ -0,0 +1 @@
<svg height="12" viewBox="0 0 16 12" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m5 2v2h2v-2zm2 2v2h-2v-2h-2v4c-.5522847 0-1-.4477153-1-1v-3h-2v3a3 3 0 0 0 0 .0507812 3 3 0 0 0 3 2.9492188h6v-4c.5522847 0 1 .4477153 1 1v3h2v-3c0-1.6568542-1.343146-3-3-3zm5 3c0 1.6568542 1.343146 3 3 3h1v-2h-1c-.552285 0-1-.4477153-1-1v-1h2v-2h-2v-2h-2z" fill="#5abbef"/><path d="m5 10v-6h-2v4a1 1 0 0 1 -1-1v-3h-2v3a3 3 0 0 0 3 3z" fill="#fff" fill-opacity=".39216"/></svg>

After

Width:  |  Height:  |  Size: 470 B

View file

@ -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);

View file

@ -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")),