diff options
| author | Stefano Facchini <stefano.facchini@gmail.com> | 2017-10-01 13:27:03 +0000 |
|---|---|---|
| committer | Stefano Facchini <stefano.facchini@gmail.com> | 2017-10-01 13:40:38 +0000 |
| commit | d4432a4aaf3fb615d9808f53557a4283436bf035 (patch) | |
| tree | 2a9cc5ae46c673d092abdaba399133659f0cfc27 | |
| parent | A little styling tweak to a LPE expander (diff) | |
| download | inkscape-d4432a4aaf3fb615d9808f53557a4283436bf035.tar.gz inkscape-d4432a4aaf3fb615d9808f53557a4283436bf035.zip | |
Fix the editing of clipping and masking objects
By passing along an edit_transform matrix, as done for clipping paths.
Cleanups:
- remove some unused methods
- use member initialization
| -rw-r--r-- | src/knot-holder-entity.cpp | 6 | ||||
| -rw-r--r-- | src/knotholder.cpp | 13 | ||||
| -rw-r--r-- | src/knotholder.h | 6 | ||||
| -rw-r--r-- | src/ui/shape-editor.cpp | 19 | ||||
| -rw-r--r-- | src/ui/shape-editor.h | 4 | ||||
| -rw-r--r-- | src/ui/tools/node-tool.cpp | 3 |
6 files changed, 29 insertions, 22 deletions
diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index 8add35d46..bb7ef6eb3 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -84,7 +84,7 @@ KnotHolderEntity::update_knot() { Geom::Point knot_pos(knot_get()); if (knot_pos.isFinite()) { - Geom::Point dp(knot_pos * item->i2dt_affine()); + Geom::Point dp(knot_pos * parent_holder->getEditTranform() * item->i2dt_affine()); _moved_connection.block(); knot->setPosition(dp, SP_KNOT_STATE_NORMAL); @@ -102,7 +102,7 @@ KnotHolderEntity::snap_knot_position(Geom::Point const &p, guint state) return p; } - Geom::Affine const i2dt (item->i2dt_affine()); + Geom::Affine const i2dt (parent_holder->getEditTranform() * item->i2dt_affine()); Geom::Point s = p * i2dt; SnapManager &m = desktop->namedview->snap_manager; @@ -120,7 +120,7 @@ KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape: return p; } - Geom::Affine const i2d (item->i2dt_affine()); + Geom::Affine const i2d (parent_holder->getEditTranform() * item->i2dt_affine()); Geom::Point s = p * i2d; SnapManager &m = desktop->namedview->snap_manager; diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 29054bcd9..5fbccf52d 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -56,7 +56,8 @@ KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFun sizeUpdatedConn(), released(relhandler), local_change(FALSE), - dragging(false) + dragging(false), + _edit_transform(Geom::identity()) { if (!desktop || !item) { g_print ("Error! Throw an exception, please!\n"); @@ -79,6 +80,12 @@ KnotHolder::~KnotHolder() { sizeUpdatedConn.disconnect(); } +void +KnotHolder::setEditTransform(Geom::Affine edit_transform) +{ + _edit_transform = edit_transform; +} + void KnotHolder::updateControlSizes() { ControlManager &mgr = ControlManager::getManager(); @@ -230,8 +237,8 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) for(std::list<KnotHolderEntity *>::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { KnotHolderEntity *e = *i; 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); + Geom::Point const q = p * item->i2dt_affine().inverse() * _edit_transform.inverse(); + e->knot_set(q, e->knot->drag_origin * item->i2dt_affine().inverse() * _edit_transform.inverse(), state); break; } } diff --git a/src/knotholder.h b/src/knotholder.h index d683b53ac..3c535cc31 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -18,6 +18,7 @@ */ #include <2geom/forward.h> +#include <2geom/affine.h> #include <list> #include <sigc++/connection.h> @@ -58,7 +59,8 @@ public: void add_pattern_knotholder(); - const SPItem *getItem() { return item; } + void setEditTransform(Geom::Affine edit_transform); + Geom::Affine getEditTranform() const { return _edit_transform; } bool knot_mouseover() const; @@ -83,6 +85,8 @@ protected: bool dragging; + Geom::Affine _edit_transform; + private: KnotHolder(); // declared but not defined }; diff --git a/src/ui/shape-editor.cpp b/src/ui/shape-editor.cpp index 6a8f5e931..2c0e662ee 100644 --- a/src/ui/shape-editor.cpp +++ b/src/ui/shape-editor.cpp @@ -31,10 +31,12 @@ namespace UI { bool ShapeEditor::_blockSetItem = false; -ShapeEditor::ShapeEditor(SPDesktop *dt) { - this->desktop = dt; - this->knotholder = NULL; - this->knotholder_listener_attached_for = NULL; +ShapeEditor::ShapeEditor(SPDesktop *dt, Geom::Affine edit_transform) : + desktop(dt), + knotholder(nullptr), + knotholder_listener_attached_for(nullptr), + _edit_transform(edit_transform) +{ } ShapeEditor::~ShapeEditor() { @@ -76,14 +78,6 @@ void ShapeEditor::decrement_local_change() { } } -const SPItem *ShapeEditor::get_item() { - const SPItem *item = NULL; - if (this->has_knotholder()) { - item = this->knotholder->getItem(); - } - return item; -} - void ShapeEditor::event_attr_changed(Inkscape::XML::Node * node, gchar const *name, gchar const *, gchar const *, bool, void *data) { g_assert(data); @@ -129,6 +123,7 @@ void ShapeEditor::set_item(SPItem *item, bool keep_knotholder) { this->knotholder = createKnotHolder(item, desktop); } if (this->knotholder) { + this->knotholder->setEditTransform(_edit_transform); this->knotholder->update_knots(); // setting new listener repr = this->knotholder->repr; diff --git a/src/ui/shape-editor.h b/src/ui/shape-editor.h index 7f435efca..e30b2d60b 100644 --- a/src/ui/shape-editor.h +++ b/src/ui/shape-editor.h @@ -23,7 +23,7 @@ namespace UI { class ShapeEditor { public: - ShapeEditor(SPDesktop *desktop); + ShapeEditor(SPDesktop *desktop, Geom::Affine edit_transform = Geom::identity()); ~ShapeEditor(); void set_item(SPItem *item, bool keep_knotholder = false); @@ -42,11 +42,11 @@ public: char const * /*new_value*/, bool /*is_interactive*/, void *data); private: void reset_item (bool keep_knotholder = true); - const SPItem *get_item(); static bool _blockSetItem; SPDesktop *desktop; Inkscape::XML::Node *knotholder_listener_attached_for; + Geom::Affine _edit_transform; }; } // namespace UI diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index d508a16f2..e7825e302 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -358,6 +358,7 @@ void NodeTool::set(const Inkscape::Preferences::Entry& value) { } /** Recursively collect ShapeRecords */ +static void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::ShapeRole role, std::set<Inkscape::UI::ShapeRecord> &s) { @@ -437,7 +438,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { if ((SP_IS_SHAPE(r.item) || SP_IS_TEXT(r.item) || SP_IS_GROUP(r.item) || SP_IS_OBJECTGROUP(r.item)) && this->_shape_editors.find(r.item) == this->_shape_editors.end()) { - ShapeEditor *si = new ShapeEditor(this->desktop); + ShapeEditor *si = new ShapeEditor(this->desktop, r.edit_transform); si->set_item(r.item); this->_shape_editors.insert(const_cast<SPItem*&>(r.item), si); } |
