Code

Merge from trunk.
[inkscape.git] / src / tweak-context.cpp
index 156ce0169b555ea0e00e2f172c7c7be72d7a34ff..1d0c004a4a40fc448a9cc87da6f729ab8734701c 100644 (file)
@@ -1,10 +1,10 @@
-#define __SP_TWEAK_CONTEXT_C__
-
 /*
  * tweaking paths without node editing
  *
  * Authors:
  *   bulia byak
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2007 authors
  *
@@ -21,7 +21,6 @@
 
 #include "svg/svg.h"
 #include "display/canvas-bpath.h"
-#include "display/bezier-utils.h"
 
 #include <glib/gmem.h>
 #include "macros.h"
@@ -30,7 +29,6 @@
 #include "desktop.h"
 #include "desktop-events.h"
 #include "desktop-handles.h"
-#include "desktop-affine.h"
 #include "desktop-style.h"
 #include "message-context.h"
 #include "pixmaps/cursor-tweak-move.xpm"
@@ -57,7 +55,6 @@
 #include "path-chemistry.h"
 #include "sp-gradient.h"
 #include "sp-stop.h"
-#include "sp-stop-fns.h"
 #include "sp-gradient-reference.h"
 #include "sp-linear-gradient.h"
 #include "sp-radial-gradient.h"
@@ -80,6 +77,8 @@
 
 #include "tweak-context.h"
 
+using Inkscape::DocumentUndo;
+
 #define DDC_RED_RGBA 0xff0000ff
 
 #define DYNA_MIN_WIDTH 1.0e-6
@@ -210,23 +209,27 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift)
    switch (tc->mode) {
        case TWEAK_MODE_MOVE:
            tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>move</b>."), sel_message);
-                           break;
            event_context->cursor_shape = cursor_tweak_move_xpm;
            break;
        case TWEAK_MODE_MOVE_IN_OUT:
            tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move in</b>; with Shift to <b>move out</b>."), sel_message);
+           event_context->cursor_shape = cursor_tweak_move_xpm;
            break;
        case TWEAK_MODE_MOVE_JITTER:
            tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move randomly</b>."), sel_message);
+           event_context->cursor_shape = cursor_tweak_move_xpm;
            break;
        case TWEAK_MODE_SCALE:
            tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>scale down</b>; with Shift to <b>scale up</b>."), sel_message);
+           event_context->cursor_shape = cursor_tweak_move_xpm;
            break;
        case TWEAK_MODE_ROTATE:
            tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>rotate clockwise</b>; with Shift, <b>counterclockwise</b>."), sel_message);
+           event_context->cursor_shape = cursor_tweak_move_xpm;
            break;
        case TWEAK_MODE_MORELESS:
            tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>duplicate</b>; with Shift, <b>delete</b>."), sel_message);
+           event_context->cursor_shape = cursor_tweak_move_xpm;
            break;
        case TWEAK_MODE_PUSH:
            tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>push paths</b>."), sel_message);
@@ -254,6 +257,7 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift)
            break;
        case TWEAK_MODE_COLORPAINT:
            tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>paint objects</b> with color."), sel_message);
+           event_context->cursor_shape = cursor_color_xpm;
            break;
        case TWEAK_MODE_COLORJITTER:
            tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>randomize colors</b>."), sel_message);
@@ -422,17 +426,25 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
     }
 
     if (SP_IS_GROUP(item) && !SP_IS_BOX3D(item)) {
-        for (SPObject *child = sp_object_first_child(SP_OBJECT(item)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+        GSList *children = NULL;
+        for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
             if (SP_IS_ITEM(child)) {
-                if (sp_tweak_dilate_recursive (selection, SP_ITEM(child), p, vector, mode, radius, force, fidelity, reverse))
-                    did = true;
+                children = g_slist_prepend(children, child);
             }
         }
 
+        for (GSList *i = children; i; i = i->next) {
+            SPItem *child = SP_ITEM(i->data);
+            if (sp_tweak_dilate_recursive (selection, SP_ITEM(child), p, vector, mode, radius, force, fidelity, reverse))
+                did = true;
+        }
+
+        g_slist_free(children);
+
     } else {
         if (mode == TWEAK_MODE_MOVE) {
 
-            Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+            Geom::OptRect a = item->getBounds(item->i2doc_affine());
             if (a) {
                 double x = Geom::L2(a->midpoint() - p)/radius;
                 if (a->contains(p)) x = 0;
@@ -445,7 +457,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
         } else if (mode == TWEAK_MODE_MOVE_IN_OUT) {
 
-            Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+            Geom::OptRect a = item->getBounds(item->i2doc_affine());
             if (a) {
                 double x = Geom::L2(a->midpoint() - p)/radius;
                 if (a->contains(p)) x = 0;
@@ -459,7 +471,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
         } else if (mode == TWEAK_MODE_MOVE_JITTER) {
 
-            Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+            Geom::OptRect a = item->getBounds(item->i2doc_affine());
             if (a) {
                 double dp = g_random_double_range(0, M_PI*2);
                 double dr = g_random_double_range(0, radius);
@@ -474,7 +486,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
         } else if (mode == TWEAK_MODE_SCALE) {
 
-            Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+            Geom::OptRect a = item->getBounds(item->i2doc_affine());
             if (a) {
                 double x = Geom::L2(a->midpoint() - p)/radius;
                 if (a->contains(p)) x = 0;
@@ -487,7 +499,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
         } else if (mode == TWEAK_MODE_ROTATE) {
 
-            Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+            Geom::OptRect a = item->getBounds(item->i2doc_affine());
             if (a) {
                 double x = Geom::L2(a->midpoint() - p)/radius;
                 if (a->contains(p)) x = 0;
@@ -500,7 +512,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
         } else if (mode == TWEAK_MODE_MORELESS) {
 
-            Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+            Geom::OptRect a = item->getBounds(item->i2doc_affine());
             if (a) {
                 double x = Geom::L2(a->midpoint() - p)/radius;
                 if (a->contains(p)) x = 0;
@@ -514,7 +526,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
                             sp_object_unref(SP_OBJECT(item), NULL);
                         } else { // duplicate
                             SPDocument *doc = SP_OBJECT_DOCUMENT(item);
-                            Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc);
+                            Inkscape::XML::Document* xml_doc = doc->getReprDoc();
                             Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(item);
                             SPObject *old_obj = doc->getObjectByRepr(old_repr);
                             Inkscape::XML::Node *parent = old_repr->parent();
@@ -526,6 +538,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
                             }
                             Inkscape::GC::release(copy);
                         }
+                        did = true;
                     }
                 }
             }
@@ -551,7 +564,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
 
         // skip those paths whose bboxes are entirely out of reach with our radius
-        Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item));
+        Geom::OptRect bbox = item->getBounds(item->i2doc_affine());
         if (bbox) {
             bbox->expandBy(radius);
             if (!bbox->contains(p)) {
@@ -569,7 +582,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
         Shape *theShape = new Shape;
         Shape *theRes = new Shape;
-        Geom::Matrix i2doc(sp_item_i2doc_affine(item));
+        Geom::Matrix i2doc(item->i2doc_affine());
 
         orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / i2doc.descrim()); // default 0.059
         orig->Fill(theShape, 0);
@@ -782,7 +795,7 @@ tweak_profile (double dist, double radius)
 
 void
 tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke,
-                          guint32 const rgb_goal, NR::Point p_w, double radius, double force, guint mode,
+                          guint32 const rgb_goal, Geom::Point p_w, double radius, double force, guint mode,
                           bool do_h, bool do_s, bool do_l, bool /*do_o*/)
 {
     SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
@@ -790,8 +803,8 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke,
     if (!gradient || !SP_IS_GRADIENT(gradient))
         return;
 
-    NR::Matrix i2d (sp_item_i2doc_affine (item));
-    NR::Point p = p_w * i2d.inverse();
+    Geom::Matrix i2d (item->i2doc_affine ());
+    Geom::Point p = p_w * i2d.inverse();
     p *= (gradient->gradientTransform).inverse();
     // now p is in gradient's original coordinates
 
@@ -800,46 +813,50 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke,
     if (SP_IS_LINEARGRADIENT(gradient)) {
         SPLinearGradient *lg = SP_LINEARGRADIENT(gradient);
 
-        NR::Point p1(lg->x1.computed, lg->y1.computed);
-        NR::Point p2(lg->x2.computed, lg->y2.computed);
-        NR::Point pdiff(p2 - p1);
-        double vl = NR::L2(pdiff);
+        Geom::Point p1(lg->x1.computed, lg->y1.computed);
+        Geom::Point p2(lg->x2.computed, lg->y2.computed);
+        Geom::Point pdiff(p2 - p1);
+        double vl = Geom::L2(pdiff);
 
         // This is the matrix which moves and rotates the gradient line
         // so it's oriented along the X axis:
-        NR::Matrix norm = NR::Matrix(Geom::Translate(-p1)) * NR::Matrix(Geom::Rotate(-atan2(pdiff[NR::Y], pdiff[NR::X])));
+        Geom::Matrix norm = Geom::Matrix(Geom::Translate(-p1)) * Geom::Matrix(Geom::Rotate(-atan2(pdiff[Geom::Y], pdiff[Geom::X])));
 
         // Transform the mouse point by it to find out its projection onto the gradient line:
-        NR::Point pnorm = p * norm;
+        Geom::Point pnorm = p * norm;
 
         // Scale its X coordinate to match the length of the gradient line:
-        pos = pnorm[NR::X] / vl;
+        pos = pnorm[Geom::X] / vl;
         // Calculate radius in lenfth-of-gradient-line units
         r = radius / vl;
 
     } else if (SP_IS_RADIALGRADIENT(gradient)) {
         SPRadialGradient *rg = SP_RADIALGRADIENT(gradient);
-        NR::Point c (rg->cx.computed, rg->cy.computed);
-        pos = NR::L2(p - c) / rg->r.computed;
+        Geom::Point c (rg->cx.computed, rg->cy.computed);
+        pos = Geom::L2(p - c) / rg->r.computed;
         r = radius / rg->r.computed;
     }
 
     // Normalize pos to 0..1, taking into accound gradient spread:
     double pos_e = pos;
-    if (gradient->spread == SP_GRADIENT_SPREAD_PAD) {
-        if (pos > 1)
+    if (gradient->getSpread() == SP_GRADIENT_SPREAD_PAD) {
+        if (pos > 1) {
             pos_e = 1;
-        if (pos < 0)
+        }
+        if (pos < 0) {
             pos_e = 0;
-    } else if (gradient->spread == SP_GRADIENT_SPREAD_REPEAT) {
-        if (pos > 1 || pos < 0)
+        }
+    } else if (gradient->getSpread() == SP_GRADIENT_SPREAD_REPEAT) {
+        if (pos > 1 || pos < 0) {
             pos_e = pos - floor(pos);
-    } else if (gradient->spread == SP_GRADIENT_SPREAD_REFLECT) {
+        }
+    } else if (gradient->getSpread() == SP_GRADIENT_SPREAD_REFLECT) {
         if (pos > 1 || pos < 0) {
             bool odd = ((int)(floor(pos)) % 2 == 1);
             pos_e = pos - floor(pos);
-            if (odd)
+            if (odd) {
                 pos_e = 1 - pos_e;
+            }
         }
     }
 
@@ -848,10 +865,10 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke,
     double offset_l = 0;
     double offset_h = 0;
     SPObject *child_prev = NULL;
-    for (SPObject *child = sp_object_first_child(vector);
-         child != NULL; child = SP_OBJECT_NEXT(child)) {
-        if (!SP_IS_STOP(child))
+    for (SPObject *child = vector->firstChild(); child; child = child->getNext()) {
+        if (!SP_IS_STOP(child)) {
             continue;
+        }
         SPStop *stop = SP_STOP (child);
 
         offset_h = stop->offset;
@@ -902,13 +919,13 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
                           guint32 stroke_goal, bool do_stroke,
                           float opacity_goal, bool do_opacity,
                           bool do_blur, bool reverse,
-                          NR::Point p, double radius, double force,
+                          Geom::Point p, double radius, double force,
                           bool do_h, bool do_s, bool do_l, bool do_o)
 {
     bool did = false;
 
     if (SP_IS_GROUP(item)) {
-        for (SPObject *child = sp_object_first_child(SP_OBJECT(item)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+        for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
             if (SP_IS_ITEM(child)) {
                 if (sp_tweak_color_recursive (mode, SP_ITEM(child), item_at_point,
                                           fill_goal, do_fill,
@@ -925,7 +942,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
         if (!style) {
             return false;
         }
-        Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item),
+        Geom::OptRect bbox = item->getBounds(item->i2doc_affine(),
                                                         SPItem::GEOMETRIC_BBOX);
         if (!bbox) {
             return false;
@@ -933,7 +950,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
 
         Geom::Rect brush(p - Geom::Point(radius, radius), p + Geom::Point(radius, radius));
 
-        NR::Point center = bbox->midpoint();
+        Geom::Point center = bbox->midpoint();
         double this_force;
 
 // if item == item_at_point, use max force
@@ -949,20 +966,20 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
 // else if object > 0.5 brush: test 4 corners of bbox and center on being in the brush, choose max
 // else if still smaller, then check only the object center:
         } else {
-            this_force = force * tweak_profile (NR::L2 (p - center), radius);
+            this_force = force * tweak_profile (Geom::L2 (p - center), radius);
         }
 
         if (this_force > 0.002) {
 
             if (do_blur) {
-                Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item),
+                Geom::OptRect bbox = item->getBounds(item->i2doc_affine(),
                                                         SPItem::GEOMETRIC_BBOX);
                 if (!bbox) {
                     return did;
                 }
 
                 double blur_now = 0;
-                Geom::Matrix i2d = sp_item_i2d_affine (item);
+                Geom::Matrix i2d = item->i2d_affine ();
                 if (style->filter.set && style->getFilter()) {
                     //cycle through filter primitives
                     SPObject *primitive_obj = style->getFilter()->children;
@@ -1033,7 +1050,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
 
 
 bool
-sp_tweak_dilate (SPTweakContext *tc, NR::Point event_p, NR::Point p, NR::Point vector, bool reverse)
+sp_tweak_dilate (SPTweakContext *tc, Geom::Point event_p, Geom::Point p, Geom::Point vector, bool reverse)
 {
     Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop);
     SPDesktop *desktop = SP_EVENT_CONTEXT(tc)->desktop;
@@ -1045,7 +1062,7 @@ sp_tweak_dilate (SPTweakContext *tc, NR::Point event_p, NR::Point p, NR::Point v
     bool did = false;
     double radius = get_dilate_radius(tc);
 
-    SPItem *item_at_point = SP_EVENT_CONTEXT(tc)->desktop->item_at_point(event_p, TRUE);
+    SPItem *item_at_point = SP_EVENT_CONTEXT(tc)->desktop->getItemAtPoint(event_p, TRUE);
 
     bool do_fill = false, do_stroke = false, do_opacity = false;
     guint32 fill_goal = sp_desktop_get_color_tool(desktop, "/tools/tweak", true, &do_fill);
@@ -1123,7 +1140,7 @@ void
 sp_tweak_update_area (SPTweakContext *tc)
 {
         double radius = get_dilate_radius(tc);
-        NR::Matrix const sm (Geom::Scale(radius, radius) * Geom::Translate(SP_EVENT_CONTEXT(tc)->desktop->point()));
+        Geom::Matrix const sm (Geom::Scale(radius, radius) * Geom::Translate(SP_EVENT_CONTEXT(tc)->desktop->point()));
         sp_canvas_item_affine_absolute(tc->dilate_area, sm);
         sp_canvas_item_show(tc->dilate_area);
 }
@@ -1174,9 +1191,9 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
                     return TRUE;
                 }
 
-                NR::Point const button_w(event->button.x,
+                Geom::Point const button_w(event->button.x,
                                          event->button.y);
-                NR::Point const button_dt(desktop->w2d(button_w));
+                Geom::Point const button_dt(desktop->w2d(button_w));
                 tc->last_push = desktop->dt2doc(button_dt);
 
                 sp_tweak_extinput(tc, event);
@@ -1191,15 +1208,15 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
             break;
         case GDK_MOTION_NOTIFY:
         {
-            NR::Point const motion_w(event->motion.x,
+            Geom::Point const motion_w(event->motion.x,
                                      event->motion.y);
-            NR::Point motion_dt(desktop->w2d(motion_w));
-            NR::Point motion_doc(desktop->dt2doc(motion_dt));
+            Geom::Point motion_dt(desktop->w2d(motion_w));
+            Geom::Point motion_doc(desktop->dt2doc(motion_dt));
             sp_tweak_extinput(tc, event);
 
             // draw the dilating cursor
                 double radius = get_dilate_radius(tc);
-                NR::Matrix const sm (Geom::Scale(radius, radius) * Geom::Translate(desktop->w2d(motion_w)));
+                Geom::Matrix const sm (Geom::Scale(radius, radius) * Geom::Translate(desktop->w2d(motion_w)));
                 sp_canvas_item_affine_absolute(tc->dilate_area, sm);
                 sp_canvas_item_show(tc->dilate_area);
 
@@ -1227,8 +1244,8 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
 
     case GDK_BUTTON_RELEASE:
     {
-        NR::Point const motion_w(event->button.x, event->button.y);
-        NR::Point const motion_dt(desktop->w2d(motion_w));
+        Geom::Point const motion_w(event->button.x, event->button.y);
+        Geom::Point const motion_dt(desktop->w2d(motion_w));
 
         sp_canvas_end_forced_full_redraws(desktop->canvas);
         tc->is_drawing = false;
@@ -1237,62 +1254,62 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
             if (!tc->has_dilated) {
                 // if we did not rub, do a light tap
                 tc->pressure = 0.03;
-                sp_tweak_dilate (tc, motion_w, desktop->dt2doc(motion_dt), NR::Point(0,0), MOD__SHIFT);
+                sp_tweak_dilate (tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT);
             }
             tc->is_dilating = false;
             tc->has_dilated = false;
             switch (tc->mode) {
                 case TWEAK_MODE_MOVE:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Move tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Move tweak"));
                     break;
                 case TWEAK_MODE_MOVE_IN_OUT:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Move in/out tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Move in/out tweak"));
                     break;
                 case TWEAK_MODE_MOVE_JITTER:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Move jitter tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Move jitter tweak"));
                     break;
                 case TWEAK_MODE_SCALE:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Scale tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Scale tweak"));
                     break;
                 case TWEAK_MODE_ROTATE:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Rotate tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Rotate tweak"));
                     break;
                 case TWEAK_MODE_MORELESS:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Duplicate/delete tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Duplicate/delete tweak"));
                     break;
                 case TWEAK_MODE_PUSH:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Push path tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Push path tweak"));
                     break;
                 case TWEAK_MODE_SHRINK_GROW:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Shrink/grow path tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Shrink/grow path tweak"));
                     break;
                 case TWEAK_MODE_ATTRACT_REPEL:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Attract/repel path tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Attract/repel path tweak"));
                     break;
                 case TWEAK_MODE_ROUGHEN:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Roughen path tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Roughen path tweak"));
                     break;
                 case TWEAK_MODE_COLORPAINT:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Color paint tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Color paint tweak"));
                     break;
                 case TWEAK_MODE_COLORJITTER:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Color jitter tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Color jitter tweak"));
                     break;
                 case TWEAK_MODE_BLUR:
-                    sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
-                                     SP_VERB_CONTEXT_TWEAK, _("Blur tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Blur tweak"));
                     break;
             }
         }
@@ -1524,4 +1541,4 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :