diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2012-05-09 07:54:48 +0000 |
|---|---|---|
| committer | Jon A. Cruz <jon@joncruz.org> | 2012-05-09 07:54:48 +0000 |
| commit | 0459094999e0298341ecad677464043528d1036f (patch) | |
| tree | b3645de4ef972c8a65910c4890bc6e2d55fdbab9 /src/ui | |
| parent | Unified variable names as scoping now makes the code safe. (diff) | |
| download | inkscape-0459094999e0298341ecad677464043528d1036f.tar.gz inkscape-0459094999e0298341ecad677464043528d1036f.zip | |
Centralized line creation and enhanced visibility.
(bzr r11350)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/control-manager.cpp | 27 | ||||
| -rw-r--r-- | src/ui/control-manager.h | 15 | ||||
| -rw-r--r-- | src/ui/tool/node.cpp | 4 |
3 files changed, 44 insertions, 2 deletions
diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp index ea9cf175d..d19c4a877 100644 --- a/src/ui/control-manager.cpp +++ b/src/ui/control-manager.cpp @@ -16,6 +16,7 @@ #include <glib-object.h> #include "display/sodipodi-ctrl.h" // for SP_TYPE_CTRL +#include "display/sp-ctrlline.h" #include "display/sp-ctrlpoint.h" #include "preferences.h" @@ -28,6 +29,11 @@ std::map<Inkscape::ControlType, std::vector<int> > sizeTable; #define FILL_COLOR_NORMAL 0xffffff7f #define FILL_COLOR_MOUSEOVER 0xff0000ff +// Default color for line: +#define LINE_COLOR_PRIMARY 0x0000ff7f +#define LINE_COLOR_SECONDARY 0xff00007f +#define LINE_COLOR_TERTIARY 0xffff007f + namespace Inkscape { class ControlManagerImpl @@ -231,6 +237,27 @@ SPCanvasItem *ControlManager::createControl(SPCanvasGroup *parent, ControlType t return item; } +SPCtrlLine *ControlManager::createControlLine(SPCanvasGroup *parent, CtrlLineType type) +{ + SPCtrlLine *line = SP_CTRLLINE(sp_canvas_item_new(parent, SP_TYPE_CTRLLINE, NULL)); + if (line) { + line->ctrlType = CTRL_TYPE_LINE; + + line->setRgba32((type == CTLINE_PRIMARY) ? LINE_COLOR_PRIMARY : + (type == CTLINE_SECONDARY) ? LINE_COLOR_SECONDARY : LINE_COLOR_TERTIARY); + } + return line; +} + +SPCtrlLine *ControlManager::createControlLine(SPCanvasGroup *parent, Geom::Point const &p1, Geom::Point const &p2, CtrlLineType type) +{ + SPCtrlLine *line = createControlLine(parent, type); + if (line) { + line->setCoords(p1, p2); + } + return line; +} + void ControlManager::track(SPCanvasItem *item) { _impl->track(item); diff --git a/src/ui/control-manager.h b/src/ui/control-manager.h index 1d3e474b3..986d474d0 100644 --- a/src/ui/control-manager.h +++ b/src/ui/control-manager.h @@ -16,16 +16,25 @@ #include "display/sp-canvas-item.h" -struct SPCanvasItem; struct SPCanvasGroup; +struct SPCanvasItem; +struct SPCtrlLine; namespace Inkscape { +enum CtrlLineType { + CTLINE_PRIMARY, + CTLINE_SECONDARY, + CTLINE_TERTIARY, +}; + + class ControlManagerImpl; class ControlManager { public: + static ControlManager &getManager(); ~ControlManager(); @@ -34,6 +43,10 @@ public: SPCanvasItem *createControl(SPCanvasGroup *parent, ControlType type); + SPCtrlLine *createControlLine(SPCanvasGroup *parent, CtrlLineType type = CTLINE_PRIMARY); + + SPCtrlLine *createControlLine(SPCanvasGroup *parent, Geom::Point const &p1, Geom::Point const &p2, CtrlLineType type = CTLINE_PRIMARY); + void track(SPCanvasItem *item); void updateItem(SPCanvasItem *item); 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); |
