X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fspiral-context.cpp;h=56c5b0ebd76bf89d1407b1e18b7d4a26ece8a483;hb=cdd0f0c6cfd89e7a83ce48bf0791b7e41f6c3a21;hp=2e4214f066308759ed214b89a44e9c85b3d2a2e1;hpb=3caca4f8381f7ae35678d16074c2414c02a0c0ff;p=inkscape.git diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 2e4214f06..56c5b0ebd 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -17,6 +17,8 @@ #include "config.h" #include +#include +#include #include "macros.h" #include "display/sp-canvas.h" @@ -129,7 +131,7 @@ sp_spiral_context_dispose(GObject *object) if (sc->item) sp_spiral_finish(sc); if (ec->shape_knot_holder) { - sp_knot_holder_destroy(ec->shape_knot_holder); + delete ec->shape_knot_holder; ec->shape_knot_holder = NULL; } @@ -165,7 +167,7 @@ sp_spiral_context_selection_changed(Inkscape::Selection *selection, gpointer dat SPEventContext *ec = SP_EVENT_CONTEXT(sc); if (ec->shape_knot_holder) { // desktroy knotholder - sp_knot_holder_destroy(ec->shape_knot_holder); + delete ec->shape_knot_holder; ec->shape_knot_holder = NULL; } @@ -258,13 +260,14 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) switch (event->type) { case GDK_BUTTON_PRESS: - if (event->button.button == 1) { + if (event->button.button == 1 && !event_context->space_panning) { dragging = TRUE; sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event); - SnapManager const &m = desktop->namedview->snap_manager; - sc->center = m.freeSnap(Inkscape::Snapper::SNAP_POINT, sc->center, sc->item).getPoint(); + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop, NULL); //null, because we don't have an item yet + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, sc->center); sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), ( GDK_KEY_PRESS_MASK | @@ -276,7 +279,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) } break; case GDK_MOTION_NOTIFY: - if (dragging && event->motion.state && GDK_BUTTON1_MASK) { + if (dragging && (event->motion.state & GDK_BUTTON1_MASK) && !event_context->space_panning) { if ( event_context->within_tolerance && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance ) @@ -289,14 +292,21 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) event_context->within_tolerance = false; NR::Point const motion_w(event->motion.x, event->motion.y); - NR::Point const motion_dt(event_context->desktop->w2d(motion_w)); + NR::Point motion_dt(event_context->desktop->w2d(motion_w)); + + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop, sc->item); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); sp_spiral_drag(sc, motion_dt, event->motion.state); + + gobble_motion_events(GDK_BUTTON1_MASK); + ret = TRUE; } break; case GDK_BUTTON_RELEASE: event_context->xp = event_context->yp = 0; - if (event->button.button == 1) { + if (event->button.button == 1 && !event_context->space_panning) { dragging = FALSE; if (!event_context->within_tolerance) { // we've been dragging, finish the spiral @@ -350,6 +360,21 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_Escape: sp_desktop_selection(desktop)->clear(); //TODO: make dragging escapable by Esc + break; + + case GDK_space: + if (dragging) { + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), + event->button.time); + dragging = false; + if (!event_context->within_tolerance) { + // we've been dragging, finish the rect + sp_spiral_finish(sc); + } + // do not return true, so that space would work switching to selector + } + break; + default: break; } @@ -413,8 +438,9 @@ sp_spiral_drag(SPSpiralContext *sc, NR::Point p, guint state) NR::Point const p0 = sp_desktop_dt2root_xy_point(desktop, sc->center); NR::Point p1 = sp_desktop_dt2root_xy_point(desktop, p); - SnapManager const &m = desktop->namedview->snap_manager; - p1 = m.freeSnap(Inkscape::Snapper::SNAP_POINT, p1, sc->item).getPoint(); + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop, sc->item); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p1); SPSpiral *spiral = SP_SPIRAL(sc->item); @@ -436,7 +462,7 @@ sp_spiral_drag(SPSpiralContext *sc, NR::Point p, guint state) /* status text */ GString *rads = SP_PX_TO_METRIC_STRING(rad, desktop->namedview->getDefaultMetric()); - sc->_message_context->setF(Inkscape::NORMAL_MESSAGE, + sc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Spiral: radius %s, angle %5g°; with Ctrl to snap angle"), rads->str, sp_round((arg + 2.0*M_PI*spiral->revo)*180/M_PI, 0.0001)); g_string_free(rads, FALSE); @@ -452,7 +478,7 @@ sp_spiral_finish(SPSpiralContext *sc) SPSpiral *spiral = SP_SPIRAL(sc->item); sp_shape_set_shape(SP_SHAPE(spiral)); - SP_OBJECT(spiral)->updateRepr(NULL, SP_OBJECT_WRITE_EXT); + SP_OBJECT(spiral)->updateRepr(SP_OBJECT_WRITE_EXT); sp_canvas_end_forced_full_redraws(desktop->canvas);