diff options
| author | Antonio Ospite <ao2@ao2.it> | 2017-04-13 20:28:27 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marcjeanmougin@free.fr> | 2017-04-13 20:28:27 +0000 |
| commit | ad40881b1d7b1e1093fce11e49222b21723608b5 (patch) | |
| tree | f7053c040de87566f70ce583358a0a5a05f7e4a7 /src/ui/object-edit.cpp | |
| parent | Do not simplify when path inset or outset (diff) | |
| download | inkscape-ad40881b1d7b1e1093fce11e49222b21723608b5.tar.gz inkscape-ad40881b1d7b1e1093fce11e49222b21723608b5.zip | |
Ellipses in Inkscape are defined by the center and the radius, but the
user cannot easily control the position of the center.
Show a control point for the center so it's easier to move the shape
around and snap it by its center.
Fixed bugs:
- https://launchpad.net/bugs/481506
(bzr r15620)
Diffstat (limited to 'src/ui/object-edit.cpp')
| -rw-r--r-- | src/ui/object-edit.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/ui/object-edit.cpp b/src/ui/object-edit.cpp index b11a61710..b76e97c15 100644 --- a/src/ui/object-edit.cpp +++ b/src/ui/object-edit.cpp @@ -782,6 +782,12 @@ public: virtual void knot_click(unsigned int state); }; +class ArcKnotHolderEntityCenter : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + /* * return values: * 1 : inside @@ -983,6 +989,30 @@ ArcKnotHolderEntityRY::knot_click(unsigned int state) } } +void +ArcKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPGenericEllipse *ge = dynamic_cast<SPGenericEllipse *>(item); + g_assert(ge != NULL); + + Geom::Point const s = snap_knot_position(p, state); + + ge->cx = s[Geom::X]; + ge->cy = s[Geom::Y]; + + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +Geom::Point +ArcKnotHolderEntityCenter::knot_get() const +{ + SPGenericEllipse const *ge = dynamic_cast<SPGenericEllipse *>(item); + g_assert(ge != NULL); + + return Geom::Point(ge->cx.computed, ge->cy.computed); +} + + ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : KnotHolder(desktop, item, relhandler) { @@ -990,6 +1020,7 @@ ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRelea ArcKnotHolderEntityRY *entity_ry = new ArcKnotHolderEntityRY(); ArcKnotHolderEntityStart *entity_start = new ArcKnotHolderEntityStart(); ArcKnotHolderEntityEnd *entity_end = new ArcKnotHolderEntityEnd(); + ArcKnotHolderEntityCenter *entity_center = new ArcKnotHolderEntityCenter(); entity_rx->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, _("Adjust ellipse <b>width</b>, with <b>Ctrl</b> to make circle"), @@ -1011,10 +1042,15 @@ ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRelea "ellipse for arc, <b>outside</b> for segment"), SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); + entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, + _("Move the ellipse"), + SP_KNOT_SHAPE_CROSS); + entity.push_back(entity_rx); entity.push_back(entity_ry); entity.push_back(entity_start); entity.push_back(entity_end); + entity.push_back(entity_center); add_pattern_knotholder(); } |
