From ff04a08000adfa762ad1f4bc4f4df64c11ed499c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 1 Jul 2017 02:35:09 +0200 Subject: working on knots selection --- src/knotholder.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/knotholder.cpp') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 98348a59f..681667aa5 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -170,6 +170,18 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) } // else { abort(); } } +void +KnotHolder::transform_selected(Geom::Affine transform){ + for (std::list::iterator i = entity.begin(); i != entity.end(); ++i) { + SPKnot *knot = (*i)->knot; + std::cout << transform << "transform\n"; + if (knot->flags & SP_KNOT_SELECTED) { + knot_moved_handler(knot, knot->pos * transform , 0); + knot->selectKnot(true); + } + } +} + void KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) { -- cgit v1.2.3 From cb312127f49aae8d0f936743ce864a8e9143f558 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 1 Jul 2017 14:24:30 +0200 Subject: Finish add selectable knot shapes --- src/knotholder.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/knotholder.cpp') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 681667aa5..3ac983cca 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -174,7 +174,6 @@ void KnotHolder::transform_selected(Geom::Affine transform){ for (std::list::iterator i = entity.begin(); i != entity.end(); ++i) { SPKnot *knot = (*i)->knot; - std::cout << transform << "transform\n"; if (knot->flags & SP_KNOT_SELECTED) { knot_moved_handler(knot, knot->pos * transform , 0); knot->selectKnot(true); -- cgit v1.2.3 From 3ea070d548ff526afe3a86ef6835146773aac020 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 2 Jul 2017 01:27:16 +0200 Subject: Improving CR feedback. thanks! --- src/knotholder.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 14 deletions(-) (limited to 'src/knotholder.cpp') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 3ac983cca..6ff914733 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -13,31 +13,34 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include - #include "document.h" #include "document-undo.h" -#include "sp-shape.h" +#include "desktop.h" +#include "verbs.h" +#include "box3d.h" +#include "style.h" #include "knot.h" #include "knotholder.h" #include "knot-holder-entity.h" +#include "display/sp-canvas.h" #include "ui/tools/rect-tool.h" #include "ui/tools/arc-tool.h" -#include "sp-ellipse.h" +#include "ui/tools-switch.h" #include "ui/tools/tweak-tool.h" -#include "sp-star.h" +#include "ui/tools/node-tool.h" +#include "ui/shape-editor.h" #include "ui/tools/spiral-tool.h" +#include "ui/control-manager.h" +#include "sp-shape.h" +#include "sp-ellipse.h" +#include "sp-star.h" #include "sp-spiral.h" #include "sp-offset.h" -#include "box3d.h" #include "sp-pattern.h" -#include "style.h" #include "live_effects/lpeobject.h" #include "live_effects/effect.h" -#include "desktop.h" -#include "display/sp-canvas.h" -#include "verbs.h" -#include "ui/control-manager.h" +// TODO due to internal breakage in glibmm headers, this must be last: +#include using Inkscape::ControlManager; using Inkscape::DocumentUndo; @@ -115,12 +118,22 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) KnotHolder *knot_holder = this; SPItem *saved_item = this->item; + if (!(state & GDK_SHIFT_MASK)) { + unselect_knots(); + } for(std::list::iterator i = knot_holder->entity.begin(); i != knot_holder->entity.end(); ++i) { KnotHolderEntity *e = *i; + if (!(state & GDK_SHIFT_MASK)) { + e->knot->selectKnot(false); + } if (e->knot == knot) { // no need to test whether knot_click exists since it's virtual now e->knot_click(state); - break; + if (!(e->knot->flags & SP_KNOT_SELECTED) || !(state & GDK_SHIFT_MASK)){ + e->knot->selectKnot(true); + } else { + e->knot->selectKnot(false); + } } } @@ -181,6 +194,29 @@ KnotHolder::transform_selected(Geom::Affine transform){ } } +void +KnotHolder::unselect_knots(){ + if (tools_isactive(desktop, TOOLS_NODES)) { + Inkscape::UI::Tools::NodeTool *nt = static_cast(desktop->event_context); + if (nt) { + for(auto i=nt->_shape_editors.begin();i!=nt->_shape_editors.end();++i){ + Inkscape::UI::ShapeEditor * shape_editor = i->second; + if (shape_editor && shape_editor->has_knotholder()) { + KnotHolder * knotholder = shape_editor->knotholder; + if (knotholder) { + for(std::list::iterator i = knotholder->entity.begin(); i != knotholder->entity.end(); ++i) { + KnotHolderEntity *e = *i; + if (e->knot->flags & SP_KNOT_SELECTED) { + e->knot->selectKnot(false); + } + } + } + } + } + } + } +} + void KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) { @@ -190,13 +226,23 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) // this was a local change and the knotholder does not need to be recreated: this->local_change = TRUE; - + if (!(state & GDK_SHIFT_MASK)) { + unselect_knots(); + } for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { KnotHolderEntity *e = *i; + if (!(state & GDK_SHIFT_MASK)) { + e->knot->selectKnot(false); + } if (e->knot == knot) { Geom::Point const q = p * item->i2dt_affine().inverse(); e->knot_set(q, e->knot->drag_origin * item->i2dt_affine().inverse(), state); - break; + e->knot_click(state); + if (!(e->knot->flags & SP_KNOT_SELECTED) || !(state & GDK_SHIFT_MASK)){ + e->knot->selectKnot(true); + } else { + e->knot->selectKnot(false); + } } } -- cgit v1.2.3 From 1d2fa48c9a62c4929264cf5b59907f8d4f0e55b5 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Tue, 4 Jul 2017 23:41:25 +0200 Subject: Fix a bug with select knots and modifiers --- src/knotholder.cpp | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'src/knotholder.cpp') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 6ff914733..29054bcd9 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -226,23 +226,13 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) // this was a local change and the knotholder does not need to be recreated: this->local_change = TRUE; - if (!(state & GDK_SHIFT_MASK)) { - unselect_knots(); - } + for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { KnotHolderEntity *e = *i; - if (!(state & GDK_SHIFT_MASK)) { - e->knot->selectKnot(false); - } if (e->knot == knot) { Geom::Point const q = p * item->i2dt_affine().inverse(); e->knot_set(q, e->knot->drag_origin * item->i2dt_affine().inverse(), state); - e->knot_click(state); - if (!(e->knot->flags & SP_KNOT_SELECTED) || !(state & GDK_SHIFT_MASK)){ - e->knot->selectKnot(true); - } else { - e->knot->selectKnot(false); - } + break; } } @@ -255,13 +245,30 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) } void -KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint) +KnotHolder::knot_ungrabbed_handler(SPKnot *knot, guint state) { - this->dragging = false; + this->dragging = false; - if (this->released) { + if (this->released) { this->released(this->item); } else { + if (!(state & GDK_SHIFT_MASK)) { + unselect_knots(); + } + for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { + KnotHolderEntity *e = *i; + if (!(state & GDK_SHIFT_MASK)) { + e->knot->selectKnot(false); + } + if (e->knot == knot) { + // no need to test whether knot_click exists since it's virtual now + if (!(e->knot->flags & SP_KNOT_SELECTED) || !(state & GDK_SHIFT_MASK)){ + e->knot->selectKnot(true); + } else { + e->knot->selectKnot(false); + } + } + } SPObject *object = (SPObject *) this->item; // Caution: this call involves a screen update, which may process events, and as a @@ -307,7 +314,6 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint) } } } - DocumentUndo::done(object->document, object_verb, _("Move handle")); } } -- cgit v1.2.3