Code

Fix self-snapping when dragging the transformation center of a selection containing...
[inkscape.git] / src / flood-context.cpp
index a45ec5dfe79569b53d5e19359789447216322e76..12a8febe2f75027fbe296dea06172722b11aece9 100644 (file)
@@ -46,6 +46,7 @@
 #include "preferences.h"
 #include "context-fns.h"
 #include "rubberband.h"
+#include "shape-editor.h"
 
 #include "display/nr-arena-item.h"
 #include "display/nr-arena.h"
@@ -133,9 +134,6 @@ static void sp_flood_context_init(SPFloodContext *flood_context)
     event_context->within_tolerance = false;
     event_context->item_to_select = NULL;
 
-    event_context->shape_repr = NULL;
-    event_context->shape_knot_holder = NULL;
-
     flood_context->item = NULL;
 
     new (&flood_context->sel_changed_connection) sigc::connection();
@@ -149,17 +147,14 @@ static void sp_flood_context_dispose(GObject *object)
     rc->sel_changed_connection.disconnect();
     rc->sel_changed_connection.~connection();
 
+    delete ec->shape_editor;
+    ec->shape_editor = NULL;
+
     /* fixme: This is necessary because we do not grab */
     if (rc->item) {
         sp_flood_finish(rc);
     }
 
-    if (ec->shape_repr) { // remove old listener
-        sp_repr_remove_listener_by_data(ec->shape_repr, ec);
-        Inkscape::GC::release(ec->shape_repr);
-        ec->shape_repr = 0;
-    }
-
     if (rc->_message_context) {
         delete rc->_message_context;
     }
@@ -167,14 +162,6 @@ static void sp_flood_context_dispose(GObject *object)
     G_OBJECT_CLASS(parent_class)->dispose(object);
 }
 
-static Inkscape::XML::NodeEventVector ec_shape_repr_events = {
-    NULL, /* child_added */
-    NULL, /* child_removed */
-    ec_shape_event_attr_changed,
-    NULL, /* content_changed */
-    NULL  /* order_changed */
-};
-
 /**
 \brief  Callback that processes the "changed" signal on the selection;
 destroys old and creates new knotholder
@@ -184,21 +171,9 @@ void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer
     SPFloodContext *rc = SP_FLOOD_CONTEXT(data);
     SPEventContext *ec = SP_EVENT_CONTEXT(rc);
 
-    if (ec->shape_repr) { // remove old listener
-        sp_repr_remove_listener_by_data(ec->shape_repr, ec);
-        Inkscape::GC::release(ec->shape_repr);
-        ec->shape_repr = 0;
-    }
-
-    SPItem *item = selection->singleItem();
-    if (item) {
-        Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
-        if (shape_repr) {
-            ec->shape_repr = shape_repr;
-            Inkscape::GC::anchor(shape_repr);
-            sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
-        }
-    }
+    ec->shape_editor->unset_item(SH_KNOTHOLDER);
+    SPItem *item = selection->singleItem(); 
+    ec->shape_editor->set_item(item, SH_KNOTHOLDER);
 }
 
 static void sp_flood_context_setup(SPEventContext *ec)
@@ -209,14 +184,11 @@ static void sp_flood_context_setup(SPEventContext *ec)
         ((SPEventContextClass *) parent_class)->setup(ec);
     }
 
+    ec->shape_editor = new ShapeEditor(ec->desktop);
+
     SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
     if (item) {
-        Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
-        if (shape_repr) {
-            ec->shape_repr = shape_repr;
-            Inkscape::GC::anchor(shape_repr);
-            sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
-        }
+        ec->shape_editor->set_item(item, SH_KNOTHOLDER);
     }
 
     rc->sel_changed_connection.disconnect();
@@ -289,10 +261,10 @@ GList * flood_channels_dropdown_items_list() {
 GList * flood_autogap_dropdown_items_list() {
     GList *glist = NULL;
 
-    glist = g_list_append (glist, _("None"));
-    glist = g_list_append (glist, _("Small"));
-    glist = g_list_append (glist, _("Medium"));
-    glist = g_list_append (glist, _("Large"));
+    glist = g_list_append (glist, (void*) C_("Flood autogap", "None"));
+    glist = g_list_append (glist, (void*) C_("Flood autogap", "Small"));
+    glist = g_list_append (glist, (void*) C_("Flood autogap", "Medium"));
+    glist = g_list_append (glist, (void*) C_("Flood autogap", "Large"));
 
     return glist;
 }
@@ -928,7 +900,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
     if (is_point_fill) {
         fill_points.push_back(Geom::Point(event->button.x, event->button.y));
     } else {
-        Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop);
+        Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
         fill_points = r->getPoints();
     }
 
@@ -1234,7 +1206,7 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven
 
     case GDK_BUTTON_RELEASE:
         if (event->button.button == 1 && !event_context->space_panning) {
-            Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop);
+            Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
             if (r->is_started()) {
                 // set "busy" cursor
                 desktop->setWaitingCursor();