From 77e38e8793a51d106a8d9436b6f7416afcfff55d Mon Sep 17 00:00:00 2001 From: cilix42 Date: Wed, 13 Aug 2008 15:06:50 +0000 Subject: [PATCH] Get rid of sp_nodepath_current() and a few instances of SP_ACTIVE_DESKTOP by passing in the current desktop and nodepath from the caller --- src/node-context.cpp | 16 ++++++++-------- src/nodepath.cpp | 36 +++++++----------------------------- src/nodepath.h | 6 +++--- src/shape-editor.cpp | 6 +++--- src/shape-editor.h | 2 +- 5 files changed, 22 insertions(+), 44 deletions(-) diff --git a/src/node-context.cpp b/src/node-context.cpp index d8a1ec1d7..96b562a3f 100644 --- a/src/node-context.cpp +++ b/src/node-context.cpp @@ -557,8 +557,8 @@ 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(mul*-10, 0); // shift - else nc->shape_editor->move_nodes_screen(mul*-1, 0); // no shift + 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 } else { // no alt if (MOD__SHIFT) nc->shape_editor->move_nodes(mul*-10*nudge, 0); // shift @@ -574,8 +574,8 @@ 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(0, mul*10); // shift - else nc->shape_editor->move_nodes_screen(0, mul*1); // no shift + 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 } else { // no alt if (MOD__SHIFT) nc->shape_editor->move_nodes(0, mul*10*nudge); // shift @@ -591,8 +591,8 @@ 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(mul*10, 0); // shift - else nc->shape_editor->move_nodes_screen(mul*1, 0); // no shift + 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 } else { // no alt if (MOD__SHIFT) nc->shape_editor->move_nodes(mul*10*nudge, 0); // shift @@ -608,8 +608,8 @@ 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(0, mul*-10); // shift - else nc->shape_editor->move_nodes_screen(0, mul*-1); // no shift + 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 } else { // no alt if (MOD__SHIFT) nc->shape_editor->move_nodes(0, mul*-10*nudge); // shift diff --git a/src/nodepath.cpp b/src/nodepath.cpp index 4132cc5ba..4260d03c8 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -836,26 +836,6 @@ static gchar *create_typestr(Inkscape::NodePath::Path *np) return typestr; } -/** - * Returns current path in context. // later eliminate this function at all! - */ -static Inkscape::NodePath::Path *sp_nodepath_current() -{ - if (!SP_ACTIVE_DESKTOP) { - return NULL; - } - - SPEventContext *event_context = (SP_ACTIVE_DESKTOP)->event_context; - - if (!SP_IS_NODE_CONTEXT(event_context)) { - return NULL; - } - - return SP_NODE_CONTEXT(event_context)->shape_editor->get_nodepath(); -} - - - /** \brief Fills node and handle positions for three nodes, splitting line marked by end at distance t. @@ -1576,11 +1556,10 @@ sp_node_selected_move(Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy * Move node selection off screen and commit the change. */ void -sp_node_selected_move_screen(Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy) +sp_node_selected_move_screen(SPDesktop *desktop, Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy) { // borrowed from sp_selection_move_screen in selection-chemistry.c // we find out the current zoom factor and divide deltas by it - SPDesktop *desktop = SP_ACTIVE_DESKTOP; gdouble zoom = desktop->current_zoom(); gdouble zdx = dx / zoom; @@ -1952,7 +1931,7 @@ sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Po curve->unref(); //find segment to segment - Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(segment_index); + Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(nodepath, segment_index); //fixme: this can return NULL, so check before proceeding. g_return_if_fail(e != NULL); @@ -1998,7 +1977,7 @@ sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p) curve->unref(); //find segment to split - Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(segment_index); + Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(nodepath, segment_index); //don't know why but t seems to flip for lines if (sp_node_path_code_from_side(e, sp_node_get_side(e, -1)) == NR_LINETO) { @@ -2024,9 +2003,9 @@ sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p) * cf. app/vectors/gimpbezierstroke.c, gimp_bezier_stroke_point_move_relative() */ void -sp_nodepath_curve_drag(int node, double t, NR::Point delta) +sp_nodepath_curve_drag(Inkscape::NodePath::Path *nodepath, int node, double t, NR::Point delta) { - Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(node); + Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(nodepath, node); //fixme: e and e->p can be NULL, so check for those before proceeding g_return_if_fail(e != NULL); @@ -4643,11 +4622,10 @@ static NRPathcode sp_node_path_code_from_side(Inkscape::NodePath::Node *node,Ink * Return node with the given index */ Inkscape::NodePath::Node * -sp_nodepath_get_node_by_index(int index) +sp_nodepath_get_node_by_index(Inkscape::NodePath::Path *nodepath, int index) { Inkscape::NodePath::Node *e = NULL; - Inkscape::NodePath::Path *nodepath = sp_nodepath_current(); if (!nodepath) { return e; } @@ -4745,7 +4723,7 @@ sp_nodepath_update_statusbar(Inkscape::NodePath::Path *nodepath)//!!!move to Sha if (nodepath) { desktop = nodepath->desktop; } else { - desktop = SP_ACTIVE_DESKTOP; + desktop = SP_ACTIVE_DESKTOP; // when this is eliminated also remove #include "inkscape.h" above } SPEventContext *ec = desktop->event_context; diff --git a/src/nodepath.h b/src/nodepath.h index b330ff964..39eb10b4f 100644 --- a/src/nodepath.h +++ b/src/nodepath.h @@ -295,8 +295,8 @@ void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, NR::Dim2 axi void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, NR::Dim2 axis); void sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p, bool toggle); void sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p); -void sp_nodepath_curve_drag(int node, double t, NR::Point delta); -Inkscape::NodePath::Node * sp_nodepath_get_node_by_index(int index); +void sp_nodepath_curve_drag(Inkscape::NodePath::Path *nodepath, int node, double t, NR::Point delta); +Inkscape::NodePath::Node * sp_nodepath_get_node_by_index(Inkscape::NodePath::Path *np, int index); /* possibly private functions */ void sp_node_selected_add_node (Inkscape::NodePath::Path *nodepath); @@ -310,7 +310,7 @@ void sp_node_selected_delete_segment (Inkscape::NodePath::Path *nodepath); void sp_node_selected_set_type (Inkscape::NodePath::Path *nodepath, Inkscape::NodePath::NodeType type); void sp_node_selected_set_line_type (Inkscape::NodePath::Path *nodepath, NRPathcode code); void sp_node_selected_move (Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy); -void sp_node_selected_move_screen (Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy); +void sp_node_selected_move_screen (SPDesktop *desktop, Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy); void sp_node_selected_move_absolute (Inkscape::NodePath::Path *nodepath, Geom::Coord val, Geom::Dim2 axis); Geom::Rect sp_node_selected_bbox (Inkscape::NodePath::Path *nodepath); boost::optional sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis); diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp index bfb0e3c0c..3575d3405 100644 --- a/src/shape-editor.cpp +++ b/src/shape-editor.cpp @@ -441,7 +441,7 @@ void ShapeEditor::curve_drag(gdouble eventx, gdouble eventy) { eventy - this->curvepoint_event[NR::Y]); NR::Point const delta_dt(this->desktop->w2d(delta_w)); - sp_nodepath_curve_drag (this->grab_node, this->grab_t, delta_dt); //!!! FIXME: which nodepath?!!! also uses current!!! + sp_nodepath_curve_drag (this->nodepath, this->grab_node, this->grab_t, delta_dt); this->curvepoint_event[NR::X] = x; this->curvepoint_event[NR::Y] = y; @@ -517,8 +517,8 @@ void ShapeEditor::set_type_of_segments(NRPathcode code) { sp_node_selected_set_line_type(this->nodepath, code); } -void ShapeEditor::move_nodes_screen(gdouble dx, gdouble dy) { - sp_node_selected_move_screen(this->nodepath, dx, dy); +void ShapeEditor::move_nodes_screen(SPDesktop *desktop, gdouble dx, gdouble dy) { + sp_node_selected_move_screen(desktop, this->nodepath, dx, dy); } void ShapeEditor::move_nodes(gdouble dx, gdouble dy) { sp_node_selected_move(this->nodepath, dx, dy); diff --git a/src/shape-editor.h b/src/shape-editor.h index fe95aca8f..c8f5aa419 100644 --- a/src/shape-editor.h +++ b/src/shape-editor.h @@ -99,7 +99,7 @@ public: void set_type_of_segments(NRPathcode code); void move_nodes(gdouble dx, gdouble dy); - void move_nodes_screen(gdouble dx, gdouble dy); + void move_nodes_screen(SPDesktop *desktop, gdouble dx, gdouble dy); void rotate_nodes(gdouble angle, int which, bool screen); -- 2.30.2