Code

Remove redundancy from snapping API (type of snapsource no longer has to be specified...
authorDiederik van Lierop <mailat-signdiedenrezidotnl>
Sat, 23 Jan 2010 13:36:56 +0000 (14:36 +0100)
committerDiederik van Lierop <mailat-signdiedenrezidotnl>
Sat, 23 Jan 2010 13:36:56 +0000 (14:36 +0100)
29 files changed:
src/arc-context.cpp
src/box3d-context.cpp
src/connector-context.cpp
src/context-fns.cpp
src/display/snap-indicator.cpp
src/draw-context.cpp
src/event-context.cpp
src/event-context.h
src/gradient-context.cpp
src/gradient-drag.cpp
src/knot-holder-entity.cpp
src/line-snapper.cpp
src/line-snapper.h
src/object-snapper.cpp
src/object-snapper.h
src/pen-context.cpp
src/pencil-context.cpp
src/rect-context.cpp
src/seltrans.cpp
src/snap-candidate.h
src/snap-enums.h [new file with mode: 0644]
src/snap-preferences.cpp
src/snap-preferences.h
src/snap.cpp
src/snap.h
src/snapper.h
src/spiral-context.cpp
src/star-context.cpp
src/ui/tool/node.cpp

index e689c93db186669b3768243e8d755cb40536aa6a..9cb6e822285101a46d81eb2e12b1996ff5e5f297 100644 (file)
@@ -244,9 +244,7 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent
                 /* Snap center */
                 SnapManager &m = desktop->namedview->snap_manager;
                 m.setup(desktop);
-                Geom::Point pt2g = to_2geom(ac->center);
-                m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g, Inkscape::SNAPSOURCE_HANDLE);
-                ac->center = from_2geom(pt2g);
+                m.freeSnapReturnByRef(ac->center, Inkscape::SNAPSOURCE_NODE_HANDLE);
 
                 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                     GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
index c8fbfa8779ff27500679337568fa9df97b53de25..ad9c51f0fda674e20c289a984beb2294b4f098dd 100644 (file)
@@ -316,7 +316,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
             /* Snap center */
             SnapManager &m = desktop->namedview->snap_manager;
             m.setup(desktop, true, bc->item);
-            m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, button_dt, Inkscape::SNAPSOURCE_HANDLE);
+            m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
             bc->center = from_2geom(button_dt);
 
             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
@@ -348,7 +348,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
 
             SnapManager &m = desktop->namedview->snap_manager;
             m.setup(desktop, true, bc->item);
-            m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, motion_dt, Inkscape::SNAPSOURCE_HANDLE);
+            m.freeSnapReturnByRef(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
 
             bc->ctrl_dragged  = event->motion.state & GDK_CONTROL_MASK;
 
@@ -381,9 +381,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
                     bc->drag_ptB_proj.normalize();
                     bc->drag_ptC_proj = cur_persp->perspective_impl->tmat.preimage (from_2geom(motion_dt), bc->drag_ptB_proj[Proj::X], Proj::X);
                 }
-                Geom::Point pt2g = to_2geom(bc->drag_ptC);
-                m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g, Inkscape::SNAPSOURCE_HANDLE);
-                bc->drag_ptC = from_2geom(pt2g);
+                m.freeSnapReturnByRef(bc->drag_ptC, Inkscape::SNAPSOURCE_NODE_HANDLE);
             }
 
             sp_box3d_drag(*bc, event->motion.state);
index 0fc9de9d0384ee0e99d98e0366012ed7851aa2ce..bfdef103213dfb7f8775cd97592c6ef12dbbd3ba 100644 (file)
@@ -774,7 +774,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const
                         if (!cc->sid) {
                             // This is the first point, so just snap it to the grid
                             // as there's no other points to go off.
-                            m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+                            m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
                         }
                         spcc_connector_set_initial_point(cc, p);
 
@@ -786,7 +786,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const
                 case SP_CONNECTOR_CONTEXT_DRAGGING:
                 {
                     // This is the second click of a connector creation.
-                    m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+                    m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 
                     spcc_connector_set_subsequent_point(cc, p);
                     spcc_connector_finish_segment(cc, p);
@@ -934,8 +934,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons
                 gobble_motion_events(mevent.state);
                 // This is movement during a connector creation.
                 if ( cc->npoints > 0 ) {
-                    m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p,
-                            Inkscape::SNAPSOURCE_HANDLE);
+                    m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
                     cc->selection->clear();
                     spcc_connector_set_subsequent_point(cc, p);
                     ret = TRUE;
@@ -947,8 +946,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons
                 gobble_motion_events(GDK_BUTTON1_MASK);
                 g_assert( SP_IS_PATH(cc->clickeditem));
 
-                m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p,
-                        Inkscape::SNAPSOURCE_HANDLE);
+                m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 
                 // Update the hidden path
                 Geom::Matrix i2d = sp_item_i2d_affine(cc->clickeditem);
@@ -1023,7 +1021,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con
                 //case SP_CONNECTOR_CONTEXT_POINT:
                 case SP_CONNECTOR_CONTEXT_DRAGGING:
                 {
-                    m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+                    m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 
                     if (cc->within_tolerance)
                     {
@@ -1044,7 +1042,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con
                 }
                 case SP_CONNECTOR_CONTEXT_REROUTING:
                 {
-                    m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+                    m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
                     cc_connector_rerouting_finish(cc, &p);
 
                     sp_document_ensure_up_to_date(doc);
@@ -1068,7 +1066,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con
 
                     if (!cc->within_tolerance)
                     {
-                        m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+                        m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
                         sp_knot_set_position(cc->selected_handle, p, 0);
                         ConnectionPoint& cp = cc->connpthandles[cc->selected_handle];
                         cp.pos = p * sp_item_dt2i_affine(cc->active_shape);
@@ -1081,7 +1079,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con
 
 
                 case SP_CONNECTOR_CONTEXT_NEWCONNPOINT:
-                    m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+                    m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 
                     sp_knot_set_position(cc->selected_handle, p, 0);
 
@@ -1184,7 +1182,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval)
 
                     if (!cc->within_tolerance)
                     {
-                        m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+                        m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
                         sp_knot_set_position(cc->selected_handle, p, 0);
                         ConnectionPoint& cp = cc->connpthandles[cc->selected_handle];
                         cp.pos = p * sp_item_dt2i_affine(cc->active_shape);
@@ -1212,7 +1210,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval)
                     m.setup(desktop);
                     Geom::Point p = cc->selected_handle->pos;
 
-                    m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+                    m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 
                     sp_knot_set_position(cc->selected_handle, p, 0);
 
index 67a7d6baadcd3e050c8a05ad68bae5363a98c4ad..0ff7bd12097c557f65426b551e0197fc5c983f11 100644 (file)
@@ -131,11 +131,11 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
             Inkscape::SnappedPoint s[2];
 
             /* Try to snap p[0] (the opposite corner) along the constraint vector */
-            s[0] = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(p[0], Inkscape::SNAPSOURCE_HANDLE),
+            s[0] = m.constrainedSnap(Inkscape::SnapCandidatePoint(p[0], Inkscape::SNAPSOURCE_NODE_HANDLE),
                                      Inkscape::Snapper::ConstraintLine(p[0] - p[1]));
 
             /* Try to snap p[1] (the dragged corner) along the constraint vector */
-            s[1] = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(p[1], Inkscape::SNAPSOURCE_HANDLE),
+            s[1] = m.constrainedSnap(Inkscape::SnapCandidatePoint(p[1], Inkscape::SNAPSOURCE_NODE_HANDLE),
                                      Inkscape::Snapper::ConstraintLine(p[1] - p[0]));
 
             /* Choose the best snap and update points accordingly */
@@ -156,7 +156,7 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
 
             /* Our origin is the opposite corner.  Snap the drag point along the constraint vector */
             p[0] = center;
-            snappoint = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(p[1], Inkscape::SNAPSOURCE_HANDLE),
+            snappoint = m.constrainedSnap(Inkscape::SnapCandidatePoint(p[1], Inkscape::SNAPSOURCE_NODE_HANDLE),
                                           Inkscape::Snapper::ConstraintLine(p[1] - p[0]));
             if (snappoint.getSnapped()) {
                 p[1] = snappoint.getPoint();
@@ -174,8 +174,8 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
 
         Inkscape::SnappedPoint s[2];
 
-        s[0] = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(p[0], Inkscape::SNAPSOURCE_HANDLE));
-        s[1] = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(p[1], Inkscape::SNAPSOURCE_HANDLE));
+        s[0] = m.freeSnap(Inkscape::SnapCandidatePoint(p[0], Inkscape::SNAPSOURCE_NODE_HANDLE));
+        s[1] = m.freeSnap(Inkscape::SnapCandidatePoint(p[1], Inkscape::SNAPSOURCE_NODE_HANDLE));
 
         if (s[0].getSnapDistance() < s[1].getSnapDistance()) {
             if (s[0].getSnapped()) {
@@ -196,7 +196,7 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
         /* There's no constraint on the corner point, so just snap it to anything */
         p[0] = center;
         p[1] = pt;
-        snappoint = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_HANDLE));
+        snappoint = m.freeSnap(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_HANDLE));
         if (snappoint.getSnapped()) {
             p[1] = snappoint.getPoint();
         }
index 54671cb28b2361f75cfb73608dfb6262b26f73d8..dd80524f1614eafe20f1ab43e2e42723f87dc758 100644 (file)
@@ -176,7 +176,8 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p)
             case SNAPSOURCE_ROTATION_CENTER:
                 source_name = _("Object rotation center");
                 break;
-            case SNAPSOURCE_HANDLE:
+            case SNAPSOURCE_NODE_HANDLE:
+            case SNAPSOURCE_OTHER_HANDLE:
                 source_name = _("Handle");
                 break;
             case SNAPSOURCE_PATH_INTERSECTION:
index 3334c82de7ef5c23407cfcbac5e2b54a8b4877d6..da22c8a7a50dfcbd07d253ea1f235c93519cecc8 100644 (file)
@@ -511,7 +511,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p,
             /* Snap it along best vector */
             SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
             m.setup(SP_EVENT_CONTEXT_DESKTOP(ec));
-            m.constrainedSnapReturnByRef( Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE, Inkscape::Snapper::ConstraintLine(best));
+            m.constrainedSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE, Inkscape::Snapper::ConstraintLine(best));
         }
     }
 }
@@ -520,16 +520,14 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p,
 void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, guint const /*state*/)
 {
     SPDesktop *dt = SP_EVENT_CONTEXT_DESKTOP(ec);
-       SnapManager &m = dt->namedview->snap_manager;
-       Inkscape::Selection *selection = sp_desktop_selection (dt);
+    SnapManager &m = dt->namedview->snap_manager;
+    Inkscape::Selection *selection = sp_desktop_selection (dt);
 
-       // selection->singleItem() is the item that is currently being drawn. This item will not be snapped to (to avoid self-snapping)
-       // TODO: Allow snapping to the stationary parts of the item, and only ignore the last segment
+    // selection->singleItem() is the item that is currently being drawn. This item will not be snapped to (to avoid self-snapping)
+    // TODO: Allow snapping to the stationary parts of the item, and only ignore the last segment
 
-       m.setup(dt, true, selection->singleItem());
-    Geom::Point pt2g = to_2geom(p);
-    m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g, Inkscape::SNAPSOURCE_HANDLE);
-    p = from_2geom(pt2g);
+    m.setup(dt, true, selection->singleItem());
+    m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE);
 }
 
 static SPCurve *
index 363f9fe71f2fe86def50d2577dc8c339609618cf..100e6b1430123126dfbf94c6466a90c4776feb58 100644 (file)
@@ -64,8 +64,10 @@ static void sp_event_context_init(SPEventContext *event_context);
 static void sp_event_context_dispose(GObject *object);
 
 static void sp_event_context_private_setup(SPEventContext *ec);
-static gint sp_event_context_private_root_handler(SPEventContext *event_context, GdkEvent *event);
-static gint sp_event_context_private_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
+static gint sp_event_context_private_root_handler(
+        SPEventContext *event_context, GdkEvent *event);
+static gint sp_event_context_private_item_handler(
+        SPEventContext *event_context, SPItem *item, GdkEvent *event);
 
 static void set_event_location(SPDesktop * desktop, GdkEvent * event);
 
@@ -91,22 +93,16 @@ static guint scroll_keyval = 0;
 /**
  * Registers the SPEventContext class with Glib and returns its type number.
  */
-GType
-sp_event_context_get_type(void)
-{
+GType sp_event_context_get_type(void) {
     static GType type = 0;
     if (!type) {
-        GTypeInfo info = {
-            sizeof(SPEventContextClass),
-            NULL, NULL,
-            (GClassInitFunc) sp_event_context_class_init,
-            NULL, NULL,
-            sizeof(SPEventContext),
-            4,
-            (GInstanceInitFunc) sp_event_context_init,
-            NULL,    /* value_table */
+        GTypeInfo info = { sizeof(SPEventContextClass), NULL, NULL,
+                (GClassInitFunc) sp_event_context_class_init, NULL, NULL,
+                sizeof(SPEventContext), 4,
+                (GInstanceInitFunc) sp_event_context_init, NULL, /* value_table */
         };
-        type = g_type_register_static(G_TYPE_OBJECT, "SPEventContext", &info, (GTypeFlags)0);
+        type = g_type_register_static(G_TYPE_OBJECT, "SPEventContext", &info,
+                (GTypeFlags) 0);
     }
     return type;
 }
@@ -114,14 +110,12 @@ sp_event_context_get_type(void)
 /**
  * Callback to set up the SPEventContext vtable.
  */
-static void
-sp_event_context_class_init(SPEventContextClass *klass)
-{
+static void sp_event_context_class_init(SPEventContextClass *klass) {
     GObjectClass *object_class;
 
     object_class = (GObjectClass *) klass;
 
-    parent_class = (GObjectClass*)g_type_class_peek_parent(klass);
+    parent_class = (GObjectClass*) g_type_class_peek_parent(klass);
 
     object_class->dispose = sp_event_context_dispose;
 
@@ -133,9 +127,7 @@ sp_event_context_class_init(SPEventContextClass *klass)
 /**
  * Clears all SPEventContext object members.
  */
-static void
-sp_event_context_init(SPEventContext *event_context)
-{
+static void sp_event_context_init(SPEventContext *event_context) {
     event_context->desktop = NULL;
     event_context->cursor = NULL;
     event_context->_message_context = NULL;
@@ -149,9 +141,7 @@ sp_event_context_init(SPEventContext *event_context)
 /**
  * Callback to free and null member variables of SPEventContext object.
  */
-static void
-sp_event_context_dispose(GObject *object)
-{
+static void sp_event_context_dispose(GObject *object) {
     SPEventContext *ec;
 
     ec = SP_EVENT_CONTEXT(object);
@@ -183,9 +173,7 @@ sp_event_context_dispose(GObject *object)
 /**
  * Recreates and draws cursor on desktop related to SPEventContext.
  */
-void
-sp_event_context_update_cursor(SPEventContext *ec)
-{
+void sp_event_context_update_cursor(SPEventContext *ec) {
     GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(ec->desktop));
     if (w->window) {
         /* fixme: */
@@ -195,13 +183,12 @@ sp_event_context_update_cursor(SPEventContext *ec)
             sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, ec->cursor_shape);
             if ((bitmap != NULL) && (mask != NULL)) {
                 if (ec->cursor)
-                    gdk_cursor_unref (ec->cursor);
+                    gdk_cursor_unref(ec->cursor);
                 ec->cursor = gdk_cursor_new_from_pixmap(bitmap, mask,
-                                                        &w->style->black,
-                                                        &w->style->white,
-                                                        ec->hot_x, ec->hot_y);
-                g_object_unref (bitmap);
-                g_object_unref (mask);
+                        &w->style->black, &w->style->white, ec->hot_x,
+                        ec->hot_y);
+                g_object_unref(bitmap);
+                g_object_unref(mask);
             }
         }
         gdk_window_set_cursor(w->window, ec->cursor);
@@ -214,58 +201,56 @@ sp_event_context_update_cursor(SPEventContext *ec)
  * Callback that gets called on initialization of SPEventContext object.
  * Redraws mouse cursor, at the moment.
  */
-static void
-sp_event_context_private_setup(SPEventContext *ec)
-{
+static void sp_event_context_private_setup(SPEventContext *ec) {
     sp_event_context_update_cursor(ec);
 }
 
 /**
  * \brief   Gobbles next key events on the queue with the same keyval and mask. Returns the number of events consumed.
  */
-gint gobble_key_events(guint keyval, gint mask)
-{
+gint gobble_key_events(guint keyval, gint mask) {
     GdkEvent *event_next;
     gint i = 0;
 
     event_next = gdk_event_get();
     // while the next event is also a key notify with the same keyval and mask,
-    while (event_next && (event_next->type == GDK_KEY_PRESS || event_next->type == GDK_KEY_RELEASE)
-           && event_next->key.keyval == keyval
-           && (!mask || (event_next->key.state & mask))) {
+    while (event_next && (event_next->type == GDK_KEY_PRESS || event_next->type
+            == GDK_KEY_RELEASE) && event_next->key.keyval == keyval && (!mask
+            || (event_next->key.state & mask))) {
         if (event_next->type == GDK_KEY_PRESS)
-            i ++;
+            i++;
         // kill it
         gdk_event_free(event_next);
         // get next
         event_next = gdk_event_get();
     }
     // otherwise, put it back onto the queue
-    if (event_next) gdk_event_put(event_next);
+    if (event_next)
+        gdk_event_put(event_next);
 
     return i;
 }
 
 /**
  * \brief   Gobbles next motion notify events on the queue with the same mask. Returns the number of events consumed.
-*/
-gint gobble_motion_events(gint mask)
-{
+ */
+gint gobble_motion_events(gint mask) {
     GdkEvent *event_next;
     gint i = 0;
 
     event_next = gdk_event_get();
     // while the next event is also a key notify with the same keyval and mask,
     while (event_next && event_next->type == GDK_MOTION_NOTIFY
-           && (event_next->motion.state & mask)) {
+            && (event_next->motion.state & mask)) {
         // kill it
         gdk_event_free(event_next);
         // get next
         event_next = gdk_event_get();
-        i ++;
+        i++;
     }
     // otherwise, put it back onto the queue
-    if (event_next) gdk_event_put(event_next);
+    if (event_next)
+        gdk_event_put(event_next);
 
     return i;
 }
@@ -274,20 +259,21 @@ gint gobble_motion_events(gint mask)
  * Toggles current tool between active tool and selector tool.
  * Subroutine of sp_event_context_private_root_handler().
  */
-static void
-sp_toggle_selector(SPDesktop *dt)
-{
-    if (!dt->event_context) return;
+static void sp_toggle_selector(SPDesktop *dt) {
+    if (!dt->event_context)
+        return;
 
     if (tools_isactive(dt, TOOLS_SELECT)) {
         if (selector_toggled) {
-            if (switch_selector_to) tools_switch (dt, switch_selector_to);
+            if (switch_selector_to)
+                tools_switch(dt, switch_selector_to);
             selector_toggled = FALSE;
-        } else return;
+        } else
+            return;
     } else {
         selector_toggled = TRUE;
         switch_selector_to = tools_active(dt);
-        tools_switch (dt, TOOLS_SELECT);
+        tools_switch(dt, TOOLS_SELECT);
     }
 }
 
@@ -295,20 +281,21 @@ sp_toggle_selector(SPDesktop *dt)
  * Toggles current tool between active tool and dropper tool.
  * Subroutine of sp_event_context_private_root_handler().
  */
-static void
-sp_toggle_dropper(SPDesktop *dt)
-{
-    if (!dt->event_context) return;
+static void sp_toggle_dropper(SPDesktop *dt) {
+    if (!dt->event_context)
+        return;
 
     if (tools_isactive(dt, TOOLS_DROPPER)) {
         if (dropper_toggled) {
-            if (switch_dropper_to) tools_switch (dt, switch_dropper_to);
+            if (switch_dropper_to)
+                tools_switch(dt, switch_dropper_to);
             dropper_toggled = FALSE;
-        } else return;
+        } else
+            return;
     } else {
         dropper_toggled = TRUE;
         switch_dropper_to = tools_active(dt);
-        tools_switch (dt, TOOLS_DROPPER);
+        tools_switch(dt, TOOLS_DROPPER);
     }
 }
 
@@ -316,8 +303,8 @@ sp_toggle_dropper(SPDesktop *dt)
  * Calculates and keeps track of scroll acceleration.
  * Subroutine of sp_event_context_private_root_handler().
  */
-static gdouble accelerate_scroll(GdkEvent *event, gdouble acceleration, SPCanvas */*canvas*/)
-{
+static gdouble accelerate_scroll(GdkEvent *event, gdouble acceleration,
+        SPCanvas */*canvas*/) {
     guint32 time_diff = ((GdkEventKey *) event)->time - scroll_event_time;
 
     /* key pressed within 500ms ? (1/2 second) */
@@ -336,8 +323,8 @@ static gdouble accelerate_scroll(GdkEvent *event, gdouble acceleration, SPCanvas
 /**
  * Main event dispatch, gets called from Gdk.
  */
-static gint sp_event_context_private_root_handler(SPEventContext *event_context, GdkEvent *event)
-{
+static gint sp_event_context_private_root_handler(
+        SPEventContext *event_context, GdkEvent *event) {
     static Geom::Point button_w;
     static unsigned int panning = 0;
     static unsigned int zoom_rb = 0;
@@ -346,380 +333,386 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
     /// @todo REmove redundant /value in preference keys
-    tolerance = prefs->getIntLimited(
-            "/options/dragtolerance/value", 0, 0, 100);
+    tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
 
     gint ret = FALSE;
 
     switch (event->type) {
-        case GDK_2BUTTON_PRESS:
-            if (panning) {
-                panning = 0;
-                sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
-                        event->button.time);
+    case GDK_2BUTTON_PRESS:
+        if (panning) {
+            panning = 0;
+            sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
+                    event->button.time);
+            ret = TRUE;
+        } else {
+            /* sp_desktop_dialog(); */
+        }
+        break;
+    case GDK_BUTTON_PRESS:
+
+        // save drag origin
+        xp = (gint) event->button.x;
+        yp = (gint) event->button.y;
+        within_tolerance = true;
+
+        button_w = Geom::Point(event->button.x, event->button.y);
+
+        switch (event->button.button) {
+        case 1:
+            if (event_context->space_panning) {
+                // When starting panning, make sure there are no snap events pending because these might disable the panning again
+                sp_event_context_discard_delayed_snap_event(event_context);
+                panning = 1;
+                sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+                        GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK
+                                | GDK_POINTER_MOTION_MASK
+                                | GDK_POINTER_MOTION_HINT_MASK, NULL,
+                        event->button.time - 1);
                 ret = TRUE;
-            } else {
-                /* sp_desktop_dialog(); */
             }
             break;
-        case GDK_BUTTON_PRESS:
-
-            // save drag origin
-            xp = (gint) event->button.x;
-            yp = (gint) event->button.y;
-            within_tolerance = true;
-
-            button_w = Geom::Point(event->button.x, event->button.y);
-
-            switch (event->button.button) {
-                case 1:
-                    if (event_context->space_panning) {
-                        // When starting panning, make sure there are no snap events pending because these might disable the panning again
-                        sp_event_context_discard_delayed_snap_event(event_context);
-                        panning = 1;
-                        sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
-                            GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
-                            NULL, event->button.time-1);
-                        ret = TRUE;
-                    }
-                    break;
-                case 2:
-                    if (event->button.state & GDK_SHIFT_MASK) {
-                        zoom_rb = 2;
-                    } else {
-                        // When starting panning, make sure there are no snap events pending because these might disable the panning again
-                        sp_event_context_discard_delayed_snap_event(event_context);
-                        panning = 2;
-                        sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
-                            GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
-                            NULL, event->button.time-1);
-                    }
-                    ret = TRUE;
-                    break;
-                case 3:
-                    if (event->button.state & GDK_SHIFT_MASK
-                            || event->button.state & GDK_CONTROL_MASK) {
-                        // When starting panning, make sure there are no snap events pending because these might disable the panning again
-                        sp_event_context_discard_delayed_snap_event(event_context);
-                        panning = 3;
-                        sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
-                                GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
-                                NULL, event->button.time);
-                        ret = TRUE;
-                    } else {
-                        sp_event_root_menu_popup(desktop, NULL, event);
-                    }
-                    break;
-                default:
-                    break;
+        case 2:
+            if (event->button.state & GDK_SHIFT_MASK) {
+                zoom_rb = 2;
+            } else {
+                // When starting panning, make sure there are no snap events pending because these might disable the panning again
+                sp_event_context_discard_delayed_snap_event(event_context);
+                panning = 2;
+                sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+                        GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK
+                                | GDK_POINTER_MOTION_HINT_MASK, NULL,
+                        event->button.time - 1);
             }
+            ret = TRUE;
             break;
-        case GDK_MOTION_NOTIFY:
-            if (panning) {
-                if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK))
-                        || (panning == 1 && !(event->motion.state & GDK_BUTTON1_MASK))
-                        || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))
-                   ) {
-                    /* Gdk seems to lose button release for us sometimes :-( */
-                    panning = 0;
-                    sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
-                            event->button.time);
-                    ret = TRUE;
-                } else {
-                    if ( within_tolerance
-                         && ( abs( (gint) event->motion.x - xp ) < tolerance )
-                         && ( abs( (gint) event->motion.y - yp ) < tolerance ))
-                    {
-                        // do not drag if we're within tolerance from origin
-                        break;
-                    }
-                    // Once the user has moved farther than tolerance from
-                    // the original location (indicating they intend to move
-                    // the object, not click), then always process the motion
-                    // notify coordinates as given (no snapping back to origin)
-                    within_tolerance = false;
-
-                    // gobble subsequent motion events to prevent "sticking"
-                    // when scrolling is slow
-                    gobble_motion_events(panning == 2 ?
-                                         GDK_BUTTON2_MASK :
-                                         (panning == 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK));
-
-                    Geom::Point const motion_w(event->motion.x, event->motion.y);
-                    Geom::Point const moved_w( motion_w - button_w );
-                    event_context->desktop->scroll_world(moved_w, true); // we're still scrolling, do not redraw
-                    ret = TRUE;
-                }
-            } else if (zoom_rb) {
-                Geom::Point const motion_w(event->motion.x, event->motion.y);
-                Geom::Point const motion_dt(desktop->w2d(motion_w));
-
-                if ( within_tolerance
-                     && ( abs( (gint) event->motion.x - xp ) < tolerance )
-                     && ( abs( (gint) event->motion.y - yp ) < tolerance ) ) {
-                    break; // do not drag if we're within tolerance from origin
-                }
-                // Once the user has moved farther than tolerance from the original location
-                // (indicating they intend to move the object, not click), then always process the
-                // motion notify coordinates as given (no snapping back to origin)
-                within_tolerance = false;
-
-                if (Inkscape::Rubberband::get(desktop)->is_started()) {
-                    Inkscape::Rubberband::get(desktop)->move(motion_dt);
-                } else {
-                    Inkscape::Rubberband::get(desktop)->start(desktop, motion_dt);
-                }
-                if (zoom_rb == 2)
-                    gobble_motion_events(GDK_BUTTON2_MASK);
+        case 3:
+            if (event->button.state & GDK_SHIFT_MASK || event->button.state
+                    & GDK_CONTROL_MASK) {
+                // When starting panning, make sure there are no snap events pending because these might disable the panning again
+                sp_event_context_discard_delayed_snap_event(event_context);
+                panning = 3;
+                sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+                        GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK
+                                | GDK_POINTER_MOTION_HINT_MASK, NULL,
+                        event->button.time);
+                ret = TRUE;
+            } else {
+                sp_event_root_menu_popup(desktop, NULL, event);
             }
             break;
-        case GDK_BUTTON_RELEASE:
-            xp = yp = 0;
-            if (within_tolerance && (panning || zoom_rb)) {
-                zoom_rb = 0;
-                if (panning) {
-                    panning = 0;
-                    sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
-                                      event->button.time);
-                }
-                Geom::Point const event_w(event->button.x, event->button.y);
-                Geom::Point const event_dt(desktop->w2d(event_w));
-                double const zoom_inc = prefs->getDoubleLimited("/options/zoomincrement/value", M_SQRT2, 1.01, 10);
-                desktop->zoom_relative_keep_point(event_dt,
-                          (event->button.state & GDK_SHIFT_MASK) ? 1/zoom_inc : zoom_inc);
-                desktop->updateNow();
-                ret = TRUE;
-            } else if (panning == event->button.button) {
+        default:
+            break;
+        }
+        break;
+    case GDK_MOTION_NOTIFY:
+        if (panning) {
+            if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK))
+                    || (panning == 1 && !(event->motion.state
+                            & GDK_BUTTON1_MASK)) || (panning == 3
+                    && !(event->motion.state & GDK_BUTTON3_MASK))) {
+                /* Gdk seems to lose button release for us sometimes :-( */
                 panning = 0;
                 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
-                                      event->button.time);
-
-                // in slow complex drawings, some of the motion events are lost;
-                // to make up for this, we scroll it once again to the button-up event coordinates
-                // (i.e. canvas will always get scrolled all the way to the mouse release point,
-                // even if few intermediate steps were visible)
-                Geom::Point const motion_w(event->button.x, event->button.y);
-                Geom::Point const moved_w( motion_w - button_w );
-                event_context->desktop->scroll_world(moved_w);
-                desktop->updateNow();
+                        event->button.time);
                 ret = TRUE;
-            } else if (zoom_rb == event->button.button) {
-                zoom_rb = 0;
-                Geom::OptRect const b = Inkscape::Rubberband::get(desktop)->getRectangle();
-                Inkscape::Rubberband::get(desktop)->stop();
-                if (b && !within_tolerance) {
-                    desktop->set_display_area(*b, 10);
+            } else {
+                if (within_tolerance && (abs((gint) event->motion.x - xp)
+                        < tolerance) && (abs((gint) event->motion.y - yp)
+                        < tolerance)) {
+                    // do not drag if we're within tolerance from origin
+                    break;
                 }
+                // Once the user has moved farther than tolerance from
+                // the original location (indicating they intend to move
+                // the object, not click), then always process the motion
+                // notify coordinates as given (no snapping back to origin)
+                within_tolerance = false;
+
+                // gobble subsequent motion events to prevent "sticking"
+                // when scrolling is slow
+                gobble_motion_events(panning == 2 ? GDK_BUTTON2_MASK : (panning
+                        == 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK));
+
+                Geom::Point const motion_w(event->motion.x, event->motion.y);
+                Geom::Point const moved_w(motion_w - button_w);
+                event_context->desktop->scroll_world(moved_w, true); // we're still scrolling, do not redraw
                 ret = TRUE;
             }
-            break;
-        case GDK_KEY_PRESS:
-            {
-            double const acceleration = prefs->getDoubleLimited("/options/scrollingacceleration/value", 0, 0, 6);
-            int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", 10, 0, 1000);
-
-            switch (get_group0_keyval(&event->key)) {
-                // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets
-                // in the editing window). So we resteal them back and run our regular shortcut
-                // invoker on them.
-                unsigned int shortcut;
-                case GDK_Tab:
-                case GDK_ISO_Left_Tab:
-                case GDK_F1:
-                    shortcut = get_group0_keyval(&event->key);
-                    if (event->key.state & GDK_SHIFT_MASK)
-                        shortcut |= SP_SHORTCUT_SHIFT_MASK;
-                    if (event->key.state & GDK_CONTROL_MASK)
-                        shortcut |= SP_SHORTCUT_CONTROL_MASK;
-                    if (event->key.state & GDK_MOD1_MASK)
-                        shortcut |= SP_SHORTCUT_ALT_MASK;
-                    ret = sp_shortcut_invoke(shortcut, desktop);
-                    break;
+        } else if (zoom_rb) {
+            Geom::Point const motion_w(event->motion.x, event->motion.y);
+            Geom::Point const motion_dt(desktop->w2d(motion_w));
+
+            if (within_tolerance && (abs((gint) event->motion.x - xp)
+                    < tolerance) && (abs((gint) event->motion.y - yp)
+                    < tolerance)) {
+                break; // do not drag if we're within tolerance from origin
+            }
+            // Once the user has moved farther than tolerance from the original location
+            // (indicating they intend to move the object, not click), then always process the
+            // motion notify coordinates as given (no snapping back to origin)
+            within_tolerance = false;
 
-                case GDK_D:
-                case GDK_d:
-                    if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) {
-                        sp_toggle_dropper(desktop);
-                        ret = TRUE;
-                    }
-                    break;
-                case GDK_Q:
-                case GDK_q:
-                    if (desktop->quick_zoomed()) {
-                        ret = TRUE;
-                    }
-                    if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) {
-                        desktop->zoom_quick(true);
-                        ret = TRUE;
-                    }
-                    break;
-                case GDK_W:
-                case GDK_w:
-                case GDK_F4:
-                    /* Close view */
-                    if (MOD__CTRL_ONLY) {
-                        sp_ui_close_view(NULL);
-                        ret = TRUE;
-                    }
-                    break;
-                case GDK_Left: // Ctrl Left
-                case GDK_KP_Left:
-                case GDK_KP_4:
-                    if (MOD__CTRL_ONLY) {
-                        int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
-                        gobble_key_events(get_group0_keyval(&event->key),
-                                GDK_CONTROL_MASK);
-                        event_context->desktop->scroll_world(i, 0);
-                        ret = TRUE;
-                    }
-                    break;
-                case GDK_Up: // Ctrl Up
-                case GDK_KP_Up:
-                case GDK_KP_8:
-                    if (MOD__CTRL_ONLY) {
-                        int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
-                        gobble_key_events(get_group0_keyval(&event->key),
-                                GDK_CONTROL_MASK);
-                        event_context->desktop->scroll_world(0, i);
-                        ret = TRUE;
-                    }
-                    break;
-                case GDK_Right: // Ctrl Right
-                case GDK_KP_Right:
-                case GDK_KP_6:
-                    if (MOD__CTRL_ONLY) {
-                        int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
-                        gobble_key_events(get_group0_keyval(&event->key),
-                                GDK_CONTROL_MASK);
-                        event_context->desktop->scroll_world(-i, 0);
-                        ret = TRUE;
-                    }
-                    break;
-                case GDK_Down: // Ctrl Down
-                case GDK_KP_Down:
-                case GDK_KP_2:
-                    if (MOD__CTRL_ONLY) {
-                        int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
-                        gobble_key_events(get_group0_keyval(&event->key),
-                                GDK_CONTROL_MASK);
-                        event_context->desktop->scroll_world(0, -i);
-                        ret = TRUE;
-                    }
-                    break;
-                case GDK_F10:
-                    if (MOD__SHIFT_ONLY) {
-                        sp_event_root_menu_popup(desktop, NULL, event);
-                        ret= TRUE;
-                    }
-                    break;
-                case GDK_space:
-                    if (prefs->getBool("/options/spacepans/value")) {
-                        event_context->space_panning = true;
-                        event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE, _("<b>Space+mouse drag</b> to pan canvas"));
-                        ret= TRUE;
-                    } else {
-                        sp_toggle_selector(desktop);
-                        ret= TRUE;
-                    }
-                    break;
-                case GDK_z:
-                case GDK_Z:
-                    if (MOD__ALT_ONLY) {
-                        desktop->zoom_grab_focus();
-                        ret = TRUE;
-                    }
-                    break;
-                default:
-                    break;
+            if (Inkscape::Rubberband::get(desktop)->is_started()) {
+                Inkscape::Rubberband::get(desktop)->move(motion_dt);
+            } else {
+                Inkscape::Rubberband::get(desktop)->start(desktop, motion_dt);
             }
+            if (zoom_rb == 2)
+                gobble_motion_events(GDK_BUTTON2_MASK);
+        }
+        break;
+    case GDK_BUTTON_RELEASE:
+        xp = yp = 0;
+        if (within_tolerance && (panning || zoom_rb)) {
+            zoom_rb = 0;
+            if (panning) {
+                panning = 0;
+                sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
+                        event->button.time);
+            }
+            Geom::Point const event_w(event->button.x, event->button.y);
+            Geom::Point const event_dt(desktop->w2d(event_w));
+            double const zoom_inc = prefs->getDoubleLimited(
+                    "/options/zoomincrement/value", M_SQRT2, 1.01, 10);
+            desktop->zoom_relative_keep_point(event_dt, (event->button.state
+                    & GDK_SHIFT_MASK) ? 1 / zoom_inc : zoom_inc);
+            desktop->updateNow();
+            ret = TRUE;
+        } else if (panning == event->button.button) {
+            panning = 0;
+            sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
+                    event->button.time);
+
+            // in slow complex drawings, some of the motion events are lost;
+            // to make up for this, we scroll it once again to the button-up event coordinates
+            // (i.e. canvas will always get scrolled all the way to the mouse release point,
+            // even if few intermediate steps were visible)
+            Geom::Point const motion_w(event->button.x, event->button.y);
+            Geom::Point const moved_w(motion_w - button_w);
+            event_context->desktop->scroll_world(moved_w);
+            desktop->updateNow();
+            ret = TRUE;
+        } else if (zoom_rb == event->button.button) {
+            zoom_rb = 0;
+            Geom::OptRect const b =
+                    Inkscape::Rubberband::get(desktop)->getRectangle();
+            Inkscape::Rubberband::get(desktop)->stop();
+            if (b && !within_tolerance) {
+                desktop->set_display_area(*b, 10);
+            }
+            ret = TRUE;
+        }
+        break;
+    case GDK_KEY_PRESS: {
+        double const acceleration = prefs->getDoubleLimited(
+                "/options/scrollingacceleration/value", 0, 0, 6);
+        int const key_scroll = prefs->getIntLimited("/options/keyscroll/value",
+                10, 0, 1000);
+
+        switch (get_group0_keyval(&event->key)) {
+        // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets
+        // in the editing window). So we resteal them back and run our regular shortcut
+        // invoker on them.
+        unsigned int shortcut;
+    case GDK_Tab:
+    case GDK_ISO_Left_Tab:
+    case GDK_F1:
+        shortcut = get_group0_keyval(&event->key);
+        if (event->key.state & GDK_SHIFT_MASK)
+            shortcut |= SP_SHORTCUT_SHIFT_MASK;
+        if (event->key.state & GDK_CONTROL_MASK)
+            shortcut |= SP_SHORTCUT_CONTROL_MASK;
+        if (event->key.state & GDK_MOD1_MASK)
+            shortcut |= SP_SHORTCUT_ALT_MASK;
+        ret = sp_shortcut_invoke(shortcut, desktop);
+        break;
+
+    case GDK_D:
+    case GDK_d:
+        if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) {
+            sp_toggle_dropper(desktop);
+            ret = TRUE;
+        }
+        break;
+    case GDK_Q:
+    case GDK_q:
+        if (desktop->quick_zoomed()) {
+            ret = TRUE;
+        }
+        if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) {
+            desktop->zoom_quick(true);
+            ret = TRUE;
+        }
+        break;
+    case GDK_W:
+    case GDK_w:
+    case GDK_F4:
+        /* Close view */
+        if (MOD__CTRL_ONLY) {
+            sp_ui_close_view(NULL);
+            ret = TRUE;
+        }
+        break;
+    case GDK_Left: // Ctrl Left
+    case GDK_KP_Left:
+    case GDK_KP_4:
+        if (MOD__CTRL_ONLY) {
+            int i = (int) floor(key_scroll * accelerate_scroll(event,
+                    acceleration, sp_desktop_canvas(desktop)));
+            gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
+            event_context->desktop->scroll_world(i, 0);
+            ret = TRUE;
+        }
+        break;
+    case GDK_Up: // Ctrl Up
+    case GDK_KP_Up:
+    case GDK_KP_8:
+        if (MOD__CTRL_ONLY) {
+            int i = (int) floor(key_scroll * accelerate_scroll(event,
+                    acceleration, sp_desktop_canvas(desktop)));
+            gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
+            event_context->desktop->scroll_world(0, i);
+            ret = TRUE;
+        }
+        break;
+    case GDK_Right: // Ctrl Right
+    case GDK_KP_Right:
+    case GDK_KP_6:
+        if (MOD__CTRL_ONLY) {
+            int i = (int) floor(key_scroll * accelerate_scroll(event,
+                    acceleration, sp_desktop_canvas(desktop)));
+            gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
+            event_context->desktop->scroll_world(-i, 0);
+            ret = TRUE;
+        }
+        break;
+    case GDK_Down: // Ctrl Down
+    case GDK_KP_Down:
+    case GDK_KP_2:
+        if (MOD__CTRL_ONLY) {
+            int i = (int) floor(key_scroll * accelerate_scroll(event,
+                    acceleration, sp_desktop_canvas(desktop)));
+            gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
+            event_context->desktop->scroll_world(0, -i);
+            ret = TRUE;
+        }
+        break;
+    case GDK_F10:
+        if (MOD__SHIFT_ONLY) {
+            sp_event_root_menu_popup(desktop, NULL, event);
+            ret = TRUE;
+        }
+        break;
+    case GDK_space:
+        if (prefs->getBool("/options/spacepans/value")) {
+            event_context->space_panning = true;
+            event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE,
+                    _("<b>Space+mouse drag</b> to pan canvas"));
+            ret = TRUE;
+        } else {
+            sp_toggle_selector(desktop);
+            ret = TRUE;
+        }
+        break;
+    case GDK_z:
+    case GDK_Z:
+        if (MOD__ALT_ONLY) {
+            desktop->zoom_grab_focus();
+            ret = TRUE;
+        }
+        break;
+    default:
+        break;
+        }
+    }
+        break;
+    case GDK_KEY_RELEASE:
+        switch (get_group0_keyval(&event->key)) {
+        case GDK_space:
+            if (event_context->space_panning) {
+                event_context->space_panning = false;
+                event_context->_message_context->clear();
+                if (panning == 1) {
+                    panning = 0;
+                    sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
+                            event->key.time);
+                    desktop->updateNow();
+                }
+                ret = TRUE;
             }
             break;
-        case GDK_KEY_RELEASE:
-            switch (get_group0_keyval(&event->key)) {
-                case GDK_space:
-                    if (event_context->space_panning) {
-                        event_context->space_panning = false;
-                        event_context->_message_context->clear();
-                        if (panning == 1) {
-                            panning = 0;
-                            sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
-                                  event->key.time);
-                            desktop->updateNow();
-                        }
-                        ret= TRUE;
-                    }
-                    break;
-                case GDK_Q:
-                case GDK_q:
-                    if (desktop->quick_zoomed()) {
-                        desktop->zoom_quick(false);
-                        ret = TRUE;
-                    }
-                    break;
-                default:
-                    break;
+        case GDK_Q:
+        case GDK_q:
+            if (desktop->quick_zoomed()) {
+                desktop->zoom_quick(false);
+                ret = TRUE;
             }
             break;
-        case GDK_SCROLL:
-        {
-            bool ctrl = (event->scroll.state & GDK_CONTROL_MASK);
-            bool wheelzooms = prefs->getBool("/options/wheelzooms/value");
-            int const wheel_scroll = prefs->getIntLimited("/options/wheelscroll/value", 40, 0, 1000);
-
-            /* shift + wheel, pan left--right */
-            if (event->scroll.state & GDK_SHIFT_MASK) {
-                switch (event->scroll.direction) {
-                    case GDK_SCROLL_UP:
-                        desktop->scroll_world(wheel_scroll, 0);
-                        break;
-                    case GDK_SCROLL_DOWN:
-                        desktop->scroll_world(-wheel_scroll, 0);
-                        break;
-                    default:
-                        break;
-                }
+        default:
+            break;
+        }
+        break;
+    case GDK_SCROLL: {
+        bool ctrl = (event->scroll.state & GDK_CONTROL_MASK);
+        bool wheelzooms = prefs->getBool("/options/wheelzooms/value");
+        int const wheel_scroll = prefs->getIntLimited(
+                "/options/wheelscroll/value", 40, 0, 1000);
+
+        /* shift + wheel, pan left--right */
+        if (event->scroll.state & GDK_SHIFT_MASK) {
+            switch (event->scroll.direction) {
+            case GDK_SCROLL_UP:
+                desktop->scroll_world(wheel_scroll, 0);
+                break;
+            case GDK_SCROLL_DOWN:
+                desktop->scroll_world(-wheel_scroll, 0);
+                break;
+            default:
+                break;
+            }
 
-                /* ctrl + wheel, zoom in--out */
-            } else if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) {
-                double rel_zoom;
-                double const zoom_inc = prefs->getDoubleLimited("/options/zoomincrement/value", M_SQRT2, 1.01, 10);
-                switch (event->scroll.direction) {
-                    case GDK_SCROLL_UP:
-                        rel_zoom = zoom_inc;
-                        break;
-                    case GDK_SCROLL_DOWN:
-                        rel_zoom = 1 / zoom_inc;
-                        break;
-                    default:
-                        rel_zoom = 0.0;
-                        break;
-                }
-                if (rel_zoom != 0.0) {
-                    Geom::Point const scroll_dt = desktop->point();
-                    desktop->zoom_relative_keep_point(scroll_dt, rel_zoom);
-                }
+            /* ctrl + wheel, zoom in--out */
+        } else if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) {
+            double rel_zoom;
+            double const zoom_inc = prefs->getDoubleLimited(
+                    "/options/zoomincrement/value", M_SQRT2, 1.01, 10);
+            switch (event->scroll.direction) {
+            case GDK_SCROLL_UP:
+                rel_zoom = zoom_inc;
+                break;
+            case GDK_SCROLL_DOWN:
+                rel_zoom = 1 / zoom_inc;
+                break;
+            default:
+                rel_zoom = 0.0;
+                break;
+            }
+            if (rel_zoom != 0.0) {
+                Geom::Point const scroll_dt = desktop->point();
+                desktop->zoom_relative_keep_point(scroll_dt, rel_zoom);
+            }
 
-                /* no modifier, pan up--down (left--right on multiwheel mice?) */
-            } else {
-                switch (event->scroll.direction) {
-                    case GDK_SCROLL_UP:
-                        desktop->scroll_world(0, wheel_scroll);
-                        break;
-                    case GDK_SCROLL_DOWN:
-                        desktop->scroll_world(0, -wheel_scroll);
-                        break;
-                    case GDK_SCROLL_LEFT:
-                        desktop->scroll_world(wheel_scroll, 0);
-                        break;
-                    case GDK_SCROLL_RIGHT:
-                        desktop->scroll_world(-wheel_scroll, 0);
-                        break;
-                }
+            /* no modifier, pan up--down (left--right on multiwheel mice?) */
+        } else {
+            switch (event->scroll.direction) {
+            case GDK_SCROLL_UP:
+                desktop->scroll_world(0, wheel_scroll);
+                break;
+            case GDK_SCROLL_DOWN:
+                desktop->scroll_world(0, -wheel_scroll);
+                break;
+            case GDK_SCROLL_LEFT:
+                desktop->scroll_world(wheel_scroll, 0);
+                break;
+            case GDK_SCROLL_RIGHT:
+                desktop->scroll_world(-wheel_scroll, 0);
+                break;
             }
-            break;
         }
-        default:
-            break;
+        break;
+    }
+    default:
+        break;
     }
 
     return ret;
@@ -731,21 +724,20 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
  * Only reacts to right mouse button at the moment.
  * \todo Fixme: do context sensitive popup menu on items.
  */
-gint
-sp_event_context_private_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event)
-{
+gint sp_event_context_private_item_handler(SPEventContext *ec, SPItem *item,
+        GdkEvent *event) {
     int ret = FALSE;
 
     switch (event->type) {
-        case GDK_BUTTON_PRESS:
-            if ((event->button.button == 3)
-                    && !(event->button.state & GDK_SHIFT_MASK || event->button.state & GDK_CONTROL_MASK)) {
-                sp_event_root_menu_popup(ec->desktop, item, event);
-                ret = TRUE;
-            }
-            break;
-        default:
-            break;
+    case GDK_BUTTON_PRESS:
+        if ((event->button.button == 3) && !(event->button.state
+                & GDK_SHIFT_MASK || event->button.state & GDK_CONTROL_MASK)) {
+            sp_event_root_menu_popup(ec->desktop, item, event);
+            ret = TRUE;
+        }
+        break;
+    default:
+        break;
     }
 
     return ret;
@@ -754,16 +746,15 @@ sp_event_context_private_item_handler(SPEventContext *ec, SPItem *item, GdkEvent
 /**
  * @brief An observer that relays pref changes to the derived classes
  */
-class ToolPrefObserver : public Inkscape::Preferences::Observer {
+class ToolPrefObserver: public Inkscape::Preferences::Observer {
 public:
     ToolPrefObserver(Glib::ustring const &path, SPEventContext *ec) :
-        Inkscape::Preferences::Observer(path),
-        _ec(ec) {}
-    virtual void notify(Inkscape::Preferences::Entry const &val)
-    {
+        Inkscape::Preferences::Observer(path), _ec(ec) {
+    }
+    virtual void notify(Inkscape::Preferences::Entry const &val) {
         if (((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set) {
             ((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set(_ec,
-                const_cast<Inkscape::Preferences::Entry*>(&val));
+                    const_cast<Inkscape::Preferences::Entry*> (&val));
         }
     }
 private:
@@ -775,15 +766,16 @@ private:
  * @todo This is bogus. pref_path should be a private property of the inheriting objects.
  */
 SPEventContext *
-sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, unsigned int key)
-{
+sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path,
+        unsigned int key) {
     g_return_val_if_fail(g_type_is_a(type, SP_TYPE_EVENT_CONTEXT), NULL);
     g_return_val_if_fail(desktop != NULL, NULL);
 
-    SPEventContext *const ec = (SPEventContext*)g_object_new(type, NULL);
+    SPEventContext * const ec = (SPEventContext*) g_object_new(type, NULL);
 
     ec->desktop = desktop;
-    ec->_message_context = new Inkscape::MessageContext(desktop->messageStack());
+    ec->_message_context
+            = new Inkscape::MessageContext(desktop->messageStack());
     ec->key = key;
     ec->pref_observer = NULL;
 
@@ -803,9 +795,7 @@ sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, uns
 /**
  * Finishes SPEventContext.
  */
-void
-sp_event_context_finish(SPEventContext *ec)
-{
+void sp_event_context_finish(SPEventContext *ec) {
     g_return_if_fail(ec != NULL);
     g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
 
@@ -854,9 +844,7 @@ void SPEventContext::enableGrDrag(bool enable) {
 /**
  * Calls virtual set() function of SPEventContext.
  */
-void
-sp_event_context_read(SPEventContext *ec, gchar const *key)
-{
+void sp_event_context_read(SPEventContext *ec, gchar const *key) {
     g_return_if_fail(ec != NULL);
     g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
     g_return_if_fail(key != NULL);
@@ -864,7 +852,7 @@ sp_event_context_read(SPEventContext *ec, gchar const *key)
     if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set) {
         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
         Inkscape::Preferences::Entry val = prefs->getEntry(
-            ec->pref_observer->observed_path + '/' + key );
+                ec->pref_observer->observed_path + '/' + key);
         ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set(ec, &val);
     }
 }
@@ -872,9 +860,7 @@ sp_event_context_read(SPEventContext *ec, gchar const *key)
 /**
  * Calls virtual activate() function of SPEventContext.
  */
-void
-sp_event_context_activate(SPEventContext *ec)
-{
+void sp_event_context_activate(SPEventContext *ec) {
     g_return_if_fail(ec != NULL);
     g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
 
@@ -890,9 +876,7 @@ sp_event_context_activate(SPEventContext *ec)
 /**
  * Calls virtual deactivate() function of SPEventContext.
  */
-void
-sp_event_context_deactivate(SPEventContext *ec)
-{
+void sp_event_context_deactivate(SPEventContext *ec) {
     g_return_if_fail(ec != NULL);
     g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
 
@@ -903,37 +887,42 @@ sp_event_context_deactivate(SPEventContext *ec)
 /**
  * Calls virtual root_handler(), the main event handling function.
  */
-gint
-sp_event_context_root_handler(SPEventContext * event_context, GdkEvent * event)
-{
+gint sp_event_context_root_handler(SPEventContext * event_context,
+        GdkEvent * event) {
     switch (event->type) {
-        case GDK_MOTION_NOTIFY:
-            sp_event_context_snap_delay_handler(event_context, NULL, NULL, (GdkEventMotion *)event, DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER);
-            break;
-        case GDK_BUTTON_RELEASE:
-            if (event_context->_delayed_snap_event) {
-                // If we have any pending snapping action, then invoke it now
-                sp_event_context_snap_watchdog_callback(event_context->_delayed_snap_event);
-            }
-            break;
-        case GDK_BUTTON_PRESS:
-        case GDK_2BUTTON_PRESS:
-        case GDK_3BUTTON_PRESS:
-            // Snapping will be on hold if we're moving the mouse at high speeds. When starting
-            // drawing a new shape we really should snap though.
-            event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
-            break;
-        default:
-            break;
+    case GDK_MOTION_NOTIFY:
+        sp_event_context_snap_delay_handler(event_context, NULL, NULL,
+                (GdkEventMotion *) event,
+                DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER);
+        break;
+    case GDK_BUTTON_RELEASE:
+        if (event_context->_delayed_snap_event) {
+            // If we have any pending snapping action, then invoke it now
+            sp_event_context_snap_watchdog_callback(
+                    event_context->_delayed_snap_event);
+        }
+        break;
+    case GDK_BUTTON_PRESS:
+    case GDK_2BUTTON_PRESS:
+    case GDK_3BUTTON_PRESS:
+        // Snapping will be on hold if we're moving the mouse at high speeds. When starting
+        // drawing a new shape we really should snap though.
+        event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(
+                false);
+        break;
+    default:
+        break;
     }
 
     return sp_event_context_virtual_root_handler(event_context, event);
 }
 
-gint
-sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEvent * event)
-{
-    gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(event_context, event);
+gint sp_event_context_virtual_root_handler(SPEventContext * event_context,
+        GdkEvent * event) {
+    gint
+            ret =
+                    ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(
+                            event_context, event);
     set_event_location(event_context->desktop, event);
     return ret;
 }
@@ -941,40 +930,44 @@ sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEvent *
 /**
  * Calls virtual item_handler(), the item event handling function.
  */
-gint
-sp_event_context_item_handler(SPEventContext * event_context, SPItem * item, GdkEvent * event)
-{
+gint sp_event_context_item_handler(SPEventContext * event_context,
+        SPItem * item, GdkEvent * event) {
     switch (event->type) {
-        case GDK_MOTION_NOTIFY:
-            sp_event_context_snap_delay_handler(event_context, item, NULL, (GdkEventMotion *)event, DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER);
-            break;
-        case GDK_BUTTON_RELEASE:
-            if (event_context->_delayed_snap_event) {
-                // If we have any pending snapping action, then invoke it now
-                sp_event_context_snap_watchdog_callback(event_context->_delayed_snap_event);
-            }
-            break;
+    case GDK_MOTION_NOTIFY:
+        sp_event_context_snap_delay_handler(event_context, item, NULL,
+                (GdkEventMotion *) event,
+                DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER);
+        break;
+    case GDK_BUTTON_RELEASE:
+        if (event_context->_delayed_snap_event) {
+            // If we have any pending snapping action, then invoke it now
+            sp_event_context_snap_watchdog_callback(
+                    event_context->_delayed_snap_event);
+        }
+        break;
         /*case GDK_BUTTON_PRESS:
-        case GDK_2BUTTON_PRESS:
-        case GDK_3BUTTON_PRESS:
-            // Snapping will be on hold if we're moving the mouse at high speeds. When starting
-            // drawing a new shape we really should snap though.
-            event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
-            break;
-        */
-        default:
-            break;
+         case GDK_2BUTTON_PRESS:
+         case GDK_3BUTTON_PRESS:
+         // Snapping will be on hold if we're moving the mouse at high speeds. When starting
+         // drawing a new shape we really should snap though.
+         event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
+         break;
+         */
+    default:
+        break;
     }
 
     return sp_event_context_virtual_item_handler(event_context, item, event);
 }
 
-gint
-sp_event_context_virtual_item_handler(SPEventContext * event_context, SPItem * item, GdkEvent * event)
-{
-    gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(event_context, item, event);
+gint sp_event_context_virtual_item_handler(SPEventContext * event_context,
+        SPItem * item, GdkEvent * event) {
+    gint
+            ret =
+                    ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(
+                            event_context, item, event);
 
-    if (! ret) {
+    if (!ret) {
         ret = sp_event_context_virtual_root_handler(event_context, event);
     } else {
         set_event_location(event_context->desktop, event);
@@ -986,8 +979,7 @@ sp_event_context_virtual_item_handler(SPEventContext * event_context, SPItem * i
 /**
  * Emits 'position_set' signal on desktop and shows coordinates on status bar.
  */
-static void set_event_location(SPDesktop *desktop, GdkEvent *event)
-{
+static void set_event_location(SPDesktop *desktop, GdkEvent *event) {
     if (event->type != GDK_MOTION_NOTIFY) {
         return;
     }
@@ -1002,9 +994,7 @@ static void set_event_location(SPDesktop *desktop, GdkEvent *event)
 /**
  * Create popup menu and tell Gtk to show it.
  */
-void
-sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event)
-{
+void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event) {
     GtkWidget *menu;
 
     /* fixme: This is not what I want but works for now (Lauris) */
@@ -1015,45 +1005,36 @@ sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event)
     gtk_widget_show(menu);
 
     switch (event->type) {
-        case GDK_BUTTON_PRESS:
-            gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL, event->button.button, event->button.time);
-            break;
-        case GDK_KEY_PRESS:
-            gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL, 0, event->key.time);
-            break;
-        default:
-            break;
+    case GDK_BUTTON_PRESS:
+        gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL,
+                event->button.button, event->button.time);
+        break;
+    case GDK_KEY_PRESS:
+        gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL, 0, event->key.time);
+        break;
+    default:
+        break;
     }
 }
 
 /**
  * Show tool context specific modifier tip.
  */
-void
-sp_event_show_modifier_tip(Inkscape::MessageContext *message_context,
+void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context,
         GdkEvent *event, gchar const *ctrl_tip, gchar const *shift_tip,
-        gchar const *alt_tip)
-{
+        gchar const *alt_tip) {
     guint keyval = get_group0_keyval(&event->key);
 
-    bool ctrl = ctrl_tip && (MOD__CTRL
-            || (keyval == GDK_Control_L)
-            || (keyval == GDK_Control_R));
-    bool shift = shift_tip
-        && (MOD__SHIFT || (keyval == GDK_Shift_L) || (keyval == GDK_Shift_R));
-    bool alt = alt_tip
-        && (MOD__ALT
-                || (keyval == GDK_Alt_L)
-                || (keyval == GDK_Alt_R)
-                || (keyval == GDK_Meta_L)
-                || (keyval == GDK_Meta_R));
-
-    gchar *tip = g_strdup_printf("%s%s%s%s%s",
-                                 ( ctrl ? ctrl_tip : "" ),
-                                 ( ctrl && (shift || alt) ? "; " : "" ),
-                                 ( shift ? shift_tip : "" ),
-                                 ( (ctrl || shift) && alt ? "; " : "" ),
-                                 ( alt ? alt_tip : "" ));
+    bool ctrl = ctrl_tip && (MOD__CTRL || (keyval == GDK_Control_L) || (keyval
+            == GDK_Control_R));
+    bool shift = shift_tip && (MOD__SHIFT || (keyval == GDK_Shift_L) || (keyval
+            == GDK_Shift_R));
+    bool alt = alt_tip && (MOD__ALT || (keyval == GDK_Alt_L) || (keyval
+            == GDK_Alt_R) || (keyval == GDK_Meta_L) || (keyval == GDK_Meta_R));
+
+    gchar *tip = g_strdup_printf("%s%s%s%s%s", (ctrl ? ctrl_tip : ""), (ctrl
+            && (shift || alt) ? "; " : ""), (shift ? shift_tip : ""), ((ctrl
+            || shift) && alt ? "; " : ""), (alt ? alt_tip : ""));
 
     if (strlen(tip) > 0) {
         message_context->flash(Inkscape::INFORMATION_MESSAGE, tip);
@@ -1069,16 +1050,12 @@ sp_event_show_modifier_tip(Inkscape::MessageContext *message_context,
  * Use this instead of simply event->keyval, so that your keyboard shortcuts
  * work regardless of layouts (e.g., in Cyrillic).
  */
-guint
-get_group0_keyval(GdkEventKey *event)
-{
+guint get_group0_keyval(GdkEventKey *event) {
     guint keyval = 0;
-    gdk_keymap_translate_keyboard_state(
-            gdk_keymap_get_for_display(gdk_display_get_default()),
-            event->hardware_keycode,
-            (GdkModifierType) event->state,
-            0   /*event->key.group*/,
-            &keyval, NULL, NULL, NULL);
+    gdk_keymap_translate_keyboard_state(gdk_keymap_get_for_display(
+            gdk_display_get_default()), event->hardware_keycode,
+            (GdkModifierType) event->state, 0 /*event->key.group*/, &keyval,
+            NULL, NULL, NULL);
     return keyval;
 }
 
@@ -1089,14 +1066,13 @@ get_group0_keyval(GdkEventKey *event)
  * into_groups.
  */
 SPItem *
-sp_event_context_find_item (SPDesktop *desktop, Geom::Point const &p,
-        bool select_under, bool into_groups)
-{
+sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p,
+        bool select_under, bool into_groups) {
     SPItem *item;
 
     if (select_under) {
-        SPItem *selected_at_point =
-            desktop->item_from_list_at_point_bottom (desktop->selection->itemList(), p);
+        SPItem *selected_at_point = desktop->item_from_list_at_point_bottom(
+                desktop->selection->itemList(), p);
         item = desktop->item_at_point(p, into_groups, selected_at_point);
         if (item == NULL) { // we may have reached bottom, flip over to the top
             item = desktop->item_at_point(p, into_groups, NULL);
@@ -1113,97 +1089,98 @@ sp_event_context_find_item (SPDesktop *desktop, Geom::Point const &p,
  * Honors into_groups.
  */
 SPItem *
-sp_event_context_over_item (SPDesktop *desktop, SPItem *item, Geom::Point const &p)
-{
+sp_event_context_over_item(SPDesktop *desktop, SPItem *item,
+        Geom::Point const &p) {
     GSList *temp = NULL;
-    temp = g_slist_prepend (temp, item);
-    SPItem *item_at_point = desktop->item_from_list_at_point_bottom (temp, p);
-    g_slist_free (temp);
+    temp = g_slist_prepend(temp, item);
+    SPItem *item_at_point = desktop->item_from_list_at_point_bottom(temp, p);
+    g_slist_free(temp);
 
     return item_at_point;
 }
 
 ShapeEditor *
-sp_event_context_get_shape_editor (SPEventContext *ec)
-{
+sp_event_context_get_shape_editor(SPEventContext *ec) {
     return ec->shape_editor;
 }
 
-void
-event_context_print_event_info(GdkEvent *event, bool print_return) {
+void event_context_print_event_info(GdkEvent *event, bool print_return) {
     switch (event->type) {
-        case GDK_BUTTON_PRESS:
-            g_print ("GDK_BUTTON_PRESS");
-            break;
-        case GDK_2BUTTON_PRESS:
-            g_print ("GDK_2BUTTON_PRESS");
-            break;
-        case GDK_3BUTTON_PRESS:
-            g_print ("GDK_3BUTTON_PRESS");
-            break;
-
-        case GDK_MOTION_NOTIFY:
-            g_print ("GDK_MOTION_NOTIFY");
-            break;
-        case GDK_ENTER_NOTIFY:
-            g_print ("GDK_ENTER_NOTIFY");
-            break;
-
-        case GDK_LEAVE_NOTIFY:
-            g_print ("GDK_LEAVE_NOTIFY");
-            break;
-        case GDK_BUTTON_RELEASE:
-            g_print ("GDK_BUTTON_RELEASE");
-            break;
-
-        case GDK_KEY_PRESS:
-            g_print ("GDK_KEY_PRESS: %d", get_group0_keyval(&event->key));
-            break;
-        case GDK_KEY_RELEASE:
-            g_print ("GDK_KEY_RELEASE: %d", get_group0_keyval(&event->key));
-            break;
-        default:
-            //g_print ("even type not recognized");
-            break;
+    case GDK_BUTTON_PRESS:
+        g_print("GDK_BUTTON_PRESS");
+        break;
+    case GDK_2BUTTON_PRESS:
+        g_print("GDK_2BUTTON_PRESS");
+        break;
+    case GDK_3BUTTON_PRESS:
+        g_print("GDK_3BUTTON_PRESS");
+        break;
+
+    case GDK_MOTION_NOTIFY:
+        g_print("GDK_MOTION_NOTIFY");
+        break;
+    case GDK_ENTER_NOTIFY:
+        g_print("GDK_ENTER_NOTIFY");
+        break;
+
+    case GDK_LEAVE_NOTIFY:
+        g_print("GDK_LEAVE_NOTIFY");
+        break;
+    case GDK_BUTTON_RELEASE:
+        g_print("GDK_BUTTON_RELEASE");
+        break;
+
+    case GDK_KEY_PRESS:
+        g_print("GDK_KEY_PRESS: %d", get_group0_keyval(&event->key));
+        break;
+    case GDK_KEY_RELEASE:
+        g_print("GDK_KEY_RELEASE: %d", get_group0_keyval(&event->key));
+        break;
+    default:
+        //g_print ("even type not recognized");
+        break;
     }
 
     if (print_return) {
-        g_print ("\n");
+        g_print("\n");
     }
 }
 
-void sp_event_context_snap_delay_handler(SPEventContext *ec, SPItem* const item, SPKnot* const knot, GdkEventMotion *event, DelayedSnapEvent::DelayedSnapEventOrigin origin)
-{
+void sp_event_context_snap_delay_handler(SPEventContext *ec,
+        SPItem* const item, SPKnot* const knot, GdkEventMotion *event,
+        DelayedSnapEvent::DelayedSnapEventOrigin origin) {
     static guint32 prev_time;
     static boost::optional<Geom::Point> prev_pos;
 
     // Snapping occurs when dragging with the left mouse button down, or when hovering e.g. in the pen tool with left mouse button up
     bool const c1 = event->state & GDK_BUTTON2_MASK; // We shouldn't hold back any events when other mouse buttons have been
     bool const c2 = event->state & GDK_BUTTON3_MASK; // pressed, e.g. when scrolling with the middle mouse button; if we do then
-                                                     // Inkscape will get stuck in an unresponsive state
+    // Inkscape will get stuck in an unresponsive state
     bool const c3 = tools_isactive(ec->desktop, TOOLS_CALLIGRAPHIC);
-                                                     // The snap delay will repeat the last motion event, which will lead to
-                                                     // erroneous points in the calligraphy context. And because we don't snap
-                                                     // in this context, we might just as well disable the snap delay all together
+    // The snap delay will repeat the last motion event, which will lead to
+    // erroneous points in the calligraphy context. And because we don't snap
+    // in this context, we might just as well disable the snap delay all together
+
     if (c1 || c2 || c3) {
         // Make sure that we don't send any pending snap events to a context if we know in advance
         // that we're not going to snap any way (e.g. while scrolling with middle mouse button)
         // Any motion event might affect the state of the context, leading to unexpected behavior
         sp_event_context_discard_delayed_snap_event(ec);
-    } else if (ec->desktop && ec->desktop->namedview->snap_manager.snapprefs.getSnapEnabledGlobally()) {
+    } else if (ec->desktop
+            && ec->desktop->namedview->snap_manager.snapprefs.getSnapEnabledGlobally()) {
         // Snap when speed drops below e.g. 0.02 px/msec, or when no motion events have occurred for some period.
         // i.e. snap when we're at stand still. A speed threshold enforces snapping for tablets, which might never
         // be fully at stand still and might keep spitting out motion events.
-        ec->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(true); // put snapping on hold
+        ec->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(
+                true); // put snapping on hold
 
         Geom::Point event_pos(event->x, event->y);
-        guint32 event_t = gdk_event_get_time ( (GdkEvent *) event );
+        guint32 event_t = gdk_event_get_time((GdkEvent *) event);
 
         if (prev_pos) {
             Geom::Coord dist = Geom::L2(event_pos - *prev_pos);
             guint32 delta_t = event_t - prev_time;
-            gdouble speed = delta_t > 0 ? dist/delta_t : 1000;
+            gdouble speed = delta_t > 0 ? dist / delta_t : 1000;
             //std::cout << "Mouse speed = " << speed << " px/msec " << std::endl;
             if (speed > 0.02) { // Jitter threshold, might be needed for tablets
                 // We're moving fast, so postpone any snapping until the next GDK_MOTION_NOTIFY event. We
@@ -1212,7 +1189,8 @@ void sp_event_context_snap_delay_handler(SPEventContext *ec, SPItem* const item,
                 // now, just in case there's no future motion event that drops under the speed limit (when
                 // stopping abruptly)
                 delete ec->_delayed_snap_event;
-                ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin); // watchdog is reset, i.e. pushed forward in time
+                ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot,
+                        event, origin); // watchdog is reset, i.e. pushed forward in time
                 // If the watchdog expires before a new motion event is received, we will snap (as explained
                 // above). This means however that when the timer is too short, we will always snap and that the
                 // speed threshold is ineffective. In the extreme case the delay is set to zero, and snapping will
@@ -1223,13 +1201,15 @@ void sp_event_context_snap_delay_handler(SPEventContext *ec, SPItem* const item,
                 // snap, and set a new watchdog again.
                 if (ec->_delayed_snap_event == NULL) { // no watchdog has been set
                     // it might have already expired, so we'll set a new one; the snapping frequency will be limited this way
-                    ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin);
+                    ec->_delayed_snap_event = new DelayedSnapEvent(ec, item,
+                            knot, event, origin);
                 } // else: watchdog has been set before and we'll wait for it to expire
             }
         } else {
             // This is the first GDK_MOTION_NOTIFY event, so postpone snapping and set the watchdog
             g_assert(ec->_delayed_snap_event == NULL);
-            ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin);
+            ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot,
+                    event, origin);
         }
 
         prev_pos = event_pos;
@@ -1237,10 +1217,9 @@ void sp_event_context_snap_delay_handler(SPEventContext *ec, SPItem* const item,
     }
 }
 
-gboolean sp_event_context_snap_watchdog_callback(gpointer data)
-{
+gboolean sp_event_context_snap_watchdog_callback(gpointer data) {
     // Snap NOW! For this the "postponed" flag will be reset and the last motion event will be repeated
-    DelayedSnapEvent *dse = reinterpret_cast<DelayedSnapEvent*>(data);
+    DelayedSnapEvent *dse = reinterpret_cast<DelayedSnapEvent*> (data);
 
     if (dse == NULL) {
         // This might occur when this method is called directly, i.e. not through the timer
@@ -1257,36 +1236,33 @@ gboolean sp_event_context_snap_watchdog_callback(gpointer data)
     dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
 
     switch (dse->getOrigin()) {
-        case DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER:
-            sp_event_context_virtual_root_handler(ec, dse->getEvent());
-            break;
-        case DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER:
-            {
-                SPItem* item = NULL;
-                item = dse->getItem();
-                if (item && SP_IS_ITEM(item)) {
-                    sp_event_context_virtual_item_handler(ec, item, dse->getEvent());
-                }
-            }
-            break;
-        case DelayedSnapEvent::KNOT_HANDLER:
-            {
-                SPKnot* knot = dse->getKnot();
-                if (knot && SP_IS_KNOT(knot)) {
-                    sp_knot_handler_request_position(dse->getEvent(), knot);
-                }
-            }
-            break;
-        case DelayedSnapEvent::CONTROL_POINT_HANDLER:
-            {
-                using Inkscape::UI::ControlPoint;
-                ControlPoint *point = reinterpret_cast<ControlPoint*>(dse->getKnot());
-                point->_eventHandler(dse->getEvent());
-            }
-            break;
-        default:
-            g_warning("Origin of snap-delay event has not been defined!;");
-            break;
+    case DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER:
+        sp_event_context_virtual_root_handler(ec, dse->getEvent());
+        break;
+    case DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER: {
+        SPItem* item = NULL;
+        item = dse->getItem();
+        if (item && SP_IS_ITEM(item)) {
+            sp_event_context_virtual_item_handler(ec, item, dse->getEvent());
+        }
+    }
+        break;
+    case DelayedSnapEvent::KNOT_HANDLER: {
+        SPKnot* knot = dse->getKnot();
+        if (knot && SP_IS_KNOT(knot)) {
+            sp_knot_handler_request_position(dse->getEvent(), knot);
+        }
+    }
+        break;
+    case DelayedSnapEvent::CONTROL_POINT_HANDLER: {
+        using Inkscape::UI::ControlPoint;
+        ControlPoint *point = reinterpret_cast<ControlPoint*> (dse->getKnot());
+        point->_eventHandler(dse->getEvent());
+    }
+        break;
+    default:
+        g_warning("Origin of snap-delay event has not been defined!;");
+        break;
     }
 
     ec->_delayed_snap_event = NULL;
@@ -1295,21 +1271,18 @@ gboolean sp_event_context_snap_watchdog_callback(gpointer data)
     return FALSE; //Kills the timer and stops it from executing this callback over and over again.
 }
 
-void sp_event_context_discard_delayed_snap_event(SPEventContext *ec)
-{
+void sp_event_context_discard_delayed_snap_event(SPEventContext *ec) {
     delete ec->_delayed_snap_event;
     ec->_delayed_snap_event = NULL;
 }
 
-
-
 /*
 Local Variables:
 mode:c++
 c-file-style:"stroustrup"
 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 indent-tabs-mode:nil
 fill-column:99
 End:
-*/
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+ */
 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
index 5be2e19fb4a2163eafb87c51ff51ff66bd85f086..97abee0d5a24a1d4298aed411e87543b7799c5ba 100644 (file)
@@ -45,42 +45,42 @@ void sp_event_context_discard_delayed_snap_event(SPEventContext *ec);
 class DelayedSnapEvent
 {
 public:
-       enum DelayedSnapEventOrigin {
-               UNDEFINED_HANDLER = 0,
-               EVENTCONTEXT_ROOT_HANDLER,
-               EVENTCONTEXT_ITEM_HANDLER,
-               KNOT_HANDLER,
-               CONTROL_POINT_HANDLER
-       };
-
-       DelayedSnapEvent(SPEventContext *event_context, SPItem* const item, SPKnot* knot, GdkEventMotion const *event, DelayedSnapEvent::DelayedSnapEventOrigin const origin)
-       : _timer_id(0), _event(NULL), _item(item), _knot(knot), _origin(origin), _event_context(event_context)
-       {
-               Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-               double value = prefs->getDoubleLimited("/options/snapdelay/value", 0, 0, 1000);
-               _timer_id = g_timeout_add(value, &sp_event_context_snap_watchdog_callback, this);
-               _event = gdk_event_copy((GdkEvent*) event);
-               ((GdkEventMotion *)_event)->time = GDK_CURRENT_TIME;
-       }
-
-       ~DelayedSnapEvent()     {
-               if (_timer_id > 0) g_source_remove(_timer_id); // Kill the watchdog
-               if (_event != NULL) gdk_event_free(_event); // Remove the copy of the original event
-       }
-
-       SPEventContext* getEventContext() {return _event_context;}
-       DelayedSnapEventOrigin getOrigin() {return _origin;}
-       GdkEvent* getEvent() {return _event;}
-       SPItem* getItem() {return _item;}
-       SPKnot* getKnot() {return _knot;}
+    enum DelayedSnapEventOrigin {
+        UNDEFINED_HANDLER = 0,
+        EVENTCONTEXT_ROOT_HANDLER,
+        EVENTCONTEXT_ITEM_HANDLER,
+        KNOT_HANDLER,
+        CONTROL_POINT_HANDLER
+    };
+
+    DelayedSnapEvent(SPEventContext *event_context, SPItem* const item, SPKnot* knot, GdkEventMotion const *event, DelayedSnapEvent::DelayedSnapEventOrigin const origin)
+    : _timer_id(0), _event(NULL), _item(item), _knot(knot), _origin(origin), _event_context(event_context)
+    {
+        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+        double value = prefs->getDoubleLimited("/options/snapdelay/value", 0, 0, 1000);
+        _timer_id = g_timeout_add(value, &sp_event_context_snap_watchdog_callback, this);
+        _event = gdk_event_copy((GdkEvent*) event);
+        ((GdkEventMotion *)_event)->time = GDK_CURRENT_TIME;
+    }
+
+    ~DelayedSnapEvent()    {
+        if (_timer_id > 0) g_source_remove(_timer_id); // Kill the watchdog
+        if (_event != NULL) gdk_event_free(_event); // Remove the copy of the original event
+    }
+
+    SPEventContext* getEventContext() {return _event_context;}
+    DelayedSnapEventOrigin getOrigin() {return _origin;}
+    GdkEvent* getEvent() {return _event;}
+    SPItem* getItem() {return _item;}
+    SPKnot* getKnot() {return _knot;}
 
 private:
-       guint _timer_id;
-       GdkEvent* _event;
-       SPItem* _item;
-       SPKnot* _knot;
-       DelayedSnapEventOrigin _origin;
-       SPEventContext* _event_context;
+    guint _timer_id;
+    GdkEvent* _event;
+    SPItem* _item;
+    SPKnot* _knot;
+    DelayedSnapEventOrigin _origin;
+    SPEventContext* _event_context;
 };
 
 void sp_event_context_snap_delay_handler(SPEventContext *ec, SPItem* const item, SPKnot* const knot, GdkEventMotion *event, DelayedSnapEvent::DelayedSnapEventOrigin origin);
index fc5c1af446593c0db42626003aab45e8d9ec11bc..a1fcf582b8c3f46ab6b814c3cbc760c8f20eb086 100644 (file)
@@ -558,7 +558,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
 
                 SnapManager &m = desktop->namedview->snap_manager;
                 m.setup(desktop);
-                m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, button_dt, Inkscape::SNAPSOURCE_HANDLE);
+                m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
                 rc->origin = from_2geom(button_dt);
             }
 
index 726f4d78add1f7fdd6e655a9db05bf49d081bcd2..5facfefd0d13c0f442a18d82ff630fd17ce1d7aa 100644 (file)
@@ -542,8 +542,8 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp
     Geom::Point p = ppointer;
 
     SPDesktop *desktop = dragger->parent->desktop;
-       SnapManager &m = desktop->namedview->snap_manager;
-       double snap_dist = m.snapprefs.getObjectTolerance() / dragger->parent->desktop->current_zoom();
+    SnapManager &m = desktop->namedview->snap_manager;
+    double snap_dist = m.snapprefs.getObjectTolerance() / dragger->parent->desktop->current_zoom();
 
     if (state & GDK_SHIFT_MASK) {
         // with Shift; unsnap if we carry more than one draggable
@@ -596,7 +596,7 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp
 
     m.setup(desktop);
     if (!((state & GDK_SHIFT_MASK) || (state & GDK_CONTROL_MASK))) {
-        Inkscape::SnappedPoint s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_OTHER, Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_HANDLE));
+        Inkscape::SnappedPoint s = m.freeSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE));
         if (s.getSnapped()) {
             p = s.getPoint();
             sp_knot_moveto (knot, p);
@@ -659,12 +659,12 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp
                 }
                 if (snap_vector) {
                     Inkscape::Snapper::ConstraintLine cl(dr_snap, p + *snap_vector - dr_snap);
-                    Inkscape::SnappedPoint s = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_OTHER, Inkscape::SnapCandidatePoint(p + *snap_vector, Inkscape::SNAPSOURCE_HANDLE), cl);
+                    Inkscape::SnappedPoint s = m.constrainedSnap(Inkscape::SnapCandidatePoint(p + *snap_vector, Inkscape::SNAPSOURCE_OTHER_HANDLE), cl);
                     if (s.getSnapped()) {
                         s.setTransformation(s.getPoint() - p);
                         sc.points.push_back(s);
                     } else {
-                        Inkscape::SnappedPoint dummy(p + *snap_vector, Inkscape::SNAPSOURCE_HANDLE, 0, Inkscape::SNAPTARGET_CONSTRAINED_ANGLE, Geom::L2(*snap_vector), 10000, true, false);
+                        Inkscape::SnappedPoint dummy(p + *snap_vector, Inkscape::SNAPSOURCE_OTHER_HANDLE, 0, Inkscape::SNAPTARGET_CONSTRAINED_ANGLE, Geom::L2(*snap_vector), 10000, true, false);
                         dummy.setTransformation(*snap_vector);
                         sc.points.push_back(dummy);
                     }
@@ -672,7 +672,7 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp
             }
         }
 
-        Inkscape::SnappedPoint bsp = m.findBestSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_HANDLE), sc, true); // snap indicator will be displayed if needed
+        Inkscape::SnappedPoint bsp = m.findBestSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE), sc, true); // snap indicator will be displayed if needed
 
         if (bsp.getSnapped()) {
             p += bsp.getTransformation();
@@ -897,45 +897,45 @@ gr_knot_clicked_handler(SPKnot */*knot*/, guint state, gpointer data)
 
     if ( (state & GDK_CONTROL_MASK) && (state & GDK_MOD1_MASK ) ) {
     // delete this knot from vector
-       SPGradient *gradient = sp_item_gradient (draggable->item, draggable->fill_or_stroke);
+        SPGradient *gradient = sp_item_gradient (draggable->item, draggable->fill_or_stroke);
         gradient = sp_gradient_get_vector (gradient, false);
-       if (gradient->vector.stops.size() > 2) { // 2 is the minimum
-               SPStop *stop = NULL;
-               switch (draggable->point_type) {  // if we delete first or last stop, move the next/previous to the edge
-               case POINT_LG_BEGIN:
-               case POINT_RG_CENTER:
-                   stop = sp_first_stop(gradient);
-                       {
-                           SPStop *next = sp_next_stop (stop);
-                               if (next) {
-                                       next->offset = 0;
-                                       sp_repr_set_css_double (SP_OBJECT_REPR (next), "offset", 0);
-                               }
-                       }
-                   break;
-               case POINT_LG_END:
-               case POINT_RG_R1:
-               case POINT_RG_R2:
-                   stop = sp_last_stop(gradient);
-                   {
-                           SPStop *prev = sp_prev_stop (stop, gradient);
-                           if (prev) {
-                                   prev->offset = 1;
-                                   sp_repr_set_css_double (SP_OBJECT_REPR (prev), "offset", 1);
-                           }
-                       }
-                   break;
-               case POINT_LG_MID:
-               case POINT_RG_MID1:
-               case POINT_RG_MID2:
-                   stop = sp_get_stop_i(gradient, draggable->point_i);
-                   break;
-               }
-
-               SP_OBJECT_REPR(gradient)->removeChild(SP_OBJECT_REPR(stop));
-               sp_document_done (SP_OBJECT_DOCUMENT (gradient), SP_VERB_CONTEXT_GRADIENT,
-                                 _("Delete gradient stop"));
-       }
+        if (gradient->vector.stops.size() > 2) { // 2 is the minimum
+            SPStop *stop = NULL;
+            switch (draggable->point_type) {  // if we delete first or last stop, move the next/previous to the edge
+            case POINT_LG_BEGIN:
+            case POINT_RG_CENTER:
+                stop = sp_first_stop(gradient);
+                {
+                    SPStop *next = sp_next_stop (stop);
+                    if (next) {
+                        next->offset = 0;
+                        sp_repr_set_css_double (SP_OBJECT_REPR (next), "offset", 0);
+                    }
+                }
+                break;
+            case POINT_LG_END:
+            case POINT_RG_R1:
+            case POINT_RG_R2:
+                stop = sp_last_stop(gradient);
+                {
+                    SPStop *prev = sp_prev_stop (stop, gradient);
+                    if (prev) {
+                        prev->offset = 1;
+                        sp_repr_set_css_double (SP_OBJECT_REPR (prev), "offset", 1);
+                    }
+                }
+                break;
+            case POINT_LG_MID:
+            case POINT_RG_MID1:
+            case POINT_RG_MID2:
+                stop = sp_get_stop_i(gradient, draggable->point_i);
+                break;
+            }
+
+            SP_OBJECT_REPR(gradient)->removeChild(SP_OBJECT_REPR(stop));
+            sp_document_done (SP_OBJECT_DOCUMENT (gradient), SP_VERB_CONTEXT_GRADIENT,
+                      _("Delete gradient stop"));
+        }
     } else {
     // select the dragger
         dragger->point_original = dragger->point;
@@ -1086,10 +1086,10 @@ Updates the statusbar tip of the dragger knot, based on its draggables
 void
 GrDragger::updateTip ()
 {
-       if (this->knot && this->knot->tip) {
-               g_free (this->knot->tip);
-               this->knot->tip = NULL;
-       }
+    if (this->knot && this->knot->tip) {
+        g_free (this->knot->tip);
+        this->knot->tip = NULL;
+    }
 
     if (g_slist_length (this->draggables) == 1) {
         GrDraggable *draggable = (GrDraggable *) this->draggables->data;
index bf7505f3c0afc64c6003f62d30bbf83906929107..2d0d5eb029f65b9ca1b1e1fc84031c0e277023a1 100644 (file)
@@ -95,7 +95,7 @@ KnotHolderEntity::snap_knot_position(Geom::Point const &p)
     SnapManager &m = desktop->namedview->snap_manager;
     m.setup(desktop, true, item);
 
-    m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, s, Inkscape::SNAPSOURCE_HANDLE);
+    m.freeSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE);
 
     return s * i2d.inverse();
 }
@@ -119,12 +119,12 @@ KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape:
 
         // freeSnap() will try snapping point p. This will not take into account the constraint, which
         // is therefore to be enforced after snap_knot_position_constrained() has finished
-        m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, s, Inkscape::SNAPSOURCE_HANDLE);
+        m.freeSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE);
     } else {
         // constrainedSnap() will first project the point p onto the constraint line and then try to snap along that line.
         // This way the constraint is already enforced, no need to worry about that later on
         Inkscape::Snapper::ConstraintLine transformed_constraint = Inkscape::Snapper::ConstraintLine(constraint.getPoint() * i2d, (constraint.getPoint() + constraint.getDirection()) * i2d - constraint.getPoint() * i2d);
-        m.constrainedSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, s, Inkscape::SNAPSOURCE_HANDLE, transformed_constraint);
+        m.constrainedSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE, transformed_constraint);
     }
 
     return s * i2d.inverse();
index 696f92405b3f9d40d0e49820c18cac6a44949abf..f2f02533246a8d6b90a20fb73db4694db4ffc678 100644 (file)
@@ -22,13 +22,12 @@ Inkscape::LineSnapper::LineSnapper(SnapManager *sm, Geom::Coord const d) : Snapp
 }
 
 void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc,
-                                                    Inkscape::SnapPreferences::PointType const &t,
                                                     Inkscape::SnapCandidatePoint const &p,
                                                     Geom::OptRect const &/*bbox_to_snap*/,
                                                     std::vector<SPItem const *> const */*it*/,
                                                     std::vector<Inkscape::SnapCandidatePoint> */*unselected_nodes*/) const
 {
-    if (!(_snap_enabled && _snapmanager->snapprefs.getSnapFrom(t)) ) {
+    if (!(_snap_enabled && _snapmanager->snapprefs.getSnapFrom(p.getSourceType())) ) {
         return;
     }
 
@@ -62,14 +61,13 @@ void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc,
 }
 
 void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
-                                               Inkscape::SnapPreferences::PointType const &t,
                                                Inkscape::SnapCandidatePoint const &p,
                                                Geom::OptRect const &/*bbox_to_snap*/,
                                                ConstraintLine const &c,
                                                std::vector<SPItem const *> const */*it*/) const
 
 {
-    if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(t) == false) {
+    if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false) {
         return;
     }
 
index 5845e081efd915d7c784743e20c96ea3c4d0976f..429139421dbaa9d2876f3d06fd87aa0beccc919f 100644 (file)
@@ -26,14 +26,12 @@ public:
   LineSnapper(SnapManager *sm, Geom::Coord const d);
 
   void freeSnap(SnappedConstraints &sc,
-                   Inkscape::SnapPreferences::PointType const &t,
                    Inkscape::SnapCandidatePoint const &p,
                    Geom::OptRect const &bbox_to_snap,
                    std::vector<SPItem const *> const *it,
                    std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes) const;
 
   void constrainedSnap(SnappedConstraints &sc,
-                          Inkscape::SnapPreferences::PointType const &t,
                           Inkscape::SnapCandidatePoint const &p,
                           Geom::OptRect const &bbox_to_snap,
                           ConstraintLine const &c,
index 47d4196292753e091eb6f96ac7ee12eebdfa3e7f..671cb66a458871b791f61531ac15791631b9b480 100644 (file)
@@ -162,7 +162,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
 }
 
 
-void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapPreferences::PointType const &t,
+void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t,
                                             bool const &first_point) const
 {
     // Now, let's first collect all points to snap to. If we have a whole bunch of points to snap,
@@ -174,9 +174,9 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapPreferences::PointType
          // Determine the type of bounding box we should snap to
         SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX;
 
-        bool p_is_a_node = t & Inkscape::SnapPreferences::SNAPPOINT_NODE;
-        bool p_is_a_bbox = t & Inkscape::SnapPreferences::SNAPPOINT_BBOX;
-        bool p_is_other = t & Inkscape::SnapPreferences::SNAPPOINT_OTHER;
+        bool p_is_a_node = t & Inkscape::SNAPSOURCE_NODE_CATEGORY;
+        bool p_is_a_bbox = t & Inkscape::SNAPSOURCE_BBOX_CATEGORY;
+        bool p_is_other = t & Inkscape::SNAPSOURCE_OTHER_CATEGORY;
 
         // A point considered for snapping should be either a node, a bbox corner or a guide. Pick only ONE!
         g_assert(!((p_is_a_node && p_is_a_bbox) || (p_is_a_bbox && p_is_other) || (p_is_a_node && p_is_other)));
@@ -248,13 +248,12 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapPreferences::PointType
 }
 
 void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc,
-                                         Inkscape::SnapPreferences::PointType const &t,
                                          Inkscape::SnapCandidatePoint const &p,
                                          std::vector<SnapCandidatePoint> *unselected_nodes) const
 {
     // Iterate through all nodes, find out which one is the closest to p, and snap to it!
 
-    _collectNodes(t, p.getSourceNum() == 0);
+    _collectNodes(p.getSourceType(), p.getSourceNum() == 0);
 
     if (unselected_nodes != NULL) {
         _points_to_snap_to->insert(_points_to_snap_to->end(), unselected_nodes->begin(), unselected_nodes->end());
@@ -277,17 +276,16 @@ void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc,
 }
 
 void Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(SnappedConstraints &sc,
-                                         Inkscape::SnapPreferences::PointType const &t,
                                          Geom::Point const &p,
                                          Geom::Point const &guide_normal) const
 {
     // Iterate through all nodes, find out which one is the closest to this guide, and snap to it!
-    _collectNodes(t, true);
+    _collectNodes(SNAPSOURCE_GUIDE, true);
 
     // Although we won't snap to paths here (which would give us under constrained snaps) we can still snap to intersections of paths.
     if (_snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToPageBorder()) {
-        _collectPaths(t, true);
-        _snapPaths(sc, t, Inkscape::SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL);
+        _collectPaths(Inkscape::SnapCandidatePoint(p, SNAPSOURCE_GUIDE), true);
+        _snapPaths(sc, Inkscape::SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL);
         // The paths themselves should be discarded in findBestSnap(), as we should only snap to their intersections
     }
 
@@ -312,7 +310,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(SnappedConstraints &s
  * Returns index of first NR_END bpath in array.
  */
 
-void Inkscape::ObjectSnapper::_collectPaths(Inkscape::SnapPreferences::PointType const &t,
+void Inkscape::ObjectSnapper::_collectPaths(Inkscape::SnapCandidatePoint const &p,
                                          bool const &first_point) const
 {
     // Now, let's first collect all paths to snap to. If we have a whole bunch of points to snap,
@@ -324,8 +322,8 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::SnapPreferences::PointType
         // Determine the type of bounding box we should snap to
         SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX;
 
-        bool p_is_a_node = t & Inkscape::SnapPreferences::SNAPPOINT_NODE;
-        bool p_is_other = t & Inkscape::SnapPreferences::SNAPPOINT_OTHER;
+        bool p_is_a_node = p.getSourceType() & Inkscape::SNAPSOURCE_NODE_CATEGORY;
+        bool p_is_other = p.getSourceType() & Inkscape::SNAPSOURCE_OTHER_CATEGORY;
 
         if (_snapmanager->snapprefs.getSnapToBBoxPath()) {
             Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -414,12 +412,11 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::SnapPreferences::PointType
 }
 
 void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc,
-                                     Inkscape::SnapPreferences::PointType const &t,
                                      Inkscape::SnapCandidatePoint const &p,
                                      std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes,
                                      SPPath const *selected_path) const
 {
-    _collectPaths(t, p.getSourceNum() == 0);
+    _collectPaths(p, p.getSourceNum() == 0);
     // Now we can finally do the real snapping, using the paths collected above
 
     g_assert(_snapmanager->getDesktop() != NULL);
@@ -514,12 +511,11 @@ bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::ve
 }
 
 void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc,
-                                     Inkscape::SnapPreferences::PointType const &t,
                                      Inkscape::SnapCandidatePoint const &p,
                                      ConstraintLine const &c) const
 {
 
-    _collectPaths(t, p.getSourceNum() == 0);
+    _collectPaths(p, p.getSourceNum() == 0);
 
     // Now we can finally do the real snapping, using the paths collected above
 
@@ -568,13 +564,12 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc,
 
 
 void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc,
-                                            Inkscape::SnapPreferences::PointType const &t,
                                             Inkscape::SnapCandidatePoint const &p,
                                             Geom::OptRect const &bbox_to_snap,
                                             std::vector<SPItem const *> const *it,
                                             std::vector<SnapCandidatePoint> *unselected_nodes) const
 {
-    if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(t) == false ) {
+    if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false ) {
         return;
     }
 
@@ -589,7 +584,7 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc,
         || _snapmanager->snapprefs.getSnapLineMidpoints() || _snapmanager->snapprefs.getSnapObjectMidpoints()
         || _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || _snapmanager->snapprefs.getSnapBBoxMidpoints()
         || _snapmanager->snapprefs.getIncludeItemCenter()) {
-        _snapNodes(sc, t, p, unselected_nodes);
+        _snapNodes(sc, p, unselected_nodes);
     }
 
     if (_snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToPageBorder()) {
@@ -607,21 +602,20 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc,
                 } // else: *it->begin() might be a SPGroup, e.g. when editing a LPE of text that has been converted to a group of paths
                 // as reported in bug #356743. In that case we can just ignore it, i.e. not snap to this item
             }
-            _snapPaths(sc, t, p, unselected_nodes, path);
+            _snapPaths(sc, p, unselected_nodes, path);
         } else {
-            _snapPaths(sc, t, p, NULL, NULL);
+            _snapPaths(sc, p, NULL, NULL);
         }
     }
 }
 
 void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc,
-                                                  Inkscape::SnapPreferences::PointType const &t,
                                                   Inkscape::SnapCandidatePoint const &p,
                                                   Geom::OptRect const &bbox_to_snap,
                                                   ConstraintLine const &c,
                                                   std::vector<SPItem const *> const *it) const
 {
-    if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(t) == false) {
+    if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false) {
         return;
     }
 
@@ -641,7 +635,7 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc,
     // so we will more or less snap to them anyhow.
 
     if (_snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToPageBorder()) {
-        _snapPathsConstrained(sc, t, p, c);
+        _snapPathsConstrained(sc, p, c);
     }
 }
 
@@ -665,7 +659,7 @@ void Inkscape::ObjectSnapper::guideFreeSnap(SnappedConstraints &sc,
     }
 
     _findCandidates(sp_document_root(_snapmanager->getDocument()), &it, true, Geom::Rect(p, p), snap_dim, false, Geom::identity());
-    _snapTranslatingGuideToNodes(sc, Inkscape::SnapPreferences::SNAPPOINT_OTHER, p, guide_normal);
+    _snapTranslatingGuideToNodes(sc, p, guide_normal);
 
 }
 
@@ -689,7 +683,7 @@ void Inkscape::ObjectSnapper::guideConstrainedSnap(SnappedConstraints &sc,
     }
 
     _findCandidates(sp_document_root(_snapmanager->getDocument()), &it, true, Geom::Rect(p, p), snap_dim, false, Geom::identity());
-    _snapTranslatingGuideToNodes(sc, Inkscape::SnapPreferences::SNAPPOINT_OTHER, p, guide_normal);
+    _snapTranslatingGuideToNodes(sc, p, guide_normal);
 
 }
 
index 556ff86def386cea8f02ab3a6facb54e9e6e3627..caf643f730e867b89f498b701f03c2eff56daa8a 100644 (file)
@@ -55,14 +55,12 @@ public:
     bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
 
     void freeSnap(SnappedConstraints &sc,
-                  Inkscape::SnapPreferences::PointType const &t,
                   Inkscape::SnapCandidatePoint const &p,
                   Geom::OptRect const &bbox_to_snap,
                   std::vector<SPItem const *> const *it,
                   std::vector<SnapCandidatePoint> *unselected_nodes) const;
 
     void constrainedSnap(SnappedConstraints &sc,
-                  Inkscape::SnapPreferences::PointType const &t,
                   Inkscape::SnapCandidatePoint const &p,
                   Geom::OptRect const &bbox_to_snap,
                   ConstraintLine const &c,
@@ -83,32 +81,28 @@ private:
                        Geom::Matrix const additional_affine) const;
 
     void _snapNodes(SnappedConstraints &sc,
-                      Inkscape::SnapPreferences::PointType const &t,
                       Inkscape::SnapCandidatePoint const &p,
                       std::vector<SnapCandidatePoint> *unselected_nodes) const; // in desktop coordinates
 
     void _snapTranslatingGuideToNodes(SnappedConstraints &sc,
-                     Inkscape::SnapPreferences::PointType const &t,
                      Geom::Point const &p,
                      Geom::Point const &guide_normal) const;
 
-    void _collectNodes(Inkscape::SnapPreferences::PointType const &t,
+    void _collectNodes(Inkscape::SnapSourceType const &t,
                   bool const &first_point) const;
 
     void _snapPaths(SnappedConstraints &sc,
-                      Inkscape::SnapPreferences::PointType const &t,
                       Inkscape::SnapCandidatePoint const &p, // in desktop coordinates
                       std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes, // in desktop coordinates
                       SPPath const *selected_path) const;
 
     void _snapPathsConstrained(SnappedConstraints &sc,
-                 Inkscape::SnapPreferences::PointType const &t,
                  Inkscape::SnapCandidatePoint const &p, // in desktop coordinates
                  ConstraintLine const &c) const;
 
     bool isUnselectedNode(Geom::Point const &point, std::vector<Inkscape::SnapCandidatePoint> const *unselected_nodes) const;
 
-    void _collectPaths(Inkscape::SnapPreferences::PointType const &t,
+    void _collectPaths(Inkscape::SnapCandidatePoint const &p,
                   bool const &first_point) const;
 
     void _clear_paths() const;
index a717537abc6f42c390f9b6ab12ab38726b357804..b71bc2e54eecc5e1313beef76085050d7e8d5366 100644 (file)
@@ -468,14 +468,14 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
                     case SP_PEN_CONTEXT_POINT:
                         if (pc->npoints == 0) {
 
-                               Geom::Point p;
+                            Geom::Point p;
                           if ((bevent.state & GDK_CONTROL_MASK) && (pc->polylines_only || pc->polylines_paraxial)) {
-                               p = event_dt;
-                               if (!(bevent.state & GDK_SHIFT_MASK)) {
-                                       SnapManager &m = desktop->namedview->snap_manager;
-                                       m.setup(desktop);
-                                                                       m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
-                               }
+                                p = event_dt;
+                                if (!(bevent.state & GDK_SHIFT_MASK)) {
+                                    SnapManager &m = desktop->namedview->snap_manager;
+                                    m.setup(desktop);
+                                    m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE);
+                                }
                               spdc_create_single_dot(event_context, p, "/tools/freehand/pen", bevent.state);
                               ret = TRUE;
                               break;
@@ -970,7 +970,7 @@ static gint
 pen_handle_key_press(SPPenContext *const pc, GdkEvent *event)
 {
 
-       gint ret = FALSE;
+    gint ret = FALSE;
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px
 
index d6050ba04e9da0e8f495a334991af59887bffdfa..acdd4d6e5d14759fc1321028e12a055b2c8ab3c5 100644 (file)
@@ -253,13 +253,13 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve
                 break;
             default:
                 /* Set first point of sequence */
-               SnapManager &m = desktop->namedview->snap_manager;
-                               m.setup(desktop);
+                SnapManager &m = desktop->namedview->snap_manager;
+                m.setup(desktop);
 
                 if (bevent.state & GDK_CONTROL_MASK) {
                     if (!(bevent.state & GDK_SHIFT_MASK)) {
-                        m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
-                         }
+                        m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE);
+                      }
                     spdc_create_single_dot(event_context, p, "/tools/freehand/pencil", bevent.state);
                     ret = true;
                     break;
@@ -270,15 +270,15 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve
                 } else {
 
                     if (!(bevent.state & GDK_SHIFT_MASK)) {
-                                               // This is the first click of a new curve; deselect item so that
+                        // This is the first click of a new curve; deselect item so that
                         // this curve is not combined with it (unless it is drawn from its
                         // anchor, which is handled by the sibling branch above)
                         selection->clear();
                         desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating new path"));
-                        m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+                        m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE);
                     } else if (selection->singleItem() && SP_IS_PATH(selection->singleItem())) {
                         desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Appending to selected path"));
-                        m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+                        m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE);
                     }
                 }
                 pc->sa = anchor;
@@ -295,9 +295,9 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve
 static gint
 pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mevent)
 {
-       SPDesktop *const dt = pc->desktop;
+       SPDesktop *const dt = pc->desktop;
 
-       if ((mevent.state & GDK_CONTROL_MASK) && (mevent.state & GDK_BUTTON1_MASK)) {
+    if ((mevent.state & GDK_CONTROL_MASK) && (mevent.state & GDK_BUTTON1_MASK)) {
         // mouse was accidentally moved during Ctrl+click;
         // ignore the motion and create a single point
         pc->is_drawing = false;
@@ -356,9 +356,9 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev
             /* We may be idle or already freehand */
             if ( mevent.state & GDK_BUTTON1_MASK && pc->is_drawing ) {
                 if (pc->state == SP_PENCIL_CONTEXT_IDLE) {
-                       sp_event_context_discard_delayed_snap_event(event_context);
+                    sp_event_context_discard_delayed_snap_event(event_context);
                 }
-               pc->state = SP_PENCIL_CONTEXT_FREEHAND;
+                pc->state = SP_PENCIL_CONTEXT_FREEHAND;
 
                 if ( !pc->sa && !pc->green_anchor ) {
                     /* Create green anchor */
@@ -373,8 +373,8 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev
                 }
 
                 if ( pc->npoints != 0) { // buttonpress may have happened before we entered draw context!
-                                       spdc_add_freehand_point(pc, p, mevent.state);
-                                       ret = TRUE;
+                    spdc_add_freehand_point(pc, p, mevent.state);
+                    ret = TRUE;
                 }
 
                 if (anchor && !pc->anchor_statusbar) {
index b88b4b83aba5a5f1443f01cf2fce2646fff87752..dcc1f0aa1309a4049da77e3cbfc1f078d6b7a9c3 100644 (file)
@@ -283,7 +283,7 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
             /* Snap center */
             SnapManager &m = desktop->namedview->snap_manager;
             m.setup(desktop);
-            m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, button_dt, Inkscape::SNAPSOURCE_HANDLE);
+            m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
             rc->center = from_2geom(button_dt);
 
             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
index 5b129f8d8b7aefbb987dd385f1f8fc750ee00697..1c601b3ea254aa6302ed4302387e0b5f3cd0a956 100644 (file)
@@ -1015,8 +1015,8 @@ gboolean Inkscape::SelTrans::scaleRequest(Geom::Point &pt, guint state)
             }
 
             // Snap along a suitable constraint vector from the origin.
-            bb = m.constrainedSnapScale(SnapPreferences::SNAPPOINT_BBOX, _bbox_points, _point, default_scale, _origin_for_bboxpoints);
-            sn = m.constrainedSnapScale(SnapPreferences::SNAPPOINT_NODE, _snap_points, _point, geom_scale, _origin_for_specpoints);
+            bb = m.constrainedSnapScale(_bbox_points, _point, default_scale, _origin_for_bboxpoints);
+            sn = m.constrainedSnapScale(_snap_points, _point, geom_scale, _origin_for_specpoints);
 
             /* Choose the smaller difference in scale.  Since s[X] == s[Y] we can
             ** just compare difference in s[X].
@@ -1025,8 +1025,8 @@ gboolean Inkscape::SelTrans::scaleRequest(Geom::Point &pt, guint state)
             sd = sn.getSnapped() ? fabs(sn.getTransformation()[Geom::X] - geom_scale[Geom::X]) : NR_HUGE;
         } else {
             /* Scale aspect ratio is unlocked */
-            bb = m.freeSnapScale(SnapPreferences::SNAPPOINT_BBOX, _bbox_points, _point, default_scale, _origin_for_bboxpoints);
-            sn = m.freeSnapScale(SnapPreferences::SNAPPOINT_NODE, _snap_points, _point, geom_scale, _origin_for_specpoints);
+            bb = m.freeSnapScale(_bbox_points, _point, default_scale, _origin_for_bboxpoints);
+            sn = m.freeSnapScale(_snap_points, _point, geom_scale, _origin_for_specpoints);
 
             /* Pick the snap that puts us closest to the original scale */
             bd = bb.getSnapped() ? fabs(Geom::L2(bb.getTransformation()) - Geom::L2(Geom::Point(default_scale[Geom::X], default_scale[Geom::Y]))) : NR_HUGE;
@@ -1114,8 +1114,8 @@ gboolean Inkscape::SelTrans::stretchRequest(SPSelTransHandle const &handle, Geom
 
         bool symmetrical = state & GDK_CONTROL_MASK;
 
-        bb = m.constrainedSnapStretch(SnapPreferences::SNAPPOINT_BBOX, _bbox_points, _point, Geom::Coord(default_scale[axis]), _origin_for_bboxpoints, Geom::Dim2(axis), symmetrical);
-        sn = m.constrainedSnapStretch(SnapPreferences::SNAPPOINT_NODE, _snap_points, _point, Geom::Coord(geom_scale[axis]), _origin_for_specpoints, Geom::Dim2(axis), symmetrical);
+        bb = m.constrainedSnapStretch(_bbox_points, _point, Geom::Coord(default_scale[axis]), _origin_for_bboxpoints, Geom::Dim2(axis), symmetrical);
+        sn = m.constrainedSnapStretch(_snap_points, _point, Geom::Coord(geom_scale[axis]), _origin_for_specpoints, Geom::Dim2(axis), symmetrical);
 
         if (bb.getSnapped()) {
             // We snapped the bbox (which is either visual or geometric)
@@ -1232,7 +1232,7 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, Geom::P
         Inkscape::Snapper::ConstraintLine const constraint(component_vectors[dim_b]);
         // When skewing, we cannot snap the corners of the bounding box, see the comment in "constrainedSnapSkew" for details
         Geom::Point const s(skew[dim_a], scale[dim_a]);
-        Inkscape::SnappedPoint sn = m.constrainedSnapSkew(Inkscape::SnapPreferences::SNAPPOINT_NODE, _snap_points, _point, constraint, s, _origin, Geom::Dim2(dim_b));
+        Inkscape::SnappedPoint sn = m.constrainedSnapSkew(_snap_points, _point, constraint, s, _origin, Geom::Dim2(dim_b));
 
         if (sn.getSnapped()) {
             // We snapped something, so change the skew to reflect it
@@ -1336,7 +1336,7 @@ gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state)
 {
     SnapManager &m = _desktop->namedview->snap_manager;
     m.setup(_desktop);
-    m.freeSnapReturnByRef(SnapPreferences::SNAPPOINT_NODE, pt, Inkscape::SNAPSOURCE_HANDLE);
+    m.freeSnapReturnByRef(pt, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 
     if (state & GDK_CONTROL_MASK) {
         if ( fabs(_point[Geom::X] - pt[Geom::X]) > fabs(_point[Geom::Y] - pt[Geom::Y]) ) {
@@ -1444,7 +1444,7 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state)
         */
 
         m.setup(_desktop, true, _items_const);
-        m.freeSnapReturnByRef(SnapPreferences::SNAPPOINT_NODE, dxy, Inkscape::SNAPSOURCE_UNDEFINED);
+        m.freeSnapReturnByRef(dxy, Inkscape::SNAPSOURCE_UNDEFINED);
 
     } else if (shift) {
         if (control) { // shift & control: constrained movement without snapping
@@ -1476,14 +1476,12 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state)
             // the constraint-line once. The constraint lines are parallel, but might not be colinear.
             // Therefore we will have to set the point through which the constraint-line runs
             // individually for each point to be snapped; this will be handled however by _snapTransformed()
-            s.push_back(m.constrainedSnapTranslation(Inkscape::SnapPreferences::SNAPPOINT_BBOX,
-                                                     _bbox_points_for_translating,
+            s.push_back(m.constrainedSnapTranslation(_bbox_points_for_translating,
                                                      _point,
                                                      Inkscape::Snapper::ConstraintLine(component_vectors[dim]),
                                                      dxy));
 
-            s.push_back(m.constrainedSnapTranslation(Inkscape::SnapPreferences::SNAPPOINT_NODE,
-                                                     _snap_points,
+            s.push_back(m.constrainedSnapTranslation(_snap_points,
                                                      _point,
                                                      Inkscape::Snapper::ConstraintLine(component_vectors[dim]),
                                                      dxy));
@@ -1495,8 +1493,8 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state)
             g_get_current_time(&starttime); */
 
             /* Snap to things with no constraint */
-            s.push_back(m.freeSnapTranslation(Inkscape::SnapPreferences::SNAPPOINT_BBOX, _bbox_points_for_translating, _point, dxy));
-            s.push_back(m.freeSnapTranslation(Inkscape::SnapPreferences::SNAPPOINT_NODE, _snap_points, _point, dxy));
+            s.push_back(m.freeSnapTranslation(_bbox_points_for_translating, _point, dxy));
+            s.push_back(m.freeSnapTranslation(_snap_points, _point, dxy));
 
               /*g_get_current_time(&endtime);
               double elapsed = ((((double)endtime.tv_sec - starttime.tv_sec) * G_USEC_PER_SEC + (endtime.tv_usec - starttime.tv_usec))) / 1000.0;
index be0b2e49090b8ce4df6c505b6a3e711a18206bbf..bd378bec83e2d57baed389292f680f1ad2ba6b1d 100644 (file)
  */
 
 //#include "snapped-point.h"
+#include "snap-enums.h"
+
 struct SPItem; // forward declaration
 
 namespace Inkscape {
 
-enum SnapTargetType {
-    SNAPTARGET_UNDEFINED = 0,
-    SNAPTARGET_GRID,
-    SNAPTARGET_GRID_INTERSECTION,
-    SNAPTARGET_GUIDE,
-    SNAPTARGET_GUIDE_INTERSECTION,
-    SNAPTARGET_GUIDE_ORIGIN,
-    SNAPTARGET_GRID_GUIDE_INTERSECTION,
-    SNAPTARGET_NODE_SMOOTH,
-    SNAPTARGET_NODE_CUSP,
-    SNAPTARGET_LINE_MIDPOINT,
-    SNAPTARGET_OBJECT_MIDPOINT,
-    SNAPTARGET_ROTATION_CENTER,
-    SNAPTARGET_HANDLE,
-    SNAPTARGET_PATH,
-    SNAPTARGET_PATH_INTERSECTION,
-    SNAPTARGET_BBOX_CORNER,
-    SNAPTARGET_BBOX_EDGE,
-    SNAPTARGET_BBOX_EDGE_MIDPOINT,
-    SNAPTARGET_BBOX_MIDPOINT,
-    SNAPTARGET_PAGE_BORDER,
-    SNAPTARGET_PAGE_CORNER,
-    SNAPTARGET_CONVEX_HULL_CORNER,
-    SNAPTARGET_ELLIPSE_QUADRANT_POINT,
-    SNAPTARGET_CENTER, // of ellipse
-    SNAPTARGET_CORNER, // of image or of rectangle
-    SNAPTARGET_TEXT_BASELINE,
-    SNAPTARGET_CONSTRAINED_ANGLE
-};
-
-enum SnapSourceType {
-    SNAPSOURCE_UNDEFINED = 0,
-    SNAPSOURCE_BBOX_CORNER,
-    SNAPSOURCE_BBOX_MIDPOINT,
-    SNAPSOURCE_BBOX_EDGE_MIDPOINT,
-    SNAPSOURCE_NODE_SMOOTH,
-    SNAPSOURCE_NODE_CUSP,
-    SNAPSOURCE_LINE_MIDPOINT,
-    SNAPSOURCE_OBJECT_MIDPOINT,
-    SNAPSOURCE_ROTATION_CENTER,
-    SNAPSOURCE_HANDLE,
-    SNAPSOURCE_PATH_INTERSECTION,
-    SNAPSOURCE_GUIDE,
-    SNAPSOURCE_GUIDE_ORIGIN,
-    SNAPSOURCE_CONVEX_HULL_CORNER,
-    SNAPSOURCE_ELLIPSE_QUADRANT_POINT,
-    SNAPSOURCE_CENTER, // of ellipse
-    SNAPSOURCE_CORNER, // of image or of rectangle
-    SNAPSOURCE_TEXT_BASELINE
-};
-
 /// Class to store data for points which are snap candidates, either as a source or as a target
 class SnapCandidatePoint
 {
diff --git a/src/snap-enums.h b/src/snap-enums.h
new file mode 100644 (file)
index 0000000..41cc65a
--- /dev/null
@@ -0,0 +1,81 @@
+#ifndef SNAPENUMS_H_
+#define SNAPENUMS_H_
+
+/**
+ * \file snap-enums.h
+ * \brief enumerations of snap source types and snap target types
+ *
+ * Authors:
+ *   Diederik van Lierop <mail@diedenrezi.nl>
+ *
+ * Copyright (C) 2010 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+namespace Inkscape {
+
+enum SnapTargetType {
+    SNAPTARGET_UNDEFINED = 0,
+    SNAPTARGET_GRID,
+    SNAPTARGET_GRID_INTERSECTION,
+    SNAPTARGET_GUIDE,
+    SNAPTARGET_GUIDE_INTERSECTION,
+    SNAPTARGET_GUIDE_ORIGIN,
+    SNAPTARGET_GRID_GUIDE_INTERSECTION,
+    SNAPTARGET_NODE_SMOOTH,
+    SNAPTARGET_NODE_CUSP,
+    SNAPTARGET_LINE_MIDPOINT,
+    SNAPTARGET_OBJECT_MIDPOINT,
+    SNAPTARGET_ROTATION_CENTER,
+    SNAPTARGET_HANDLE,
+    SNAPTARGET_PATH,
+    SNAPTARGET_PATH_INTERSECTION,
+    SNAPTARGET_BBOX_CORNER,
+    SNAPTARGET_BBOX_EDGE,
+    SNAPTARGET_BBOX_EDGE_MIDPOINT,
+    SNAPTARGET_BBOX_MIDPOINT,
+    SNAPTARGET_PAGE_BORDER,
+    SNAPTARGET_PAGE_CORNER,
+    SNAPTARGET_CONVEX_HULL_CORNER,
+    SNAPTARGET_ELLIPSE_QUADRANT_POINT,
+    SNAPTARGET_CENTER, // of ellipse
+    SNAPTARGET_CORNER, // of image or of rectangle
+    SNAPTARGET_TEXT_BASELINE,
+    SNAPTARGET_CONSTRAINED_ANGLE
+};
+
+enum SnapSourceType {
+    SNAPSOURCE_UNDEFINED = 0,
+    //-------------------------------------------------------------------
+    // Bbox points can be located at the edge of the stroke (for visual bboxes); they will therefore not snap
+    // to nodes because these are always located at the center of the stroke
+    SNAPSOURCE_BBOX_CATEGORY = 256, // will be used as a flag and must therefore be a power of two
+    SNAPSOURCE_BBOX_CORNER,
+    SNAPSOURCE_BBOX_MIDPOINT,
+    SNAPSOURCE_BBOX_EDGE_MIDPOINT,
+    //-------------------------------------------------------------------
+    // For the same reason, nodes will not snap to bbox points
+    SNAPSOURCE_NODE_CATEGORY = 512, // will be used as a flag and must therefore be a power of two
+    SNAPSOURCE_NODE_SMOOTH,
+    SNAPSOURCE_NODE_CUSP,
+    SNAPSOURCE_LINE_MIDPOINT,
+    SNAPSOURCE_PATH_INTERSECTION,
+    SNAPSOURCE_CORNER, // of image or of rectangle
+    SNAPSOURCE_CONVEX_HULL_CORNER,
+    SNAPSOURCE_ELLIPSE_QUADRANT_POINT,
+    SNAPSOURCE_NODE_HANDLE,
+    //-------------------------------------------------------------------
+    // Other points (e.g. guides, gradient knots) will snap to both bounding boxes and nodes
+    SNAPSOURCE_OTHER_CATEGORY = 1024, // will be used as a flag and must therefore be a power of two
+    SNAPSOURCE_OBJECT_MIDPOINT,
+    SNAPSOURCE_ROTATION_CENTER,
+    SNAPSOURCE_CENTER, // of ellipse
+    SNAPSOURCE_GUIDE,
+    SNAPSOURCE_GUIDE_ORIGIN,
+    SNAPSOURCE_TEXT_BASELINE,
+    SNAPSOURCE_OTHER_HANDLE
+};
+
+}
+#endif /* SNAPENUMS_H_ */
index 0ba3b15dc6e4663d135e078f0b4f6bdee378623a..aa967349d0fdf1d0c0deab27f63ec3c78275d082 100644 (file)
 #include "inkscape.h"
 #include "snap-preferences.h"
 
-Inkscape::SnapPreferences::PointType const Inkscape::SnapPreferences::SNAPPOINT_NODE  = 0x1;
-Inkscape::SnapPreferences::PointType const Inkscape::SnapPreferences::SNAPPOINT_BBOX  = 0x2;
-Inkscape::SnapPreferences::PointType const Inkscape::SnapPreferences::SNAPPOINT_OTHER = 0x4;
-
-
 Inkscape::SnapPreferences::SnapPreferences() :
-       _include_item_center(false),
-       _intersectionGG(true),
-       _snap_to_grids(true),
-       _snap_to_guides(true),
+    _include_item_center(false),
+    _intersectionGG(true),
+    _snap_to_grids(true),
+    _snap_to_guides(true),
     _snap_enabled_globally(true),
     _snap_postponed_globally(false),
     _snap_to_itemnode(true), _snap_to_itempath(true),
-       _snap_to_bboxnode(true), _snap_to_bboxpath(true),
-       _snap_to_page_border(false),
-       _strict_snapping(true)
+    _snap_to_bboxnode(true), _snap_to_bboxpath(true),
+    _snap_to_page_border(false),
+    _strict_snapping(true)
 {
-       setSnapFrom(SNAPPOINT_BBOX | SNAPPOINT_NODE | SNAPPOINT_OTHER, true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab
+    setSnapFrom(SnapSourceType(SNAPSOURCE_BBOX_CATEGORY | SNAPSOURCE_NODE_CATEGORY | SNAPSOURCE_OTHER_CATEGORY), true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab
 }
 
 /*
@@ -47,54 +42,54 @@ Inkscape::SnapPreferences::SnapPreferences() :
 
 void Inkscape::SnapPreferences::setSnapModeBBox(bool enabled)
 {
-       if (enabled) {
-        _snap_from |= Inkscape::SnapPreferences::SNAPPOINT_BBOX;
+    if (enabled) {
+        _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_BBOX_CATEGORY);
     } else {
-        _snap_from &= ~Inkscape::SnapPreferences::SNAPPOINT_BBOX;
+        _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_BBOX_CATEGORY);
     }
 }
 
 bool Inkscape::SnapPreferences::getSnapModeBBox() const
 {
-       return (_snap_from & Inkscape::SnapPreferences::SNAPPOINT_BBOX);
+    return (_snap_from & Inkscape::SNAPSOURCE_BBOX_CATEGORY);
 }
 
 void Inkscape::SnapPreferences::setSnapModeNode(bool enabled)
 {
-       if (enabled) {
-        _snap_from |= Inkscape::SnapPreferences::SNAPPOINT_NODE;
+    if (enabled) {
+        _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_NODE_CATEGORY);
     } else {
-        _snap_from &= ~Inkscape::SnapPreferences::SNAPPOINT_NODE;
+        _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_NODE_CATEGORY);
     }
 }
 
 bool Inkscape::SnapPreferences::getSnapModeNode() const
 {
-       return (_snap_from & Inkscape::SnapPreferences::SNAPPOINT_NODE);
+    return (_snap_from & Inkscape::SNAPSOURCE_NODE_CATEGORY);
 }
 
 bool Inkscape::SnapPreferences::getSnapModeBBoxOrNodes() const
 {
-       return (_snap_from & (Inkscape::SnapPreferences::SNAPPOINT_BBOX | Inkscape::SnapPreferences::SNAPPOINT_NODE) );
+    return (_snap_from & (Inkscape::SNAPSOURCE_BBOX_CATEGORY | Inkscape::SNAPSOURCE_NODE_CATEGORY) );
 }
 
 bool Inkscape::SnapPreferences::getSnapModeAny() const
 {
-       return (_snap_from != 0);
+    return (_snap_from != 0);
 }
 
 void Inkscape::SnapPreferences::setSnapModeGuide(bool enabled)
 {
-       if (enabled) {
-        _snap_from |= Inkscape::SnapPreferences::SNAPPOINT_OTHER;
+    if (enabled) {
+        _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_OTHER_CATEGORY);
     } else {
-        _snap_from &= ~Inkscape::SnapPreferences::SNAPPOINT_OTHER;
+        _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_OTHER_CATEGORY);
     }
 }
 
 bool Inkscape::SnapPreferences::getSnapModeGuide() const
 {
-       return (_snap_from & Inkscape::SnapPreferences::SNAPPOINT_OTHER);
+    return (_snap_from & Inkscape::SNAPSOURCE_OTHER_CATEGORY);
 }
 
 /**
@@ -102,12 +97,12 @@ bool Inkscape::SnapPreferences::getSnapModeGuide() const
  *  \param t Point type.
  *  \param s true to snap to this point type, otherwise false;
  */
-void Inkscape::SnapPreferences::setSnapFrom(PointType t, bool s)
+void Inkscape::SnapPreferences::setSnapFrom(Inkscape::SnapSourceType t, bool s)
 {
     if (s) {
-        _snap_from |= t;
+        _snap_from = SnapSourceType(_snap_from | t);
     } else {
-        _snap_from &= ~t;
+        _snap_from = SnapSourceType(_snap_from & ~t);
     }
 }
 
@@ -115,7 +110,7 @@ void Inkscape::SnapPreferences::setSnapFrom(PointType t, bool s)
  *  \param t Point type.
  *  \return true if snapper will snap this type of point, otherwise false.
  */
-bool Inkscape::SnapPreferences::getSnapFrom(PointType t) const
+bool Inkscape::SnapPreferences::getSnapFrom(Inkscape::SnapSourceType t) const
 {
     return (_snap_from & t);
 }
index c88503e7da28d6ceaa51d7812e16d858297cb688..49d52cdb2bddaa2968bd256cb9e37fc7d02d735c 100644 (file)
@@ -8,12 +8,13 @@
  * Authors:
  *   Diederik van Lierop <mail@diedenrezi.nl>
  *
- * Copyright (C) 2008 Authors
+ * Copyright (C) 2008 - 2010 Authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 
 #include "helper/units.h"
+#include "snap-enums.h"
 
 namespace Inkscape
 {
@@ -21,13 +22,7 @@ namespace Inkscape
 class SnapPreferences
 {
 public:
-       SnapPreferences();
-
-       /// Point types to snap.
-    typedef int PointType; // can be only one of the types below, never two or more at the same time
-    static const PointType SNAPPOINT_NODE; // will in general not snap to bounding boxes
-    static const PointType SNAPPOINT_BBOX; // will in general not snap to nodes
-    static const PointType SNAPPOINT_OTHER;// e.g. guides, gradient knots
+    SnapPreferences();
 
     void setSnapModeBBox(bool enabled);
     void setSnapModeNode(bool enabled);
@@ -44,20 +39,20 @@ public:
     void setSnapLineMidpoints(bool enabled) {_line_midpoints = enabled;}
     void setSnapObjectMidpoints(bool enabled) {_object_midpoints = enabled;}
     void setSnapBBoxEdgeMidpoints(bool enabled) {_bbox_edge_midpoints = enabled;}
-       void setSnapBBoxMidpoints(bool enabled) {_bbox_midpoints = enabled;}
+    void setSnapBBoxMidpoints(bool enabled) {_bbox_midpoints = enabled;}
     bool getSnapIntersectionGG() const {return _intersectionGG;}
     bool getSnapIntersectionCS() const {return _intersectionCS;}
     bool getSnapSmoothNodes() const {return _smoothNodes;}
     bool getSnapLineMidpoints() const {return _line_midpoints;}
     bool getSnapObjectMidpoints() const {return _object_midpoints;}
     bool getSnapBBoxEdgeMidpoints() const {return _bbox_edge_midpoints;}
-       bool getSnapBBoxMidpoints() const {return _bbox_midpoints;}
+    bool getSnapBBoxMidpoints() const {return _bbox_midpoints;}
 
-       void setSnapToGrids(bool enabled) {_snap_to_grids = enabled;}
+    void setSnapToGrids(bool enabled) {_snap_to_grids = enabled;}
     bool getSnapToGrids() const {return _snap_to_grids;}
 
     void setSnapToGuides(bool enabled) {_snap_to_guides = enabled;}
-       bool getSnapToGuides() const {return _snap_to_guides;}
+    bool getSnapToGuides() const {return _snap_to_guides;}
 
     void setIncludeItemCenter(bool enabled) {_include_item_center = enabled;}
     bool getIncludeItemCenter() const {return _include_item_center;}
@@ -68,29 +63,29 @@ public:
     void setSnapPostponedGlobally(bool postponed) {_snap_postponed_globally = postponed;}
     bool getSnapPostponedGlobally() const {return _snap_postponed_globally;}
 
-    void setSnapFrom(PointType t, bool s);
-    bool getSnapFrom(PointType t) const;
+    void setSnapFrom(Inkscape::SnapSourceType t, bool s);
+    bool getSnapFrom(Inkscape::SnapSourceType t) const;
 
     // These will only be used for the object snapper
     void setSnapToItemNode(bool s) {_snap_to_itemnode = s;}
-       bool getSnapToItemNode() const {return _snap_to_itemnode;}
-       void setSnapToItemPath(bool s) {_snap_to_itempath = s;}
-       bool getSnapToItemPath() const {return _snap_to_itempath;}
-       void setSnapToBBoxNode(bool s) {_snap_to_bboxnode = s;}
-       bool getSnapToBBoxNode() const {return _snap_to_bboxnode;}
-       void setSnapToBBoxPath(bool s) {_snap_to_bboxpath = s;}
-       bool getSnapToBBoxPath() const {return _snap_to_bboxpath;}
-       void setSnapToPageBorder(bool s) {_snap_to_page_border = s;}
-       bool getSnapToPageBorder() const {return _snap_to_page_border;}
-       bool getStrictSnapping() const {return _strict_snapping;}
-
-       gdouble getGridTolerance() const {return _grid_tolerance;}
-       gdouble getGuideTolerance() const {return _guide_tolerance;}
-       gdouble getObjectTolerance() const {return _object_tolerance;}
-
-       void setGridTolerance(gdouble val) {_grid_tolerance = val;}
-       void setGuideTolerance(gdouble val) {_guide_tolerance = val;}
-       void setObjectTolerance(gdouble val) {_object_tolerance = val;}
+    bool getSnapToItemNode() const {return _snap_to_itemnode;}
+    void setSnapToItemPath(bool s) {_snap_to_itempath = s;}
+    bool getSnapToItemPath() const {return _snap_to_itempath;}
+    void setSnapToBBoxNode(bool s) {_snap_to_bboxnode = s;}
+    bool getSnapToBBoxNode() const {return _snap_to_bboxnode;}
+    void setSnapToBBoxPath(bool s) {_snap_to_bboxpath = s;}
+    bool getSnapToBBoxPath() const {return _snap_to_bboxpath;}
+    void setSnapToPageBorder(bool s) {_snap_to_page_border = s;}
+    bool getSnapToPageBorder() const {return _snap_to_page_border;}
+    bool getStrictSnapping() const {return _strict_snapping;}
+
+    gdouble getGridTolerance() const {return _grid_tolerance;}
+    gdouble getGuideTolerance() const {return _guide_tolerance;}
+    gdouble getObjectTolerance() const {return _object_tolerance;}
+
+    void setGridTolerance(gdouble val) {_grid_tolerance = val;}
+    void setGuideTolerance(gdouble val) {_guide_tolerance = val;}
+    void setObjectTolerance(gdouble val) {_object_tolerance = val;}
 
 
 private:
@@ -101,28 +96,28 @@ private:
     bool _line_midpoints;
     bool _object_midpoints; // the midpoint of shapes (e.g. a circle, rect, polygon) or of any other shape (at [h/2, w/2])
     bool _bbox_edge_midpoints;
-       bool _bbox_midpoints;
-       bool _snap_to_grids;
-       bool _snap_to_guides;
+    bool _bbox_midpoints;
+    bool _snap_to_grids;
+    bool _snap_to_guides;
     bool _snap_enabled_globally; // Toggles ALL snapping
     bool _snap_postponed_globally; // Hold all snapping temporarily when the mouse is moving fast
-    PointType _snap_from; ///< bitmap of point types that we will snap from
+    SnapSourceType _snap_from; ///< bitmap of point types that we will snap from
 
     // These will only be used for the object snapper
     bool _snap_to_itemnode;
-       bool _snap_to_itempath;
-       bool _snap_to_bboxnode;
-       bool _snap_to_bboxpath;
-       bool _snap_to_page_border;
-       //If enabled, then bbox corners will only snap to bboxes,
-       //and nodes will only snap to nodes and paths. We will not
-       //snap bbox corners to nodes, or nodes to bboxes.
-       //(snapping to grids and guides is not affected by this)
-       bool _strict_snapping;
-
-       gdouble _grid_tolerance;
-       gdouble _guide_tolerance;
-       gdouble _object_tolerance;
+    bool _snap_to_itempath;
+    bool _snap_to_bboxnode;
+    bool _snap_to_bboxpath;
+    bool _snap_to_page_border;
+    //If enabled, then bbox corners will only snap to bboxes,
+    //and nodes will only snap to nodes and paths. We will not
+    //snap bbox corners to nodes, or nodes to bboxes.
+    //(snapping to grids and guides is not affected by this)
+    bool _strict_snapping;
+
+    gdouble _grid_tolerance;
+    gdouble _guide_tolerance;
+    gdouble _object_tolerance;
 };
 
 }
index 705e9047045d1414bcb49596a8ab8e0fc07301bd..4727c7b3e2f78cbfad54bf5caa5faba671c2a63d 100644 (file)
@@ -165,19 +165,17 @@ bool SnapManager::gridSnapperMightSnap() const
  *  2) Only to be used when a single source point is to be snapped; it assumes
  *  that source_num = 0, which is inefficient when snapping sets our source points
  *
- *  \param point_type Category of points to which the source point belongs: node, guide or bounding box
  *  \param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred
  *  \param source_type Detailed description of the source type, will be used by the snap indicator
  *  \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation
  */
 
-void SnapManager::freeSnapReturnByRef(Inkscape::SnapPreferences::PointType point_type,
-                                      Geom::Point &p,
+void SnapManager::freeSnapReturnByRef(Geom::Point &p,
                                       Inkscape::SnapSourceType const source_type,
                                       Geom::OptRect const &bbox_to_snap) const
 {
     //TODO: SnapCandidatePoint and point_type are somewhat redundant; can't we get rid of the point_type parameter?
-    Inkscape::SnappedPoint const s = freeSnap(point_type, Inkscape::SnapCandidatePoint(p, source_type), bbox_to_snap);
+    Inkscape::SnappedPoint const s = freeSnap(Inkscape::SnapCandidatePoint(p, source_type), bbox_to_snap);
     s.getPoint(p);
 }
 
@@ -193,15 +191,13 @@ void SnapManager::freeSnapReturnByRef(Inkscape::SnapPreferences::PointType point
  *  PS: SnapManager::setup() must have been called before calling this method,
  *  but only once for a set of points
  *
- *  \param point_type Category of points to which the source point belongs: node, guide or bounding box
  *  \param p Source point to be snapped
  *  \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation
  *  \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics
  */
 
 
-Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapPreferences::PointType const point_type,
-                                             Inkscape::SnapCandidatePoint const &p,
+Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const &p,
                                              Geom::OptRect const &bbox_to_snap) const
 {
     if (!someSnapperMightSnap()) {
@@ -212,7 +208,7 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapPreferences::PointTyp
     SnapperList const snappers = getSnappers();
 
     for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) {
-        (*i)->freeSnap(sc, point_type, p, bbox_to_snap, &_items_to_ignore, _unselected_nodes);
+        (*i)->freeSnap(sc, p, bbox_to_snap, &_items_to_ignore, _unselected_nodes);
     }
 
     return findBestSnap(p, sc, false);
@@ -264,7 +260,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t) const
                 Geom::Point const t_offset = t + grid->origin;
                 SnappedConstraints sc;
                 // Only the first three parameters are being used for grid snappers
-                snapper->freeSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_UNDEFINED),Geom::OptRect(), NULL, NULL);
+                snapper->freeSnap(sc, Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_UNDEFINED),Geom::OptRect(), NULL, NULL);
                 // Find the best snap for this grid, including intersections of the grid-lines
                 Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_UNDEFINED), sc, false);
                 if (s.getSnapped() && (s.getSnapDistance() < nearest_distance)) {
@@ -307,20 +303,18 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t) const
  *  that source_num = 0, which is inefficient when snapping sets our source points
 
  *
- *  \param point_type Category of points to which the source point belongs: node, guide or bounding box
  *  \param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred
  *  \param source_type Detailed description of the source type, will be used by the snap indicator
  *  \param constraint The direction or line along which snapping must occur
  *  \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation
  */
 
-void SnapManager::constrainedSnapReturnByRef(Inkscape::SnapPreferences::PointType point_type,
-                                             Geom::Point &p,
+void SnapManager::constrainedSnapReturnByRef(Geom::Point &p,
                                              Inkscape::SnapSourceType const source_type,
                                              Inkscape::Snapper::ConstraintLine const &constraint,
                                              Geom::OptRect const &bbox_to_snap) const
 {
-    Inkscape::SnappedPoint const s = constrainedSnap(point_type, Inkscape::SnapCandidatePoint(p, source_type, 0), constraint, bbox_to_snap);
+    Inkscape::SnappedPoint const s = constrainedSnap(Inkscape::SnapCandidatePoint(p, source_type, 0), constraint, bbox_to_snap);
     s.getPoint(p);
 }
 
@@ -335,14 +329,12 @@ void SnapManager::constrainedSnapReturnByRef(Inkscape::SnapPreferences::PointTyp
  *  PS: SnapManager::setup() must have been called before calling this method,
  *  but only once for a set of points
  *
- *  \param point_type Category of points to which the source point belongs: node, guide or bounding box
  *  \param p Source point to be snapped
  *  \param constraint The direction or line along which snapping must occur
  *  \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation
  */
 
-Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapPreferences::PointType const point_type,
-                                                    Inkscape::SnapCandidatePoint const &p,
+Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint const &p,
                                                     Inkscape::Snapper::ConstraintLine const &constraint,
                                                     Geom::OptRect const &bbox_to_snap) const
 {
@@ -358,7 +350,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapPreferences::P
     SnappedConstraints sc;
     SnapperList const snappers = getSnappers();
     for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) {
-        (*i)->constrainedSnap(sc, point_type, candidate, bbox_to_snap, constraint, &_items_to_ignore);
+        (*i)->constrainedSnap(sc, candidate, bbox_to_snap, constraint, &_items_to_ignore);
     }
 
     return findBestSnap(candidate, sc, true);
@@ -401,7 +393,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal,
     SnapperList snappers = getGridSnappers();
     snappers.push_back(&guide);
     for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) {
-        (*i)->freeSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_OTHER, candidate, Geom::OptRect(), NULL, NULL);
+        (*i)->freeSnap(sc, candidate, Geom::OptRect(), NULL, NULL);
     }
 
     // Snap to intersections of curves, but not to the curves themselves! (see _snapTranslatingGuideToNodes in object-snapper.cpp)
@@ -440,14 +432,14 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline)
     SnappedConstraints sc;
     Inkscape::Snapper::ConstraintLine cl(guideline.point_on_line, Geom::rot90(guideline.normal_to_line));
     if (object.ThisSnapperMightSnap()) {
-        object.constrainedSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_OTHER, candidate, Geom::OptRect(), cl, NULL);
+        object.constrainedSnap(sc, candidate, Geom::OptRect(), cl, NULL);
     }
 
     // Snap to guides & grid lines
     SnapperList snappers = getGridSnappers();
     snappers.push_back(&guide);
     for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) {
-        (*i)->constrainedSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_OTHER, candidate, Geom::OptRect(), cl, NULL);
+        (*i)->constrainedSnap(sc, candidate, Geom::OptRect(), cl, NULL);
     }
 
     Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false);
@@ -467,7 +459,6 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline)
  *  some metrics to quantify the snap "distance", and see if it's better than the
  *  previous snap. Finally, the best ("nearest") snap from all these points is returned.
  *
- *  \param type Category of points to which the source point belongs: node or bounding box.
  *  \param points Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source.
  *  \param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed).
  *  \param constrained true if the snap is constrained, e.g. for stretching or for purely horizontal translation.
@@ -481,7 +472,6 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline)
  */
 
 Inkscape::SnappedPoint SnapManager::_snapTransformed(
-    Inkscape::SnapPreferences::PointType type,
     std::vector<Inkscape::SnapCandidatePoint> const &points,
     Geom::Point const &pointer,
     bool constrained,
@@ -564,7 +554,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed(
             if (transformation_type == SCALE && !uniform) {
                 g_warning("Non-uniform constrained scaling is not supported!");
             }
-            snapped_point = constrainedSnap(type, *j, dedicated_constraint, bbox);
+            snapped_point = constrainedSnap(*j, dedicated_constraint, bbox);
         } else {
             bool const c1 = fabs(b[Geom::X]) < 1e-6;
             bool const c2 = fabs(b[Geom::Y]) < 1e-6;
@@ -573,9 +563,9 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed(
                 // move in that specific direction; therefore it should only snap in that direction, otherwise
                 // we will get snapped points with an invalid transformation
                 dedicated_constraint = Inkscape::Snapper::ConstraintLine(origin, component_vectors[c1]);
-                snapped_point = constrainedSnap(type, *j, dedicated_constraint, bbox);
+                snapped_point = constrainedSnap(*j, dedicated_constraint, bbox);
             } else {
-                snapped_point = freeSnap(type, *j, bbox);
+                snapped_point = freeSnap(*j, bbox);
             }
         }
         // std::cout << "dist = " << snapped_point.getSnapDistance() << std::endl;
@@ -699,24 +689,22 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed(
 /**
  *  \brief Apply a translation to a set of points and try to snap freely in 2 degrees-of-freedom
  *
- *  \param point_type Category of points to which the source point belongs: node or bounding box.
  *  \param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source.
  *  \param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed).
  *  \param tr Proposed translation; the final translation can only be calculated after snapping has occurred
  *  \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
  */
 
-Inkscape::SnappedPoint SnapManager::freeSnapTranslation(Inkscape::SnapPreferences::PointType point_type,
-                                                        std::vector<Inkscape::SnapCandidatePoint> const &p,
+Inkscape::SnappedPoint SnapManager::freeSnapTranslation(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                                         Geom::Point const &pointer,
                                                         Geom::Point const &tr) const
 {
     if (p.size() == 1) {
         Geom::Point pt = _transformPoint(p.at(0), TRANSLATION, tr, Geom::Point(0,0), Geom::X, false);
-        _displaySnapsource(point_type, Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
+        _displaySnapsource(Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
     }
 
-    return _snapTransformed(point_type, p, pointer, false, Geom::Point(0,0), TRANSLATION, tr, Geom::Point(0,0), Geom::X, false);
+    return _snapTransformed(p, pointer, false, Geom::Point(0,0), TRANSLATION, tr, Geom::Point(0,0), Geom::X, false);
 }
 
 /**
@@ -730,18 +718,17 @@ Inkscape::SnappedPoint SnapManager::freeSnapTranslation(Inkscape::SnapPreference
  *  \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
  */
 
-Inkscape::SnappedPoint SnapManager::constrainedSnapTranslation(Inkscape::SnapPreferences::PointType point_type,
-                                                               std::vector<Inkscape::SnapCandidatePoint> const &p,
+Inkscape::SnappedPoint SnapManager::constrainedSnapTranslation(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                                                Geom::Point const &pointer,
                                                                Inkscape::Snapper::ConstraintLine const &constraint,
                                                                Geom::Point const &tr) const
 {
     if (p.size() == 1) {
         Geom::Point pt = _transformPoint(p.at(0), TRANSLATION, tr, Geom::Point(0,0), Geom::X, false);
-        _displaySnapsource(point_type, Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
+        _displaySnapsource(Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
     }
 
-    return _snapTransformed(point_type, p, pointer, true, constraint, TRANSLATION, tr, Geom::Point(0,0), Geom::X, false);
+    return _snapTransformed(p, pointer, true, constraint, TRANSLATION, tr, Geom::Point(0,0), Geom::X, false);
 }
 
 
@@ -756,18 +743,17 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapTranslation(Inkscape::SnapPre
  *  \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
  */
 
-Inkscape::SnappedPoint SnapManager::freeSnapScale(Inkscape::SnapPreferences::PointType point_type,
-                                                  std::vector<Inkscape::SnapCandidatePoint> const &p,
+Inkscape::SnappedPoint SnapManager::freeSnapScale(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                                   Geom::Point const &pointer,
                                                   Geom::Scale const &s,
                                                   Geom::Point const &o) const
 {
     if (p.size() == 1) {
         Geom::Point pt = _transformPoint(p.at(0), SCALE, Geom::Point(s[Geom::X], s[Geom::Y]), o, Geom::X, false);
-        _displaySnapsource(point_type, Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
+        _displaySnapsource(Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
     }
 
-    return _snapTransformed(point_type, p, pointer, false, Geom::Point(0,0), SCALE, Geom::Point(s[Geom::X], s[Geom::Y]), o, Geom::X, false);
+    return _snapTransformed(p, pointer, false, Geom::Point(0,0), SCALE, Geom::Point(s[Geom::X], s[Geom::Y]), o, Geom::X, false);
 }
 
 
@@ -782,8 +768,7 @@ Inkscape::SnappedPoint SnapManager::freeSnapScale(Inkscape::SnapPreferences::Poi
  *  \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
  */
 
-Inkscape::SnappedPoint SnapManager::constrainedSnapScale(Inkscape::SnapPreferences::PointType point_type,
-                                                         std::vector<Inkscape::SnapCandidatePoint> const &p,
+Inkscape::SnappedPoint SnapManager::constrainedSnapScale(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                                          Geom::Point const &pointer,
                                                          Geom::Scale const &s,
                                                          Geom::Point const &o) const
@@ -791,10 +776,10 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapScale(Inkscape::SnapPreferenc
     // When constrained scaling, only uniform scaling is supported.
     if (p.size() == 1) {
         Geom::Point pt = _transformPoint(p.at(0), SCALE, Geom::Point(s[Geom::X], s[Geom::Y]), o, Geom::X, true);
-        _displaySnapsource(point_type, Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
+        _displaySnapsource(Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
     }
 
-    return _snapTransformed(point_type, p, pointer, true, Geom::Point(0,0), SCALE, Geom::Point(s[Geom::X], s[Geom::Y]), o, Geom::X, true);
+    return _snapTransformed(p, pointer, true, Geom::Point(0,0), SCALE, Geom::Point(s[Geom::X], s[Geom::Y]), o, Geom::X, true);
 }
 
 /**
@@ -810,8 +795,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapScale(Inkscape::SnapPreferenc
  *  \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
  */
 
-Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(Inkscape::SnapPreferences::PointType point_type,
-                                                            std::vector<Inkscape::SnapCandidatePoint> const &p,
+Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                                             Geom::Point const &pointer,
                                                             Geom::Coord const &s,
                                                             Geom::Point const &o,
@@ -820,10 +804,10 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(Inkscape::SnapPrefere
 {
     if (p.size() == 1) {
         Geom::Point pt = _transformPoint(p.at(0), STRETCH, Geom::Point(s, s), o, d, u);
-        _displaySnapsource(point_type, Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
+        _displaySnapsource(Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
     }
 
-    return _snapTransformed(point_type, p, pointer, true, Geom::Point(0,0), STRETCH, Geom::Point(s, s), o, d, u);
+    return _snapTransformed(p, pointer, true, Geom::Point(0,0), STRETCH, Geom::Point(s, s), o, d, u);
 }
 
 /**
@@ -839,8 +823,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(Inkscape::SnapPrefere
  *  \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics.
  */
 
-Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(Inkscape::SnapPreferences::PointType point_type,
-                                                 std::vector<Inkscape::SnapCandidatePoint> const &p,
+Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                                  Geom::Point const &pointer,
                                                  Inkscape::Snapper::ConstraintLine const &constraint,
                                                  Geom::Point const &s,
@@ -854,14 +837,16 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(Inkscape::SnapPreference
     // NOT the case for example when rotating or skewing. The bounding box itself cannot possibly rotate or skew,
     // so it's corners have a different transformation. The snappers cannot handle this, therefore snapping
     // of bounding boxes is not allowed here.
-    g_assert(!(point_type & Inkscape::SnapPreferences::SNAPPOINT_BBOX));
+    if (p.size() > 0) {
+        g_assert(!(p.at(0).getSourceType() & Inkscape::SNAPSOURCE_BBOX_CATEGORY));
+    }
 
     if (p.size() == 1) {
         Geom::Point pt = _transformPoint(p.at(0), SKEW, s, o, d, false);
-        _displaySnapsource(point_type, Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
+        _displaySnapsource(Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
     }
 
-    return _snapTransformed(point_type, p, pointer, true, constraint, SKEW, s, o, d, false);
+    return _snapTransformed(p, pointer, true, constraint, SKEW, s, o, d, false);
 }
 
 /**
@@ -1122,12 +1107,13 @@ Geom::Point SnapManager::_transformPoint(Inkscape::SnapCandidatePoint const &p,
  * \param p The transformed position of the source point, paired with an identifier of the type of the snap source.
  */
 
-void SnapManager::_displaySnapsource(Inkscape::SnapPreferences::PointType point_type, Inkscape::SnapCandidatePoint const &p) const {
+void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) const {
 
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     if (prefs->getBool("/options/snapclosestonly/value")) {
-        bool p_is_a_node = point_type & Inkscape::SnapPreferences::SNAPPOINT_NODE;
-        bool p_is_a_bbox = point_type & Inkscape::SnapPreferences::SNAPPOINT_BBOX;
+        bool p_is_a_node = p.getSourceType() & Inkscape::SNAPSOURCE_NODE_CATEGORY;
+        bool p_is_a_bbox = p.getSourceType() & Inkscape::SNAPSOURCE_BBOX_CATEGORY;
+
         if (snapprefs.getSnapEnabledGlobally() && ((p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) {
             _desktop->snapindicator->set_new_snapsource(p);
         } else {
index ae136a355d7365cbce1230cd6c3b44d519ac8cf9..24a60eaf0ce152c6b85dfcbd87cc083d7171de26 100644 (file)
@@ -98,66 +98,56 @@ public:
 
     // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a
     // point if snapping has occurred (by overwriting p); otherwise p is untouched
-    void freeSnapReturnByRef(Inkscape::SnapPreferences::PointType point_type,
-                                Geom::Point &p,
+    void freeSnapReturnByRef(Geom::Point &p,
                                 Inkscape::SnapSourceType const source_type,
                                 Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const;
 
-    Inkscape::SnappedPoint freeSnap(Inkscape::SnapPreferences::PointType const point_type,
-                                    Inkscape::SnapCandidatePoint const &p,
+    Inkscape::SnappedPoint freeSnap(Inkscape::SnapCandidatePoint const &p,
                                     Geom::OptRect const &bbox_to_snap = Geom::OptRect() ) const;
 
     Geom::Point multipleOfGridPitch(Geom::Point const &t) const;
 
     // constrainedSnapReturnByRef() is preferred over constrainedSnap(), because it only returns a
     // point, by overwriting p, if snapping has occurred; otherwise p is untouched
-    void constrainedSnapReturnByRef(Inkscape::SnapPreferences::PointType point_type,
-                                    Geom::Point &p,
+    void constrainedSnapReturnByRef(Geom::Point &p,
                                     Inkscape::SnapSourceType const source_type,
                                     Inkscape::Snapper::ConstraintLine const &constraint,
                                     Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const;
 
-    Inkscape::SnappedPoint constrainedSnap(Inkscape::SnapPreferences::PointType const point_type,
-                                           Inkscape::SnapCandidatePoint const &p,
+    Inkscape::SnappedPoint constrainedSnap(Inkscape::SnapCandidatePoint const &p,
                                            Inkscape::Snapper::ConstraintLine const &constraint,
                                            Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const;
 
     void guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, SPGuideDragType drag_type) const;
     void guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const;
 
-    Inkscape::SnappedPoint freeSnapTranslation(Inkscape::SnapPreferences::PointType point_type,
-                                               std::vector<Inkscape::SnapCandidatePoint> const &p,
+    Inkscape::SnappedPoint freeSnapTranslation(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                                Geom::Point const &pointer,
                                                Geom::Point const &tr) const;
 
-    Inkscape::SnappedPoint constrainedSnapTranslation(Inkscape::SnapPreferences::PointType point_type,
-                                                      std::vector<Inkscape::SnapCandidatePoint> const &p,
+    Inkscape::SnappedPoint constrainedSnapTranslation(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                                       Geom::Point const &pointer,
                                                       Inkscape::Snapper::ConstraintLine const &constraint,
                                                       Geom::Point const &tr) const;
 
-    Inkscape::SnappedPoint freeSnapScale(Inkscape::SnapPreferences::PointType point_type,
-                                         std::vector<Inkscape::SnapCandidatePoint> const &p,
+    Inkscape::SnappedPoint freeSnapScale(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                          Geom::Point const &pointer,
                                          Geom::Scale const &s,
                                          Geom::Point const &o) const;
 
-    Inkscape::SnappedPoint constrainedSnapScale(Inkscape::SnapPreferences::PointType point_type,
-                                                std::vector<Inkscape::SnapCandidatePoint> const &p,
+    Inkscape::SnappedPoint constrainedSnapScale(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                                 Geom::Point const &pointer,
                                                 Geom::Scale const &s,
                                                 Geom::Point const &o) const;
 
-    Inkscape::SnappedPoint constrainedSnapStretch(Inkscape::SnapPreferences::PointType point_type,
-                                                  std::vector<Inkscape::SnapCandidatePoint> const &p,
+    Inkscape::SnappedPoint constrainedSnapStretch(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                                   Geom::Point const &pointer,
                                                   Geom::Coord const &s,
                                                   Geom::Point const &o,
                                                   Geom::Dim2 d,
                                                   bool uniform) const;
 
-    Inkscape::SnappedPoint constrainedSnapSkew(Inkscape::SnapPreferences::PointType point_type,
-                                               std::vector<Inkscape::SnapCandidatePoint> const &p,
+    Inkscape::SnappedPoint constrainedSnapSkew(std::vector<Inkscape::SnapCandidatePoint> const &p,
                                                Geom::Point const &pointer,
                                                Inkscape::Snapper::ConstraintLine const &constraint,
                                                Geom::Point const &s, // s[0] = skew factor, s[1] = scale factor
@@ -193,8 +183,7 @@ private:
     //correctly then in other cases the int is being used for Inkscape::SnapSourceType, or for both. How to make
     //this type safe?
 
-    Inkscape::SnappedPoint _snapTransformed(Inkscape::SnapPreferences::PointType type,
-                                            std::vector<Inkscape::SnapCandidatePoint> const &points,
+    Inkscape::SnappedPoint _snapTransformed(std::vector<Inkscape::SnapCandidatePoint> const &points,
                                             Geom::Point const &pointer,
                                             bool constrained,
                                             Inkscape::Snapper::ConstraintLine const &constraint,
@@ -211,7 +200,7 @@ private:
                                             Geom::Dim2 const dim,
                                             bool const uniform) const;
 
-    void _displaySnapsource(Inkscape::SnapPreferences::PointType point_type, Inkscape::SnapCandidatePoint const &p) const;
+    void _displaySnapsource(Inkscape::SnapCandidatePoint const &p) const;
 };
 
 #endif /* !SEEN_SNAP_H */
index 47c1c514e4ed389db63e55c0dd8b67b265cbf6a0..b5bb17de9240c210e58b0f6314c4d82b02faf8fa 100644 (file)
@@ -58,7 +58,6 @@ public:
     bool getSnapVisibleOnly() const {return _snap_visible_only;}
 
     virtual void freeSnap(SnappedConstraints &/*sc*/,
-                          SnapPreferences::PointType const &/*t*/,
                           Inkscape::SnapCandidatePoint const &/*p*/,
                           Geom::OptRect const &/*bbox_to_snap*/,
                           std::vector<SPItem const *> const */*it*/,
@@ -102,7 +101,6 @@ public:
     };
 
     virtual void constrainedSnap(SnappedConstraints &/*sc*/,
-                                 SnapPreferences::PointType const &/*t*/,
                                  Inkscape::SnapCandidatePoint const &/*p*/,
                                  Geom::OptRect const &/*bbox_to_snap*/,
                                  ConstraintLine const &/*c*/,
index 3825f74c7909376eba419ad1571d2f8e56bfc4e7..d751fae6dbc75781f3e0917b820300916e3a1533 100644 (file)
@@ -241,9 +241,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event)
 
                 SnapManager &m = desktop->namedview->snap_manager;
                 m.setup(desktop);
-                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);
 
                 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                     ( GDK_KEY_PRESS_MASK |
@@ -273,7 +271,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event)
 
                 SnapManager &m = desktop->namedview->snap_manager;
                 m.setup(desktop, true, sc->item);
-                m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, motion_dt, Inkscape::SNAPSOURCE_HANDLE);
+                m.freeSnapReturnByRef(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
                 sp_spiral_drag(sc, from_2geom(motion_dt), event->motion.state);
 
                 gobble_motion_events(GDK_BUTTON1_MASK);
@@ -424,7 +422,7 @@ sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state)
     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);
 
     Geom::Point const p0 = desktop->dt2doc(sc->center);
     Geom::Point const p1 = desktop->dt2doc(pt2g);
index 3d6825e31414d973319adfe5304016ddf26fe3b0..f67ca434d26c60311ebcd0b59e24f9d299831c43 100644 (file)
@@ -259,9 +259,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
             /* 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);
 
             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                 GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
@@ -437,7 +435,7 @@ static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state)
     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);
 
     Geom::Point const p0 = desktop->dt2doc(sc->center);
     Geom::Point const p1 = desktop->dt2doc(pt2g);
index ef98e7c84058a21f6045a2773a19f4c1a60353fa..f2bec1f5ffb3fa5a7295df47ce293886f428707d 100644 (file)
@@ -847,7 +847,6 @@ void Node::_draggedHandler(Geom::Point &new_pos, GdkEventMotion *event)
 {
     // For a note on how snapping is implemented in Inkscape, see snap.h.
     SnapManager &sm = _desktop->namedview->snap_manager;
-    Inkscape::SnapPreferences::PointType t = Inkscape::SnapPreferences::SNAPPOINT_NODE;
     bool snap = sm.someSnapperMightSnap();
     std::vector<Inkscape::SnapCandidatePoint> unselected;
     if (snap) {
@@ -882,8 +881,8 @@ void Node::_draggedHandler(Geom::Point &new_pos, GdkEventMotion *event)
             // TODO: combine these two branches by modifying snap.h / snap.cpp
             if (snap) {
                 Inkscape::SnappedPoint fp, bp;
-                fp = sm.constrainedSnap(t, Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_front);
-                bp = sm.constrainedSnap(t, Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_back);
+                fp = sm.constrainedSnap(Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_front);
+                bp = sm.constrainedSnap(Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_back);
 
                 if (fp.isOtherSnapBetter(bp, false)) {
                     bp.getPoint(new_pos);
@@ -906,8 +905,8 @@ void Node::_draggedHandler(Geom::Point &new_pos, GdkEventMotion *event)
                 Inkscape::SnappedPoint fp, bp;
                 Inkscape::Snapper::ConstraintLine line_x(origin, Geom::Point(1, 0));
                 Inkscape::Snapper::ConstraintLine line_y(origin, Geom::Point(0, 1));
-                fp = sm.constrainedSnap(t, Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_x);
-                bp = sm.constrainedSnap(t, Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_y);
+                fp = sm.constrainedSnap(Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_x);
+                bp = sm.constrainedSnap(Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_y);
 
                 if (fp.isOtherSnapBetter(bp, false)) {
                     fp = bp;
@@ -921,7 +920,7 @@ void Node::_draggedHandler(Geom::Point &new_pos, GdkEventMotion *event)
             }
         }
     } else if (snap) {
-        sm.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, new_pos, _snapSourceType());
+        sm.freeSnapReturnByRef(new_pos, _snapSourceType());
     }
 }