From 5ba49eaa5621b2e232f8df179798a1b2b282890c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 19 Dec 2016 19:00:54 +0100 Subject: Add update_helperpaths not member of nodetool class to easy call from outside (bzr r15335) --- src/ui/tool/node.cpp | 10 ++-------- src/ui/tools/node-tool.cpp | 40 +++++++++++++++++++++++----------------- src/ui/tools/node-tool.h | 4 ++-- 3 files changed, 27 insertions(+), 27 deletions(-) (limited to 'src/ui') 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(_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(_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(desktop->event_context); + Inkscape::UI::ControlPointSelection *selectionNodes = nt->_selected_nodes; std::vector selectedNodesPositions; for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) { Inkscape::UI::Node *n = dynamic_cast(*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 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); } + } } -- cgit v1.2.3 From c5b33e5041c6bd1f62ef550ac2b8e1bc739a40e2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 19 Dec 2016 19:14:56 +0100 Subject: Remove unneeded static var from previous commit (bzr r15336) --- src/ui/tools/node-tool.cpp | 24 ++++++++++++------------ src/ui/tools/node-tool.h | 7 ++++--- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 668ebda27..0c948c91c 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -157,7 +157,9 @@ NodeTool::~NodeTool() { if (this->flash_tempitem) { this->desktop->remove_temporary_canvasitem(this->flash_tempitem); } - sp_update_helperpath(true); + if (this->helperpath_tmpitem) { + this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem); + } this->_selection_changed_connection.disconnect(); //this->_selection_modified_connection.disconnect(); this->_mouseover_changed_connection.disconnect(); @@ -209,7 +211,7 @@ void NodeTool::setup() { this->_sizeUpdatedConn = ControlManager::getManager().connectCtrlSizeChanged( sigc::mem_fun(this, &NodeTool::handleControlUiStyleChange) ); - + this->helperpath_tmpitem = NULL; this->_selected_nodes = new Inkscape::UI::ControlPointSelection(this->desktop, this->_transform_handle_group); data.node_data.selection = this->_selected_nodes; @@ -273,24 +275,22 @@ void NodeTool::setup() { } // show helper paths of the applied LPE, if any -void sp_update_helperpath(bool remove) { +void sp_update_helperpath() { SPDesktop * desktop = SP_ACTIVE_DESKTOP; if (!desktop || !tools_isactive(desktop, TOOLS_NODES)) { return; } + Inkscape::UI::Tools::NodeTool *nt = static_cast(desktop->event_context); 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 (nt->helperpath_tmpitem) { + desktop->remove_temporary_canvasitem(nt->helperpath_tmpitem); + nt->helperpath_tmpitem = NULL; } + 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::Tools::NodeTool *nt = static_cast(desktop->event_context); + Inkscape::UI::ControlPointSelection *selectionNodes = nt->_selected_nodes; std::vector selectedNodesPositions; for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) { @@ -312,7 +312,7 @@ void sp_update_helperpath(bool remove) { 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()); - helperpath_tmpitem = desktop->add_temporary_canvasitem(helperpath, 0); + nt->helperpath_tmpitem = desktop->add_temporary_canvasitem(helperpath, 0); } c->unref(); cc->unref(); diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index 8517c54fe..983ba6cee 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -49,7 +49,8 @@ public: Inkscape::UI::ControlPointSelection* _selected_nodes; Inkscape::UI::MultiPathManipulator* _multipath; - + Inkscape::Display::TemporaryItem *helperpath_tmpitem; + bool edit_clipping_paths; bool edit_masks; @@ -67,6 +68,7 @@ private: sigc::connection _sizeUpdatedConn; SPItem *flashed_item; + Inkscape::Display::TemporaryItem *flash_tempitem; Inkscape::UI::Selector* _selector; Inkscape::UI::PathSharedData* _path_data; @@ -94,8 +96,7 @@ private: void update_tip(GdkEvent *event); void handleControlUiStyleChange(); }; - -void sp_update_helperpath(bool remove = false); + void sp_update_helperpath(); } } -- cgit v1.2.3 From 952eb10b1e00f0e4abfbf8dd23fcb3935019f098 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Mon, 19 Dec 2016 21:54:42 +0100 Subject: Remove some ocurrences of desktop in knot functions (bzr r15337) --- src/ui/object-edit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/object-edit.cpp b/src/ui/object-edit.cpp index 2763e6c4b..cf2c03396 100644 --- a/src/ui/object-edit.cpp +++ b/src/ui/object-edit.cpp @@ -43,7 +43,7 @@ static KnotHolder *sp_lpe_knot_holder(SPLPEItem *item, SPDesktop *desktop) KnotHolder *knot_holder = new KnotHolder(desktop, item, NULL); Inkscape::LivePathEffect::Effect *effect = item->getCurrentLPE(); - effect->addHandles(knot_holder, desktop, item); + effect->addHandles(knot_holder, item); return knot_holder; } -- cgit v1.2.3