X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fstar-context.cpp;h=bb002ec893215ff57d463aa650336be6ab7f4d36;hb=b93042846520d88136cc3f211ec0a4adc60780cf;hp=612f5d5bbd5d5fe0810eebd1bf4fb720de37d507;hpb=c87d0307348fcfdc65b6b4ab6999a3cb0de2431f;p=inkscape.git diff --git a/src/star-context.cpp b/src/star-context.cpp index 612f5d5bb..bb002ec89 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -31,7 +31,6 @@ #include "desktop-style.h" #include "message-context.h" #include "pixmaps/cursor-star.xpm" -#include "pixmaps/cursor-star.pixbuf" #include "sp-metrics.h" #include #include "prefs-utils.h" @@ -96,11 +95,6 @@ sp_star_context_init (SPStarContext * star_context) SPEventContext *event_context = SP_EVENT_CONTEXT (star_context); event_context->cursor_shape = cursor_star_xpm; - event_context->cursor_pixbuf = gdk_pixbuf_new_from_inline( - -1, - cursor_star_pixbuf, - FALSE, - NULL); event_context->hot_x = 4; event_context->hot_y = 4; event_context->xp = 0; @@ -262,7 +256,7 @@ sp_star_context_set (SPEventContext *ec, const gchar *key, const gchar *val) static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent *event) { - static bool dragging; + static gboolean dragging; SPDesktop *desktop = event_context->desktop; Inkscape::Selection *selection = sp_desktop_selection (desktop); @@ -282,7 +276,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent 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(); + sc->center = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, sc->center, sc->item).getPoint(); sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | @@ -305,7 +299,11 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent 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::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, motion_dt, sc->item).getPoint(); + sp_star_drag (sc, motion_dt, event->motion.state); ret = TRUE; } @@ -366,6 +364,21 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent 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_star_finish(sc); + } + // do not return true, so that space would work switching to selector + } + break; + default: break; } @@ -411,7 +424,8 @@ static void sp_star_drag(SPStarContext *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", "star"); /* Set style */ @@ -421,6 +435,8 @@ static void sp_star_drag(SPStarContext *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); @@ -467,11 +483,13 @@ sp_star_finish (SPStarContext * sc) sp_shape_set_shape(SP_SHAPE(sc->item)); - object->updateRepr(NULL, SP_OBJECT_WRITE_EXT); + object->updateRepr(SP_OBJECT_WRITE_EXT); + + sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(sc->item); sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, - /* TODO: annotate */ "star-context.cpp:474"); + _("Create star")); sc->item = NULL; }