diff options
-rw-r--r-- | core/script_language.cpp | 4 | ||||
-rw-r--r-- | editor/editor_inspector.cpp | 59 | ||||
-rw-r--r-- | editor/editor_inspector.h | 3 | ||||
-rw-r--r-- | editor/editor_properties.cpp | 8 |
4 files changed, 59 insertions, 15 deletions
diff --git a/core/script_language.cpp b/core/script_language.cpp index 360995ea15..b63aeb952c 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -33,8 +33,6 @@ #include "core/core_string_names.h" #include "core/debugger/engine_debugger.h" #include "core/debugger/script_debugger.h" -#include "core/io/resource_loader.h" -#include "core/os/file_access.h" #include "core/project_settings.h" #include <stdint.h> @@ -164,7 +162,7 @@ void ScriptServer::init_languages() { for (int i = 0; i < script_classes.size(); i++) { Dictionary c = script_classes[i]; - if (!c.has("class") || !c.has("language") || !c.has("path") || !FileAccess::exists(ResourceLoader::path_remap(c["path"])) || !c.has("base")) { + if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base")) { continue; } add_global_class(c["class"], c["base"], c["language"], c["path"]); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index cf32ffb4e0..2e716a636e 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1174,6 +1174,47 @@ void EditorInspectorSection::_notification(int p_what) { if (arrow.is_valid()) { draw_texture(arrow, Point2(Math::round(arrow_margin * EDSCALE), (h - arrow->get_height()) / 2).floor()); } + + if (dropping && !vbox->is_visible_in_tree()) { + Color accent_color = get_theme_color("accent_color", "Editor"); + draw_rect(Rect2(Point2(), get_size()), accent_color, false); + } + } + + if (p_what == NOTIFICATION_DRAG_BEGIN) { + Dictionary dd = get_viewport()->gui_get_drag_data(); + + // Only allow dropping if the section contains properties which can take the dragged data. + bool children_can_drop = false; + for (int child_idx = 0; child_idx < vbox->get_child_count(); child_idx++) { + Control *editor_property = Object::cast_to<Control>(vbox->get_child(child_idx)); + + // Test can_drop_data and can_drop_data_fw, since can_drop_data only works if set up with forwarding or if script attached. + if (editor_property && (editor_property->can_drop_data(Point2(), dd) || editor_property->call("can_drop_data_fw", Point2(), dd, this))) { + children_can_drop = true; + break; + } + } + + dropping = children_can_drop; + update(); + } + + if (p_what == NOTIFICATION_DRAG_END) { + dropping = false; + update(); + } + + if (p_what == NOTIFICATION_MOUSE_ENTER) { + if (dropping) { + dropping_unfold_timer->start(); + } + } + + if (p_what == NOTIFICATION_MOUSE_EXIT) { + if (dropping) { + dropping_unfold_timer->stop(); + } } } @@ -1236,14 +1277,11 @@ void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) { return; } - _test_unfold(); - - bool unfold = !object->editor_is_section_unfolded(section); - object->editor_set_section_unfold(section, unfold); - if (unfold) { - vbox->show(); + bool should_unfold = !object->editor_is_section_unfolded(section); + if (should_unfold) { + unfold(); } else { - vbox->hide(); + fold(); } } } @@ -1291,6 +1329,13 @@ EditorInspectorSection::EditorInspectorSection() { foldable = false; vbox = memnew(VBoxContainer); vbox_added = false; + + dropping = false; + dropping_unfold_timer = memnew(Timer); + dropping_unfold_timer->set_wait_time(0.6); + dropping_unfold_timer->set_one_shot(true); + add_child(dropping_unfold_timer); + dropping_unfold_timer->connect("timeout", callable_mp(this, &EditorInspectorSection::unfold)); } EditorInspectorSection::~EditorInspectorSection() { diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 95072fd703..36b80a7dd4 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -231,6 +231,9 @@ class EditorInspectorSection : public Container { Color bg_color; bool foldable; + Timer *dropping_unfold_timer; + bool dropping; + void _test_unfold(); protected: diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 34d553b5f9..d5cc9ac5c1 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2947,11 +2947,9 @@ void EditorPropertyResource::_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; - assign->update(); - } + if (_is_drop_valid(get_viewport()->gui_get_drag_data())) { + dropping = true; + assign->update(); } } |