From 0459094999e0298341ecad677464043528d1036f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 9 May 2012 00:54:48 -0700 Subject: Centralized line creation and enhanced visibility. (bzr r11350) --- src/ui/control-manager.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/ui/control-manager.cpp') 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 #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 > 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); -- cgit v1.2.3