control-manager.cpp revision 8457d3565b2841ffc4ba020b3b91830f55e5a7c7
/*
* Central facade for accessing and managing on-canvas controls.
*
* Author:
* Jon A. Cruz <jon@joncruz.org>
*
* Copyright 2012 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "control-manager.h"
#include <algorithm>
#include <set>
#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-ctrlcurve.h"
#include "display/sp-ctrlpoint.h"
#include "preferences.h"
using Inkscape::ControlFlags;
namespace {
// Note: The following operator overloads are local to this file at the moment to discourage flag manipulation elsewhere.
/*
ControlFlags operator |(ControlFlags lhs, ControlFlags rhs)
{
return static_cast<ControlFlags>(static_cast<int>(lhs) | static_cast<int>(rhs));
}
*/
{
}
{
}
{
return lhs;
}
} // 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
#define LINE_COLOR_TERTIARY 0xffff007f
namespace Inkscape {
class ControlManagerImpl
{
public:
~ControlManagerImpl() {}
private:
{
public:
PrefListener(ControlManagerImpl &manager) : Inkscape::Preferences::Observer("/options/grabsize/value"), _mgr(manager) {}
virtual ~PrefListener() {}
}
};
int _size;
};
_prefHook(*this),
_size(3),
_itemList(),
{
// -------
// -------
// -------
{
_sizeTable[CTRL_TYPE_UNKNOWN] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
}
{
}
{
_sizeTable[CTRL_TYPE_ADJ_HANDLE] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
}
{
}
{
}
{
_sizeTable[CTRL_TYPE_NODE_AUTO] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
_sizeTable[CTRL_TYPE_NODE_CUSP] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
}
{
_sizeTable[CTRL_TYPE_NODE_SMOOTH] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
_sizeTable[CTRL_TYPE_NODE_SYMETRICAL] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
}
{
_sizeTable[CTRL_TYPE_INVISIPOINT] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
}
}
{
{
if (*it) {
updateItem(*it);
}
}
}
}
{
SPCanvasItem *item = 0;
switch (type)
{
case CTRL_TYPE_ADJ_HANDLE:
"shape", SP_CTRL_SHAPE_CIRCLE,
"size", targetSize,
"filled", 0,
"fill_color", 0xff00007f,
"stroked", 1,
"stroke_color", 0x0000ff7f,
NULL);
break;
case CTRL_TYPE_ANCHOR:
"size", targetSize,
"filled", 1,
"fill_color", FILL_COLOR_NORMAL,
"stroked", 1,
"stroke_color", 0x000000ff,
NULL);
break;
case CTRL_TYPE_NODE_AUTO:
case CTRL_TYPE_NODE_CUSP:
case CTRL_TYPE_NODE_SMOOTH:
{
"shape", shape,
"size", targetSize,
NULL);
break;
}
case CTRL_TYPE_ORIGIN:
NULL);
break;
case CTRL_TYPE_INVISIPOINT:
"shape", SP_CTRL_SHAPE_SQUARE,
"size", targetSize,
NULL);
break;
case CTRL_TYPE_UNKNOWN:
default:
}
if (item) {
}
return item;
}
{
setControlSize(_size, true);
}
{
}
{
if (item) {
} else {
target += 2;
}
}
}
}
{
bool accepted = false;
// nothing to do
accepted = true;
} else if (item) {
targetSize += 2.0;
}
accepted = true;
}
}
return accepted;
}
{
// TODO refresh colors
targetSize += 2.0;
}
}
}
{
if (data) {
}
}
{
if (wasItem)
{
{
}
}
}
// ----------------------------------------------------
_impl(new ControlManagerImpl(*this))
{
}
{
}
{
static ControlManager instance;
return instance;
}
{
}
{
if (line) {
}
return line;
}
SPCtrlLine *ControlManager::createControlLine(SPCanvasGroup *parent, Geom::Point const &p1, Geom::Point const &p2, CtrlLineType type)
{
if (line) {
}
return line;
}
SPCtrlCurve *ControlManager::createControlCurve(SPCanvasGroup *parent, Geom::Point const &p0, Geom::Point const &p1, Geom::Point const &p2, Geom::Point const &p3, CtrlLineType type)
{
if (line) {
}
return line;
}
{
}
{
}
{
}
{
}
{
}
{
}
}
{
}
{
}
}
{
}
{
}
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :