diff options
| author | Martin Owens <doctormo@gmail.com> | 2016-04-02 18:21:12 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2016-04-02 18:21:12 +0000 |
| commit | ab843636c11bb0d0550a8987fbdfcb089a55832e (patch) | |
| tree | ce5db2b27601e5726a3183abccafcde41f6755e2 /src/ui | |
| parent | Remove unused variable warnings. (diff) | |
| download | inkscape-ab843636c11bb0d0550a8987fbdfcb089a55832e.tar.gz inkscape-ab843636c11bb0d0550a8987fbdfcb089a55832e.zip | |
Fix node size regression and add ctrlResize property for multiple use.
Fixed bugs:
- https://launchpad.net/bugs/1562197
(bzr r14761)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/control-manager.cpp | 56 | ||||
| -rw-r--r-- | src/ui/control-manager.h | 2 | ||||
| -rw-r--r-- | src/ui/draw-anchor.cpp | 12 |
3 files changed, 41 insertions, 29 deletions
diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp index cedaea405..a2c977533 100644 --- a/src/ui/control-manager.cpp +++ b/src/ui/control-manager.cpp @@ -54,9 +54,6 @@ ControlFlags& operator ^=(ControlFlags &lhs, ControlFlags rhs) } // namespace -#define FILL_COLOR_NORMAL 0xffffff7f -#define FILL_COLOR_MOUSEOVER 0xff0000ff - // Default color for line: #define LINE_COLOR_PRIMARY 0x0000ff7f #define LINE_COLOR_SECONDARY 0xff00007f @@ -83,6 +80,8 @@ public: bool setControlType(SPCanvasItem *item, ControlType type); + bool setControlResize(SPCanvasItem *item, int ctrlResize); + void setSelected(SPCanvasItem *item, bool selected); private: @@ -108,12 +107,13 @@ private: ControlManager &_manager; sigc::signal<void> _sizeChangedSignal; PrefListener _prefHook; - int _size; + int _size; // Size from the grabsize preference + int _resize; // Way size should change from grabsize std::vector<SPCanvasItem *> _itemList; std::map<Inkscape::ControlType, std::vector<int> > _sizeTable; std::map<Inkscape::ControlType, GType> _typeTable; std::map<Inkscape::ControlType, SPCtrlShapeType> _ctrlToShape; - std::set<Inkscape::ControlType> _sizeChangers; + std::set<Inkscape::ControlType> _resizeOnSelect; }; ControlManagerImpl::ControlManagerImpl(ControlManager &manager) : @@ -121,6 +121,7 @@ ControlManagerImpl::ControlManagerImpl(ControlManager &manager) : _sizeChangedSignal(), _prefHook(*this), _size(3), + _resize(3), _itemList(), _sizeTable() { @@ -153,10 +154,10 @@ ControlManagerImpl::ControlManagerImpl(ControlManager &manager) : // ------- - _sizeChangers.insert(CTRL_TYPE_NODE_AUTO); - _sizeChangers.insert(CTRL_TYPE_NODE_CUSP); - _sizeChangers.insert(CTRL_TYPE_NODE_SMOOTH); - _sizeChangers.insert(CTRL_TYPE_NODE_SYMETRICAL); + _resizeOnSelect.insert(CTRL_TYPE_NODE_AUTO); + _resizeOnSelect.insert(CTRL_TYPE_NODE_CUSP); + _resizeOnSelect.insert(CTRL_TYPE_NODE_SMOOTH); + _resizeOnSelect.insert(CTRL_TYPE_NODE_SYMETRICAL); // ------- @@ -234,7 +235,7 @@ SPCanvasItem *ControlManagerImpl::createControl(SPCanvasGroup *parent, ControlTy item = sp_canvas_item_new(parent, SP_TYPE_CTRL, "size", targetSize, "filled", 1, - "fill_color", FILL_COLOR_NORMAL, + "fill_color", 0xffffff7f, "stroked", 1, "stroke_color", 0x000000ff, NULL); @@ -284,11 +285,8 @@ sigc::connection ControlManagerImpl::connectCtrlSizeChanged(const sigc::slot<voi void ControlManagerImpl::updateItem(SPCanvasItem *item) { if (item) { - double target = _sizeTable[item->ctrlType][_size - 1]; + double target = _sizeTable[item->ctrlType][_size - 1] + item->ctrlResize; - if (_sizeChangers.count(item->ctrlType) && _manager.isSelected(item)) { - target += 2; - } g_object_set(item, "size", target, NULL); sp_canvas_item_request_update(item); @@ -303,11 +301,9 @@ bool ControlManagerImpl::setControlType(SPCanvasItem *item, ControlType type) accepted = true; } else if (item) { if (_ctrlToShape.count(type) && (_typeTable[type] == _typeTable[item->ctrlType])) { // compatible? - double targetSize = _sizeTable[type][_size - 1]; - if (_manager.isSelected(item) && _sizeChangers.count(item->ctrlType)) { - targetSize += 2.0; - } + double targetSize = _sizeTable[type][_size - 1] + item->ctrlResize; SPCtrlShapeType targetShape = _ctrlToShape[type]; + g_object_set(item, "shape", targetShape, "size", targetSize, NULL); item->ctrlType = type; accepted = true; @@ -317,17 +313,28 @@ bool ControlManagerImpl::setControlType(SPCanvasItem *item, ControlType type) return accepted; } +bool ControlManagerImpl::setControlResize(SPCanvasItem *item, int ctrlResize) +{ + if(item) { + item->ctrlResize = ctrlResize; + double targetSize = _sizeTable[item->ctrlType][_size - 1] + item->ctrlResize; + g_object_set(item, "size", targetSize, NULL); + return true; + } + return false; +} void ControlManagerImpl::setSelected(SPCanvasItem *item, bool selected) { if (_manager.isSelected(item) != selected) { item->ctrlFlags ^= CTRL_FLAG_SELECTED; // toggle, since we know it is different - // TODO refresh colors - double targetSize = _sizeTable[item->ctrlType][_size - 1]; - if (selected && _sizeChangers.count(item->ctrlType)) { - targetSize += 2.0; + if (selected && _resizeOnSelect.count(item->ctrlType)) { + item->ctrlResize = 2; } + + // TODO refresh colors + double targetSize = _sizeTable[item->ctrlType][_size - 1] + _resize; g_object_set(item, "size", targetSize, NULL); } } @@ -431,6 +438,11 @@ bool ControlManager::setControlType(SPCanvasItem *item, ControlType type) return _impl->setControlType(item, type); } +bool ControlManager::setControlResize(SPCanvasItem *item, int ctrlResize) +{ + return _impl->setControlResize(item, ctrlResize); +} + bool ControlManager::isActive(SPCanvasItem *item) const { return (item->ctrlFlags & CTRL_FLAG_ACTIVE) != 0; diff --git a/src/ui/control-manager.h b/src/ui/control-manager.h index 964ad0a29..3f090d0bd 100644 --- a/src/ui/control-manager.h +++ b/src/ui/control-manager.h @@ -63,6 +63,8 @@ public: bool setControlType(SPCanvasItem *item, ControlType type); + bool setControlResize(SPCanvasItem *item, int ctrlResize); + bool isActive(SPCanvasItem *item) const; void setActive(SPCanvasItem *item, bool active); diff --git a/src/ui/draw-anchor.cpp b/src/ui/draw-anchor.cpp index e5a7a493e..c3bc5676d 100644 --- a/src/ui/draw-anchor.cpp +++ b/src/ui/draw-anchor.cpp @@ -26,9 +26,6 @@ using Inkscape::ControlManager; #define FILL_COLOR_NORMAL 0xffffff7f #define FILL_COLOR_MOUSEOVER 0xff0000ff -#define NODE_SIZE_NORMAL 7.0 -#define NODE_SIZE_MOUSEOVER 10.0 - /** * Creates an anchor object and initializes it. */ @@ -81,18 +78,19 @@ SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, bool acti if ( activate && ( Geom::LInfty( w - anchor->dc->getDesktop().d2w(anchor->dp) ) <= (ctrl->box.width() / 2.0) ) ) { if (!anchor->active) { - g_object_set(anchor->ctrl, "fill_color", FILL_COLOR_MOUSEOVER, - "size", NODE_SIZE_MOUSEOVER, NULL); + ControlManager::getManager().setControlResize(anchor->ctrl, 4); + g_object_set(anchor->ctrl, "fill_color", FILL_COLOR_MOUSEOVER, NULL); anchor->active = TRUE; } return anchor; } if (anchor->active) { - g_object_set(anchor->ctrl, "fill_color", FILL_COLOR_NORMAL, - "size", NODE_SIZE_NORMAL, NULL); + ControlManager::getManager().setControlResize(anchor->ctrl, 0); + g_object_set(anchor->ctrl, "fill_color", FILL_COLOR_NORMAL, NULL); anchor->active = FALSE; } + return NULL; } |
