diff options
-rw-r--r-- | core/register_core_types.cpp | 2 | ||||
-rw-r--r-- | core/script_language.h | 1 | ||||
-rw-r--r-- | doc/classes/Transform.xml | 4 | ||||
-rw-r--r-- | doc/classes/Transform2D.xml | 3 | ||||
-rw-r--r-- | drivers/gles2/shader_compiler_gles2.cpp | 2 | ||||
-rw-r--r-- | editor/animation_track_editor.cpp | 6 | ||||
-rw-r--r-- | editor/animation_track_editor.h | 6 | ||||
-rw-r--r-- | editor/code_editor.cpp | 51 | ||||
-rw-r--r-- | editor/code_editor.h | 1 | ||||
-rw-r--r-- | editor/editor_node.cpp | 2 | ||||
-rw-r--r-- | editor/editor_node.h | 2 | ||||
-rw-r--r-- | editor/rename_dialog.cpp | 6 | ||||
-rw-r--r-- | editor/rename_dialog.h | 7 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 1 | ||||
-rw-r--r-- | editor/script_create_dialog.cpp | 4 | ||||
-rw-r--r-- | editor/script_create_dialog.h | 4 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 2 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 72 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 8 | ||||
-rw-r--r-- | servers/visual/visual_server_canvas.cpp | 17 | ||||
-rw-r--r-- | servers/visual/visual_server_canvas.h | 1 |
21 files changed, 140 insertions, 62 deletions
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index af863dd385..11cd07042f 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -190,6 +190,8 @@ void register_core_types() { ClassDB::register_class<JSONParseResult>(); + ClassDB::register_virtual_class<ResourceImporter>(); + ip = IP::create(); _geometry = memnew(_Geometry); diff --git a/core/script_language.h b/core/script_language.h index cb103646ed..87f103bb33 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -216,6 +216,7 @@ struct ScriptCodeCompletionOption { Kind kind; String display; String insert_text; + RES icon; ScriptCodeCompletionOption() { kind = KIND_PLAIN_TEXT; diff --git a/doc/classes/Transform.xml b/doc/classes/Transform.xml index 80a393dcee..9916d25af5 100644 --- a/doc/classes/Transform.xml +++ b/doc/classes/Transform.xml @@ -167,12 +167,16 @@ </members> <constants> <constant name="IDENTITY" value="Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + [Transform] with no translation, rotation or scaling applied. When applied to other data structures, [constant IDENTITY] performs no transformation. </constant> <constant name="FLIP_X" value="Transform( -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + [Transform] with mirroring applied perpendicular to the YZ plane. </constant> <constant name="FLIP_Y" value="Transform( 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0 )"> + [Transform] with mirroring applied perpendicular to the XZ plane. </constant> <constant name="FLIP_Z" value="Transform( 1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0 )"> + [Transform] with mirroring applied perpendicular to the XY plane. </constant> </constants> </class> diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index c5ae88d050..f6fce1aaa1 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -172,10 +172,13 @@ </members> <constants> <constant name="IDENTITY" value="Transform2D( 1, 0, 0, 1, 0, 0 )"> + [Transform2D] with no translation, rotation or scaling applied. When applied to other data structures, [constant IDENTITY] performs no transformation. </constant> <constant name="FLIP_X" value="Transform2D( -1, 0, 0, 1, 0, 0 )"> + [Transform2D] with mirroring applied parallel to the X axis. </constant> <constant name="FLIP_Y" value="Transform2D( 1, 0, 0, -1, 0, 0 )"> + [Transform2D] with mirroring applied parallel to the Y axis. </constant> </constants> </class> diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index b48b93944c..ee34a478b1 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -318,7 +318,7 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener // use highp if no precision is specified to prevent different default values in fragment and vertex shader SL::DataPrecision precision = E->get().precision; - if (precision == SL::PRECISION_DEFAULT) { + if (precision == SL::PRECISION_DEFAULT && E->get().type != SL::TYPE_BOOL) { precision = SL::PRECISION_HIGHP; } diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index c835dda1b9..f5b5cfa848 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -5273,17 +5273,17 @@ AnimationTrackEditor::AnimationTrackEditor() { VBoxContainer *cleanup_vb = memnew(VBoxContainer); cleanup_dialog->add_child(cleanup_vb); - cleanup_keys = memnew(CheckButton); + cleanup_keys = memnew(CheckBox); cleanup_keys->set_text(TTR("Remove invalid keys")); cleanup_keys->set_pressed(true); cleanup_vb->add_child(cleanup_keys); - cleanup_tracks = memnew(CheckButton); + cleanup_tracks = memnew(CheckBox); cleanup_tracks->set_text(TTR("Remove unresolved and empty tracks")); cleanup_tracks->set_pressed(true); cleanup_vb->add_child(cleanup_tracks); - cleanup_all = memnew(CheckButton); + cleanup_all = memnew(CheckBox); cleanup_all->set_text(TTR("Clean-up all animations")); cleanup_vb->add_child(cleanup_all); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 0d5a621e07..8dc2304a95 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -439,9 +439,9 @@ class AnimationTrackEditor : public VBoxContainer { SpinBox *optimize_max_angle; ConfirmationDialog *cleanup_dialog; - CheckButton *cleanup_keys; - CheckButton *cleanup_tracks; - CheckButton *cleanup_all; + CheckBox *cleanup_keys; + CheckBox *cleanup_tracks; + CheckBox *cleanup_all; ConfirmationDialog *scale_dialog; SpinBox *scale; diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index d59f9a2e94..7c396e1da3 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -738,15 +738,54 @@ void CodeTextEditor::_complete_request() { if (entries.size() == 0) return; - Vector<String> options; - options.resize(entries.size()); - size_t i = 0; for (List<ScriptCodeCompletionOption>::Element *E = entries.front(); E; E = E->next()) { - options.write[i] = E->get().insert_text; - i++; + E->get().icon = _get_completion_icon(E->get()); } + text_editor->code_complete(entries, forced); +} - text_editor->code_complete(options, forced); +Ref<Texture> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOption &p_option) { + Ref<Texture> tex; + switch (p_option.kind) { + case ScriptCodeCompletionOption::KIND_CLASS: { + if (has_icon(p_option.display, "EditorIcons")) { + tex = get_icon(p_option.display, "EditorIcons"); + } else { + tex = get_icon("Object", "EditorIcons"); + } + } break; + case ScriptCodeCompletionOption::KIND_ENUM: + tex = get_icon("Enum", "EditorIcons"); + break; + case ScriptCodeCompletionOption::KIND_FILE_PATH: + tex = get_icon("File", "EditorIcons"); + break; + case ScriptCodeCompletionOption::KIND_NODE_PATH: + tex = get_icon("NodePath", "EditorIcons"); + break; + case ScriptCodeCompletionOption::KIND_VARIABLE: + tex = get_icon("Variant", "EditorIcons"); + break; + case ScriptCodeCompletionOption::KIND_CONSTANT: + tex = get_icon("MemberConstant", "EditorIcons"); + break; + case ScriptCodeCompletionOption::KIND_MEMBER: + tex = get_icon("MemberProperty", "EditorIcons"); + break; + case ScriptCodeCompletionOption::KIND_SIGNAL: + tex = get_icon("MemberSignal", "EditorIcons"); + break; + case ScriptCodeCompletionOption::KIND_FUNCTION: + tex = get_icon("MemberMethod", "EditorIcons"); + break; + case ScriptCodeCompletionOption::KIND_PLAIN_TEXT: + tex = get_icon("CubeMesh", "EditorIcons"); + break; + default: + tex = get_icon("String", "EditorIcons"); + break; + } + return tex; } void CodeTextEditor::_font_resize_timeout() { diff --git a/editor/code_editor.h b/editor/code_editor.h index 2653a8cecc..5af1f531a9 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -162,6 +162,7 @@ class CodeTextEditor : public VBoxContainer { void _update_font(); void _complete_request(); + Ref<Texture> _get_completion_icon(const ScriptCodeCompletionOption &p_option); void _font_resize_timeout(); bool _add_font_size(int p_delta); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d9600172d7..8d2d760e51 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6258,7 +6258,7 @@ EditorNode::EditorNode() { file_export_lib->set_title(TTR("Export Library")); file_export_lib->set_mode(EditorFileDialog::MODE_SAVE_FILE); file_export_lib->connect("file_selected", this, "_dialog_action"); - file_export_lib_merge = memnew(CheckButton); + file_export_lib_merge = memnew(CheckBox); file_export_lib_merge->set_text(TTR("Merge With Existing")); file_export_lib_merge->set_pressed(true); file_export_lib->get_vbox()->add_child(file_export_lib_merge); diff --git a/editor/editor_node.h b/editor/editor_node.h index ca64126c60..733f29c8ff 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -330,7 +330,7 @@ private: EditorFileDialog *file_export; EditorFileDialog *file_export_lib; EditorFileDialog *file_script; - CheckButton *file_export_lib_merge; + CheckBox *file_export_lib_merge; LineEdit *file_export_password; String current_path; MenuButton *update_spinner; diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 40343cf908..cc9e14975f 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -131,7 +131,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und vbc_substitute->set_name(TTR("Substitute")); tabc_features->add_child(vbc_substitute); - cbut_substitute = memnew(CheckButton); + cbut_substitute = memnew(CheckBox); cbut_substitute->set_text(TTR("Substitute")); vbc_substitute->add_child(cbut_substitute); @@ -246,7 +246,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und vbc_regex->set_custom_minimum_size(Size2(0, feature_min_height)); tabc_features->add_child(vbc_regex); - cbut_regex = memnew(CheckButton); + cbut_regex = memnew(CheckBox); cbut_regex->set_text(TTR("Regular Expressions")); vbc_regex->add_child(cbut_regex); @@ -258,7 +258,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und vbc_process->set_custom_minimum_size(Size2(0, feature_min_height)); tabc_features->add_child(vbc_process); - cbut_process = memnew(CheckButton); + cbut_process = memnew(CheckBox); cbut_process->set_text(TTR("Post-Process")); vbc_process->add_child(cbut_process); diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h index 4e0fab6a9f..9f0fbf66a1 100644 --- a/editor/rename_dialog.h +++ b/editor/rename_dialog.h @@ -32,7 +32,6 @@ #define RENAME_DIALOG_H #include "scene/gui/check_box.h" -#include "scene/gui/check_button.h" #include "scene/gui/dialogs.h" #include "scene/gui/option_button.h" #include "scene/gui/spin_box.h" @@ -75,9 +74,9 @@ class RenameDialog : public ConfirmationDialog { TabContainer *tabc_features; - CheckButton *cbut_substitute; - CheckButton *cbut_regex; - CheckButton *cbut_process; + CheckBox *cbut_substitute; + CheckBox *cbut_regex; + CheckBox *cbut_process; CheckBox *chk_per_level_counter; Button *but_insert_name; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 442de08ffa..2458aa0759 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -439,6 +439,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } script_create_dialog->connect("script_created", this, "_script_created"); script_create_dialog->connect("popup_hide", this, "_script_creation_closed"); + script_create_dialog->set_inheritance_base_type("Node"); script_create_dialog->config(inherits, path); script_create_dialog->popup_centered(); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 8916f4d8c4..bebfe6d3a1 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -742,8 +742,8 @@ ScriptCreateDialog::ScriptCreateDialog() { /* Built-in Script */ - internal = memnew(CheckButton); - internal->set_h_size_flags(0); + internal = memnew(CheckBox); + internal->set_text(TTR("On")); internal->connect("pressed", this, "_built_in_pressed"); internal_label = memnew(Label(TTR("Built-in Script"))); internal_label->set_align(Label::ALIGN_RIGHT); diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h index 61f87f5732..288b8f604b 100644 --- a/editor/script_create_dialog.h +++ b/editor/script_create_dialog.h @@ -33,7 +33,7 @@ #include "editor/editor_file_dialog.h" #include "editor/editor_settings.h" -#include "scene/gui/check_button.h" +#include "scene/gui/check_box.h" #include "scene/gui/dialogs.h" #include "scene/gui/grid_container.h" #include "scene/gui/line_edit.h" @@ -57,7 +57,7 @@ class ScriptCreateDialog : public ConfirmationDialog { LineEdit *file_path; Button *path_button; EditorFileDialog *file_browse; - CheckButton *internal; + CheckBox *internal; Label *internal_label; VBoxContainer *path_vb; AcceptDialog *alert; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index e535f6a148..0a9cfc0214 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2586,7 +2586,7 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, modstr.resize(cmdline.size()); for (int i = 0; i < cmdline.size(); i++) modstr.write[i] = cmdline[i]; - int ret = CreateProcessW(NULL, modstr.ptrw(), NULL, NULL, 0, NORMAL_PRIORITY_CLASS, NULL, NULL, si_w, &pi.pi); + int ret = CreateProcessW(NULL, modstr.ptrw(), NULL, NULL, 0, NORMAL_PRIORITY_CLASS & CREATE_NO_WINDOW, NULL, NULL, si_w, &pi.pi); ERR_FAIL_COND_V(ret == 0, ERR_CANT_FORK); if (p_blocking) { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index a6e3d644f6..9242e7997a 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -35,6 +35,7 @@ #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/project_settings.h" +#include "core/script_language.h" #include "scene/main/viewport.h" #ifdef TOOLS_ENABLED @@ -1362,7 +1363,7 @@ void TextEdit::_notification(int p_what) { if (completion_options.size() < 50) { for (int i = 0; i < completion_options.size(); i++) { - int w2 = MIN(cache.font->get_string_size(completion_options[i]).x, cmax_width); + int w2 = MIN(cache.font->get_string_size(completion_options[i].display).x, cmax_width); if (w2 > w) w = w2; } @@ -1370,6 +1371,11 @@ void TextEdit::_notification(int p_what) { w = cmax_width; } + // Add space for completion icons + const int icon_hsep = get_constant("hseparation", "ItemList"); + Size2 icon_area_size(get_row_height(), get_row_height()); + w += icon_area_size.width + icon_hsep; + int th = h + csb->get_minimum_size().y; if (cursor_pos.y + get_row_height() + th > get_size().height) { @@ -1405,12 +1411,26 @@ void TextEdit::_notification(int p_what) { ERR_CONTINUE(l < 0 || l >= completion_options.size()); Color text_color = cache.completion_font_color; for (int j = 0; j < color_regions.size(); j++) { - if (completion_options[l].begins_with(color_regions[j].begin_key)) { + if (completion_options[l].insert_text.begins_with(color_regions[j].begin_key)) { text_color = color_regions[j].color; } } int yofs = (get_row_height() - cache.font->get_height()) / 2; - draw_string(cache.font, Point2(completion_rect.position.x, completion_rect.position.y + i * get_row_height() + cache.font->get_ascent() + yofs), completion_options[l], text_color, completion_rect.size.width); + Point2 title_pos(completion_rect.position.x, completion_rect.position.y + i * get_row_height() + cache.font->get_ascent() + yofs); + + //draw completion icon if it is valid + Ref<Texture> icon = completion_options[l].icon; + Rect2 icon_area(completion_rect.position.x, completion_rect.position.y + i * get_row_height(), icon_area_size.width, icon_area_size.height); + if (icon.is_valid()) { + const real_t max_scale = 0.7f; + const real_t side = max_scale * icon_area.size.width; + real_t scale = MIN(side / icon->get_width(), side / icon->get_height()); + Size2 icon_size = icon->get_size() * scale; + draw_texture_rect(icon, Rect2(icon_area.position + (icon_area.size - icon_size) / 2, icon_size)); + } + + title_pos.x = icon_area.position.x + icon_area.size.width + icon_hsep; + draw_string(cache.font, title_pos, completion_options[l].display, text_color, completion_rect.size.width); } if (scrollw) { @@ -5925,12 +5945,12 @@ void TextEdit::_confirm_completion() { _remove_text(cursor.line, cursor.column - completion_base.length(), cursor.line, cursor.column); cursor_set_column(cursor.column - completion_base.length(), false); - insert_text_at_cursor(completion_current); + insert_text_at_cursor(completion_current.insert_text); // When inserted into the middle of an existing string/method, don't add an unnecessary quote/bracket. String line = text[cursor.line]; CharType next_char = line[cursor.column]; - CharType last_completion_char = completion_current[completion_current.length() - 1]; + CharType last_completion_char = completion_current.insert_text[completion_current.insert_text.length() - 1]; if ((last_completion_char == '"' || last_completion_char == '\'') && last_completion_char == next_char) { _base_remove_text(cursor.line, cursor.column, cursor.line, cursor.column + 1); @@ -6066,39 +6086,41 @@ void TextEdit::_update_completion_candidates() { completion_base = s; Vector<float> sim_cache; bool single_quote = s.begins_with("'"); - Vector<String> completion_options_casei; + Vector<ScriptCodeCompletionOption> completion_options_casei; + + for (List<ScriptCodeCompletionOption>::Element *E = completion_sources.front(); E; E = E->next()) { + ScriptCodeCompletionOption &option = E->get(); - for (int i = 0; i < completion_strings.size(); i++) { - if (single_quote && completion_strings[i].is_quoted()) { - completion_strings.write[i] = completion_strings[i].unquote().quote("'"); + if (single_quote && option.display.is_quoted()) { + option.display = option.display.unquote().quote("'"); } - if (inquote && restore_quotes == 1 && !completion_strings[i].is_quoted()) { + if (inquote && restore_quotes == 1 && !option.display.is_quoted()) { String quote = single_quote ? "'" : "\""; - completion_strings.write[i] = completion_strings[i].quote(quote); + option.display = option.display.quote(quote); } - if (completion_strings[i].begins_with(s)) { - completion_options.push_back(completion_strings[i]); - } else if (completion_strings[i].to_lower().begins_with(s.to_lower())) { - completion_options_casei.push_back(completion_strings[i]); + if (option.display.begins_with(s)) { + completion_options.push_back(option); + } else if (option.display.to_lower().begins_with(s.to_lower())) { + completion_options_casei.push_back(option); } } completion_options.append_array(completion_options_casei); if (completion_options.size() == 0) { - for (int i = 0; i < completion_strings.size(); i++) { - if (s.is_subsequence_of(completion_strings[i])) { - completion_options.push_back(completion_strings[i]); + for (int i = 0; i < completion_sources.size(); i++) { + if (s.is_subsequence_of(completion_sources[i].display)) { + completion_options.push_back(completion_sources[i]); } } } if (completion_options.size() == 0) { - for (int i = 0; i < completion_strings.size(); i++) { - if (s.is_subsequence_ofi(completion_strings[i])) { - completion_options.push_back(completion_strings[i]); + for (int i = 0; i < completion_sources.size(); i++) { + if (s.is_subsequence_ofi(completion_sources[i].display)) { + completion_options.push_back(completion_sources[i]); } } } @@ -6109,7 +6131,7 @@ void TextEdit::_update_completion_candidates() { return; } - if (completion_options.size() == 1 && s == completion_options[0]) { + if (completion_options.size() == 1 && s == completion_options[0].display) { // A perfect match, stop completion _cancel_completion(); return; @@ -6147,12 +6169,12 @@ void TextEdit::set_code_hint(const String &p_hint) { update(); } -void TextEdit::code_complete(const Vector<String> &p_strings, bool p_forced) { +void TextEdit::code_complete(const List<ScriptCodeCompletionOption> &p_strings, bool p_forced) { - completion_strings = p_strings; + completion_sources = p_strings; completion_active = true; completion_forced = p_forced; - completion_current = ""; + completion_current = ScriptCodeCompletionOption(); completion_index = 0; _update_completion_candidates(); } diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 30956ccb23..9fb8e03288 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -255,11 +255,11 @@ private: Set<String> completion_prefixes; bool completion_enabled; - Vector<String> completion_strings; - Vector<String> completion_options; + List<ScriptCodeCompletionOption> completion_sources; + Vector<ScriptCodeCompletionOption> completion_options; bool completion_active; bool completion_forced; - String completion_current; + ScriptCodeCompletionOption completion_current; String completion_base; int completion_index; Rect2i completion_rect; @@ -704,7 +704,7 @@ public: void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata); void set_completion(bool p_enabled, const Vector<String> &p_prefixes); - void code_complete(const Vector<String> &p_strings, bool p_forced = false); + void code_complete(const List<ScriptCodeCompletionOption> &p_strings, bool p_forced = false); void set_code_hint(const String &p_hint); void query_code_comple(); diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp index 66e2429bd0..fc75fda583 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/visual/visual_server_canvas.cpp @@ -49,13 +49,14 @@ void VisualServerCanvas::_render_canvas_item_tree(Item *p_canvas_item, const Tra } } -void _collect_ysort_children(VisualServerCanvas::Item *p_canvas_item, Transform2D p_transform, VisualServerCanvas::Item *p_material_owner, VisualServerCanvas::Item **r_items, int &r_index) { +void _collect_ysort_children(VisualServerCanvas::Item *p_canvas_item, Transform2D p_transform, VisualServerCanvas::Item *p_material_owner, const Color p_modulate, VisualServerCanvas::Item **r_items, int &r_index) { int child_item_count = p_canvas_item->child_items.size(); VisualServerCanvas::Item **child_items = p_canvas_item->child_items.ptrw(); for (int i = 0; i < child_item_count; i++) { if (child_items[i]->visible) { if (r_items) { r_items[r_index] = child_items[i]; + child_items[i]->ysort_modulate = p_modulate; child_items[i]->ysort_xform = p_transform; child_items[i]->ysort_pos = p_transform.xform(child_items[i]->xform.elements[2]); child_items[i]->material_owner = child_items[i]->use_parent_material ? p_material_owner : NULL; @@ -64,7 +65,11 @@ void _collect_ysort_children(VisualServerCanvas::Item *p_canvas_item, Transform2 r_index++; if (child_items[i]->sort_y) - _collect_ysort_children(child_items[i], p_transform * child_items[i]->xform, child_items[i]->use_parent_material ? p_material_owner : child_items[i], r_items, r_index); + _collect_ysort_children(child_items[i], + p_transform * child_items[i]->xform, + child_items[i]->use_parent_material ? p_material_owner : child_items[i], + p_modulate * child_items[i]->modulate, + r_items, r_index); } } } @@ -125,14 +130,14 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transfor if (ci->ysort_children_count == -1) { ci->ysort_children_count = 0; - _collect_ysort_children(ci, Transform2D(), p_material_owner, NULL, ci->ysort_children_count); + _collect_ysort_children(ci, Transform2D(), p_material_owner, Color(1, 1, 1, 1), NULL, ci->ysort_children_count); } child_item_count = ci->ysort_children_count; child_items = (Item **)alloca(child_item_count * sizeof(Item *)); int i = 0; - _collect_ysort_children(ci, Transform2D(), p_material_owner, child_items, i); + _collect_ysort_children(ci, Transform2D(), p_material_owner, Color(1, 1, 1, 1), child_items, i); SortArray<Item *, ItemPtrSort> sorter; sorter.sort(child_items, child_item_count); @@ -148,7 +153,7 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transfor if (!child_items[i]->behind || (ci->sort_y && child_items[i]->sort_y)) continue; if (ci->sort_y) { - _render_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner); + _render_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate * child_items[i]->ysort_modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner); } else { _render_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner); } @@ -190,7 +195,7 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transfor if (child_items[i]->behind || (ci->sort_y && child_items[i]->sort_y)) continue; if (ci->sort_y) { - _render_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner); + _render_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate * child_items[i]->ysort_modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner); } else { _render_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner); } diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index 28a8770c90..822e3f8ce3 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -49,6 +49,7 @@ public: int index; bool children_order_dirty; int ysort_children_count; + Color ysort_modulate; Transform2D ysort_xform; Vector2 ysort_pos; |