From 01239625858ee751a304e3203c3b6405aa437087 Mon Sep 17 00:00:00 2001 From: learner99 Date: Sun, 13 Aug 2023 10:47:04 +0500 Subject: [PATCH] Adding feature to allow layer drag n drop in bottom empty space If a user drops any layer in the bottom empty space, perviously nothing happened but, now the layer will become the bottom/last layer. on_drag_motion(): moved the drag_status() to cater situations for empty space on_drag_drop(): added logic to detect empty space and move the selected layer to the last/end. Fixes https://gitlab.com/inkscape/inkscape/-/issues/4436 --- src/ui/dialog/objects.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 950c72e172..8f5c0f75f1 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -1757,9 +1757,10 @@ bool ObjectsPanel::on_drag_motion(const Glib::RefPtr &context, goto finally; } - context->drag_status(Gdk::ACTION_MOVE, time); - return false; } + // need to cater scenarios where we got no selection/empty bottom space + context->drag_status(Gdk::ACTION_MOVE, time); + return false; finally: // remove drop highlight @@ -1780,9 +1781,18 @@ bool ObjectsPanel::on_drag_drop(const Glib::RefPtr &context, i _tree.get_dest_row_at_pos(x, y, path, pos); if (!path) { - return true; + + if (_tree.is_blank_at_pos(x, y)){ + // We are in background/bottom empty space. Hence, need to + // drop the layer at end. + // We will move to the last node/path and set drop position accordingly + path = --_store->children().end(); + pos = Gtk::TREE_VIEW_DROP_AFTER; + } else { + return true; + } } - + auto drop_repr = getRepr(*_store->get_iter(path)); bool const drop_into = pos != Gtk::TREE_VIEW_DROP_BEFORE && // pos != Gtk::TREE_VIEW_DROP_AFTER; -- GitLab