From 0459094999e0298341ecad677464043528d1036f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 9 May 2012 00:54:48 -0700 Subject: Centralized line creation and enhanced visibility. (bzr r11350) --- src/ui/tool/node.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index ad48b523b..ad22d95e6 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -28,6 +28,7 @@ #include "snap-preferences.h" #include "sp-metrics.h" #include "sp-namedview.h" +#include "ui/control-manager.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/event-utils.h" #include "ui/tool/node.h" @@ -92,9 +93,10 @@ Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node , _degenerate(true) { _cset = &handle_colors; - _handle_line = SP_CTRLLINE(sp_canvas_item_new(data.handle_line_group, SP_TYPE_CTRLLINE, NULL)); + _handle_line = ControlManager::getManager().createControlLine(data.handle_line_group); setVisible(false); } + Handle::~Handle() { //sp_canvas_item_hide(_handle_line); -- cgit v1.2.3 From e9412c187da3f62f01bc5acb6190af2d5a395ccb Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 16 May 2012 19:33:16 -0700 Subject: Corrected protected type access (comments were incorrect). Unified color set types; fixed uninitialized member; Switched colorsets to references; Added const correctness. (bzr r11373) --- src/ui/tool/node.cpp | 167 +++++++++++++++++++++------------------------------ 1 file changed, 69 insertions(+), 98 deletions(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index ad22d95e6..1a26b5d55 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -1,7 +1,3 @@ -/** - * @file - * Editable node - implementation. - */ /* Authors: * Krzysztof Kosiński * Jon A. Cruz @@ -42,18 +38,21 @@ namespace Inkscape { namespace UI { -static SelectableControlPoint::ColorSet node_colors = { - { - {0xbfbfbf00, 0x000000ff}, // normal fill, stroke - {0xff000000, 0x000000ff}, // mouseover fill, stroke - {0xff000000, 0x000000ff} // clicked fill, stroke - }, +ControlPoint::ColorSet Node::node_colors = { + {0xbfbfbf00, 0x000000ff}, // normal fill, stroke + {0xff000000, 0x000000ff}, // mouseover fill, stroke + {0xff000000, 0x000000ff}, // clicked fill, stroke + // {0x0000ffff, 0x000000ff}, // normal fill, stroke when selected {0xff000000, 0x000000ff}, // mouseover fill, stroke when selected {0xff000000, 0x000000ff} // clicked fill, stroke when selected }; -static ControlPoint::ColorSet handle_colors = { +ControlPoint::ColorSet Handle::_handle_colors = { + {0xffffffff, 0x000000ff}, // normal fill, stroke + {0xff000000, 0x000000ff}, // mouseover fill, stroke + {0xff000000, 0x000000ff}, // clicked fill, stroke + // {0xffffffff, 0x000000ff}, // normal fill, stroke {0xff000000, 0x000000ff}, // mouseover fill, stroke {0xff000000, 0x000000ff} // clicked fill, stroke @@ -76,24 +75,20 @@ static Geom::Point direction(Geom::Point const &first, Geom::Point const &second return Geom::unit_vector(second - first); } -/** - * Control point of a cubic Bezier curve in a path. - * - * Handle keeps the node type invariant only for the opposite handle of the same node. - * Keeping the invariant on node moves is left to the %Node class. - */ Geom::Point Handle::_saved_other_pos(0, 0); + double Handle::_saved_length = 0.0; + bool Handle::_drag_out = false; -Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node *parent) - : ControlPoint(data.desktop, initial_pos, SP_ANCHOR_CENTER, SP_CTRL_SHAPE_CIRCLE, 7.0, - &handle_colors, data.handle_group) - , _parent(parent) - , _degenerate(true) +Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node *parent) : + ControlPoint(data.desktop, initial_pos, SP_ANCHOR_CENTER, + SP_CTRL_SHAPE_CIRCLE, 7.0, + _handle_colors, data.handle_group), + _parent(parent), + _handle_line(ControlManager::getManager().createControlLine(data.handle_line_group)), + _degenerate(true) { - _cset = &handle_colors; - _handle_line = ControlManager::getManager().createControlLine(data.handle_line_group); setVisible(false); } @@ -389,10 +384,18 @@ bool Handle::clicked(GdkEventButton *event) return true; } +Handle const *Handle::other() const +{ + return const_cast(this)->other(); +} + Handle *Handle::other() { - if (this == &_parent->_front) return &_parent->_back; - return &_parent->_front; + if (this == &_parent->_front) { + return &_parent->_back; + } else { + return &_parent->_front; + } } static double snap_increment_degrees() { @@ -401,7 +404,7 @@ static double snap_increment_degrees() { return 180.0 / snaps; } -Glib::ustring Handle::_getTip(unsigned state) +Glib::ustring Handle::_getTip(unsigned state) const { char const *more; bool can_shift_rotate = _parent->type() == NODE_CUSP && !other()->isDegenerate(); @@ -459,7 +462,7 @@ Glib::ustring Handle::_getTip(unsigned state) } } -Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) +Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) const { Geom::Point dist = position() - _last_drag_origin(); // report angle in mathematical convention @@ -477,34 +480,48 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) return ret; } -/** - * Curve endpoint in an editable path. - * - * The method move() keeps node type invariants during translations. - */ -Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) - : SelectableControlPoint(data.desktop, initial_pos, SP_ANCHOR_CENTER, - SP_CTRL_SHAPE_DIAMOND, 9.0, *data.selection, &node_colors, data.node_group) - , _front(data, initial_pos, this) - , _back(data, initial_pos, this) - , _type(NODE_CUSP) - , _handles_shown(false) +Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : + SelectableControlPoint(data.desktop, initial_pos, SP_ANCHOR_CENTER, + SP_CTRL_SHAPE_DIAMOND, 9.0, + *data.selection, + node_colors, data.node_group), + _front(data, initial_pos, this), + _back(data, initial_pos, this), + _type(NODE_CUSP), + _handles_shown(false) { // NOTE we do not set type here, because the handles are still degenerate } +Node const *Node::_next() const +{ + return const_cast(this)->_next(); +} + // NOTE: not using iterators won't make this much quicker because iterators can be 100% inlined. Node *Node::_next() { NodeList::iterator n = NodeList::get_iterator(this).next(); - if (n) return n.ptr(); - return NULL; + if (n) { + return n.ptr(); + } else { + return NULL; + } } + +Node const *Node::_prev() const +{ + return const_cast(this)->_prev(); +} + Node *Node::_prev() { NodeList::iterator p = NodeList::get_iterator(this).prev(); - if (p) return p.ptr(); - return NULL; + if (p) { + return p.ptr(); + } else { + return NULL; + } } void Node::move(Geom::Point const &new_pos) @@ -533,7 +550,7 @@ void Node::transform(Geom::Affine const &m) _fixNeighbors(old_pos, position()); } -Geom::Rect Node::bounds() +Geom::Rect Node::bounds() const { Geom::Rect b(position(), position()); b.expandTo(_front.position()); @@ -614,13 +631,6 @@ void Node::showHandles(bool v) if (!_back.isDegenerate()) _back.setVisible(v); } -/** Sets the node type and optionally restores the invariants associated with the given type. - * @param type The type to set - * @param update_handles Whether to restore invariants associated with the given type. - * Passing false is useful e.g. wen initially creating the path, - * and when making cusp nodes during some node algorithms. - * Pass true when used in response to an UI node type button. - */ void Node::setType(NodeType type, bool update_handles) { if (type == NODE_PICK_BEST) { @@ -717,8 +727,6 @@ void Node::setType(NodeType type, bool update_handles) updateState(); } -/** Pick the best type for this node, based on the position of its handles. - * This is what assigns types to nodes created using the pen tool. */ void Node::pickBestType() { _type = NODE_CUSP; @@ -768,13 +776,11 @@ void Node::pickBestType() updateState(); } -bool Node::isEndNode() +bool Node::isEndNode() const { return !_prev() || !_next(); } -/** Move the node to the bottom of its canvas group. Useful for node break, to ensure that - * the selected nodes are above the unselected ones. */ void Node::sink() { sp_canvas_item_move_to_z(_canvas_item, 0); @@ -791,7 +797,6 @@ NodeType Node::parse_nodetype(char x) } } -/** Customized event handler to catch scroll events needed for selection grow/shrink. */ bool Node::_eventHandler(SPEventContext *event_context, GdkEvent *event) { int dir = 0; @@ -836,8 +841,6 @@ bool Node::_eventHandler(SPEventContext *event_context, GdkEvent *event) return ControlPoint::_eventHandler(event_context, event); } -/** Select or deselect a node in this node's subpath based on its path distance from this node. - * @param dir If negative, shrink selection by one node; if positive, grow by one node */ void Node::_linearGrow(int dir) { // Interestingly, we do not need any help from PathManipulator when doing linear grow. @@ -1140,13 +1143,13 @@ bool Node::clicked(GdkEventButton *event) return SelectableControlPoint::clicked(event); } -Inkscape::SnapSourceType Node::_snapSourceType() +Inkscape::SnapSourceType Node::_snapSourceType() const { if (_type == NODE_SMOOTH || _type == NODE_AUTO) return SNAPSOURCE_NODE_SMOOTH; return SNAPSOURCE_NODE_CUSP; } -Inkscape::SnapTargetType Node::_snapTargetType() +Inkscape::SnapTargetType Node::_snapTargetType() const { if (_type == NODE_SMOOTH || _type == NODE_AUTO) return SNAPTARGET_NODE_SMOOTH; @@ -1158,10 +1161,6 @@ Inkscape::SnapCandidatePoint Node::snapCandidatePoint() return SnapCandidatePoint(position(), _snapSourceType(), _snapTargetType()); } -/** - * Gets the handle that faces the given adjacent node. - * Will abort with error if the given node is not adjacent. - */ Handle *Node::handleToward(Node *to) { if (_next() == to) { @@ -1173,10 +1172,6 @@ Handle *Node::handleToward(Node *to) g_error("Node::handleToward(): second node is not adjacent!"); } -/** - * Gets the node in the direction of the given handle. - * Will abort with error if the handle doesn't belong to this node. - */ Node *Node::nodeToward(Handle *dir) { if (front() == dir) { @@ -1188,10 +1183,6 @@ Node *Node::nodeToward(Handle *dir) g_error("Node::nodeToward(): handle is not a child of this node!"); } -/** - * Gets the handle that goes in the direction opposite to the given adjacent node. - * Will abort with error if the given node is not adjacent. - */ Handle *Node::handleAwayFrom(Node *to) { if (_next() == to) { @@ -1203,10 +1194,6 @@ Handle *Node::handleAwayFrom(Node *to) g_error("Node::handleAwayFrom(): second node is not adjacent!"); } -/** - * Gets the node in the direction opposite to the given handle. - * Will abort with error if the handle doesn't belong to this node. - */ Node *Node::nodeAwayFrom(Handle *h) { if (front() == h) { @@ -1218,7 +1205,7 @@ Node *Node::nodeAwayFrom(Handle *h) g_error("Node::nodeAwayFrom(): handle is not a child of this node!"); } -Glib::ustring Node::_getTip(unsigned state) +Glib::ustring Node::_getTip(unsigned state) const { if (state_held_shift(state)) { bool can_drag_out = (_next() && _front.isDegenerate()) || (_prev() && _back.isDegenerate()); @@ -1260,7 +1247,7 @@ Glib::ustring Node::_getTip(unsigned state) "%s: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt)"), nodetype); } -Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/) +Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/) const { Geom::Point dist = position() - _last_drag_origin(); GString *x = SP_PX_TO_METRIC_STRING(dist[Geom::X], _desktop->namedview->getDefaultMetric()); @@ -1283,7 +1270,6 @@ char const *Node::node_type_to_localized_string(NodeType type) } } -/** Determine whether two nodes are joined by a linear segment. */ bool Node::_is_line_segment(Node *first, Node *second) { if (!first || !second) return false; @@ -1306,13 +1292,6 @@ SPCtrlShapeType Node::_node_type_to_shape(NodeType type) } -/** - * An editable list of nodes representing a subpath. - * - * It can optionally be cyclic to represent a closed path. - * The list has iterators that act like plain node iterators, but can also be used - * to obtain shared pointers to nodes. - */ NodeList::NodeList(SubpathList &splist) : _list(splist) , _closed(false) @@ -1344,8 +1323,6 @@ bool NodeList::closed() return _closed; } -/** A subpath is degenerate if it has no segments - either one node in an open path - * or no nodes in a closed path */ bool NodeList::degenerate() { return closed() ? empty() : ++begin() == end(); @@ -1362,10 +1339,9 @@ NodeList::iterator NodeList::before(double t, double *fracpart) return ret; } -// insert a node before i -NodeList::iterator NodeList::insert(iterator i, Node *x) +NodeList::iterator NodeList::insert(iterator pos, Node *x) { - ListNode *ins = i._node; + ListNode *ins = pos._node; x->ln_next = ins; x->ln_prev = ins->ln_prev; ins->ln_prev->ln_next = x; @@ -1471,11 +1447,6 @@ NodeList &NodeList::get(iterator const &i) { } -/** - * @class SubpathList - * Editable path composed of one or more subpaths. - */ - } // namespace UI } // namespace Inkscape -- cgit v1.2.3 From b6ea2239ffc053e66238eb8484bbc5c1ba8700ac Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 17 May 2012 02:10:15 -0700 Subject: Extended resizing to node handles. (bzr r11375) --- src/ui/tool/node.cpp | 73 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 22 deletions(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 1a26b5d55..7408e4309 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -83,7 +83,7 @@ bool Handle::_drag_out = false; Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node *parent) : ControlPoint(data.desktop, initial_pos, SP_ANCHOR_CENTER, - SP_CTRL_SHAPE_CIRCLE, 7.0, + CTRL_TYPE_ADJ_HANDLE, _handle_colors, data.handle_group), _parent(parent), _handle_line(ControlManager::getManager().createControlLine(data.handle_line_group)), @@ -627,10 +627,23 @@ void Node::_updateAutoHandles() void Node::showHandles(bool v) { _handles_shown = v; - if (!_front.isDegenerate()) _front.setVisible(v); - if (!_back.isDegenerate()) _back.setVisible(v); + if (!_front.isDegenerate()) { + _front.setVisible(v); + } + if (!_back.isDegenerate()) { + _back.setVisible(v); + } } +void Node::updateHandles() +{ + _handleControlStyling(); + + _front._handleControlStyling(); + _back._handleControlStyling(); +} + + void Node::setType(NodeType type, bool update_handles) { if (type == NODE_PICK_BEST) { @@ -954,28 +967,36 @@ void Node::_setState(State state) { // change node size to match type and selection state switch (_type) { - case NODE_AUTO: - case NODE_CUSP: - if (selected()) _setSize(11); - else _setSize(9); - break; - default: - if(selected()) _setSize(9); - else _setSize(7); - break; + case NODE_AUTO: + case NODE_CUSP: + if (selected()) { + _setSize(11); + } else { + _setSize(9); + } + break; + default: + if (selected()) { + _setSize(9); + } else { + _setSize(7); + } + break; } SelectableControlPoint::_setState(state); } bool Node::grabbed(GdkEventMotion *event) { - if (SelectableControlPoint::grabbed(event)) + if (SelectableControlPoint::grabbed(event)) { return true; + } // Dragging out handles with Shift + drag on a node. - if (!held_shift(*event)) return false; + if (!held_shift(*event)) { + return false; + } - Handle *h; Geom::Point evp = event_point(*event); Geom::Point rel_evp = evp - _last_click_event_point(); @@ -996,8 +1017,11 @@ bool Node::grabbed(GdkEventMotion *event) angle_prev = fabs(Geom::angle_between(rel_evp, prev_relpos)); has_degenerate = true; } - if (!has_degenerate) return false; - h = angle_next < angle_prev ? &_front : &_back; + if (!has_degenerate) { + return false; + } + + Handle *h = angle_next < angle_prev ? &_front : &_back; h->setPosition(_desktop->w2d(evp)); h->setVisible(true); @@ -1283,11 +1307,16 @@ bool Node::_is_line_segment(Node *first, Node *second) SPCtrlShapeType Node::_node_type_to_shape(NodeType type) { switch(type) { - case NODE_CUSP: return SP_CTRL_SHAPE_DIAMOND; - case NODE_SMOOTH: return SP_CTRL_SHAPE_SQUARE; - case NODE_AUTO: return SP_CTRL_SHAPE_CIRCLE; - case NODE_SYMMETRIC: return SP_CTRL_SHAPE_SQUARE; - default: return SP_CTRL_SHAPE_DIAMOND; + case NODE_CUSP: + return SP_CTRL_SHAPE_DIAMOND; + case NODE_SMOOTH: + return SP_CTRL_SHAPE_SQUARE; + case NODE_AUTO: + return SP_CTRL_SHAPE_CIRCLE; + case NODE_SYMMETRIC: + return SP_CTRL_SHAPE_SQUARE; + default: + return SP_CTRL_SHAPE_DIAMOND; } } -- cgit v1.2.3 From 9d9347ae2714146bc1a943e8b15f26f161e6e10c Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 20 May 2012 21:44:54 -0700 Subject: Extended control resizing to node editing. Fixes half of bug #172059. Additional prep for centralizing color setting. (bzr r11390) --- src/ui/tool/node.cpp | 75 ++++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 34 deletions(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 7408e4309..8098cbee2 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -35,6 +35,31 @@ #include "compat-key-syms.h" #endif +namespace { + +Inkscape::ControlType nodeTypeToCtrlType(Inkscape::UI::NodeType type) +{ + Inkscape::ControlType result = Inkscape::CTRL_TYPE_NODE_CUSP; + switch(type) { + case Inkscape::UI::NODE_SMOOTH: + result = Inkscape::CTRL_TYPE_NODE_SMOOTH; + break; + case Inkscape::UI::NODE_AUTO: + result = Inkscape::CTRL_TYPE_NODE_AUTO; + break; + case Inkscape::UI::NODE_SYMMETRIC: + result = Inkscape::CTRL_TYPE_NODE_SYMETRICAL; + break; + case Inkscape::UI::NODE_CUSP: + default: + result = Inkscape::CTRL_TYPE_NODE_CUSP; + break; + } + return result; +} + +} // namespace + namespace Inkscape { namespace UI { @@ -482,7 +507,7 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) const Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : SelectableControlPoint(data.desktop, initial_pos, SP_ANCHOR_CENTER, - SP_CTRL_SHAPE_DIAMOND, 9.0, + CTRL_TYPE_NODE_CUSP, *data.selection, node_colors, data.node_group), _front(data, initial_pos, this), @@ -736,7 +761,7 @@ void Node::setType(NodeType type, bool update_handles) } } _type = type; - _setShape(_node_type_to_shape(type)); + _setControlType(nodeTypeToCtrlType(_type)); updateState(); } @@ -785,7 +810,7 @@ void Node::pickBestType() } } } while (false); - _setShape(_node_type_to_shape(_type)); + _setControlType(nodeTypeToCtrlType(_type)); updateState(); } @@ -966,21 +991,20 @@ void Node::_linearGrow(int dir) void Node::_setState(State state) { // change node size to match type and selection state - switch (_type) { - case NODE_AUTO: - case NODE_CUSP: - if (selected()) { - _setSize(11); - } else { - _setSize(9); - } + ControlManager &mgr = ControlManager::getManager(); + mgr.setSelected(_canvas_item, selected()); + switch (state) { + case STATE_NORMAL: + mgr.setActive(_canvas_item, false); + mgr.setPrelight(_canvas_item, false); break; - default: - if (selected()) { - _setSize(9); - } else { - _setSize(7); - } + case STATE_MOUSEOVER: + mgr.setActive(_canvas_item, false); + mgr.setPrelight(_canvas_item, true); + break; + case STATE_CLICKED: + mgr.setActive(_canvas_item, true); + mgr.setPrelight(_canvas_item, false); break; } SelectableControlPoint::_setState(state); @@ -1304,23 +1328,6 @@ bool Node::_is_line_segment(Node *first, Node *second) return false; } -SPCtrlShapeType Node::_node_type_to_shape(NodeType type) -{ - switch(type) { - case NODE_CUSP: - return SP_CTRL_SHAPE_DIAMOND; - case NODE_SMOOTH: - return SP_CTRL_SHAPE_SQUARE; - case NODE_AUTO: - return SP_CTRL_SHAPE_CIRCLE; - case NODE_SYMMETRIC: - return SP_CTRL_SHAPE_SQUARE; - default: - return SP_CTRL_SHAPE_DIAMOND; - } -} - - NodeList::NodeList(SubpathList &splist) : _list(splist) , _closed(false) -- cgit v1.2.3 From 62dd6c138e3547689acdcccbb289d822b458cdb0 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 9 Jun 2012 14:40:09 +0100 Subject: Stop deriving SPCanvasItem from GtkObject (bzr r11469.1.1) --- src/ui/tool/node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 8098cbee2..136309a8e 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -120,7 +120,7 @@ Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node Handle::~Handle() { //sp_canvas_item_hide(_handle_line); - gtk_object_destroy(_handle_line); + sp_canvas_item_destroy(_handle_line); } void Handle::setVisible(bool v) -- cgit v1.2.3 From 9abd33133650d77714fccf09d0c9ff27c9b75a78 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 5 Jul 2012 22:39:08 +0100 Subject: Drop GTK+ 2.20 support. Fixed bugs: - https://launchpad.net/bugs/1020494 (bzr r11529) --- src/ui/tool/node.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 136309a8e..bda410856 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -31,10 +31,6 @@ #include "ui/tool/path-manipulator.h" #include -#if !GTK_CHECK_VERSION(2,22,0) -#include "compat-key-syms.h" -#endif - namespace { Inkscape::ControlType nodeTypeToCtrlType(Inkscape::UI::NodeType type) -- cgit v1.2.3 From f903bca67cd52fce0079dfcccecf712b3bc726df Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 13 Oct 2012 23:38:45 +0200 Subject: Shift key should disable snapping when dragging a handle in the node tool Fixed bugs: - https://launchpad.net/bugs/1065931 (bzr r11791) --- src/ui/tool/node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index bda410856..dc6e0fbae 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -293,7 +293,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) Geom::Point parent_pos = _parent->position(); Geom::Point origin = _last_drag_origin(); SnapManager &sm = _desktop->namedview->snap_manager; - bool snap = sm.someSnapperMightSnap(); + bool snap = held_shift(*event) ? false : sm.someSnapperMightSnap(); boost::optional ctrl_constraint; // with Alt, preserve length -- cgit v1.2.3 From fdf69629c66f6c1a69d88a00bb6c1311c97b631b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sat, 20 Jul 2013 15:08:31 -0400 Subject: Ported away from and removed "sp-metrics.*". (bzr r12380.1.47) --- src/ui/tool/node.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index dc6e0fbae..82eb697bd 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -22,7 +22,6 @@ #include "preferences.h" #include "snap.h" #include "snap-preferences.h" -#include "sp-metrics.h" #include "sp-namedview.h" #include "ui/control-manager.h" #include "ui/tool/control-point-selection.h" @@ -490,9 +489,13 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) const double angle = Geom::angle_between(Geom::Point(-1,0), position() - _parent->position()); angle += M_PI; // angle is (-M_PI...M_PI] - offset by +pi and scale to 0...360 angle *= 360.0 / (2 * M_PI); - GString *x = SP_PX_TO_METRIC_STRING(dist[Geom::X], _desktop->namedview->getDefaultMetric()); - GString *y = SP_PX_TO_METRIC_STRING(dist[Geom::Y], _desktop->namedview->getDefaultMetric()); - GString *len = SP_PX_TO_METRIC_STRING(length(), _desktop->namedview->getDefaultMetric()); + + Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); + Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); + Inkscape::Util::Quantity len_q = Inkscape::Util::Quantity(length(), "px"); + GString *x = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); + GString *y = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); + GString *len = g_string_new(len_q.string(*_desktop->namedview->doc_units).c_str()); Glib::ustring ret = format_tip(C_("Path handle tip", "Move handle by %s, %s; angle %.2f°, length %s"), x->str, y->str, angle, len->str); g_string_free(x, TRUE); @@ -1294,8 +1297,11 @@ Glib::ustring Node::_getTip(unsigned state) const Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/) const { Geom::Point dist = position() - _last_drag_origin(); - GString *x = SP_PX_TO_METRIC_STRING(dist[Geom::X], _desktop->namedview->getDefaultMetric()); - GString *y = SP_PX_TO_METRIC_STRING(dist[Geom::Y], _desktop->namedview->getDefaultMetric()); + + Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); + Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); + GString *x = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); + GString *y = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), x->str, y->str); g_string_free(x, TRUE); -- cgit v1.2.3 From a970dc423d59ea844bdb1af48d5d9419a5e2a287 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Oct 2013 00:24:05 +0200 Subject: Units: stop newing Unit objects. pass around pointers to "undeletable" Unit objects in the UnitTable. I think we should move to using indexed units, and pass around the index of the unit in the unittable, or smth like that... ? (bzr r12679) --- src/ui/tool/node.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 82eb697bd..76ec68c3e 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -493,9 +493,9 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) const Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); Inkscape::Util::Quantity len_q = Inkscape::Util::Quantity(length(), "px"); - GString *x = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); - GString *y = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); - GString *len = g_string_new(len_q.string(*_desktop->namedview->doc_units).c_str()); + GString *x = g_string_new(x_q.string(_desktop->namedview->doc_units).c_str()); + GString *y = g_string_new(y_q.string(_desktop->namedview->doc_units).c_str()); + GString *len = g_string_new(len_q.string(_desktop->namedview->doc_units).c_str()); Glib::ustring ret = format_tip(C_("Path handle tip", "Move handle by %s, %s; angle %.2f°, length %s"), x->str, y->str, angle, len->str); g_string_free(x, TRUE); @@ -1300,10 +1300,9 @@ Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/) const Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); - GString *x = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); - GString *y = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); - Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), - x->str, y->str); + GString *x = g_string_new(x_q.string(_desktop->namedview->doc_units).c_str()); + GString *y = g_string_new(y_q.string(_desktop->namedview->doc_units).c_str()); + Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), x->str, y->str); g_string_free(x, TRUE); g_string_free(y, TRUE); return ret; -- cgit v1.2.3 From 55b451bf382e0c3d5ed8728e42fbb535acfa8a33 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 7 Nov 2013 21:44:00 +0100 Subject: First step of moving tools into appropriate namespaces. (bzr r12782) --- src/ui/tool/node.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 76ec68c3e..e246bf997 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -250,7 +250,7 @@ char const *Handle::handle_type_to_localized_string(NodeType type) } } -bool Handle::_eventHandler(SPEventContext *event_context, GdkEvent *event) +bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event) { switch (event->type) { @@ -834,7 +834,7 @@ NodeType Node::parse_nodetype(char x) } } -bool Node::_eventHandler(SPEventContext *event_context, GdkEvent *event) +bool Node::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event) { int dir = 0; -- cgit v1.2.3 From 9df0bd626eed33451e8eeebffcb393fb7ae0f0d8 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 22 Mar 2014 13:21:38 +0100 Subject: tool/node.cpp : don't rely on g_error terminating the program, allow more graceful error handling. (bzr r13183) --- src/ui/tool/node.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index e246bf997..fbbc4be64 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -1217,6 +1217,7 @@ Handle *Node::handleToward(Node *to) return back(); } g_error("Node::handleToward(): second node is not adjacent!"); + return NULL; } Node *Node::nodeToward(Handle *dir) @@ -1228,6 +1229,7 @@ Node *Node::nodeToward(Handle *dir) return _prev(); } g_error("Node::nodeToward(): handle is not a child of this node!"); + return NULL; } Handle *Node::handleAwayFrom(Node *to) @@ -1239,6 +1241,7 @@ Handle *Node::handleAwayFrom(Node *to) return front(); } g_error("Node::handleAwayFrom(): second node is not adjacent!"); + return NULL; } Node *Node::nodeAwayFrom(Handle *h) @@ -1250,6 +1253,7 @@ Node *Node::nodeAwayFrom(Handle *h) return _next(); } g_error("Node::nodeAwayFrom(): handle is not a child of this node!"); + return NULL; } Glib::ustring Node::_getTip(unsigned state) const -- cgit v1.2.3