summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2019-05-18 19:14:16 +0000
committerDiederik van Lierop <mail@diedenrezi.nl>2019-05-20 16:22:27 +0000
commit25f00397565bbdce7d7e98420f1921afd5b5092a (patch)
treeeb911793c46904938c43c26d789c6a3b12c2347f /src
parentAnother pixel alignment fix (diff)
downloadinkscape-25f00397565bbdce7d7e98420f1921afd5b5092a.tar.gz
inkscape-25f00397565bbdce7d7e98420f1921afd5b5092a.zip
More pixel-level alignment fixes for various controls, by making all controls have an odd-integer size (measured in pixels)
Diffstat (limited to 'src')
-rw-r--r--src/display/guideline.cpp4
-rw-r--r--src/display/snap-indicator.cpp6
-rw-r--r--src/display/sodipodi-ctrl.cpp28
-rw-r--r--src/knot.cpp2
-rw-r--r--src/selcue.cpp4
-rw-r--r--src/ui/control-manager.cpp35
-rw-r--r--src/ui/tools/box3d-tool.cpp4
-rw-r--r--src/ui/tools/measure-tool.cpp2
8 files changed, 40 insertions, 45 deletions
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp
index 51c99ddce..6dcc6d402 100644
--- a/src/display/guideline.cpp
+++ b/src/display/guideline.cpp
@@ -186,11 +186,11 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine,
if (gl->locked) {
g_object_set(G_OBJECT(gl->origin), "stroke_color", 0x0000ff88,
"shape", SP_CTRL_SHAPE_CROSS,
- "size", 6.0, NULL);
+ "size", 7.0, NULL);
} else {
g_object_set(G_OBJECT(gl->origin), "stroke_color", 0xff000088,
"shape", SP_CTRL_SHAPE_CIRCLE,
- "size", 4.0, NULL);
+ "size", 5.0, NULL);
}
gl->origin->moveto(gl->point_on_line);
sp_canvas_item_request_update(SP_CANVAS_ITEM(gl->origin));
diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp
index 4039a3717..ebd017c64 100644
--- a/src/display/snap-indicator.cpp
+++ b/src/display/snap-indicator.cpp
@@ -250,7 +250,7 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap
canvasitem = sp_canvas_item_new(_desktop->getTempGroup(),
SP_TYPE_CTRL,
"anchor", SP_ANCHOR_CENTER,
- "size", 10.0,
+ "size", 11.0,
"stroked", TRUE,
"stroke_color", pre_snap ? 0x7f7f7fff : 0xff0000ff,
"mode", SP_KNOT_MODE_XOR,
@@ -372,7 +372,7 @@ SnapIndicator::set_new_snapsource(Inkscape::SnapCandidatePoint const &p)
SPCanvasItem * canvasitem = sp_canvas_item_new( _desktop->getTempGroup(),
SP_TYPE_CTRL,
"anchor", SP_ANCHOR_CENTER,
- "size", 6.0,
+ "size", 7.0,
"stroked", TRUE,
"stroke_color", 0xff0000ff,
"mode", SP_KNOT_MODE_XOR,
@@ -391,7 +391,7 @@ SnapIndicator::set_new_debugging_point(Geom::Point const &p)
SPCanvasItem * canvasitem = sp_canvas_item_new( _desktop->getTempGroup(),
SP_TYPE_CTRL,
"anchor", SP_ANCHOR_CENTER,
- "size", 10.0,
+ "size", 11.0,
"fill_color", 0x00ff00ff,
"stroked", FALSE,
"mode", SP_KNOT_MODE_XOR,
diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp
index 601d99e1c..a48ec4cd8 100644
--- a/src/display/sodipodi-ctrl.cpp
+++ b/src/display/sodipodi-ctrl.cpp
@@ -254,15 +254,8 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla
if (!ctrl->defined) return;
- int w = (ctrl->width + 1);
- int h = (ctrl->height + 1);
- if ((ctrl->shape == SP_CTRL_SHAPE_BITMAP) or (ctrl->shape == SP_CTRL_SHAPE_IMAGE)) {
- w = ctrl->width;
- h = ctrl->height;
- }
- int w_half = floor(w/2.0);
- int h_half = floor(h/2.0);
-
+ int w_half = floor(ctrl->width/2.0);
+ int h_half = floor(ctrl->height/2.0);
int x = floor(affine[4]) - w_half;
int y = floor(affine[5]) - h_half;
@@ -361,12 +354,8 @@ sp_ctrl_build_cache (SPCtrl *ctrl, int device_scale)
stroke_color = fill_color;
}
- gint width = (ctrl->width + 1) * device_scale;
- gint height = (ctrl->height + 1) * device_scale;
- if ((ctrl->shape == SP_CTRL_SHAPE_BITMAP) or (ctrl->shape == SP_CTRL_SHAPE_IMAGE)) {
- width = ctrl->width * device_scale;
- height = ctrl->height * device_scale;
- }
+ gint width = ctrl->width * device_scale;
+ gint height = ctrl->height * device_scale;
if (width < 2) return;
gint size = width * height;
@@ -611,12 +600,9 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf)
}
// Must match width/height sp_ctrl_build_cache.
- int w = (ctrl->width + 1) * buf->device_scale;
- int h = (ctrl->height + 1) * buf->device_scale;
- if ((ctrl->shape == SP_CTRL_SHAPE_BITMAP) or (ctrl->shape == SP_CTRL_SHAPE_IMAGE)) {
- w = ctrl->width * buf->device_scale;
- h = ctrl->height * buf->device_scale;
- }
+ int w = ctrl->width * buf->device_scale;
+ int h = ctrl->height * buf->device_scale;
+
double x = ctrl->box.left() - buf->rect.left();
double y = ctrl->box.top() - buf->rect.top();
diff --git a/src/knot.cpp b/src/knot.cpp
index dcf654b2d..58df9cac9 100644
--- a/src/knot.cpp
+++ b/src/knot.cpp
@@ -114,7 +114,7 @@ SPKnot::SPKnot(SPDesktop *desktop, gchar const *tip)
this->item = sp_canvas_item_new(desktop->getControls(),
SP_TYPE_CTRL,
"anchor", SP_ANCHOR_CENTER,
- "size", 8.0,
+ "size", 9.0,
"angle", 0.0,
"filled", TRUE,
"fill_color", 0xffffff00,
diff --git a/src/selcue.cpp b/src/selcue.cpp
index e10b70a96..9a276325f 100644
--- a/src/selcue.cpp
+++ b/src/selcue.cpp
@@ -162,7 +162,7 @@ void Inkscape::SelCue::_newItemBboxes()
SP_TYPE_CTRL,
"mode", SP_CTRL_MODE_XOR,
"shape", SP_CTRL_SHAPE_DIAMOND,
- "size", 5.0,
+ "size", 6.0,
"filled", TRUE,
"fill_color", 0x000000ff,
"stroked", FALSE,
@@ -214,7 +214,7 @@ void Inkscape::SelCue::_newTextBaselines()
if (pt) {
baseline_point = sp_canvas_item_new(_desktop->getControls(), SP_TYPE_CTRL,
"mode", SP_CTRL_MODE_XOR,
- "size", 4.0,
+ "size", 5.0,
"filled", 0,
"stroked", 1,
"stroke_color", 0x000000ff,
diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp
index d97405f7a..c1e4d857c 100644
--- a/src/ui/control-manager.cpp
+++ b/src/ui/control-manager.cpp
@@ -125,11 +125,6 @@ ControlManagerImpl::ControlManagerImpl(ControlManager &manager) :
_itemList(),
_sizeTable()
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->addObserver(_prefHook);
-
- _size = prefs->getIntLimited("/options/grabsize/value", 3, 1, 7);
-
_typeTable[CTRL_TYPE_UNKNOWN] = SP_TYPE_CTRL;
_typeTable[CTRL_TYPE_ADJ_HANDLE] = SP_TYPE_CTRL;
_typeTable[CTRL_TYPE_ANCHOR] = SP_TYPE_CTRL;
@@ -141,7 +136,6 @@ ControlManagerImpl::ControlManagerImpl(ControlManager &manager) :
_typeTable[CTRL_TYPE_LINE] = SP_TYPE_CTRLLINE;
-
// -------
_ctrlToShape[CTRL_TYPE_UNKNOWN] = SP_CTRL_SHAPE_DIAMOND;
_ctrlToShape[CTRL_TYPE_NODE_CUSP] = SP_CTRL_SHAPE_DIAMOND;
@@ -161,32 +155,44 @@ ControlManagerImpl::ControlManagerImpl(ControlManager &manager) :
// -------
+ // The size of the controls is determined by the grabsize preference; see the "Handle size" parameter in
+ // the input/output group, on the "input devices" tab; this parameter ranges from 1 to 7; When selecting a control, we
+ // increase the size by an additional 2 pixels, if _resizeOnSelect is true (see setSelected())
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->addObserver(_prefHook);
+
+ _size = prefs->getIntLimited("/options/grabsize/value", 3, 1, 7);
+
+ // _sizeTable will have odd numbers, which allow for pixel perfect alignment (e.g. relative to grids
+ // or guides, which are 1 px wide. It is not possible to accurately center a control to them if the
+ // control has an even width).
{
- int sizes[] = {8, 8, 8, 8, 8, 8, 8};
+ int sizes[] = {7, 7, 7, 7, 7, 7, 7};
_sizeTable[CTRL_TYPE_UNKNOWN] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
}
{
- int sizes[] = {2, 4, 6, 8, 10, 12, 14};
+ int sizes[] = {3, 5, 7, 9, 11, 13, 15};
_sizeTable[CTRL_TYPE_ANCHOR] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
}
{
- int sizes[] = {2, 4, 7, 8, 9, 10, 12};
+ int sizes[] = {3, 5, 7, 9, 11, 13, 15};
_sizeTable[CTRL_TYPE_ADJ_HANDLE] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
}
{
- int sizes[] = {4, 6, 8, 10, 12, 14, 16};
+ int sizes[] = {5, 7, 9, 11, 13, 15, 17};
_sizeTable[CTRL_TYPE_POINT] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
_sizeTable[CTRL_TYPE_ROTATE] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
_sizeTable[CTRL_TYPE_SIZER] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
_sizeTable[CTRL_TYPE_SHAPER] = std::vector<int>(sizes, sizes + (sizeof(sizes) / sizeof(sizes[0])));
}
{
- int sizes[] = {5, 7, 9, 10, 11, 12, 13};
+ int sizes[] = {5, 7, 9, 11, 13, 15, 17};
_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])));
}
{
- int sizes[] = {3, 5, 7, 8, 9, 10, 11};
+ int sizes[] = {3, 5, 7, 9, 11, 13, 15};
_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])));
}
@@ -286,7 +292,6 @@ void ControlManagerImpl::updateItem(SPCanvasItem *item)
{
if (item) {
double target = _sizeTable[item->ctrlType][_size - 1] + item->ctrlResize;
-
g_object_set(item, "size", target, NULL);
sp_canvas_item_request_update(item);
@@ -315,6 +320,10 @@ bool ControlManagerImpl::setControlType(SPCanvasItem *item, ControlType type)
bool ControlManagerImpl::setControlResize(SPCanvasItem *item, int ctrlResize)
{
+ // _sizeTable will have odd numbers, which allow for pixel perfect alignment (e.g. relative to grids
+ // or guides, which are 1 px wide. It is not possible to accurately center a control to them if the
+ // control has an even width). ctrlResize should therefore be an even number, such that the sum (targetSize)
+ // is also odd
if(item) {
item->ctrlResize = ctrlResize;
double targetSize = _sizeTable[item->ctrlType][_size - 1] + item->ctrlResize;
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index ef73eea9b..f54e07784 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -394,11 +394,11 @@ bool Box3dTool::root_handler(GdkEvent* event) {
ret = true;
break;
- /* TODO: what is this???
+ /* FOR DEBUGGING PURPOSES
case GDK_O:
if (MOD__CTRL(event) && MOD__SHIFT(event)) {
Box3D::create_canvas_point(persp3d_get_VP(document()->getCurrentPersp3D(), Proj::W).affine(),
- 6, 0xff00ff00);
+ 7, 0xff00ff00);
}
ret = true;
break;
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index 64824514e..3c706fbc6 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -1080,7 +1080,7 @@ void MeasureTool::setMeasureCanvasItem(Geom::Point position, bool to_item, bool
SPCanvasItem * canvasitem = sp_canvas_item_new(desktop->getTempGroup(),
SP_TYPE_CTRL,
"anchor", SP_ANCHOR_CENTER,
- "size", 8.0,
+ "size", 9.0,
"stroked", TRUE,
"stroke_color", color,
"mode", SP_KNOT_MODE_XOR,