diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/animation_bezier_editor.cpp | 6 | ||||
-rw-r--r-- | editor/animation_track_editor_plugins.cpp | 4 | ||||
-rw-r--r-- | editor/debugger/editor_profiler.cpp | 2 | ||||
-rw-r--r-- | editor/debugger/editor_visual_profiler.cpp | 2 | ||||
-rw-r--r-- | editor/editor_fonts.cpp | 2 | ||||
-rw-r--r-- | editor/editor_help.cpp | 21 | ||||
-rw-r--r-- | editor/editor_properties_array_dict.cpp | 102 | ||||
-rw-r--r-- | editor/editor_properties_array_dict.h | 7 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 2 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 50 | ||||
-rw-r--r-- | editor/node_3d_editor_gizmos.cpp | 9 | ||||
-rw-r--r-- | editor/plugins/animation_player_editor_plugin.cpp | 8 | ||||
-rw-r--r-- | editor/plugins/animation_state_machine_editor.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 14 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 27 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/quick_open.cpp | 10 | ||||
-rw-r--r-- | editor/rename_dialog.cpp | 2 |
18 files changed, 205 insertions, 71 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index e6a020bf41..57c63dd40d 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -162,7 +162,7 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) { float c = (t - low_pos.x) / (high_pos.x - low_pos.x); - h = low_pos.linear_interpolate(high_pos, c).y; + h = low_pos.lerp(high_pos, c).y; } h = _bezier_h_to_pixel(h); @@ -201,12 +201,12 @@ void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const V if (to.x > p_clip_right) { float c = (p_clip_right - from.x) / (to.x - from.x); - to = from.linear_interpolate(to, c); + to = from.lerp(to, c); } if (from.x < p_clip_left) { float c = (p_clip_left - from.x) / (to.x - from.x); - from = from.linear_interpolate(to, c); + from = from.lerp(to, c); } draw_line(from, to, p_color); diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 695c294ad2..0ce3ab292e 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -112,13 +112,13 @@ void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int if (x_from < p_clip_left) { float c = float(p_clip_left - x_from) / (x_to - x_from); - color = color.linear_interpolate(color_next, c); + color = color.lerp(color_next, c); x_from = p_clip_left; } if (x_to > p_clip_right) { float c = float(p_clip_right - x_from) / (x_to - x_from); - color_next = color.linear_interpolate(color_next, c); + color_next = color.lerp(color_next, c); x_to = p_clip_right; } diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 1577e24ac0..c7d4e9128a 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -136,7 +136,7 @@ Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) c double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.linear_interpolate(get_theme_color("base_color", "Editor"), 0.07); + return c.lerp(get_theme_color("base_color", "Editor"), 0.07); } void EditorProfiler::_item_edited() { diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index d2edba5970..7d2822b1c9 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -132,7 +132,7 @@ Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signat double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.linear_interpolate(get_theme_color("base_color", "Editor"), 0.07); + return c.lerp(get_theme_color("base_color", "Editor"), 0.07); } void EditorVisualProfiler::_item_selected() { diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 8aadf02ea6..cf00c536a7 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -247,10 +247,12 @@ void editor_register_fonts(Ref<Theme> p_theme) { MAKE_BOLD_FONT(df_doc_bold, int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE); MAKE_BOLD_FONT(df_doc_title, int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE); MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE); + MAKE_SOURCE_FONT(df_doc_kbd, (int(EDITOR_GET("text_editor/help/help_source_font_size")) - 1) * EDSCALE); p_theme->set_font("doc", "EditorFonts", df_doc); p_theme->set_font("doc_bold", "EditorFonts", df_doc_bold); p_theme->set_font("doc_title", "EditorFonts", df_doc_title); p_theme->set_font("doc_source", "EditorFonts", df_doc_code); + p_theme->set_font("doc_keyboard", "EditorFonts", df_doc_kbd); // Ruler font MAKE_DEFAULT_FONT(df_rulers, 8 * EDSCALE); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 050b0a5f33..8089d463bd 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -47,12 +47,12 @@ void EditorHelp::_init_colors() { title_color = get_theme_color("accent_color", "Editor"); text_color = get_theme_color("default_color", "RichTextLabel"); headline_color = get_theme_color("headline_color", "EditorHelp"); - base_type_color = title_color.linear_interpolate(text_color, 0.5); + base_type_color = title_color.lerp(text_color, 0.5); comment_color = text_color * Color(1, 1, 1, 0.6); symbol_color = comment_color; value_color = text_color * Color(1, 1, 1, 0.6); qualifier_color = text_color * Color(1, 1, 1, 0.8); - type_color = get_theme_color("accent_color", "Editor").linear_interpolate(text_color, 0.5); + type_color = get_theme_color("accent_color", "Editor").lerp(text_color, 0.5); class_desc->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); class_desc->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE)); } @@ -196,7 +196,7 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) { } } const Color text_color = get_theme_color("default_color", "RichTextLabel"); - const Color type_color = get_theme_color("accent_color", "Editor").linear_interpolate(text_color, 0.5); + const Color type_color = get_theme_color("accent_color", "Editor").lerp(text_color, 0.5); class_desc->push_color(type_color); bool add_array = false; if (can_ref) { @@ -1222,11 +1222,14 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { Ref<Font> doc_font = p_rt->get_theme_font("doc", "EditorFonts"); Ref<Font> doc_bold_font = p_rt->get_theme_font("doc_bold", "EditorFonts"); Ref<Font> doc_code_font = p_rt->get_theme_font("doc_source", "EditorFonts"); + Ref<Font> doc_kbd_font = p_rt->get_theme_font("doc_keyboard", "EditorFonts"); Color font_color_hl = p_rt->get_theme_color("headline_color", "EditorHelp"); Color accent_color = p_rt->get_theme_color("accent_color", "Editor"); - Color link_color = accent_color.linear_interpolate(font_color_hl, 0.8); - Color code_color = accent_color.linear_interpolate(font_color_hl, 0.6); + Color property_color = p_rt->get_theme_color("property_color", "Editor"); + Color link_color = accent_color.lerp(font_color_hl, 0.8); + Color code_color = accent_color.lerp(font_color_hl, 0.6); + Color kbd_color = accent_color.lerp(property_color, 0.6); String bbcode = p_bbcode.dedent().replace("\t", "").replace("\r", "").strip_edges(); @@ -1337,6 +1340,14 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { code_tag = true; pos = brk_end + 1; tag_stack.push_front(tag); + } else if (tag == "kbd") { + + //use keyboard font with custom color + p_rt->push_font(doc_kbd_font); + p_rt->push_color(kbd_color); + code_tag = true; // though not strictly a code tag, logic is similar + pos = brk_end + 1; + tag_stack.push_front(tag); } else if (tag == "center") { //align to center diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index fdd5bd8db6..49cffb015f 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -412,8 +412,104 @@ void EditorPropertyArray::_remove_pressed(int p_index) { update_property(); } +void EditorPropertyArray::_button_draw() { + if (dropping) { + Color color = get_theme_color("accent_color", "Editor"); + edit->draw_rect(Rect2(Point2(), edit->get_size()), color, false); + } +} + +bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const { + String allowed_type = Variant::get_type_name(subtype); + + Dictionary drag_data = p_drag_data; + + if (drag_data.has("type") && String(drag_data["type"]) == "files") { + + Vector<String> files = drag_data["files"]; + + for (int i = 0; i < files.size(); i++) { + String file = files[i]; + String ftype = EditorFileSystem::get_singleton()->get_file_type(file); + + for (int j = 0; j < allowed_type.get_slice_count(","); j++) { + String at = allowed_type.get_slice(",", j).strip_edges(); + // Fail if one of the files is not of allowed type + if (!ClassDB::is_parent_class(ftype, at)) { + return false; + } + } + } + + // If no files fail, drop is valid + return true; + } + + return false; +} + +bool EditorPropertyArray::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { + + return _is_drop_valid(p_data); +} + +void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { + ERR_FAIL_COND(!_is_drop_valid(p_data)); + + Dictionary drag_data = p_data; + + if (drag_data.has("type") && String(drag_data["type"]) == "files") { + + Vector<String> files = drag_data["files"]; + + Variant array = object->get_array(); + + // Handle the case where array is not initialised yet + if (!array.is_array()) { + Callable::CallError ce; + array = Variant::construct(array_type, nullptr, 0, ce); + } + + // Loop the file array and add to existing array + for (int i = 0; i < files.size(); i++) { + String file = files[i]; + + RES res = ResourceLoader::load(file); + if (res.is_valid()) { + array.call("push_back", res); + } + } + + if (array.get_type() == Variant::ARRAY) { + array = array.call("duplicate"); + } + + emit_changed(get_edited_property(), array, "", false); + object->set_array(array); + + update_property(); + } +} + void EditorPropertyArray::_notification(int p_what) { + if (p_what == NOTIFICATION_DRAG_BEGIN) { + + if (is_visible_in_tree()) { + if (_is_drop_valid(get_viewport()->gui_get_drag_data())) { + dropping = true; + edit->update(); + } + } + } + + if (p_what == NOTIFICATION_DRAG_END) { + if (dropping) { + dropping = false; + edit->update(); + } + } } + void EditorPropertyArray::_edit_pressed() { Variant array = get_edited_object()->get(get_edited_property()); @@ -490,6 +586,8 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint } void EditorPropertyArray::_bind_methods() { + ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &EditorPropertyArray::can_drop_data_fw); + ClassDB::bind_method(D_METHOD("drop_data_fw"), &EditorPropertyArray::drop_data_fw); } EditorPropertyArray::EditorPropertyArray() { @@ -503,6 +601,8 @@ EditorPropertyArray::EditorPropertyArray() { edit->set_clip_text(true); edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_edit_pressed)); edit->set_toggle_mode(true); + edit->set_drag_forwarding(this); + edit->connect("draw", callable_mp(this, &EditorPropertyArray::_button_draw)); add_child(edit); add_focusable(edit); vbox = nullptr; @@ -524,6 +624,8 @@ EditorPropertyArray::EditorPropertyArray() { subtype = Variant::NIL; subtype_hint = PROPERTY_HINT_NONE; subtype_hint_string = ""; + + dropping = false; } ///////////////////// DICTIONARY /////////////////////////// diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index 51a4be1b3a..d6f3c976f9 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -33,6 +33,7 @@ #include "editor/editor_inspector.h" #include "editor/editor_spin_slider.h" +#include "editor/filesystem_dock.h" #include "scene/gui/button.h" class EditorPropertyArrayObject : public Reference { @@ -82,6 +83,7 @@ class EditorPropertyArray : public EditorProperty { PopupMenu *change_type; bool updating; + bool dropping; Ref<EditorPropertyArrayObject> object; int page_len; @@ -107,6 +109,11 @@ class EditorPropertyArray : public EditorProperty { void _object_id_selected(const StringName &p_property, ObjectID p_id); void _remove_pressed(int p_index); + void _button_draw(); + bool _is_drop_valid(const Dictionary &p_drag_data) const; + bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; + void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); + protected: static void _bind_methods(); void _notification(int p_what); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 9b58c18f51..5e34913cf0 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -561,6 +561,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // 3D: Freelook _initial_set("editors/3d/freelook/freelook_navigation_scheme", false); hints["editors/3d/freelook/freelook_navigation_scheme"] = PropertyInfo(Variant::INT, "editors/3d/freelook/freelook_navigation_scheme", PROPERTY_HINT_ENUM, "Default,Partially Axis-Locked (id Tech),Fully Axis-Locked (Minecraft)"); + _initial_set("editors/3d/freelook/freelook_sensitivity", 0.4); + hints["editors/3d/freelook/freelook_sensitivity"] = PropertyInfo(Variant::FLOAT, "editors/3d/freelook/freelook_sensitivity", PROPERTY_HINT_RANGE, "0.0, 2, 0.01"); _initial_set("editors/3d/freelook/freelook_inertia", 0.1); hints["editors/3d/freelook/freelook_inertia"] = PropertyInfo(Variant::FLOAT, "editors/3d/freelook/freelook_inertia", PROPERTY_HINT_RANGE, "0.0, 1, 0.01"); _initial_set("editors/3d/freelook/freelook_base_speed", 5.0); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 576ee436de..0ef173f074 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -337,24 +337,24 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { //Colors bool dark_theme = EditorSettings::get_singleton()->is_dark_theme(); - const Color dark_color_1 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast); - const Color dark_color_2 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 1.5); - const Color dark_color_3 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 2); + const Color dark_color_1 = base_color.lerp(Color(0, 0, 0, 1), contrast); + const Color dark_color_2 = base_color.lerp(Color(0, 0, 0, 1), contrast * 1.5); + const Color dark_color_3 = base_color.lerp(Color(0, 0, 0, 1), contrast * 2); const Color background_color = dark_color_2; // white (dark theme) or black (light theme), will be used to generate the rest of the colors const Color mono_color = dark_theme ? Color(1, 1, 1) : Color(0, 0, 0); - const Color contrast_color_1 = base_color.linear_interpolate(mono_color, MAX(contrast, default_contrast)); - const Color contrast_color_2 = base_color.linear_interpolate(mono_color, MAX(contrast * 1.5, default_contrast * 1.5)); + const Color contrast_color_1 = base_color.lerp(mono_color, MAX(contrast, default_contrast)); + const Color contrast_color_2 = base_color.lerp(mono_color, MAX(contrast * 1.5, default_contrast * 1.5)); - const Color font_color = mono_color.linear_interpolate(base_color, 0.25); - const Color font_color_hl = mono_color.linear_interpolate(base_color, 0.15); + const Color font_color = mono_color.lerp(base_color, 0.25); + const Color font_color_hl = mono_color.lerp(base_color, 0.15); const Color font_color_disabled = Color(mono_color.r, mono_color.g, mono_color.b, 0.3); const Color font_color_selection = accent_color * Color(1, 1, 1, 0.4); - const Color color_disabled = mono_color.inverted().linear_interpolate(base_color, 0.7); - const Color color_disabled_bg = mono_color.inverted().linear_interpolate(base_color, 0.9); + const Color color_disabled = mono_color.inverted().lerp(base_color, 0.7); + const Color color_disabled_bg = mono_color.inverted().lerp(base_color, 0.9); Color icon_color_hover = Color(1, 1, 1) * (dark_theme ? 1.15 : 1.45); icon_color_hover.a = 1.0; @@ -391,13 +391,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Color success_color = Color(0.45, 0.95, 0.5); Color warning_color = Color(1, 0.87, 0.4); Color error_color = Color(1, 0.47, 0.42); - Color property_color = font_color.linear_interpolate(Color(0.5, 0.5, 0.5), 0.5); + Color property_color = font_color.lerp(Color(0.5, 0.5, 0.5), 0.5); if (!dark_theme) { // Darken some colors to be readable on a light background - success_color = success_color.linear_interpolate(mono_color, 0.35); - warning_color = warning_color.linear_interpolate(mono_color, 0.35); - error_color = error_color.linear_interpolate(mono_color, 0.25); + success_color = success_color.lerp(mono_color, 0.35); + warning_color = warning_color.lerp(mono_color, 0.35); + error_color = error_color.lerp(mono_color, 0.25); } theme->set_color("success_color", "Editor", success_color); @@ -434,7 +434,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { editor_register_fonts(theme); // Highlighted tabs and border width - Color tab_color = highlight_tabs ? base_color.linear_interpolate(font_color, contrast) : base_color; + Color tab_color = highlight_tabs ? base_color.lerp(font_color, contrast) : base_color; const int border_width = CLAMP(border_size, 0, 3) * EDSCALE; const int default_margin_size = 4; @@ -686,7 +686,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons")); theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE); - Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1.linear_interpolate(accent_color, 0.08), 2, 0, 2, 2); + Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1.lerp(accent_color, 0.08), 2, 0, 2, 2); sub_inspector_bg->set_border_width(MARGIN_LEFT, 2); sub_inspector_bg->set_border_width(MARGIN_RIGHT, 2); sub_inspector_bg->set_border_width(MARGIN_BOTTOM, 2); @@ -763,9 +763,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("title_button_hover", "Tree", style_tree_title); theme->set_stylebox("title_button_pressed", "Tree", style_tree_title); - Color prop_category_color = dark_color_1.linear_interpolate(mono_color, 0.12); - Color prop_section_color = dark_color_1.linear_interpolate(mono_color, 0.09); - Color prop_subsection_color = dark_color_1.linear_interpolate(mono_color, 0.06); + 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); @@ -1124,7 +1124,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("toggle_hidden", "FileDialog", theme->get_icon("GuiVisibilityVisible", "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_modulate", "FileDialog", (dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).linear_interpolate(accent_color, 0.7)); + theme->set_color("folder_icon_modulate", "FileDialog", (dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).lerp(accent_color, 0.7)); theme->set_color("files_disabled", "FileDialog", font_color_disabled); // color picker @@ -1158,13 +1158,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // editor main color const Color main_color = dark_theme ? Color(0.34, 0.7, 1.0) : Color(0.02, 0.5, 1.0); - const Color symbol_color = Color(0.34, 0.57, 1.0).linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); + const Color symbol_color = Color(0.34, 0.57, 1.0).lerp(mono_color, dark_theme ? 0.5 : 0.3); const Color keyword_color = Color(1.0, 0.44, 0.52); const Color basetype_color = dark_theme ? Color(0.26, 1.0, 0.76) : Color(0.0, 0.76, 0.38); - const Color type_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.4 : 0.3); - const Color usertype_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.7 : 0.5); + const Color type_color = basetype_color.lerp(mono_color, dark_theme ? 0.4 : 0.3); + const Color usertype_color = basetype_color.lerp(mono_color, dark_theme ? 0.7 : 0.5); const Color comment_color = dim_color; - const Color string_color = (dark_theme ? Color(1.0, 0.85, 0.26) : Color(1.0, 0.82, 0.09)).linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); + const Color string_color = (dark_theme ? Color(1.0, 0.85, 0.26) : Color(1.0, 0.82, 0.09)).lerp(mono_color, dark_theme ? 0.5 : 0.3); const Color te_background_color = dark_theme ? background_color : base_color; const Color completion_background_color = dark_theme ? base_color : background_color; @@ -1183,9 +1183,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color current_line_color = alpha1; const Color line_length_guideline_color = dark_theme ? base_color : background_color; const Color word_highlighted_color = alpha1; - const Color number_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); + const Color number_color = basetype_color.lerp(mono_color, dark_theme ? 0.5 : 0.3); const Color function_color = main_color; - const Color member_variable_color = main_color.linear_interpolate(mono_color, 0.6); + const Color member_variable_color = main_color.lerp(mono_color, 0.6); const Color mark_color = Color(error_color.r, error_color.g, error_color.b, 0.3); const Color bookmark_color = Color(0.08, 0.49, 0.98); const Color breakpoint_color = error_color; diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp index 31a8320209..5fcc783644 100644 --- a/editor/node_3d_editor_gizmos.cpp +++ b/editor/node_3d_editor_gizmos.cpp @@ -486,11 +486,12 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector Vector<Plane> transformed_frustum; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < p_frustum.size(); i++) { transformed_frustum.push_back(it.xform(p_frustum[i])); } - if (collision_mesh->inside_convex_shape(transformed_frustum.ptr(), transformed_frustum.size(), mesh_scale)) { + Vector<Vector3> convex_points = Geometry::compute_convex_mesh_points(p_frustum.ptr(), p_frustum.size()); + if (collision_mesh->inside_convex_shape(transformed_frustum.ptr(), transformed_frustum.size(), convex_points.ptr(), convex_points.size(), mesh_scale)) { return true; } } @@ -2827,10 +2828,10 @@ void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { lines.push_back(a); lines.push_back(b); } else { - Vector3 ah = a.linear_interpolate(b, 0.2); + Vector3 ah = a.lerp(b, 0.2); lines.push_back(a); lines.push_back(ah); - Vector3 bh = b.linear_interpolate(a, 0.2); + Vector3 bh = b.lerp(a, 0.2); lines.push_back(b); lines.push_back(bh); } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index db51c5c6ba..0a252cc0a3 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -433,7 +433,9 @@ void AnimationPlayerEditor::_animation_remove() { if (animation->get_item_count() == 0) return; - delete_dialog->set_text(TTR("Delete Animation?")); + String current = animation->get_item_text(animation->get_selected()); + + delete_dialog->set_text(TTR("Delete Animation '" + current + "'?")); delete_dialog->popup_centered(); } @@ -1135,7 +1137,9 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { case TOOL_DUPLICATE_ANIM: { _animation_duplicate(); - } break; + + [[fallthrough]]; // Allow immediate rename after animation is duplicated + } case TOOL_RENAME_ANIM: { _animation_rename(); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index c28f533958..ed51a2d2cf 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -885,7 +885,7 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() { state_machine_play_pos->draw_line(from, to, bg, 2); - to = from.linear_interpolate(to, c); + to = from.lerp(to, c); state_machine_play_pos->draw_line(from, to, fg, 2); } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 79111762b2..e882b3a8d7 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1437,13 +1437,13 @@ void CanvasItemEditor::_solve_IK(Node2D *leaf_node, Point2 target_position) { Vector2 direction = (joints_pos[node_id + 1] - joints_pos[node_id]).normalized(); int len = E->get(); if (E == se->pre_drag_bones_length.front()) { - joints_pos[1] = joints_pos[1].linear_interpolate(joints_pos[0] + len * direction, solver_k); + joints_pos[1] = joints_pos[1].lerp(joints_pos[0] + len * direction, solver_k); } else if (E == se->pre_drag_bones_length.back()) { - joints_pos[node_id] = joints_pos[node_id].linear_interpolate(joints_pos[node_id + 1] - len * direction, solver_k); + joints_pos[node_id] = joints_pos[node_id].lerp(joints_pos[node_id + 1] - len * direction, solver_k); } else { Vector2 center = (joints_pos[node_id + 1] + joints_pos[node_id]) / 2.0; - joints_pos[node_id] = joints_pos[node_id].linear_interpolate(center - (direction * len) / 2.0, solver_k); - joints_pos[node_id + 1] = joints_pos[node_id + 1].linear_interpolate(center + (direction * len) / 2.0, solver_k); + joints_pos[node_id] = joints_pos[node_id].lerp(center - (direction * len) / 2.0, solver_k); + joints_pos[node_id + 1] = joints_pos[node_id + 1].lerp(center + (direction * len) / 2.0, solver_k); } node_id++; } @@ -2698,7 +2698,7 @@ void CanvasItemEditor::_draw_smart_snapping() { void CanvasItemEditor::_draw_rulers() { Color bg_color = get_theme_color("dark_color_2", "Editor"); - Color graduation_color = get_theme_color("font_color", "Editor").linear_interpolate(bg_color, 0.5); + Color graduation_color = get_theme_color("font_color", "Editor").lerp(bg_color, 0.5); Color font_color = get_theme_color("font_color", "Editor"); font_color.a = 0.8; Ref<Font> font = get_theme_font("rulers", "EditorFonts"); @@ -3072,8 +3072,8 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { Vector2 line_ends[4]; for (int i = 0; i < 4; i++) { float anchor_val = (i >= 2) ? ANCHOR_END - anchors_values[i] : anchors_values[i]; - line_starts[i] = Vector2::linear_interpolate(corners_pos[i], corners_pos[(i + 1) % 4], anchor_val); - line_ends[i] = Vector2::linear_interpolate(corners_pos[(i + 3) % 4], corners_pos[(i + 2) % 4], anchor_val); + line_starts[i] = corners_pos[i].lerp(corners_pos[(i + 1) % 4], anchor_val); + line_ends[i] = corners_pos[(i + 3) % 4].lerp(corners_pos[(i + 2) % 4], anchor_val); anchor_snapped = anchors_values[i] == 0.0 || anchors_values[i] == 0.5 || anchors_values[i] == 1.0; viewport->draw_line(line_starts[i], line_ends[i], anchor_snapped ? color_snapped : color_base, (i == dragged_anchor || (i + 3) % 4 == dragged_anchor) ? 2 : 1); } diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index af34dd5cab..60a49f72c0 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -268,7 +268,7 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) { real_t factor = (1.0 / inertia) * p_interp_delta; // We interpolate a different point here, because in freelook mode the focus point (cursor.pos) orbits around eye_pos - camera_cursor.eye_pos = old_camera_cursor.eye_pos.linear_interpolate(cursor.eye_pos, CLAMP(factor, 0, 1)); + camera_cursor.eye_pos = old_camera_cursor.eye_pos.lerp(cursor.eye_pos, CLAMP(factor, 0, 1)); float orbit_inertia = EDITOR_GET("editors/3d/navigation_feel/orbit_inertia"); orbit_inertia = MAX(0.0001, orbit_inertia); @@ -318,7 +318,7 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) { camera_cursor.y_rot = cursor.y_rot; } - camera_cursor.pos = old_camera_cursor.pos.linear_interpolate(cursor.pos, MIN(1.f, p_interp_delta * (1 / translation_inertia))); + camera_cursor.pos = old_camera_cursor.pos.lerp(cursor.pos, MIN(1.f, p_interp_delta * (1 / translation_inertia))); camera_cursor.distance = Math::lerp(old_camera_cursor.distance, cursor.distance, MIN(1.f, p_interp_delta * (1 / zoom_inertia))); } } @@ -674,17 +674,13 @@ void Node3DEditorViewport::_select_region() { } } - if (!orthogonal) { - Plane near(cam_pos, -_get_camera_normal()); - near.d -= get_znear(); + Plane near(cam_pos, -_get_camera_normal()); + near.d -= get_znear(); + frustum.push_back(near); - frustum.push_back(near); - - Plane far = -near; - far.d += get_zfar(); - - frustum.push_back(far); - } + Plane far = -near; + far.d += get_zfar(); + frustum.push_back(far); Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world()->get_scenario()); Vector<Node *> selected; @@ -2166,7 +2162,7 @@ void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const _menu_option(VIEW_PERSPECTIVE); } - real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity"); + real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/freelook/freelook_sensitivity"); real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel); bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y_axis"); @@ -2882,7 +2878,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { undo_redo->add_undo_method(sp, "set_global_transform", sp->get_global_gizmo_transform()); } undo_redo->commit_action(); - focus_selection(); } break; case VIEW_ALIGN_ROTATION_WITH_VIEW: { @@ -4570,10 +4565,10 @@ void Node3DEditor::_generate_selection_box() { st->add_color(Color(1.0, 1.0, 0.8, 0.8)); st->add_vertex(a); st->add_color(Color(1.0, 1.0, 0.8, 0.4)); - st->add_vertex(a.linear_interpolate(b, 0.2)); + st->add_vertex(a.lerp(b, 0.2)); st->add_color(Color(1.0, 1.0, 0.8, 0.4)); - st->add_vertex(a.linear_interpolate(b, 0.8)); + st->add_vertex(a.lerp(b, 0.8)); st->add_color(Color(1.0, 1.0, 0.8, 0.8)); st->add_vertex(b); } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 7af98cf346..35a08f2d1c 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1742,7 +1742,7 @@ void ScriptEditor::_update_script_colors() { int non_zero_hist_size = (hist_size == 0) ? 1 : hist_size; float v = Math::ease((edit_pass - pass) / float(non_zero_hist_size), 0.4); - script_list->set_item_custom_fg_color(i, hot_color.linear_interpolate(cold_color, v)); + script_list->set_item_custom_fg_color(i, hot_color.lerp(cold_color, v)); } } } @@ -1866,6 +1866,10 @@ void ScriptEditor::_update_script_names() { if (new_cur_tab == -1 && sedata[i].index == cur_tab) { new_cur_tab = i; } + // Update index of sd entries for sorted order + _ScriptEditorItemData sd = sedata[i]; + sd.index = i; + sedata.set(i, sd); } tab_container->set_current_tab(new_prev_tab); tab_container->set_current_tab(new_cur_tab); diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 1b4439f0a8..b872bc3dd4 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -113,12 +113,18 @@ void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) { float EditorQuickOpen::_path_cmp(String search, String path) const { + // Exact match. if (search == path) { return 1.2f; } - if (path.findn(search) != -1) { - return 1.1f; + + // Substring match, with positive bias for matches close to the end of the path. + int pos = path.rfindn(search); + if (pos != -1) { + return 1.1f + 0.09 / (path.length() - pos + 1); } + + // Similarity. return path.to_lower().similarity(search.to_lower()); } diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 0266ef6a2b..8ae8d0991d 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -403,7 +403,7 @@ void RenameDialog::_update_preview(String new_text) { // 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("accent_color", "Editor"); const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("default_color", "RichTextLabel"); - lbl_preview->add_theme_color_override("font_color", accent_color.linear_interpolate(text_color, 0.5)); + 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("success_color", "Editor")); } |