diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-12-19 18:00:54 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-12-19 18:00:54 +0000 |
| commit | 5ba49eaa5621b2e232f8df179798a1b2b282890c (patch) | |
| tree | 669a012939a78bc8231401e6f914821a8207bffa /src | |
| parent | Add translatable strings to trunk (diff) | |
| download | inkscape-5ba49eaa5621b2e232f8df179798a1b2b282890c.tar.gz inkscape-5ba49eaa5621b2e232f8df179798a1b2b282890c.zip | |
Add update_helperpaths not member of nodetool class to easy call from outside
(bzr r15335)
Diffstat (limited to 'src')
| -rw-r--r-- | src/knot.cpp | 12 | ||||
| -rw-r--r-- | src/live_effects/effect.cpp | 9 | ||||
| -rw-r--r-- | src/live_effects/lpe-knot.cpp | 1 | ||||
| -rw-r--r-- | src/live_effects/lpe-simplify.cpp | 6 | ||||
| -rw-r--r-- | src/ui/tool/node.cpp | 10 | ||||
| -rw-r--r-- | src/ui/tools/node-tool.cpp | 40 | ||||
| -rw-r--r-- | src/ui/tools/node-tool.h | 4 |
7 files changed, 31 insertions, 51 deletions
diff --git a/src/knot.cpp b/src/knot.cpp index 8ac84b97b..84b72d780 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -25,8 +25,6 @@ #include "document-undo.h" #include "message-stack.h" #include "message-context.h" -#include "ui/tools-switch.h" -#include "ui/tools/tool-base.h" #include "ui/tools/node-tool.h" #include <gtk/gtk.h> @@ -254,10 +252,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot consumed = TRUE; } } - if (tools_isactive(knot->desktop, TOOLS_NODES)) { - Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(knot->desktop->event_context); - nt->update_helperpath(); - } + Inkscape::UI::Tools::sp_update_helperpath(); break; case GDK_MOTION_NOTIFY: if (grabbed && knot->desktop && knot->desktop->event_context && !knot->desktop->event_context->space_panning) { @@ -290,10 +285,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot sp_knot_handler_request_position(event, knot); moved = TRUE; } - if (tools_isactive(knot->desktop, TOOLS_NODES)) { - Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(knot->desktop->event_context); - nt->update_helperpath(); - } + Inkscape::UI::Tools::sp_update_helperpath(); break; case GDK_ENTER_NOTIFY: knot->setFlag(SP_KNOT_MOUSEOVER, TRUE); diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 41b7d8c2c..4458c3a20 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -660,14 +660,7 @@ Effect::addCanvasIndicators(SPLPEItem const*/*lpeitem*/, std::vector<Geom::PathV */ void Effect::update_helperpath() { - using namespace Inkscape::UI; - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) { - if (tools_isactive(desktop, TOOLS_NODES)) { - Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context); - nt->update_helperpath(); - } - } + Inkscape::UI::Tools::sp_update_helperpath(); } /** diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index c35da0601..7c6882f30 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -20,7 +20,6 @@ #include "knot-holder-entity.h" #include "knotholder.h" -#include <glibmm/i18n.h> #include <gdk/gdk.h> #include <2geom/sbasis-to-bezier.h> diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 8bdb19b4f..5de9816bb 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -140,11 +140,7 @@ LPESimplify::doEffect(SPCurve *curve) Geom::PathVector result = Geom::parse_svg_path(pathliv->svg_dump_path()); generateHelperPathAndSmooth(result); curve->set_pathvector(result); - SPDesktop* desktop = SP_ACTIVE_DESKTOP; - if(desktop && INK_IS_NODE_TOOL(desktop->event_context)) { - Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context); - nt->update_helperpath(); - } + Inkscape::UI::Tools::sp_update_helperpath(); } void diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 0e5a9279d..d6e491ac3 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -326,10 +326,7 @@ bool Handle::grabbed(GdkEventMotion *) void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) { - if (tools_isactive(_desktop, TOOLS_NODES)) { - Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(_desktop->event_context); - nt->update_helperpath(); - } + Inkscape::UI::Tools::sp_update_helperpath(); Geom::Point parent_pos = _parent->position(); Geom::Point origin = _last_drag_origin(); SnapManager &sm = _desktop->namedview->snap_manager; @@ -1199,10 +1196,7 @@ bool Node::grabbed(GdkEventMotion *event) void Node::dragged(Geom::Point &new_pos, GdkEventMotion *event) { - if (tools_isactive(_desktop, TOOLS_NODES)) { - Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(_desktop->event_context); - nt->update_helperpath(); - } + Inkscape::UI::Tools::sp_update_helperpath(); // For a note on how snapping is implemented in Inkscape, see snap.h. SnapManager &sm = _desktop->namedview->snap_manager; // even if we won't really snap, we might still call the one of the diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index f3679b40f..668ebda27 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -32,6 +32,8 @@ #include "sp-text.h" #include "ui/control-manager.h" #include "ui/tools/node-tool.h" +#include "ui/tools-switch.h" +#include "ui/tools/tool-base.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/event-utils.h" #include "ui/tool/multi-path-manipulator.h" @@ -155,9 +157,7 @@ NodeTool::~NodeTool() { if (this->flash_tempitem) { this->desktop->remove_temporary_canvasitem(this->flash_tempitem); } - if (this->helperpath_tmpitem) { - this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem); - } + sp_update_helperpath(true); this->_selection_changed_connection.disconnect(); //this->_selection_modified_connection.disconnect(); this->_mouseover_changed_connection.disconnect(); @@ -237,7 +237,6 @@ void NodeTool::setup() { ))) ); - this->helperpath_tmpitem = NULL; this->cursor_drag = false; this->show_transform_handles = true; this->single_node_transform_handles = false; @@ -270,29 +269,36 @@ void NodeTool::setup() { } this->desktop->emitToolSubselectionChanged(NULL); // sets the coord entry fields to inactive - this->update_helperpath(); + sp_update_helperpath(); } // show helper paths of the applied LPE, if any -void NodeTool::update_helperpath () { - Inkscape::Selection *selection = this->desktop->getSelection(); - - if (this->helperpath_tmpitem) { - this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem); - this->helperpath_tmpitem = NULL; +void sp_update_helperpath(bool remove) { + SPDesktop * desktop = SP_ACTIVE_DESKTOP; + if (!desktop || !tools_isactive(desktop, TOOLS_NODES)) { + return; + } + Inkscape::Selection *selection = desktop->getSelection(); + static Inkscape::Display::TemporaryItem * helperpath_tmpitem; + if (helperpath_tmpitem) { + desktop->remove_temporary_canvasitem(helperpath_tmpitem); + helperpath_tmpitem = NULL; + } + if (remove) { + return; } - if (SP_IS_LPE_ITEM(selection->singleItem())) { Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(selection->singleItem())->getCurrentLPE(); if (lpe && lpe->isVisible()/* && lpe->showOrigPath()*/) { - Inkscape::UI::ControlPointSelection *selectionNodes = _selected_nodes; + Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context); + Inkscape::UI::ControlPointSelection *selectionNodes = nt->_selected_nodes; std::vector<Geom::Point> selectedNodesPositions; for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) { Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i); selectedNodesPositions.push_back(n->position()); } lpe->setSelectedNodePoints(selectedNodesPositions); - lpe->setCurrentZoom(this->desktop->current_zoom()); + lpe->setCurrentZoom(desktop->current_zoom()); SPCurve *c = new SPCurve(); SPCurve *cc = new SPCurve(); std::vector<Geom::PathVector> cs = lpe->getCanvasIndicators(SP_LPE_ITEM(selection->singleItem())); @@ -302,11 +308,11 @@ void NodeTool::update_helperpath () { cc->reset(); } if (!c->is_empty()) { - SPCanvasItem *helperpath = sp_canvas_bpath_new(this->desktop->getTempGroup(), c, true); + SPCanvasItem *helperpath = sp_canvas_bpath_new(desktop->getTempGroup(), c, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(helperpath), 0x0000ff9A, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(helperpath), 0, SP_WIND_RULE_NONZERO); sp_canvas_item_affine_absolute(helperpath, selection->singleItem()->i2dt_affine()); - this->helperpath_tmpitem = this->desktop->add_temporary_canvasitem(helperpath, 0); + helperpath_tmpitem = desktop->add_temporary_canvasitem(helperpath, 0); } c->unref(); cc->unref(); @@ -468,7 +474,7 @@ bool NodeTool::root_handler(GdkEvent* event) { switch (event->type) { case GDK_MOTION_NOTIFY: { - update_helperpath(); + sp_update_helperpath(); combine_motion_events(desktop->canvas, event->motion, 0); SPItem *over_item = sp_event_context_find_item (desktop, event_point(event->button), FALSE, TRUE); diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index 8342d66a6..8517c54fe 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -56,7 +56,6 @@ public: static const std::string prefsPath; virtual void setup(); - virtual void update_helperpath(); virtual void set(const Inkscape::Preferences::Entry& val); virtual bool root_handler(GdkEvent* event); @@ -68,7 +67,6 @@ private: sigc::connection _sizeUpdatedConn; SPItem *flashed_item; - Inkscape::Display::TemporaryItem *helperpath_tmpitem; Inkscape::Display::TemporaryItem *flash_tempitem; Inkscape::UI::Selector* _selector; Inkscape::UI::PathSharedData* _path_data; @@ -97,7 +95,9 @@ private: void handleControlUiStyleChange(); }; +void sp_update_helperpath(bool remove = false); } + } } |
