diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2012-05-17 09:10:15 +0000 |
|---|---|---|
| committer | Jon A. Cruz <jon@joncruz.org> | 2012-05-17 09:10:15 +0000 |
| commit | b6ea2239ffc053e66238eb8484bbc5c1ba8700ac (patch) | |
| tree | aa69d18959e71ca3a5d268acdc24b85e24663e29 /src/ui/control-manager.cpp | |
| parent | Fix for 997888 : Merge into Document Properties (diff) | |
| download | inkscape-b6ea2239ffc053e66238eb8484bbc5c1ba8700ac.tar.gz inkscape-b6ea2239ffc053e66238eb8484bbc5c1ba8700ac.zip | |
Extended resizing to node handles.
(bzr r11375)
Diffstat (limited to 'src/ui/control-manager.cpp')
| -rw-r--r-- | src/ui/control-manager.cpp | 89 |
1 files changed, 55 insertions, 34 deletions
diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp index d19c4a877..33d262c31 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-canvas-item.h" #include "display/sp-ctrlline.h" #include "display/sp-ctrlpoint.h" #include "preferences.h" @@ -43,6 +44,8 @@ public: ~ControlManagerImpl() {} + SPCanvasItem *createControl(SPCanvasGroup *parent, ControlType type); + void setControlSize(int size, bool force = false); void track(SPCanvasItem *anchor); @@ -98,7 +101,7 @@ ControlManagerImpl::ControlManagerImpl() : _sizeTable[CTRL_TYPE_ANCHOR] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0]))); } { - int sizes[] = {2, 3, 4, 7, 8, 9, 10}; + int sizes[] = {2, 4, 7, 8, 9, 10, 12}; _sizeTable[CTRL_TYPE_ADJ_HANDLE] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0]))); } { @@ -112,6 +115,10 @@ ControlManagerImpl::ControlManagerImpl() : int sizes[] = {2, 3, 4, 7, 8, 9, 10}; _sizeTable[CTRL_TYPE_ORIGIN] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0]))); } + { + int sizes[] = {1, 1, 1, 1, 1, 1, 1}; + _sizeTable[CTRL_TYPE_INVISIPOINT] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0]))); + } } @@ -133,6 +140,52 @@ void ControlManagerImpl::setControlSize(int size, bool force) } } +SPCanvasItem *ControlManagerImpl::createControl(SPCanvasGroup *parent, ControlType type) +{ + SPCanvasItem *item = 0; + double targetSize = _sizeTable[type][_size - 1]; + switch (type) + { + case CTRL_TYPE_ADJ_HANDLE: + item = sp_canvas_item_new(parent, SP_TYPE_CTRL, + "shape", SP_CTRL_SHAPE_CIRCLE, + "size", targetSize, + "filled", 0, + "fill_color", 0xff00007f, + "stroked", 1, + "stroke_color", 0x0000ff7f, + NULL); + break; + case CTRL_TYPE_ANCHOR: + item = sp_canvas_item_new(parent, SP_TYPE_CTRL, + "size", targetSize, + "filled", 1, + "fill_color", FILL_COLOR_NORMAL, + "stroked", 1, + "stroke_color", 0x000000ff, + NULL); + break; + case CTRL_TYPE_ORIGIN: + item = sp_canvas_item_new(parent, SP_TYPE_CTRLPOINT, + "size", targetSize, + NULL); + break; + case CTRL_TYPE_INVISIPOINT: + item = sp_canvas_item_new(parent, SP_TYPE_CTRL, + "shape", SP_CTRL_SHAPE_SQUARE, + "size", targetSize, + NULL); + break; + case CTRL_TYPE_UNKNOWN: + default: + item = sp_canvas_item_new(parent, SP_TYPE_CTRL, NULL); + } + if (item) { + item->ctrlType = type; + } + return item; +} + void ControlManagerImpl::track(SPCanvasItem *item) { g_object_weak_ref( G_OBJECT(item), ControlManagerImpl::thingFinalized, this ); @@ -202,39 +255,7 @@ ControlManager &ControlManager::getManager() SPCanvasItem *ControlManager::createControl(SPCanvasGroup *parent, ControlType type) { - SPCanvasItem *item = 0; - switch (type) - { - case CTRL_TYPE_ADJ_HANDLE: - item = sp_canvas_item_new(parent, SP_TYPE_CTRL, - "shape", SP_CTRL_SHAPE_CIRCLE, - "size", 4.0, - "filled", 0, - "fill_color", 0xff00007f, - "stroked", 1, - "stroke_color", 0x0000ff7f, - NULL); - break; - case CTRL_TYPE_ANCHOR: - item = sp_canvas_item_new(parent, SP_TYPE_CTRL, - "size", 6.0, - "filled", 1, - "fill_color", FILL_COLOR_NORMAL, - "stroked", 1, - "stroke_color", 0x000000ff, - NULL); - break; - case CTRL_TYPE_ORIGIN: - item = sp_canvas_item_new(parent, SP_TYPE_CTRLPOINT, NULL); - break; - case CTRL_TYPE_UNKNOWN: - default: - item = sp_canvas_item_new(parent, SP_TYPE_CTRL, NULL); - } - if (item) { - item->ctrlType = type; - } - return item; + return _impl->createControl(parent, type); } SPCtrlLine *ControlManager::createControlLine(SPCanvasGroup *parent, CtrlLineType type) |
