Enable Drag and Drop for SubViewports and Windows

Make Drag and Drop an application-wide operation.
This allows do drop on Controls in other Viewports/Windows.

In order to achieve this, `Viewport::_update_mouse_over` is adjusted to
remember the Control, that the mouse is over (possibly within nested
viewports). This Control is used as a basis for the Drop-operation, which
replaces the previous algorithm, which was only aware of the topmost
Viewport.

Also now all nodes in the SceneTree are notified about the Drag and Drop
operation, with the exception of SubViewports that are not children of
SubViewportContainers.
This commit is contained in:
Markus Sauermann
2023-01-20 00:21:11 +01:00
parent 6681f2563b
commit 60aaa017ff
7 changed files with 213 additions and 148 deletions
+8 -4
View File
@@ -2755,12 +2755,16 @@ Transform2D Window::get_popup_base_transform() const {
return popup_base_transform;
}
bool Window::is_directly_attached_to_screen() const {
Viewport *Window::get_section_root_viewport() const {
if (get_embedder()) {
return get_embedder()->is_directly_attached_to_screen();
return get_embedder()->get_section_root_viewport();
}
// Distinguish between the case that this is a native Window and not inside the tree.
return is_inside_tree();
if (is_inside_tree()) {
// Native window.
return SceneTree::get_singleton()->get_root();
}
Window *vp = const_cast<Window *>(this);
return vp;
}
bool Window::is_attached_in_viewport() const {