X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fspiral-context.cpp;h=6dbdb74c950275680f85c57dd6cae02e979ba2f3;hb=1ed9f185c8ae0efc48813e56e431d389561a4b5c;hp=15bf513dcc4b36fd7ff597aa082b25f0f4ff8ac3;hpb=f951374eef04129c6a0d213e7ab4d9ed2095ca69;p=inkscape.git diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 15bf513dc..6dbdb74c9 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -183,7 +183,6 @@ sp_spiral_context_selection_changed(Inkscape::Selection *selection, gpointer dat ec->shape_repr = shape_repr; Inkscape::GC::anchor(shape_repr); sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec); - sp_repr_synthesize_events(shape_repr, &ec_shape_repr_events, ec); } } } @@ -200,7 +199,7 @@ sp_spiral_context_setup(SPEventContext *ec) sp_event_context_read(ec, "revolution"); sp_event_context_read(ec, "t0"); - Inkscape::Selection *selection = SP_DT_SELECTION(ec->desktop); + Inkscape::Selection *selection = sp_desktop_selection(ec->desktop); SPItem *item = selection->singleItem(); if (item) { @@ -210,7 +209,6 @@ sp_spiral_context_setup(SPEventContext *ec) ec->shape_repr = shape_repr; Inkscape::GC::anchor(shape_repr); sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec); - sp_repr_synthesize_events(shape_repr, &ec_shape_repr_events, ec); } } @@ -251,7 +249,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) static gboolean dragging; SPDesktop *desktop = event_context->desktop; - Inkscape::Selection *selection = SP_DT_SELECTION (desktop); + Inkscape::Selection *selection = sp_desktop_selection (desktop); SPSpiralContext *sc = SP_SPIRAL_CONTEXT(event_context); event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100); @@ -260,13 +258,13 @@ 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); - sc->center = m.freeSnap(Inkscape::Snapper::SNAP_POINT, sc->center, sc->item).getPoint(); + SnapManager const &m = desktop->namedview->snap_manager; + sc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, sc->center, sc->item).getPoint(); sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), ( GDK_KEY_PRESS_MASK | @@ -278,7 +276,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 ) @@ -291,14 +289,20 @@ 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 const &m = desktop->namedview->snap_manager; + motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt, sc->item).getPoint(); 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,8 +354,23 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) } break; case GDK_Escape: - SP_DT_SELECTION(desktop)->clear(); + 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; } @@ -398,7 +417,8 @@ sp_spiral_drag(SPSpiralContext *sc, NR::Point p, guint state) } /* Create object */ - Inkscape::XML::Node *repr = sp_repr_new("svg:path"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(sc)); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("sodipodi:type", "spiral"); /* Set style */ @@ -408,12 +428,14 @@ sp_spiral_drag(SPSpiralContext *sc, NR::Point p, guint state) Inkscape::GC::release(repr); sc->item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer()); sc->item->updateRepr(); + + sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); } 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); - p1 = m.freeSnap(Inkscape::Snapper::SNAP_POINT, p1, sc->item).getPoint(); + SnapManager const &m = desktop->namedview->snap_manager; + p1 = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p1, sc->item).getPoint(); SPSpiral *spiral = SP_SPIRAL(sc->item); @@ -435,7 +457,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); @@ -451,10 +473,13 @@ 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); - SP_DT_SELECTION(desktop)->set(sc->item); - sp_document_done(SP_DT_DOCUMENT(desktop)); + sp_desktop_selection(desktop)->set(sc->item); + sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL, + _("Create spiral")); sc->item = NULL; }