summaryrefslogtreecommitdiffstats
path: root/src/ui/tool
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2012-05-21 04:44:54 +0000
committerJon A. Cruz <jon@joncruz.org>2012-05-21 04:44:54 +0000
commit9d9347ae2714146bc1a943e8b15f26f161e6e10c (patch)
treec25924e3bd82d66e60feff7ef64564f0026ebc3d /src/ui/tool
parentFix for 1000023 : Fill & Stroke dialog redesign (diff)
downloadinkscape-9d9347ae2714146bc1a943e8b15f26f161e6e10c.tar.gz
inkscape-9d9347ae2714146bc1a943e8b15f26f161e6e10c.zip
Extended control resizing to node editing. Fixes half of bug #172059.
Additional prep for centralizing color setting. (bzr r11390)
Diffstat (limited to 'src/ui/tool')
-rw-r--r--src/ui/tool/control-point.cpp23
-rw-r--r--src/ui/tool/control-point.h13
-rw-r--r--src/ui/tool/node.cpp75
-rw-r--r--src/ui/tool/node.h1
-rw-r--r--src/ui/tool/selectable-control-point.cpp6
-rw-r--r--src/ui/tool/selectable-control-point.h2
6 files changed, 52 insertions, 68 deletions
diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp
index 9c559be03..c3e7ccbe6 100644
--- a/src/ui/tool/control-point.cpp
+++ b/src/ui/tool/control-point.cpp
@@ -68,25 +68,6 @@ ControlPoint::ColorSet ControlPoint::invisible_cset = {
};
ControlPoint::ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor,
- SPCtrlShapeType shape, unsigned int size,
- ColorSet const &cset, SPCanvasGroup *group) :
- _desktop(d),
- _canvas_item(NULL),
- _cset(cset),
- _state(STATE_NORMAL),
- _position(initial_pos),
- _lurking(false)
-{
- _canvas_item = sp_canvas_item_new(
- group ? group : sp_desktop_controls (_desktop), SP_TYPE_CTRL,
- "anchor", (SPAnchorType) anchor, "size", (gdouble) size, "shape", shape,
- "filled", TRUE, "fill_color", _cset.normal.fill,
- "stroked", TRUE, "stroke_color", _cset.normal.stroke,
- "mode", SP_CTRL_MODE_XOR, NULL);
- _commonInit();
-}
-
-ControlPoint::ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor,
Glib::RefPtr<Gdk::Pixbuf> pixbuf,
ColorSet const &cset, SPCanvasGroup *group) :
_desktop(d),
@@ -216,9 +197,9 @@ void ControlPoint::_setSize(unsigned int size)
g_object_set(_canvas_item, "size", (gdouble) size, NULL);
}
-void ControlPoint::_setShape(SPCtrlShapeType shape)
+bool ControlPoint::_setControlType(Inkscape::ControlType type)
{
- g_object_set(_canvas_item, "shape", shape, NULL);
+ return ControlManager::getManager().setControlType(_canvas_item, type);
}
void ControlPoint::_setAnchor(SPAnchorType anchor)
diff --git a/src/ui/tool/control-point.h b/src/ui/tool/control-point.h
index 20122e09c..835fa5ab3 100644
--- a/src/ui/tool/control-point.h
+++ b/src/ui/tool/control-point.h
@@ -16,6 +16,8 @@
#include <sigc++/signal.h>
#include <sigc++/trackable.h>
#include <2geom/point.h>
+
+#include "ui/control-types.h"
#include "util/accumulators.h"
#include "display/sodipodi-ctrl.h"
#include "enums.h"
@@ -213,13 +215,12 @@ protected:
* @param d Desktop for this control
* @param initial_pos Initial position of the control point in desktop coordinates
* @param anchor Where is the control point rendered relative to its desktop coordinates
- * @param shape Shape of the control point: square, diamond, circle...
- * @param size Pixel size of the visual representation
+ * @param type Logical type of the control point.
* @param cset Colors of the point
* @param group The canvas group the point's canvas item should be created in
*/
ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor,
- SPCtrlShapeType shape, unsigned int size,
+ ControlType type,
ColorSet const &cset = _default_color_set, SPCanvasGroup *group = 0);
/**
@@ -236,10 +237,6 @@ protected:
Glib::RefPtr<Gdk::Pixbuf> pixbuf,
ColorSet const &cset = _default_color_set, SPCanvasGroup *group = 0);
- ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor,
- ControlType type,
- ColorSet const &cset = _default_color_set, SPCanvasGroup *group = 0);
-
/// @name Handle control point events in subclasses
/// @{
/**
@@ -310,7 +307,7 @@ protected:
void _setSize(unsigned int size);
- void _setShape(SPCtrlShapeType shape);
+ bool _setControlType(Inkscape::ControlType type);
void _setAnchor(SPAnchorType anchor);
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)
diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h
index 084ea1dff..b3964a257 100644
--- a/src/ui/tool/node.h
+++ b/src/ui/tool/node.h
@@ -251,7 +251,6 @@ private:
Inkscape::SnapSourceType _snapSourceType() const;
Inkscape::SnapTargetType _snapTargetType() const;
inline PathManipulator &_pm();
- static SPCtrlShapeType _node_type_to_shape(NodeType type);
/** Determine whether two nodes are joined by a linear segment. */
static bool _is_line_segment(Node *first, Node *second);
diff --git a/src/ui/tool/selectable-control-point.cpp b/src/ui/tool/selectable-control-point.cpp
index f431b9d57..f3f9c0e1e 100644
--- a/src/ui/tool/selectable-control-point.cpp
+++ b/src/ui/tool/selectable-control-point.cpp
@@ -24,10 +24,10 @@ ControlPoint::ColorSet SelectableControlPoint::_default_scp_color_set = {
};
SelectableControlPoint::SelectableControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor,
- SPCtrlShapeType shape, unsigned int size,
+ Inkscape::ControlType type,
ControlPointSelection &sel,
ColorSet const &cset, SPCanvasGroup *group) :
- ControlPoint(d, initial_pos, anchor, shape, size, cset, group),
+ ControlPoint(d, initial_pos, anchor, type, cset, group),
_selection(sel)
{
_selection.allPoints().insert(this);
@@ -37,7 +37,7 @@ SelectableControlPoint::SelectableControlPoint(SPDesktop *d, Geom::Point const &
Glib::RefPtr<Gdk::Pixbuf> pixbuf,
ControlPointSelection &sel,
ColorSet const &cset, SPCanvasGroup *group) :
- ControlPoint (d, initial_pos, anchor, pixbuf, cset, group),
+ ControlPoint(d, initial_pos, anchor, pixbuf, cset, group),
_selection (sel)
{
_selection.allPoints().insert(this);
diff --git a/src/ui/tool/selectable-control-point.h b/src/ui/tool/selectable-control-point.h
index 45da6c2b2..8acfc1168 100644
--- a/src/ui/tool/selectable-control-point.h
+++ b/src/ui/tool/selectable-control-point.h
@@ -32,7 +32,7 @@ public:
protected:
SelectableControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor,
- SPCtrlShapeType shape, unsigned int size,
+ Inkscape::ControlType type,
ControlPointSelection &sel,
ColorSet const &cset = _default_scp_color_set, SPCanvasGroup *group = 0);