diff --git a/src/star-context.cpp b/src/star-context.cpp
index f0c64e875e0277a8bb77ec8a831dc9df42095550..603865ce16d966490602102fbdef7f132f769cc1 100644 (file)
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
static void sp_star_context_dispose (GObject *object);
static void sp_star_context_setup (SPEventContext *ec);
+static void sp_star_context_finish(SPEventContext *ec);
static void sp_star_context_set (SPEventContext *ec, Inkscape::Preferences::Entry *val);
static gint sp_star_context_root_handler (SPEventContext *ec, GdkEvent *event);
object_class->dispose = sp_star_context_dispose;
event_context_class->setup = sp_star_context_setup;
+ event_context_class->finish = sp_star_context_finish;
event_context_class->set = sp_star_context_set;
event_context_class->root_handler = sp_star_context_root_handler;
}
event_context->tolerance = 0;
event_context->within_tolerance = false;
event_context->item_to_select = NULL;
+ event_context->tool_url = "/tools/shapes/star";
star_context->item = NULL;
new (&star_context->sel_changed_connection) sigc::connection();
}
+static void sp_star_context_finish(SPEventContext *ec)
+{
+ SPStarContext *sc = SP_STAR_CONTEXT(ec);
+ SPDesktop *desktop = ec->desktop;
+
+ sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), GDK_CURRENT_TIME);
+ sp_star_finish(sc);
+ sc->sel_changed_connection.disconnect();
+
+ if (((SPEventContextClass *) parent_class)->finish) {
+ ((SPEventContextClass *) parent_class)->finish(ec);
+ }
+}
+
+
static void
sp_star_context_dispose (GObject *object)
{
@@ -236,17 +254,14 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
if (event->button.button == 1 && !event_context->space_panning) {
dragging = TRUE;
- sp_event_context_snap_window_open(event_context);
sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event);
/* Snap center */
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true);
- Geom::Point pt2g = to_2geom(sc->center);
- m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g, Inkscape::SNAPSOURCE_HANDLE);
- sc->center = from_2geom(pt2g);
-
+ m.freeSnapReturnByRef(sc->center, Inkscape::SNAPSOURCE_NODE_HANDLE);
+ m.unSetup();
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK |
@@ -277,13 +292,22 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
gobble_motion_events(GDK_BUTTON1_MASK);
ret = TRUE;
+ } else if (!sp_event_context_knot_mouseover(event_context)) {
+ SnapManager &m = desktop->namedview->snap_manager;
+ m.setup(desktop);
+
+ Geom::Point const motion_w(event->motion.x, event->motion.y);
+ Geom::Point motion_dt(desktop->w2d(motion_w));
+
+ m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE));
+ m.unSetup();
}
break;
case GDK_BUTTON_RELEASE:
event_context->xp = event_context->yp = 0;
if (event->button.button == 1 && !event_context->space_panning) {
dragging = FALSE;
- sp_event_context_snap_window_closed(event_context, false); //button release will also occur on a double-click; in that case suppress warnings
+ sp_event_context_discard_delayed_snap_event(event_context);
if (!event_context->within_tolerance) {
// we've been dragging, finish the star
sp_star_finish (sc);
@@ -336,7 +360,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
case GDK_Escape:
if (dragging) {
dragging = false;
- sp_event_context_snap_window_closed(event_context);
+ sp_event_context_discard_delayed_snap_event(event_context);
// if drawing, cancel, otherwise pass it up for deselecting
sp_star_cancel(sc);
ret = TRUE;
@@ -347,7 +371,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
event->button.time);
dragging = false;
- sp_event_context_snap_window_closed(event_context);
+ sp_event_context_discard_delayed_snap_event(event_context);
if (!event_context->within_tolerance) {
// we've been dragging, finish the star
sp_star_finish(sc);
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true, sc->item);
Geom::Point pt2g = to_2geom(p);
- m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g, Inkscape::SNAPSOURCE_HANDLE);
-
+ m.freeSnapReturnByRef(pt2g, Inkscape::SNAPSOURCE_NODE_HANDLE);
+ m.unSetup();
Geom::Point const p0 = desktop->dt2doc(sc->center);
Geom::Point const p1 = desktop->dt2doc(pt2g);
sc->_message_context->clear();
if (sc->item != NULL) {
- SPStar *star = SP_STAR(sc->item);
- if (star->r[1] == 0) {
- sp_star_cancel(sc); // Don't allow the creating of zero sized arc, for example when the start and and point snap to the snap grid point
- return;
- }
+ SPStar *star = SP_STAR(sc->item);
+ if (star->r[1] == 0) {
+ sp_star_cancel(sc); // Don't allow the creating of zero sized arc, for example when the start and and point snap to the snap grid point
+ return;
+ }
+
+ // Set transform center, so that odd stars rotate correctly
+ // LP #462157
+ sc->item->setCenter(sc->center);
- SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
+ SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
SPObject *object = SP_OBJECT(sc->item);
sp_shape_set_shape(SP_SHAPE(sc->item));
static void sp_star_cancel(SPStarContext *sc)
{
- SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
+ SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
- sp_desktop_selection(desktop)->clear();
- sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0);
+ sp_desktop_selection(desktop)->clear();
+ sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0);
if (sc->item != NULL) {
- SP_OBJECT(sc->item)->deleteObject();
- sc->item = NULL;
+ SP_OBJECT(sc->item)->deleteObject();
+ sc->item = NULL;
}
sc->within_tolerance = false;