diff options
| author | Marc Jeanmougin <marcjeanmougin@free.fr> | 2017-10-05 09:01:39 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marcjeanmougin@free.fr> | 2017-10-05 09:01:39 +0000 |
| commit | 577a34f67d1d3bb523c362373efbbe7d00c1afab (patch) | |
| tree | ba088c3888a7f1b3809d2e5c40f2dba0f6dc8fa9 /src | |
| parent | Merge branch 'interp_att_ext' of gitlab.com:Moini/inkscape (diff) | |
| parent | Rename object-edit.cpp to what it really is (diff) | |
| download | inkscape-577a34f67d1d3bb523c362373efbbe7d00c1afab.tar.gz inkscape-577a34f67d1d3bb523c362373efbbe7d00c1afab.zip | |
Merge branch 'edit-clip-object' of gitlab.com:stfacc/inkscape
Diffstat (limited to 'src')
| -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/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/ui/object-edit.h | 84 | ||||
| -rw-r--r-- | src/ui/shape-editor-knotholders.cpp (renamed from src/ui/object-edit.cpp) | 50 | ||||
| -rw-r--r-- | src/ui/shape-editor.cpp | 23 | ||||
| -rw-r--r-- | src/ui/shape-editor.h | 4 | ||||
| -rw-r--r-- | src/ui/tools/node-tool.cpp | 3 |
9 files changed, 81 insertions, 111 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/CMakeLists.txt b/src/ui/CMakeLists.txt index efdb279b4..be13d9b1b 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -5,10 +5,10 @@ set(ui_SRC dialog-events.cpp draw-anchor.cpp interface.cpp - object-edit.cpp previewholder.cpp selected-color.cpp shape-editor.cpp + shape-editor-knotholders.cpp tool-factory.cpp tools-switch.cpp uxmanager.cpp @@ -185,7 +185,6 @@ set(ui_SRC event-debug.h icon-names.h interface.h - object-edit.h previewable.h previewfillable.h previewholder.h diff --git a/src/ui/object-edit.h b/src/ui/object-edit.h deleted file mode 100644 index 75f3ce12b..000000000 --- a/src/ui/object-edit.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef OBJECT_EDIT_H_SEEN -#define OBJECT_EDIT_H_SEEN - -/* - * Node editing extension to objects - * - * Authors: - * Lauris Kaplinski <lauris@kaplinski.com> - * Mitsuru Oka - * Jon A. Cruz <jon@joncruz.org> - * - * Licensed under GNU GPL - */ - -#include "knotholder.h" - -namespace Inkscape { -namespace UI { - -KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop); - -} -} - -class RectKnotHolder : public KnotHolder { -public: - RectKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~RectKnotHolder() {}; -}; - -class Box3DKnotHolder : public KnotHolder { -public: - Box3DKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~Box3DKnotHolder() {}; -}; - -class ArcKnotHolder : public KnotHolder { -public: - ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~ArcKnotHolder() {}; -}; - -class StarKnotHolder : public KnotHolder { -public: - StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~StarKnotHolder() {}; -}; - -class SpiralKnotHolder : public KnotHolder { -public: - SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~SpiralKnotHolder() {}; -}; - -class OffsetKnotHolder : public KnotHolder { -public: - OffsetKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~OffsetKnotHolder() {}; -}; - -class FlowtextKnotHolder : public KnotHolder { -public: - FlowtextKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~FlowtextKnotHolder() {}; -}; - -class MiscKnotHolder : public KnotHolder { -public: - MiscKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~MiscKnotHolder() {}; -}; - -#endif // OBJECT_EDIT_H_SEEN - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/object-edit.cpp b/src/ui/shape-editor-knotholders.cpp index a2b6a2de0..b2e41bac4 100644 --- a/src/ui/object-edit.cpp +++ b/src/ui/shape-editor-knotholders.cpp @@ -31,11 +31,59 @@ #include "live_effects/effect.h" #include "sp-pattern.h" #include <glibmm/i18n.h> -#include "ui/object-edit.h" +#include "knotholder.h" #include "knot-holder-entity.h" #define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m))) +class RectKnotHolder : public KnotHolder { +public: + RectKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~RectKnotHolder() {}; +}; + +class Box3DKnotHolder : public KnotHolder { +public: + Box3DKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~Box3DKnotHolder() {}; +}; + +class ArcKnotHolder : public KnotHolder { +public: + ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~ArcKnotHolder() {}; +}; + +class StarKnotHolder : public KnotHolder { +public: + StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~StarKnotHolder() {}; +}; + +class SpiralKnotHolder : public KnotHolder { +public: + SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~SpiralKnotHolder() {}; +}; + +class OffsetKnotHolder : public KnotHolder { +public: + OffsetKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~OffsetKnotHolder() {}; +}; + +class FlowtextKnotHolder : public KnotHolder { +public: + FlowtextKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~FlowtextKnotHolder() {}; +}; + +class MiscKnotHolder : public KnotHolder { +public: + MiscKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~MiscKnotHolder() {}; +}; + namespace { static KnotHolder *sp_lpe_knot_holder(SPLPEItem *item, SPDesktop *desktop) diff --git a/src/ui/shape-editor.cpp b/src/ui/shape-editor.cpp index 6a8f5e931..4851c413f 100644 --- a/src/ui/shape-editor.cpp +++ b/src/ui/shape-editor.cpp @@ -20,21 +20,23 @@ #include "sp-shape.h" #include "sp-path.h" #include "inkscape.h" -#include "ui/object-edit.h" #include "ui/shape-editor.h" #include "xml/node-event-vector.h" -//using Inkscape::createKnotHolder; namespace Inkscape { namespace UI { +KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop); + 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); } |
