Code

display/inkscape-cairo.h: Supply missing #includes/declarations so that we don't...
[inkscape.git] / src / star-context.cpp
index 385d16d0cbcf8df34e5c6dd04337f88afe86e20a..c5fa5a0b975ce3907be51ad74e66e269de4da3e8 100644 (file)
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <cstring>
+#include <string>
 
 #include <gdk/gdkkeysyms.h>
 
@@ -127,7 +132,7 @@ sp_star_context_dispose (GObject *object)
     sc->sel_changed_connection.~connection();
 
     if (ec->shape_knot_holder) {
-        sp_knot_holder_destroy (ec->shape_knot_holder);
+        delete ec->shape_knot_holder;
         ec->shape_knot_holder = NULL;
     }
 
@@ -169,7 +174,7 @@ sp_star_context_selection_changed (Inkscape::Selection * selection, gpointer dat
     SPEventContext *ec = SP_EVENT_CONTEXT (sc);
 
     if (ec->shape_knot_holder) { // desktroy knotholder
-        sp_knot_holder_destroy (ec->shape_knot_holder);
+        delete ec->shape_knot_holder;
         ec->shape_knot_holder = NULL;
     }
 
@@ -274,9 +279,11 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
             dragging = TRUE;
 
             sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event);
-
-            SnapManager const &m = desktop->namedview->snap_manager;
-            sc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, sc->center, sc->item).getPoint();
+            
+            /* Snap center */
+            SnapManager &m = desktop->namedview->snap_manager;
+            m.setup(desktop, NULL); //null, because we don't have an item yet
+            m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, sc->center);     
 
             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                 GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
@@ -299,12 +306,12 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
             event_context->within_tolerance = false;
 
             NR::Point const motion_w(event->motion.x, event->motion.y);
-            NR::Point motion_dt(event_context->desktop->w2d(motion_w));
-            
-            SnapManager const &m = desktop->namedview->snap_manager;
-            motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt, sc->item).getPoint();
+            NR::Point motion_dt(desktop->w2d(motion_w));
             
             sp_star_drag (sc, motion_dt, event->motion.state);
+
+            gobble_motion_events(GDK_BUTTON1_MASK);
+
             ret = TRUE;
         }
         break;
@@ -439,13 +446,14 @@ static void sp_star_drag(SPStarContext *sc, NR::Point p, guint state)
         sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
     }
 
+    /* Snap corner point with no constraints */
+    SnapManager &m = desktop->namedview->snap_manager;
+    m.setup(desktop, sc->item);
+    m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);    
+    
     NR::Point const p0 = sp_desktop_dt2root_xy_point(desktop, sc->center);
     NR::Point p1 = sp_desktop_dt2root_xy_point(desktop, p);
-
-    /* Snap corner point with no constraints */
-    SnapManager const &m = desktop->namedview->snap_manager;
-    p1 = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p1, sc->item).getPoint();
-
+    
     SPStar *star = SP_STAR(sc->item);
 
     double const sides = (gdouble) sc->magnitude;
@@ -463,7 +471,7 @@ static void sp_star_drag(SPStarContext *sc, NR::Point p, guint state)
 
     /* status text */
     GString *rads = SP_PX_TO_METRIC_STRING(r1, desktop->namedview->getDefaultMetric());
-    sc->_message_context->setF(Inkscape::NORMAL_MESSAGE,
+    sc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE,
                                ( sc->isflatsided?
                                  _("<b>Polygon</b>: radius %s, angle %5g&#176;; with <b>Ctrl</b> to snap angle")
                                  : _("<b>Star</b>: radius %s, angle %5g&#176;; with <b>Ctrl</b> to snap angle") ),