diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-07-01 23:27:16 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-07-01 23:27:16 +0000 |
| commit | 3ea070d548ff526afe3a86ef6835146773aac020 (patch) | |
| tree | f4ea742ed6d29e02e4d34829701cc0d671d5ce24 /src | |
| parent | Finish add selectable knot shapes (diff) | |
| download | inkscape-3ea070d548ff526afe3a86ef6835146773aac020.tar.gz inkscape-3ea070d548ff526afe3a86ef6835146773aac020.zip | |
Improving CR feedback. thanks!
Diffstat (limited to 'src')
| -rw-r--r-- | src/knot.cpp | 2 | ||||
| -rw-r--r-- | src/knotholder.cpp | 74 | ||||
| -rw-r--r-- | src/knotholder.h | 2 | ||||
| -rw-r--r-- | src/ui/tools/arc-tool.cpp | 9 | ||||
| -rw-r--r-- | src/ui/tools/rect-tool.cpp | 9 | ||||
| -rw-r--r-- | src/ui/tools/spiral-tool.cpp | 8 | ||||
| -rw-r--r-- | src/ui/tools/star-tool.cpp | 9 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.cpp | 11 |
8 files changed, 68 insertions, 56 deletions
diff --git a/src/knot.cpp b/src/knot.cpp index 2d6bf2864..0f27c5581 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -223,7 +223,6 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot knot->startDragging(p, (gint) event->button.x, (gint) event->button.y, event->button.time); knot->mousedown_signal.emit(knot, event->button.state); consumed = TRUE; - knot->selectKnot(!(knot->flags & SP_KNOT_SELECTED)); } break; case GDK_BUTTON_RELEASE: @@ -248,7 +247,6 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot if (moved) { knot->setFlag(SP_KNOT_DRAGGING, FALSE); knot->ungrabbed_signal.emit(knot, event->button.state); - knot->selectKnot(true); } else { knot->click_signal.emit(knot, event->button.state); } 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 <glibmm/i18n.h> - #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 <glibmm/i18n.h> 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<KnotHolderEntity *>::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<Inkscape::UI::Tools::NodeTool*>(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<KnotHolderEntity *>::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<KnotHolderEntity *>::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); + } } } diff --git a/src/knotholder.h b/src/knotholder.h index 6523988db..559454727 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -49,7 +49,7 @@ public: virtual ~KnotHolder(); void update_knots(); - + void unselect_knots(); void knot_moved_handler(SPKnot *knot, Geom::Point const &p, unsigned int state); void knot_clicked_handler(SPKnot *knot, unsigned int state); void knot_ungrabbed_handler(SPKnot *knot, unsigned int); diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index 01e0c3e00..b501962fb 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -244,15 +244,6 @@ bool ArcTool::root_handler(GdkEvent* event) { } break; - case GDK_KEY_Up: - case GDK_KEY_Down: - case GDK_KEY_KP_Up: - case GDK_KEY_KP_Down: - // prevent the zoom field from activation - if (!MOD__CTRL_ONLY(event)) - handled = true; - break; - case GDK_KEY_x: case GDK_KEY_X: if (MOD__ALT_ONLY(event)) { diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 8eaae2f7b..9ebf51e76 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -274,15 +274,6 @@ bool RectTool::root_handler(GdkEvent* event) { NULL); } break; - case GDK_KEY_Up: - case GDK_KEY_Down: - case GDK_KEY_KP_Up: - case GDK_KEY_KP_Down: - // prevent the zoom field from activation - if (!MOD__CTRL_ONLY(event)) - ret = TRUE; - break; - case GDK_KEY_x: case GDK_KEY_X: if (MOD__ALT_ONLY(event)) { diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index 08c35b9b0..b681aec38 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -245,14 +245,6 @@ bool SpiralTool::root_handler(GdkEvent* event) { NULL, _("<b>Alt</b>: lock spiral radius")); break; - case GDK_KEY_Up: - case GDK_KEY_Down: - case GDK_KEY_KP_Up: - case GDK_KEY_KP_Down: - // prevent the zoom field from activation - if (!MOD__CTRL_ONLY(event)) - ret = TRUE; - break; case GDK_KEY_x: case GDK_KEY_X: diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index 18992d87a..32f0e6d92 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -260,15 +260,6 @@ bool StarTool::root_handler(GdkEvent* event) { NULL); break; - case GDK_KEY_Up: - case GDK_KEY_Down: - case GDK_KEY_KP_Up: - case GDK_KEY_KP_Down: - // prevent the zoom field from activation - if (!MOD__CTRL_ONLY(event)) - ret = TRUE; - break; - case GDK_KEY_x: case GDK_KEY_X: if (MOD__ALT_ONLY(event)) { diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index ddd7c19c4..457d704aa 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -328,13 +328,16 @@ bool ToolBase::_keyboardMove(GdkEventKey const &event, Geom::Point const &dir) if (knotholder) { knotholder->transform_selected(Geom::Translate(delta)); } - } else { + } else if (tools_isactive(desktop, TOOLS_NODES)) { Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context); if (nt) { for(auto i=nt->_shape_editors.begin();i!=nt->_shape_editors.end();++i){ - KnotHolder * knotholder = i->second->knotholder; - if (knotholder) { - knotholder->transform_selected(Geom::Translate(delta)); + ShapeEditor * shape_editor = i->second; + if (shape_editor && shape_editor->has_knotholder()) { + KnotHolder * knotholder = shape_editor->knotholder; + if (knotholder) { + knotholder->transform_selected(Geom::Translate(delta)); + } } } } |
