Code

* on-canvas clip and mask editing :) in the object menu you can find how to edit...
[inkscape.git] / src / nodepath.cpp
index 38552f7f785ee95567b27b1ce4fba0faf74ecd12..e03484d7a383033b8af80f7499e5b8040ad11f62 100644 (file)
@@ -47,6 +47,8 @@
 #include "display/bezier-utils.h"
 #include <vector>
 #include <algorithm>
+#include <cstring>
+#include <string>
 #include "live_effects/lpeobject.h"
 #include "live_effects/parameter/parameter.h"
 #include "util/mathfns.h"
@@ -199,6 +201,8 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object,
     np->local_change = 0;
     np->show_handles = show_handles;
     np->helper_path = NULL;
+    np->helperpath_rgba = 0xff0000ff;
+    np->helperpath_width = 1.0;
     np->curve = sp_curve_copy(curve);
     np->show_helperpath = false;
     np->straight_path = false;
@@ -1391,7 +1395,8 @@ void sp_node_selected_move_absolute(Inkscape::NodePath::Path *nodepath, NR::Coor
  */
 NR::Maybe<NR::Coord> sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis)
 {
-    g_return_val_if_fail(nodepath->selected, NR::Nothing());
+    NR::Maybe<NR::Coord> no_coord = NR::Nothing();
+    g_return_val_if_fail(nodepath->selected, no_coord);
 
     // determine coordinate of first selected node
     GList *nsel = nodepath->selected;
@@ -4538,6 +4543,26 @@ void sp_nodepath_set_curve (Inkscape::NodePath::Path *np, SPCurve *curve) {
 
 void sp_nodepath_show_helperpath(Inkscape::NodePath::Path *np, bool show) {
     np->show_helperpath = show;
+
+    if (show) {
+        SPCurve *helper_curve = sp_curve_copy(np->curve);
+        sp_curve_transform(helper_curve, np->i2d );
+        if (!np->helper_path) {
+            np->helper_path = sp_canvas_bpath_new(sp_desktop_controls(np->desktop), helper_curve);
+            sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(np->helper_path), np->helperpath_rgba, np->helperpath_width, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
+            sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(np->helper_path), 0, SP_WIND_RULE_NONZERO);
+            sp_canvas_item_show(np->helper_path);
+        } else {
+            sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(np->helper_path), helper_curve);
+        }
+        sp_curve_unref(helper_curve);
+    } else {
+        if (np->helper_path) {
+            GtkObject *temp = np->helper_path;
+            np->helper_path = NULL;
+            gtk_object_destroy(temp);
+        }
+    }
 }
 
 /* this function does not work yet */