Code

move shape_editor from node context to the parent class, event context
authorbuliabyak <buliabyak@users.sourceforge.net>
Thu, 8 Jan 2009 05:34:40 +0000 (05:34 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Thu, 8 Jan 2009 05:34:40 +0000 (05:34 +0000)
src/desktop.cpp
src/event-context.cpp
src/event-context.h
src/live_effects/parameter/path.cpp
src/node-context.cpp
src/node-context.h
src/selection-chemistry.cpp
src/sp-lpe-item.cpp
src/ui/dialog/align-and-distribute.cpp
src/verbs.cpp
src/widgets/toolbox.cpp

index 85c53be6fe91d8fe96de847cd4d2b85a1979384c..8b60291ef36c8c39df023a0bc1ee2037acaf3c78 100644 (file)
@@ -883,9 +883,8 @@ SPDesktop::zoom_quick (bool enable)
         if (!zoomed) {
             SPItem * singleItem = selection->singleItem();
             if (singleItem != NULL && tools_isactive(this, TOOLS_NODES)) {
-                SPNodeContext * ncontext = SP_NODE_CONTEXT(event_context);
 
-                Inkscape::NodePath::Path * nodepath = ncontext->shape_editor->get_nodepath();
+                Inkscape::NodePath::Path * nodepath = event_context->shape_editor->get_nodepath();
                 // printf("I've got a nodepath, crazy\n");
 
                 Geom::Rect nodes;
index 963bf2d7e67b16f3e92b72b7378a1199bc13c55a..7039c3b130c050ef37d87de12f61e4ae4f4c0991 100644 (file)
@@ -141,6 +141,7 @@ sp_event_context_init(SPEventContext *event_context)
     event_context->_selcue = NULL;
     event_context->_grdrag = NULL;
     event_context->space_panning = false;
+    event_context->shape_editor = NULL;
 }
 
 /**
@@ -1058,48 +1059,9 @@ sp_event_context_over_item (SPDesktop *desktop, SPItem *item, Geom::Point const
 ShapeEditor *
 sp_event_context_get_shape_editor (SPEventContext *ec)
 {
-    if (SP_IS_NODE_CONTEXT(ec)) {
-        return SP_NODE_CONTEXT(ec)->shape_editor;
-    } else if (SP_IS_LPETOOL_CONTEXT(ec)) {
-        return SP_LPETOOL_CONTEXT(ec)->shape_editor;
-    } else {
-        g_warning("ShapeEditor only exists in Node and Geometric Tool.");
-        return NULL;
-    }
-}
-
-/**
- * Called when SPEventContext subclass node attribute changed.
- */
-void
-ec_shape_event_attr_changed(Inkscape::XML::Node */*shape_repr*/, gchar const *name,
-                            gchar const */*old_value*/, gchar const */*new_value*/,
-                            bool const /*is_interactive*/, gpointer const data)
-{
-    if (!name
-            || !strcmp(name, "style")
-            || SP_ATTRIBUTE_IS_CSS(sp_attribute_lookup(name))) {
-        // no need to regenrate knotholder if only style changed
-        return;
-    }
-
-    SPEventContext *ec = SP_EVENT_CONTEXT(data);
-
-    if (ec->shape_knot_holder) {
-        delete ec->shape_knot_holder;
-    }
-    ec->shape_knot_holder = NULL;
-
-    SPDesktop *desktop = ec->desktop;
-
-    SPItem *item = sp_desktop_selection(desktop)->singleItem();
-
-    if (item) {
-        ec->shape_knot_holder = sp_item_knot_holder(item, desktop);
-    }
+    return ec->shape_editor;
 }
 
-
 void
 event_context_print_event_info(GdkEvent *event, bool print_return) {
     switch (event->type) {
index 9b464b7fa8e2c751fc34425b80f5d3465d7a0221..37b0ea75be45136e401788b71f0c530b6a49a069 100644 (file)
@@ -72,8 +72,7 @@ struct SPEventContext : public GObject {
     GrDrag *_grdrag;
     GrDrag *get_drag () {return _grdrag;}
 
-    KnotHolder *shape_knot_holder;
-    Inkscape::XML::Node *shape_repr;
+    ShapeEditor* shape_editor;
 
     bool space_panning;
 };
index 78ebca38470774152a10c28789fff6b5a84ebee3..1214a1766db3281d66926d12c91bcd9475159468 100644 (file)
@@ -200,7 +200,7 @@ PathParam::param_editOncanvas(SPItem * item, SPDesktop * dt)
         tools_switch(dt, TOOLS_NODES);
     }
 
-    ShapeEditor * shape_editor = SP_NODE_CONTEXT( dt->event_context )->shape_editor;
+    ShapeEditor * shape_editor = dt->event_context->shape_editor;
     if (!href) {
         shape_editor->set_item_lpe_path_parameter(item, SP_OBJECT(param_effect->getLPEObj()), param_key.c_str());
     } else {
index 3f241850e76f9bc3407f77b9ea490e30e470aa12..ec86a4c8096a82311172a5a2d5bc7eae2ed647f8 100644 (file)
@@ -121,7 +121,7 @@ sp_node_context_dispose(GObject *object)
     nc->sel_changed_connection.disconnect();
     nc->sel_changed_connection.~connection();
 
-    delete nc->shape_editor;
+    delete ec->shape_editor;
 
     if (nc->_node_message_context) {
         delete nc->_node_message_context;
@@ -145,7 +145,7 @@ sp_node_context_setup(SPEventContext *ec)
 
     SPItem *item = selection->singleItem();
 
-    nc->shape_editor = new ShapeEditor(ec->desktop);
+    ec->shape_editor = new ShapeEditor(ec->desktop);
 
     nc->rb_escaped = false;
 
@@ -156,8 +156,8 @@ sp_node_context_setup(SPEventContext *ec)
     nc->current_state = SP_NODE_CONTEXT_INACTIVE;
 
     if (item) {
-        nc->shape_editor->set_item(item, SH_NODEPATH);
-        nc->shape_editor->set_item(item, SH_KNOTHOLDER);
+        ec->shape_editor->set_item(item, SH_NODEPATH);
+        ec->shape_editor->set_item(item, SH_KNOTHOLDER);
     }
 
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -172,7 +172,7 @@ sp_node_context_setup(SPEventContext *ec)
 
     nc->_node_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
 
-    nc->shape_editor->update_statusbar();
+    ec->shape_editor->update_statusbar();
 }
 
 static void
@@ -209,15 +209,15 @@ destroys old and creates new nodepath and reassigns listeners to the new selecte
 void
 sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data)
 {
-    SPNodeContext *nc = SP_NODE_CONTEXT(data);
+    SPEventContext *ec = SP_EVENT_CONTEXT(data);
 
     // TODO: update ShapeEditorsCollective instead
-    nc->shape_editor->unset_item(SH_NODEPATH);
-    nc->shape_editor->unset_item(SH_KNOTHOLDER);
+    ec->shape_editor->unset_item(SH_NODEPATH);
+    ec->shape_editor->unset_item(SH_KNOTHOLDER);
     SPItem *item = selection->singleItem(); 
-    nc->shape_editor->set_item(item, SH_NODEPATH);
-    nc->shape_editor->set_item(item, SH_KNOTHOLDER);
-    nc->shape_editor->update_statusbar();
+    ec->shape_editor->set_item(item, SH_NODEPATH);
+    ec->shape_editor->set_item(item, SH_KNOTHOLDER);
+    ec->shape_editor->update_statusbar();
 }
 
 void
@@ -260,6 +260,7 @@ static gint
 sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
 {
     SPDesktop *desktop = event_context->desktop;
+    ShapeEditor* se = event_context->shape_editor;
     Inkscape::Selection *selection = sp_desktop_selection (desktop);
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
@@ -285,13 +286,13 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 event_context->xp = (gint) event->button.x;
                 event_context->yp = (gint) event->button.y;
                 event_context->within_tolerance = true;
-                nc->shape_editor->cancel_hit();
+                se->cancel_hit();
 
                 if (!(event->button.state & GDK_SHIFT_MASK)) {
                     if (!nc->drag) {
-                        if (nc->shape_editor->has_nodepath() && selection->single() /* && item_over */) {
+                        if (se->has_nodepath() && selection->single() /* && item_over */) {
                             // save drag origin
-                            bool over_stroke = nc->shape_editor->is_over_stroke(Geom::Point(event->button.x, event->button.y), true);
+                            bool over_stroke = se->is_over_stroke(Geom::Point(event->button.x, event->button.y), true);
                             //only dragging curves
                             if (over_stroke) {
                                 ret = TRUE;
@@ -321,7 +322,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 // The path went away while dragging; throw away any further motion
                 // events until the mouse pointer is released.
                 
-                if (nc->shape_editor->hits_curve() && !nc->shape_editor->has_nodepath()) {
+                if (se->hits_curve() && !se->has_nodepath()) {
                   break;
                 }
 
@@ -334,7 +335,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 // selection rubberband), make sure we continue to perform that operation
                 // until the mouse pointer is lifted.
                 if (nc->current_state == SP_NODE_CONTEXT_INACTIVE) {
-                    if (nc->shape_editor->hits_curve() && nc->shape_editor->has_nodepath()) {
+                    if (se->hits_curve() && se->has_nodepath()) {
                         nc->current_state = SP_NODE_CONTEXT_NODE_DRAGGING;
                     } else {
                         nc->current_state = SP_NODE_CONTEXT_RUBBERBAND_DRAGGING;
@@ -344,7 +345,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 switch (nc->current_state) {
                     case SP_NODE_CONTEXT_NODE_DRAGGING:
                         {
-                            nc->shape_editor->curve_drag (event->motion.x, event->motion.y);
+                            se->curve_drag (event->motion.x, event->motion.y);
 
                             gobble_motion_events(GDK_BUTTON1_MASK);
                             break;
@@ -362,12 +363,12 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 nc->drag = TRUE;
                 ret = TRUE;
             } else {
-                if (!nc->shape_editor->has_nodepath() || selection->singleItem() == NULL) {
+                if (!se->has_nodepath() || selection->singleItem() == NULL) {
                     break;
                 }
 
                 bool over_stroke = false;
-                over_stroke = nc->shape_editor->is_over_stroke(Geom::Point(event->motion.x, event->motion.y), false);
+                over_stroke = se->is_over_stroke(Geom::Point(event->motion.x, event->motion.y), false);
 
                 if (nc->cursor_drag && !over_stroke) {
                     event_context->cursor_shape = cursor_node_xpm;
@@ -396,8 +397,8 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 event_context->xp = event_context->yp = 0;
 
                 bool over_stroke = false;
-                if (nc->shape_editor->has_nodepath()) {
-                    over_stroke = nc->shape_editor->is_over_stroke(Geom::Point(event->button.x, event->button.y), false);
+                if (se->has_nodepath()) {
+                    over_stroke = se->is_over_stroke(Geom::Point(event->button.x, event->button.y), false);
                 }
 
                 if (item_clicked || over_stroke) {
@@ -406,7 +407,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                             case GDK_BUTTON_RELEASE:
                                 if (event->button.state & GDK_CONTROL_MASK && event->button.state & GDK_MOD1_MASK) {
                                     //add a node
-                                    nc->shape_editor->add_node_near_point();
+                                    se->add_node_near_point();
                                 } else {
                                     if (nc->added_node) { // we just received double click, ignore release
                                         nc->added_node = false;
@@ -414,16 +415,16 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                                     }
                                     //select the segment
                                     if (event->button.state & GDK_SHIFT_MASK) {
-                                        nc->shape_editor->select_segment_near_point(true);
+                                        se->select_segment_near_point(true);
                                     } else {
-                                        nc->shape_editor->select_segment_near_point(false);
+                                        se->select_segment_near_point(false);
                                     }
                                     desktop->updateNow();
                                 }
                                 break;
                             case GDK_2BUTTON_PRESS:
                                 //add a node
-                                nc->shape_editor->add_node_near_point();
+                                se->add_node_near_point();
                                 nc->added_node = true;
                                 break;
                             default:
@@ -446,14 +447,14 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 if (event->button.button == 1) {
                     Geom::OptRect b = Inkscape::Rubberband::get(desktop)->getRectangle();
 
-                    if (nc->shape_editor->hits_curve() && !event_context->within_tolerance) { //drag curve
-                        nc->shape_editor->finish_drag();
+                    if (se->hits_curve() && !event_context->within_tolerance) { //drag curve
+                        se->finish_drag();
                     } else if (b && !event_context->within_tolerance) { // drag to select
-                        nc->shape_editor->select_rect(*b, event->button.state & GDK_SHIFT_MASK);
+                        se->select_rect(*b, event->button.state & GDK_SHIFT_MASK);
                     } else {
                         if (!(nc->rb_escaped)) { // unless something was cancelled
-                            if (nc->shape_editor->has_selection())
-                                nc->shape_editor->deselect();
+                            if (se->has_selection())
+                                se->deselect();
                             else
                                 sp_desktop_selection(desktop)->clear();
                         }
@@ -463,7 +464,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                     desktop->updateNow();
                     nc->rb_escaped = false;
                     nc->drag = FALSE;
-                    nc->shape_editor->cancel_hit();
+                    se->cancel_hit();
                     nc->current_state = SP_NODE_CONTEXT_INACTIVE;
                 }
             }
@@ -473,79 +474,79 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 case GDK_Insert:
                 case GDK_KP_Insert:
                     // with any modifiers
-                    nc->shape_editor->add_node();
+                    se->add_node();
                     ret = TRUE;
                     break;
                 case GDK_Delete:
                 case GDK_KP_Delete:
                 case GDK_BackSpace:
                     if (MOD__CTRL_ONLY) {
-                        nc->shape_editor->delete_nodes();
+                        se->delete_nodes();
                     } else {
-                        nc->shape_editor->delete_nodes_preserving_shape();
+                        se->delete_nodes_preserving_shape();
                     }
                     ret = TRUE;
                     break;
                 case GDK_C:
                 case GDK_c:
                     if (MOD__SHIFT_ONLY) {
-                        nc->shape_editor->set_node_type(Inkscape::NodePath::NODE_CUSP);
+                        se->set_node_type(Inkscape::NodePath::NODE_CUSP);
                         ret = TRUE;
                     }
                     break;
                 case GDK_S:
                 case GDK_s:
                     if (MOD__SHIFT_ONLY) {
-                        nc->shape_editor->set_node_type(Inkscape::NodePath::NODE_SMOOTH);
+                        se->set_node_type(Inkscape::NodePath::NODE_SMOOTH);
                         ret = TRUE;
                     }
                     break;
                 case GDK_A:
                 case GDK_a:
                     if (MOD__SHIFT_ONLY) {
-                        nc->shape_editor->set_node_type(Inkscape::NodePath::NODE_AUTO);
+                        se->set_node_type(Inkscape::NodePath::NODE_AUTO);
                         ret = TRUE;
                     }
                     break;
                 case GDK_Y:
                 case GDK_y:
                     if (MOD__SHIFT_ONLY) {
-                        nc->shape_editor->set_node_type(Inkscape::NodePath::NODE_SYMM);
+                        se->set_node_type(Inkscape::NodePath::NODE_SYMM);
                         ret = TRUE;
                     }
                     break;
                 case GDK_B:
                 case GDK_b:
                     if (MOD__SHIFT_ONLY) {
-                        nc->shape_editor->break_at_nodes();
+                        se->break_at_nodes();
                         ret = TRUE;
                     }
                     break;
                 case GDK_J:
                 case GDK_j:
                     if (MOD__SHIFT_ONLY) {
-                        nc->shape_editor->join_nodes();
+                        se->join_nodes();
                         ret = TRUE;
                     }
                     break;
                 case GDK_D:
                 case GDK_d:
                     if (MOD__SHIFT_ONLY) {
-                        nc->shape_editor->duplicate_nodes();
+                        se->duplicate_nodes();
                         ret = TRUE;
                     }
                     break;
                 case GDK_L:
                 case GDK_l:
                     if (MOD__SHIFT_ONLY) {
-                        nc->shape_editor->set_type_of_segments(NR_LINETO);
+                        se->set_type_of_segments(NR_LINETO);
                         ret = TRUE;
                     }
                     break;
                 case GDK_U:
                 case GDK_u:
                     if (MOD__SHIFT_ONLY) {
-                        nc->shape_editor->set_type_of_segments(NR_CURVETO);
+                        se->set_type_of_segments(NR_CURVETO);
                         ret = TRUE;
                     }
                     break;
@@ -571,12 +572,12 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         gint mul = 1 + gobble_key_events(
                             get_group0_keyval(&event->key), 0); // with any mask
                         if (MOD__ALT) { // alt
-                            if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(desktop, mul*-10, 0); // shift
-                            else nc->shape_editor->move_nodes_screen(desktop, mul*-1, 0); // no shift
+                            if (MOD__SHIFT) se->move_nodes_screen(desktop, mul*-10, 0); // shift
+                            else se->move_nodes_screen(desktop, mul*-1, 0); // no shift
                         }
                         else { // no alt
-                            if (MOD__SHIFT) nc->shape_editor->move_nodes(mul*-10*nudge, 0); // shift
-                            else nc->shape_editor->move_nodes(mul*-nudge, 0); // no shift
+                            if (MOD__SHIFT) se->move_nodes(mul*-10*nudge, 0); // shift
+                            else se->move_nodes(mul*-nudge, 0); // no shift
                         }
                         ret = TRUE;
                     }
@@ -588,12 +589,12 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         gint mul = 1 + gobble_key_events(
                             get_group0_keyval(&event->key), 0); // with any mask
                         if (MOD__ALT) { // alt
-                            if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(desktop, 0, mul*10); // shift
-                            else nc->shape_editor->move_nodes_screen(desktop, 0, mul*1); // no shift
+                            if (MOD__SHIFT) se->move_nodes_screen(desktop, 0, mul*10); // shift
+                            else se->move_nodes_screen(desktop, 0, mul*1); // no shift
                         }
                         else { // no alt
-                            if (MOD__SHIFT) nc->shape_editor->move_nodes(0, mul*10*nudge); // shift
-                            else nc->shape_editor->move_nodes(0, mul*nudge); // no shift
+                            if (MOD__SHIFT) se->move_nodes(0, mul*10*nudge); // shift
+                            else se->move_nodes(0, mul*nudge); // no shift
                         }
                         ret = TRUE;
                     }
@@ -605,12 +606,12 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         gint mul = 1 + gobble_key_events(
                             get_group0_keyval(&event->key), 0); // with any mask
                         if (MOD__ALT) { // alt
-                            if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(desktop, mul*10, 0); // shift
-                            else nc->shape_editor->move_nodes_screen(desktop, mul*1, 0); // no shift
+                            if (MOD__SHIFT) se->move_nodes_screen(desktop, mul*10, 0); // shift
+                            else se->move_nodes_screen(desktop, mul*1, 0); // no shift
                         }
                         else { // no alt
-                            if (MOD__SHIFT) nc->shape_editor->move_nodes(mul*10*nudge, 0); // shift
-                            else nc->shape_editor->move_nodes(mul*nudge, 0); // no shift
+                            if (MOD__SHIFT) se->move_nodes(mul*10*nudge, 0); // shift
+                            else se->move_nodes(mul*nudge, 0); // no shift
                         }
                         ret = TRUE;
                     }
@@ -622,12 +623,12 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         gint mul = 1 + gobble_key_events(
                             get_group0_keyval(&event->key), 0); // with any mask
                         if (MOD__ALT) { // alt
-                            if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(desktop, 0, mul*-10); // shift
-                            else nc->shape_editor->move_nodes_screen(desktop, 0, mul*-1); // no shift
+                            if (MOD__SHIFT) se->move_nodes_screen(desktop, 0, mul*-10); // shift
+                            else se->move_nodes_screen(desktop, 0, mul*-1); // no shift
                         }
                         else { // no alt
-                            if (MOD__SHIFT) nc->shape_editor->move_nodes(0, mul*-10*nudge); // shift
-                            else nc->shape_editor->move_nodes(0, mul*-nudge); // no shift
+                            if (MOD__SHIFT) se->move_nodes(0, mul*-10*nudge); // shift
+                            else se->move_nodes(0, mul*-nudge); // no shift
                         }
                         ret = TRUE;
                     }
@@ -640,8 +641,8 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         nc->current_state = SP_NODE_CONTEXT_INACTIVE;
                         nc->rb_escaped = true;
                     } else {
-                        if (nc->shape_editor->has_selection()) {
-                            nc->shape_editor->deselect();
+                        if (se->has_selection()) {
+                            se->deselect();
                         } else {
                             sp_desktop_selection(desktop)->clear();
                         }
@@ -653,40 +654,40 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 case GDK_bracketleft:
                     if ( MOD__CTRL && !MOD__ALT && ( snaps != 0 ) ) {
                         if (nc->leftctrl)
-                            nc->shape_editor->rotate_nodes (M_PI/snaps, -1, false);
+                            se->rotate_nodes (M_PI/snaps, -1, false);
                         if (nc->rightctrl)
-                            nc->shape_editor->rotate_nodes (M_PI/snaps, 1, false);
+                            se->rotate_nodes (M_PI/snaps, 1, false);
                     } else if ( MOD__ALT && !MOD__CTRL ) {
                         if (nc->leftalt && nc->rightalt)
-                            nc->shape_editor->rotate_nodes (1, 0, true);
+                            se->rotate_nodes (1, 0, true);
                         else {
                             if (nc->leftalt)
-                                nc->shape_editor->rotate_nodes (1, -1, true);
+                                se->rotate_nodes (1, -1, true);
                             if (nc->rightalt)
-                                nc->shape_editor->rotate_nodes (1, 1, true);
+                                se->rotate_nodes (1, 1, true);
                         }
                     } else if ( snaps != 0 ) {
-                        nc->shape_editor->rotate_nodes (M_PI/snaps, 0, false);
+                        se->rotate_nodes (M_PI/snaps, 0, false);
                     }
                     ret = TRUE;
                     break;
                 case GDK_bracketright:
                     if ( MOD__CTRL && !MOD__ALT && ( snaps != 0 ) ) {
                         if (nc->leftctrl)
-                            nc->shape_editor->rotate_nodes (-M_PI/snaps, -1, false);
+                            se->rotate_nodes (-M_PI/snaps, -1, false);
                         if (nc->rightctrl)
-                            nc->shape_editor->rotate_nodes (-M_PI/snaps, 1, false);
+                            se->rotate_nodes (-M_PI/snaps, 1, false);
                     } else if ( MOD__ALT && !MOD__CTRL ) {
                         if (nc->leftalt && nc->rightalt)
-                            nc->shape_editor->rotate_nodes (-1, 0, true);
+                            se->rotate_nodes (-1, 0, true);
                         else {
                             if (nc->leftalt)
-                                nc->shape_editor->rotate_nodes (-1, -1, true);
+                                se->rotate_nodes (-1, -1, true);
                             if (nc->rightalt)
-                                nc->shape_editor->rotate_nodes (-1, 1, true);
+                                se->rotate_nodes (-1, 1, true);
                         }
                     } else if ( snaps != 0 ) {
-                        nc->shape_editor->rotate_nodes (-M_PI/snaps, 0, false);
+                        se->rotate_nodes (-M_PI/snaps, 0, false);
                     }
                     ret = TRUE;
                     break;
@@ -694,20 +695,20 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 case GDK_comma:
                     if (MOD__CTRL) {
                         if (nc->leftctrl)
-                            nc->shape_editor->scale_nodes(-offset, -1);
+                            se->scale_nodes(-offset, -1);
                         if (nc->rightctrl)
-                            nc->shape_editor->scale_nodes(-offset, 1);
+                            se->scale_nodes(-offset, 1);
                     } else if (MOD__ALT) {
                         if (nc->leftalt && nc->rightalt)
-                            nc->shape_editor->scale_nodes_screen (-1, 0);
+                            se->scale_nodes_screen (-1, 0);
                         else {
                             if (nc->leftalt)
-                                nc->shape_editor->scale_nodes_screen (-1, -1);
+                                se->scale_nodes_screen (-1, -1);
                             if (nc->rightalt)
-                                nc->shape_editor->scale_nodes_screen (-1, 1);
+                                se->scale_nodes_screen (-1, 1);
                         }
                     } else {
-                        nc->shape_editor->scale_nodes (-offset, 0);
+                        se->scale_nodes (-offset, 0);
                     }
                     ret = TRUE;
                     break;
@@ -715,20 +716,20 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 case GDK_period:
                     if (MOD__CTRL) {
                         if (nc->leftctrl)
-                            nc->shape_editor->scale_nodes (offset, -1);
+                            se->scale_nodes (offset, -1);
                         if (nc->rightctrl)
-                            nc->shape_editor->scale_nodes (offset, 1);
+                            se->scale_nodes (offset, 1);
                     } else if (MOD__ALT) {
                         if (nc->leftalt && nc->rightalt)
-                            nc->shape_editor->scale_nodes_screen (1, 0);
+                            se->scale_nodes_screen (1, 0);
                         else {
                             if (nc->leftalt)
-                                nc->shape_editor->scale_nodes_screen (1, -1);
+                                se->scale_nodes_screen (1, -1);
                             if (nc->rightalt)
-                                nc->shape_editor->scale_nodes_screen (1, 1);
+                                se->scale_nodes_screen (1, 1);
                         }
                     } else {
-                        nc->shape_editor->scale_nodes (offset, 0);
+                        se->scale_nodes (offset, 0);
                     }
                     ret = TRUE;
                     break;
index f266cc4135fbefefdaf8afd84ab995efd71cc41e..0e141274f635c96b8623888faa73aa09458e509a 100644 (file)
@@ -38,8 +38,6 @@ struct SPNodeContext {
 
        guint drag : 1;
 
-       ShapeEditor* shape_editor;
-
        gboolean leftalt;
        gboolean rightalt;
        gboolean leftctrl;
index de8662cc3ad5f37f1c5db8b91e3d43b9b33ca6f7..9081bbdb2fceabeb9f803f950fd882fa8c06b443 100644 (file)
@@ -1731,7 +1731,7 @@ void sp_selection_edit_clip_or_mask(SPDesktop * dt, bool clip)
                             tools_switch(dt, TOOLS_NODES);
                         }
 
-                        ShapeEditor * shape_editor = SP_NODE_CONTEXT( dt->event_context )->shape_editor;
+                        ShapeEditor * shape_editor = dt->event_context->shape_editor;
                         // TODO: should we set the item for nodepath or knotholder or both? seems to work with both.
                         shape_editor->set_item(SP_ITEM(child), SH_NODEPATH);
                         shape_editor->set_item(SP_ITEM(child), SH_KNOTHOLDER);
index 1939b2ec076b5b7826196c8d35e23cc5063dae25..f1e4c96c28bc4949299f1659c912e100cab7c677 100644 (file)
@@ -252,8 +252,7 @@ sp_lpe_item_update(SPObject *object, SPCtx *ctx, guint flags)
     // FIXME: ditch inkscape_active_event_context()
     SPEventContext *ec = inkscape_active_event_context();
     if (!SP_IS_NODE_CONTEXT(ec)) return;
-    SPNodeContext *nc = SP_NODE_CONTEXT(ec);
-    ShapeEditor *sh = nc->shape_editor;
+    ShapeEditor *sh = ec->shape_editor;
     g_assert(sh);
     if (!sh->has_nodepath()) return;
 
index b509d041ff745f0bb757e2d6b6395a4f1c39bd8f..3203816d36f96850cdd956bade4456b46d03c163 100644 (file)
@@ -441,9 +441,9 @@ private :
         if (!SP_IS_NODE_CONTEXT (event_context)) return ;
 
         if (_distribute)
-            SP_NODE_CONTEXT (event_context)->shape_editor->distribute((Geom::Dim2)_orientation);
+            event_context->shape_editor->distribute((Geom::Dim2)_orientation);
         else
-            SP_NODE_CONTEXT (event_context)->shape_editor->align((Geom::Dim2)_orientation);
+            event_context->shape_editor->align((Geom::Dim2)_orientation);
 
     }
 };
index 46dc868232a473c9ccf487fe8febdb6487bada49..c84a17da651adfb60aa42e9ee426af0a8e94d5c9 100644 (file)
@@ -921,28 +921,28 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
             break;
         case SP_VERB_EDIT_SELECT_ALL:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                SP_NODE_CONTEXT(ec)->shape_editor->select_all_from_subpath(false);
+                ec->shape_editor->select_all_from_subpath(false);
             } else {
                 sp_edit_select_all(dt);
             }
             break;
         case SP_VERB_EDIT_INVERT:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                SP_NODE_CONTEXT(ec)->shape_editor->select_all_from_subpath(true);
+                ec->shape_editor->select_all_from_subpath(true);
             } else {
                 sp_edit_invert(dt);
             }
             break;
         case SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                SP_NODE_CONTEXT(ec)->shape_editor->select_all(false);
+                ec->shape_editor->select_all(false);
             } else {
                 sp_edit_select_all_in_all_layers(dt);
             }
             break;
         case SP_VERB_EDIT_INVERT_IN_ALL_LAYERS:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                SP_NODE_CONTEXT(ec)->shape_editor->select_all(true);
+                ec->shape_editor->select_all(true);
             } else {
                 sp_edit_invert_in_all_layers(dt);
             }
@@ -950,7 +950,7 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
 
         case SP_VERB_EDIT_SELECT_NEXT:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                SP_NODE_CONTEXT(ec)->shape_editor->select_next();
+                ec->shape_editor->select_next();
             } else if (tools_isactive(dt, TOOLS_GRADIENT)
                        && ec->_grdrag->isNonEmpty()) {
                 sp_gradient_context_select_next (ec);
@@ -960,7 +960,7 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
             break;
         case SP_VERB_EDIT_SELECT_PREV:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                SP_NODE_CONTEXT(ec)->shape_editor->select_prev();
+                ec->shape_editor->select_prev();
             } else if (tools_isactive(dt, TOOLS_GRADIENT)
                        && ec->_grdrag->isNonEmpty()) {
                 sp_gradient_context_select_prev (ec);
@@ -971,7 +971,7 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
 
         case SP_VERB_EDIT_DESELECT:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                SP_NODE_CONTEXT(ec)->shape_editor->deselect();
+                ec->shape_editor->deselect();
             } else {
                 sp_desktop_selection(dt)->clear();
             }
@@ -1356,11 +1356,11 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ )
                 if (active_node) {
 
                     // ... flip the selected nodes about that node
-                    SP_NODE_CONTEXT(ec)->shape_editor->flip(Geom::X, active_node->pos);
+                    ec->shape_editor->flip(Geom::X, active_node->pos);
                 } else {
 
                     // ... or else about the center of their bounding box.
-                    SP_NODE_CONTEXT(ec)->shape_editor->flip(Geom::X);
+                    ec->shape_editor->flip(Geom::X);
                 }
 
             // When working with the selector tool, flip the selection about its rotation center
@@ -1376,9 +1376,9 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ )
             if (tools_isactive(dt, TOOLS_NODES)) {
                 Inkscape::NodePath::Node *active_node = Inkscape::NodePath::Path::active_node;
                 if (active_node) {
-                    SP_NODE_CONTEXT(ec)->shape_editor->flip(Geom::Y, active_node->pos);
+                    ec->shape_editor->flip(Geom::Y, active_node->pos);
                 } else {
-                    SP_NODE_CONTEXT(ec)->shape_editor->flip(Geom::Y);
+                    ec->shape_editor->flip(Geom::Y);
                 }
             } else {
                 sp_selection_scale_relative(sel, center, Geom::Scale(1.0, -1.0));
index ca6a72ca2ec6c929393caac18f4bc88f7d5834ac..c2e80db784b3065c415ca4cbcbc26499db7032f1 100644 (file)
@@ -968,7 +968,7 @@ static ShapeEditor *get_current_shape_editor()
         return NULL;
     }
 
-    return SP_NODE_CONTEXT(event_context)->shape_editor;
+    return event_context->shape_editor;
 }