diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 8f5c0f75f1121a065d6cdf26630ec4b81fa47315..66bd06c14b5ba657b71d4e5acc706c82cd0373ad 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -12,58 +12,36 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ +#include "objects.h" + #include #include #include -#include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "objects.h" -#include "actions/actions-tools.h" -#include "desktop.h" #include "desktop-style.h" -#include "display/drawing-group.h" -#include "document.h" +#include "desktop.h" +#include "display/drawing-item.h" #include "document-undo.h" +#include "document.h" #include "filter-chemistry.h" -#include "include/gtkmm_version.h" -#include "inkscape.h" #include "inkscape-window.h" #include "layer-manager.h" #include "message-stack.h" -#include "object/filters/blend.h" -#include "object/filters/gaussian-blur.h" #include "object/sp-clippath.h" #include "object/sp-mask.h" #include "object/sp-root.h" -#include "object/sp-shape.h" #include "style-enums.h" #include "style.h" #include "svg/css-ostringstream.h" #include "ui/builder-utils.h" #include "ui/contextmenu.h" #include "ui/controller.h" -#include "ui/dialog-events.h" #include "ui/icon-loader.h" #include "ui/icon-names.h" -#include "ui/selected-color.h" #include "ui/shortcuts.h" -#include "ui/tools/node-tool.h" #include "ui/util.h" #include "ui/widget/canvas.h" #include "ui/widget/filter-effect-chooser.h" @@ -349,8 +327,6 @@ void ObjectWatcher::updateRowAncestorState(bool invisible, bool locked) { } } -Gdk::RGBA selection_color; - /** * Updates the row's background colour as indicated by its selection. */ @@ -364,7 +340,7 @@ void ObjectWatcher::updateRowBg(guint32 rgba) return; } - const auto& sel = selection_color; + const auto& sel = ObjectsPanel::selection_color; const auto gdk_color = change_alpha(sel, sel.get_alpha() * alpha); row[panel->_model->_colBgColor] = gdk_color; } @@ -1731,6 +1707,15 @@ bool ObjectsPanel::cleanDummyChildren(Gtk::TreeModel::Row const &row) return false; } +/** Show current drag destination as invalid and reject it as a drop location, + * removing the highlight. Always returns true. */ +bool ObjectsPanel::_refuseDrag(const Glib::RefPtr &context, guint time) +{ + _tree.unset_drag_dest_row(); + context->drag_refuse(time); + return true; +} + /** * Signal handler for "drag-motion" * @@ -1744,29 +1729,20 @@ bool ObjectsPanel::on_drag_motion(const Glib::RefPtr &context, auto selection = getSelection(); auto document = getDocument(); - if (!selection || !document) - goto finally; + if (!selection || !document) { + return _refuseDrag(context, time); + } _tree.get_dest_row_at_pos(x, y, path, pos); if (path) { - auto item = getItem(*_store->get_iter(path)); - - // don't drop on self - if (selection->includes(item)) { - goto finally; + if (auto item = getItem(*_store->get_iter(path)); selection->includes(item)) { // don't drop on self + return _refuseDrag(context, time); } - } - // need to cater scenarios where we got no selection/empty bottom space + // need to handle scenarios where we hover over the empty space at the bottom context->drag_status(Gdk::ACTION_MOVE, time); return false; - -finally: - // remove drop highlight - _tree.unset_drag_dest_row(); - context->drag_refuse(time); - return true; } /** diff --git a/src/ui/dialog/objects.h b/src/ui/dialog/objects.h index c30b50f8691dd46db970efc6c6670db7a073b2bb..3599e6b551a0cd30e819b20625fb36ee997d697e 100644 --- a/src/ui/dialog/objects.h +++ b/src/ui/dialog/objects.h @@ -167,6 +167,7 @@ private: bool on_drag_drop(const Glib::RefPtr &, int, int, guint) override; void on_drag_start(const Glib::RefPtr &); void on_drag_end(const Glib::RefPtr &) override; + bool _refuseDrag(const Glib::RefPtr &context, guint time); bool selectCursorItem(unsigned int state); SPItem *_getCursorItem(Gtk::TreeViewColumn *column); @@ -190,6 +191,7 @@ private: bool _selectionChanged(); auto_connection _idle_connection; + static Gdk::RGBA selection_color; }; } //namespace Dialog