From 80cd661e8fc8ee72c5e77608961fd392c5b11d4a Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 15 Aug 2016 23:52:21 -0400 Subject: Add Shift+drag to arc start and end knots, holding shift will now move both knots together, maintaining the arc's size. Adjusted buffer for closed/open auto flipping. (bzr r15061) --- src/ui/object-edit.cpp | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'src/ui/object-edit.cpp') diff --git a/src/ui/object-edit.cpp b/src/ui/object-edit.cpp index ddf770f59..2763e6c4b 100644 --- a/src/ui/object-edit.cpp +++ b/src/ui/object-edit.cpp @@ -795,8 +795,11 @@ sp_genericellipse_side(SPGenericEllipse *ellipse, Geom::Point const &p) gdouble dy = (p[Geom::Y] - ellipse->cy.computed) / ellipse->ry.computed; gdouble s = dx * dx + dy * dy; - if (s < 1.0) return 1; - if (s > 1.0) return -1; + // We add a bit of a buffer, so there's a decent chance the user will + // be able to adjust the arc without the closed status flipping between + // open and closed during micro mouse movements. + if (s < 0.75) return 1; + if (s > 1.25) return -1; return 0; } @@ -808,16 +811,21 @@ ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*or SPGenericEllipse *arc = dynamic_cast(item); g_assert(arc != NULL); - arc->setClosed(sp_genericellipse_side(arc, p) == -1); + gint side = sp_genericellipse_side(arc, p); + if(side != 0) { arc->setClosed(side == -1); } Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed); Geom::Scale sc(arc->rx.computed, arc->ry.computed); - arc->start = atan2(delta * sc.inverse()); + double offset = arc->start - atan2(delta * sc.inverse()); + arc->start -= offset; if ((state & GDK_CONTROL_MASK) && snaps) { arc->start = sp_round(arc->start, M_PI / snaps); } + if (state & GDK_SHIFT_MASK) { + arc->end -= offset; + } arc->normalize(); arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -852,16 +860,21 @@ ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*orig SPGenericEllipse *arc = dynamic_cast(item); g_assert(arc != NULL); - arc->setClosed(sp_genericellipse_side(arc, p) == -1); + gint side = sp_genericellipse_side(arc, p); + if(side != 0) { arc->setClosed(side == -1); } Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed); Geom::Scale sc(arc->rx.computed, arc->ry.computed); - arc->end = atan2(delta * sc.inverse()); + double offset = arc->end - atan2(delta * sc.inverse()); + arc->end -= offset; if ((state & GDK_CONTROL_MASK) && snaps) { arc->end = sp_round(arc->end, M_PI/snaps); } + if (state & GDK_SHIFT_MASK) { + arc->start -= offset; + } arc->normalize(); arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -983,13 +996,15 @@ ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRelea SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); entity_start->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, - _("Position the start point of the arc or segment; with Ctrl " - "to snap angle; drag inside the ellipse for arc, outside for segment"), + _("Position the start point of the arc or segment; with Shift to move " + "with end point; with Ctrl to snap angle; drag inside the " + "ellipse for arc, outside for segment"), SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); entity_end->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, - _("Position the end point of the arc or segment; with Ctrl to snap angle; " - "drag inside the ellipse for arc, outside for segment"), + _("Position the end point of the arc or segment; with Shift to move " + "with start point; with Ctrl to snap angle; drag inside the " + "ellipse for arc, outside for segment"), SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); entity.push_back(entity_rx); -- cgit v1.2.3