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/transform-handle-set.cpp | 121 +++++++++++++++++++++++------------ 1 file changed, 79 insertions(+), 42 deletions(-) (limited to 'src/ui/tool/transform-handle-set.cpp') diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index b4a27170a..0e94cb25e 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -3,6 +3,7 @@ */ /* Authors: * Krzysztof Kosiński + * Jon A. Cruz * * Copyright (C) 2009 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@ -38,6 +39,7 @@ namespace Inkscape { namespace UI { namespace { + SPAnchorType corner_to_anchor(unsigned c) { switch (c % 4) { case 0: return SP_ANCHOR_NE; @@ -46,6 +48,7 @@ SPAnchorType corner_to_anchor(unsigned c) { default: return SP_ANCHOR_SE; } } + SPAnchorType side_to_anchor(unsigned s) { switch (s % 4) { case 0: return SP_ANCHOR_N; @@ -62,30 +65,30 @@ double snap_angle(double a) { double unit_angle = M_PI / snaps; return CLAMP(unit_angle * round(a / unit_angle), -M_PI, M_PI); } + double snap_increment_degrees() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int snaps = prefs->getIntLimited("/options/rotationsnapsperpi/value", 12, 1, 1000); return 180.0 / snaps; } -ControlPoint::ColorSet thandle_cset = { +} // anonymous namespace + +ControlPoint::ColorSet TransformHandle::thandle_cset = { + {0x000000ff, 0x000000ff}, + {0x00ff6600, 0x000000ff}, + {0x00ff6600, 0x000000ff}, + // {0x000000ff, 0x000000ff}, {0x00ff6600, 0x000000ff}, {0x00ff6600, 0x000000ff} }; -ControlPoint::ColorSet center_cset = { - {0x00000000, 0x000000ff}, - {0x00000000, 0xff0000b0}, - {0x00000000, 0xff0000b0} -}; -} // anonymous namespace - -/** Base class for node transform handles to simplify implementation */ -TransformHandle::TransformHandle(TransformHandleSet &th, SPAnchorType anchor, Glib::RefPtr pb) - : ControlPoint(th._desktop, Geom::Point(), anchor, pb, &thandle_cset, - th._transform_handle_group) - , _th(th) +TransformHandle::TransformHandle(TransformHandleSet &th, SPAnchorType anchor, Glib::RefPtr pb) : + ControlPoint(th._desktop, Geom::Point(), anchor, + pb, + thandle_cset, th._transform_handle_group), + _th(th) { setVisible(false); } @@ -121,7 +124,8 @@ bool TransformHandle::grabbed(GdkEventMotion *) startTransform(); _th._setActiveHandle(this); - _cset = &invisible_cset; + _setLurking(true); + g_message("Lurk ON for %p", this); _setState(_state); // Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector. @@ -171,7 +175,8 @@ void TransformHandle::ungrabbed(GdkEventButton *) { _snap_points.clear(); _th._clearActiveHandle(); - _cset = &thandle_cset; + _setLurking(false); + g_message("Lurk off for %p", this); _setState(_state); endTransform(); _th.signal_commit.emit(getCommitEvent()); @@ -184,7 +189,7 @@ public: : TransformHandle(th, anchor, pb) {} protected: - virtual Glib::ustring _getTip(unsigned state) { + virtual Glib::ustring _getTip(unsigned state) const { if (state_held_control(state)) { if (state_held_shift(state)) { return C_("Transform handle tip", @@ -205,31 +210,36 @@ protected: return C_("Transform handle tip", "Scale handle: drag to scale the selection"); } - virtual Glib::ustring _getDragTip(GdkEventMotion */*event*/) { + virtual Glib::ustring _getDragTip(GdkEventMotion */*event*/) const { return format_tip(C_("Transform handle tip", "Scale by %.2f%% x %.2f%%"), _last_scale_x * 100, _last_scale_y * 100); } - virtual bool _hasDragTips() { return true; } + virtual bool _hasDragTips() const { return true; } static double _last_scale_x, _last_scale_y; }; double ScaleHandle::_last_scale_x = 1.0; double ScaleHandle::_last_scale_y = 1.0; -/// Corner scaling handle for node transforms +/** + * Corner scaling handle for node transforms. + */ class ScaleCornerHandle : public ScaleHandle { public: - ScaleCornerHandle(TransformHandleSet &th, unsigned corner) - : ScaleHandle(th, corner_to_anchor(corner), _corner_to_pixbuf(corner)) - , _corner(corner) + + ScaleCornerHandle(TransformHandleSet &th, unsigned corner) : + ScaleHandle(th, corner_to_anchor(corner), _corner_to_pixbuf(corner)), + _corner(corner) {} + protected: virtual void startTransform() { _sc_center = _th.rotationCenter(); _sc_opposite = _th.bounds().corner(_corner + 2); _last_scale_x = _last_scale_y = 1.0; } + virtual Geom::Affine computeTransform(Geom::Point const &new_pos, GdkEventMotion *event) { Geom::Point scc = held_shift(*event) ? _sc_center : _sc_opposite; Geom::Point vold = _origin - scc, vnew = new_pos - scc; @@ -275,25 +285,35 @@ protected: * Geom::Translate(scc); return t; } + virtual CommitEvent getCommitEvent() { return _last_transform.isUniformScale() ? COMMIT_MOUSE_SCALE_UNIFORM : COMMIT_MOUSE_SCALE; } + private: + static Glib::RefPtr _corner_to_pixbuf(unsigned c) { sp_select_context_get_type(); switch (c % 2) { - case 0: return Glib::wrap(handles[1], true); - default: return Glib::wrap(handles[0], true); + case 0: + return Glib::wrap(handles[1], true); + break; + default: + return Glib::wrap(handles[0], true); + break; } } + Geom::Point _sc_center; Geom::Point _sc_opposite; unsigned _corner; }; -/// Side scaling handle for node transforms +/** + * Side scaling handle for node transforms. + */ class ScaleSideHandle : public ScaleHandle { public: ScaleSideHandle(TransformHandleSet &th, unsigned side) @@ -369,7 +389,9 @@ private: unsigned _side; }; -/// Rotation handle for node transforms +/** + * Rotation handle for node transforms. + */ class RotateHandle : public TransformHandle { public: RotateHandle(TransformHandleSet &th, unsigned corner) @@ -410,7 +432,7 @@ protected: virtual CommitEvent getCommitEvent() { return COMMIT_MOUSE_ROTATE; } - virtual Glib::ustring _getTip(unsigned state) { + virtual Glib::ustring _getTip(unsigned state) const { if (state_held_shift(state)) { if (state_held_control(state)) { return format_tip(C_("Transform handle tip", @@ -427,12 +449,12 @@ protected: "the selection around the rotation center"); } - virtual Glib::ustring _getDragTip(GdkEventMotion */*event*/) { + virtual Glib::ustring _getDragTip(GdkEventMotion */*event*/) const { return format_tip(C_("Transform handle tip", "Rotate by %.2f°"), _last_angle * 360.0); } - virtual bool _hasDragTips() { return true; } + virtual bool _hasDragTips() const { return true; } private: static Glib::RefPtr _corner_to_pixbuf(unsigned c) { @@ -550,7 +572,7 @@ protected: : COMMIT_MOUSE_SKEW_X; } - virtual Glib::ustring _getTip(unsigned state) { + virtual Glib::ustring _getTip(unsigned state) const { if (state_held_shift(state)) { if (state_held_control(state)) { return format_tip(C_("Transform handle tip", @@ -568,7 +590,7 @@ protected: "the opposite handle"); } - virtual Glib::ustring _getDragTip(GdkEventMotion */*event*/) { + virtual Glib::ustring _getDragTip(GdkEventMotion */*event*/) const { if (_last_horizontal) { return format_tip(C_("Transform handle tip", "Skew horizontally by %.2f°"), _last_angle * 360.0); @@ -578,7 +600,7 @@ protected: } } - virtual bool _hasDragTips() { return true; } + virtual bool _hasDragTips() const { return true; } private: @@ -601,11 +623,13 @@ bool SkewHandle::_last_horizontal = false; double SkewHandle::_last_angle = 0; class RotationCenter : public ControlPoint { + public: - RotationCenter(TransformHandleSet &th) - : ControlPoint(th._desktop, Geom::Point(), SP_ANCHOR_CENTER, _get_pixbuf(), - ¢er_cset, th._transform_handle_group) - , _th(th) + RotationCenter(TransformHandleSet &th) : + ControlPoint(th._desktop, Geom::Point(), SP_ANCHOR_CENTER, + _get_pixbuf(), + _center_cset, th._transform_handle_group), + _th(th) { setVisible(false); } @@ -628,7 +652,7 @@ protected: } sm.unSetup(); } - virtual Glib::ustring _getTip(unsigned /*state*/) { + virtual Glib::ustring _getTip(unsigned /*state*/) const { return C_("Transform handle tip", "Rotation center: drag to change the origin of transforms"); } @@ -640,9 +664,21 @@ private: return Glib::wrap(handles[12], true); } + static ColorSet _center_cset; TransformHandleSet &_th; }; +ControlPoint::ColorSet RotationCenter::_center_cset = { + {0x00000000, 0x000000ff}, + {0x00000000, 0xff0000b0}, + {0x00000000, 0xff0000b0}, + // + {0x00000000, 0x000000ff}, + {0x00000000, 0xff0000b0}, + {0x00000000, 0xff0000b0} +}; + + TransformHandleSet::TransformHandleSet(SPDesktop *d, SPCanvasGroup *th_group) : Manipulator(d) , _active(0) @@ -674,18 +710,22 @@ TransformHandleSet::~TransformHandleSet() } } -/** Sets the mode of transform handles (scale or rotate). */ void TransformHandleSet::setMode(Mode m) { _mode = m; _updateVisibility(_visible); } -Geom::Rect TransformHandleSet::bounds() +Geom::Rect TransformHandleSet::bounds() const { return Geom::Rect(*_scale_corners[0], *_scale_corners[2]); } +ControlPoint const &TransformHandleSet::rotationCenter() const +{ + return *_center; +} + ControlPoint &TransformHandleSet::rotationCenter() { return *_center; @@ -746,9 +786,6 @@ void TransformHandleSet::_clearActiveHandle() _updateVisibility(_visible); } -/** Update the visibility of transformation handles according to settings and the dimensions - * of the bounding box. It hides the handles that would have no effect or lead to - * discontinuities. Additionally, side handles for which there is no space are not shown. */ void TransformHandleSet::_updateVisibility(bool v) { if (v) { -- 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/transform-handle-set.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/ui/tool/transform-handle-set.cpp') diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 0e94cb25e..f0bf149f4 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -125,7 +125,6 @@ bool TransformHandle::grabbed(GdkEventMotion *) _th._setActiveHandle(this); _setLurking(true); - g_message("Lurk ON for %p", this); _setState(_state); // Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector. @@ -176,7 +175,6 @@ void TransformHandle::ungrabbed(GdkEventButton *) _snap_points.clear(); _th._clearActiveHandle(); _setLurking(false); - g_message("Lurk off for %p", this); _setState(_state); endTransform(); _th.signal_commit.emit(getCommitEvent()); -- cgit v1.2.3 From 1227ca0189590b281116fcc808bdd8c674b2196c Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 20 Apr 2013 21:16:13 +0200 Subject: Further changes to EventContexts; they work without GObject (bzr r11608.1.97) --- src/ui/tool/transform-handle-set.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui/tool/transform-handle-set.cpp') diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index f0bf149f4..479a29d1f 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -129,7 +129,8 @@ bool TransformHandle::grabbed(GdkEventMotion *) // Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector. InkNodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context); - ControlPointSelection *selection = nt->_selected_nodes.get(); + //ControlPointSelection *selection = nt->_selected_nodes.get(); + ControlPointSelection* selection = nt->_selected_nodes; selection->setOriginalPoints(); selection->getOriginalPoints(_snap_points); -- cgit v1.2.3 From 65ba6ad9a82f8f47974eb10665478fd783692bb5 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 20 Apr 2013 23:19:46 +0200 Subject: Merging of EventContext classes complete. (bzr r11608.1.98) --- src/ui/tool/transform-handle-set.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui/tool/transform-handle-set.cpp') diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 479a29d1f..348420994 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -294,7 +294,7 @@ protected: private: static Glib::RefPtr _corner_to_pixbuf(unsigned c) { - sp_select_context_get_type(); + //sp_select_context_get_type(); switch (c % 2) { case 0: return Glib::wrap(handles[1], true); @@ -377,7 +377,7 @@ protected: } private: static Glib::RefPtr _side_to_pixbuf(unsigned c) { - sp_select_context_get_type(); + //sp_select_context_get_type(); switch (c % 2) { case 0: return Glib::wrap(handles[3], true); default: return Glib::wrap(handles[2], true); @@ -457,7 +457,7 @@ protected: private: static Glib::RefPtr _corner_to_pixbuf(unsigned c) { - sp_select_context_get_type(); + //sp_select_context_get_type(); switch (c % 4) { case 0: return Glib::wrap(handles[10], true); case 1: return Glib::wrap(handles[8], true); @@ -604,7 +604,7 @@ protected: private: static Glib::RefPtr _side_to_pixbuf(unsigned s) { - sp_select_context_get_type(); + //sp_select_context_get_type(); switch (s % 4) { case 0: return Glib::wrap(handles[9], true); case 1: return Glib::wrap(handles[7], true); @@ -659,7 +659,7 @@ protected: private: static Glib::RefPtr _get_pixbuf() { - sp_select_context_get_type(); + //sp_select_context_get_type(); return Glib::wrap(handles[12], true); } -- cgit v1.2.3 From 6c31882fb2319fcbfbc3e17ac368deac2edd2e79 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 4 Jul 2013 18:58:42 -0400 Subject: Improve handle xpm loading using rotate (bzr r12401.1.1) --- src/ui/tool/transform-handle-set.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/ui/tool/transform-handle-set.cpp') diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index f0bf149f4..30963cabd 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -458,9 +458,9 @@ private: static Glib::RefPtr _corner_to_pixbuf(unsigned c) { sp_select_context_get_type(); switch (c % 4) { - case 0: return Glib::wrap(handles[10], true); - case 1: return Glib::wrap(handles[8], true); - case 2: return Glib::wrap(handles[6], true); + case 0: return Glib::wrap(handles[7], true); + case 1: return Glib::wrap(handles[6], true); + case 2: return Glib::wrap(handles[5], true); default: return Glib::wrap(handles[4], true); } } @@ -605,9 +605,9 @@ private: static Glib::RefPtr _side_to_pixbuf(unsigned s) { sp_select_context_get_type(); switch (s % 4) { - case 0: return Glib::wrap(handles[9], true); - case 1: return Glib::wrap(handles[7], true); - case 2: return Glib::wrap(handles[5], true); + case 0: return Glib::wrap(handles[10], true); + case 1: return Glib::wrap(handles[9], true); + case 2: return Glib::wrap(handles[8], true); default: return Glib::wrap(handles[11], true); } } -- 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/transform-handle-set.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/tool/transform-handle-set.cpp') diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index daed3a523..535a138ed 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -128,7 +128,7 @@ bool TransformHandle::grabbed(GdkEventMotion *) _setState(_state); // Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector. - InkNodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context); + Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context); //ControlPointSelection *selection = nt->_selected_nodes.get(); ControlPointSelection* selection = nt->_selected_nodes; @@ -754,7 +754,7 @@ void TransformHandleSet::setBounds(Geom::Rect const &r, bool preserve_center) } } -bool TransformHandleSet::event(SPEventContext *, GdkEvent*) +bool TransformHandleSet::event(Inkscape::UI::Tools::ToolBase *, GdkEvent*) { return false; } -- cgit v1.2.3 From c04e30df241a3ee039077425bab9b9c37abe2854 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 9 Nov 2013 23:36:13 +0100 Subject: Moved and renamed some tool-related files. (bzr r12785) --- src/ui/tool/transform-handle-set.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tool/transform-handle-set.cpp') diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 535a138ed..f21e1661a 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -26,7 +26,7 @@ #include "ui/tool/selectable-control-point.h" #include "ui/tool/event-utils.h" #include "ui/tool/transform-handle-set.h" -#include "ui/tool/node-tool.h" +#include "ui/tools/node-tool.h" #include "ui/tool/node.h" #include "seltrans.h" -- cgit v1.2.3 From 575b063cd65a705dc8c6ce5b5420ca217d5026e2 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 7 Dec 2013 16:29:48 -0500 Subject: patch by Adolf Mathias and ~suv for Bug 1136495 Fixed bugs: - https://launchpad.net/bugs/1136495 (bzr r12841) --- src/ui/tool/transform-handle-set.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tool/transform-handle-set.cpp') diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index f21e1661a..7d5c9bf0c 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -450,7 +450,7 @@ protected: virtual Glib::ustring _getDragTip(GdkEventMotion */*event*/) const { return format_tip(C_("Transform handle tip", "Rotate by %.2f°"), - _last_angle * 360.0); + _last_angle * 180.0 / M_PI); } virtual bool _hasDragTips() const { return true; } -- cgit v1.2.3