diff options
author | Thaddeus Crews <repiteo@outlook.com> | 2024-11-21 17:56:48 -0600 |
---|---|---|
committer | Thaddeus Crews <repiteo@outlook.com> | 2024-11-21 17:56:48 -0600 |
commit | 0eca686191d0c90735b93ef5d97a1df3e6b53d75 (patch) | |
tree | f765f475bd9d2e65b9ba64e0ab3534d088bfdaa8 /scene/gui | |
parent | 38ebcf92edb6d4f3e8ab490d40be2783fb27aeb5 (diff) | |
parent | 117158d2718d11c5026f4e2791c7784b4815d0aa (diff) | |
download | redot-engine-0eca686191d0c90735b93ef5d97a1df3e6b53d75.tar.gz |
Merge pull request #99270 from Sauermann/fix-svc-drop-config
Introduce a `SubViewportContainer` config for drag-and-drop target locations
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/subviewport_container.cpp | 12 | ||||
-rw-r--r-- | scene/gui/subviewport_container.h | 5 |
2 files changed, 17 insertions, 0 deletions
diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp index a443ae9abf..775db65c3f 100644 --- a/scene/gui/subviewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -246,6 +246,14 @@ bool SubViewportContainer::_is_propagated_in_gui_input(const Ref<InputEvent> &p_ return false; } +void SubViewportContainer::set_consume_drag_and_drop(bool p_enable) { + consume_drag_and_drop = p_enable; +} + +bool SubViewportContainer::is_consume_drag_and_drop_enabled() { + return consume_drag_and_drop; +} + void SubViewportContainer::add_child_notify(Node *p_child) { if (Object::cast_to<SubViewport>(p_child)) { queue_redraw(); @@ -286,8 +294,12 @@ void SubViewportContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_stretch_shrink", "amount"), &SubViewportContainer::set_stretch_shrink); ClassDB::bind_method(D_METHOD("get_stretch_shrink"), &SubViewportContainer::get_stretch_shrink); + ClassDB::bind_method(D_METHOD("set_consume_drag_and_drop", "amount"), &SubViewportContainer::set_consume_drag_and_drop); + ClassDB::bind_method(D_METHOD("is_consume_drag_and_drop_enabled"), &SubViewportContainer::is_consume_drag_and_drop_enabled); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stretch"), "set_stretch", "is_stretch_enabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_shrink", PROPERTY_HINT_RANGE, "1,32,1,or_greater"), "set_stretch_shrink", "get_stretch_shrink"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "consume_drag_and_drop"), "set_consume_drag_and_drop", "is_consume_drag_and_drop_enabled"); GDVIRTUAL_BIND(_propagate_input_event, "event"); } diff --git a/scene/gui/subviewport_container.h b/scene/gui/subviewport_container.h index 06420de730..7230615771 100644 --- a/scene/gui/subviewport_container.h +++ b/scene/gui/subviewport_container.h @@ -38,6 +38,8 @@ class SubViewportContainer : public Container { bool stretch = false; int shrink = 1; + bool consume_drag_and_drop = false; + void _notify_viewports(int p_notification); bool _is_propagated_in_gui_input(const Ref<InputEvent> &p_event); void _send_event_to_viewports(const Ref<InputEvent> &p_event); @@ -63,6 +65,9 @@ public: int get_stretch_shrink() const; void recalc_force_viewport_sizes(); + void set_consume_drag_and_drop(bool p_enable); + bool is_consume_drag_and_drop_enabled(); + virtual Size2 get_minimum_size() const override; virtual Vector<int> get_allowed_size_flags_horizontal() const override; |