Code

Filter effects dialog:
[inkscape.git] / src / gradient-context.cpp
index c44cf1c594231e77369170209c52d4bbb320cf8a..e9192652a63675b2736a02c1e00c1f6dceb8a36a 100644 (file)
@@ -44,7 +44,8 @@
 #include "sp-stop.h"
 #include "svg/css-ostringstream.h"
 #include "svg/svg-color.h"
-
+#include "snap.h"
+#include "sp-namedview.h"
 
 
 
@@ -272,7 +273,7 @@ sp_gradient_context_add_stop_near_point (SPGradientContext *rc, SPItem *item,  N
     } while (!fill_or_stroke && !addknot) ;
 
     if (addknot) {
-        SPGradient *vector = sp_gradient_get_vector (gradient, false);
+        SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (gradient, false);
         SPStop* prev_stop = sp_first_stop(vector);
         SPStop* next_stop = sp_next_stop(prev_stop);
         while ( (next_stop) && (next_stop->offset < offset) ) {
@@ -285,7 +286,7 @@ sp_gradient_context_add_stop_near_point (SPGradientContext *rc, SPItem *item,  N
         }
 
         Inkscape::XML::Node *new_stop_repr = NULL;
-        new_stop_repr = SP_OBJECT_REPR(prev_stop)->duplicate();
+        new_stop_repr = SP_OBJECT_REPR(prev_stop)->duplicate(SP_OBJECT_REPR(vector)->document());
         SP_OBJECT_REPR(vector)->addChild(new_stop_repr, SP_OBJECT_REPR(prev_stop));
 
         SPStop *newstop = (SPStop *) SP_OBJECT_DOCUMENT(vector)->getObjectByRepr(new_stop_repr);
@@ -410,8 +411,9 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
             /* Position center */
             NR::Point const button_dt = desktop->w2d(button_w);
             /* Snap center to nearest magnetic point */
-
-            rc->origin = button_dt;
+            
+            SnapManager const &m = desktop->namedview->snap_manager;
+            rc->origin = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, button_dt, NULL).getPoint();
 
             ret = TRUE;
         }