summaryrefslogtreecommitdiffstats
path: root/src/draw-anchor.cpp
diff options
context:
space:
mode:
authorDenis Declara <declara91@gmail.com>2012-05-05 13:32:42 +0000
committerDenis Declara <declara91@gmail.com>2012-05-05 13:32:42 +0000
commitaeb9c1bde66de096910757abb17dedb94ad74207 (patch)
treec0adf97685b0fa8af1553b14d20601f280492762 /src/draw-anchor.cpp
parentFixed some math, so that the objects now line up correctly (diff)
parentAdding checks to prevent null pointer dereferences (diff)
downloadinkscape-aeb9c1bde66de096910757abb17dedb94ad74207.tar.gz
inkscape-aeb9c1bde66de096910757abb17dedb94ad74207.zip
Trunk merge
(bzr r11073.1.29)
Diffstat (limited to 'src/draw-anchor.cpp')
-rw-r--r--src/draw-anchor.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/draw-anchor.cpp b/src/draw-anchor.cpp
index d11ac462f..62a091608 100644
--- a/src/draw-anchor.cpp
+++ b/src/draw-anchor.cpp
@@ -20,6 +20,9 @@
#include "lpe-tool-context.h"
#include "display/sodipodi-ctrl.h"
#include "display/curve.h"
+#include "ui/control-manager.h"
+
+using Inkscape::ControlManager;
#define FILL_COLOR_NORMAL 0xffffff7f
#define FILL_COLOR_MOUSEOVER 0xff0000ff
@@ -44,16 +47,12 @@ SPDrawAnchor *sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean sta
a->start = start;
a->active = FALSE;
a->dp = delta;
- a->ctrl = sp_canvas_item_new(sp_desktop_controls(dt), SP_TYPE_CTRL,
- "size", 6.0,
- "filled", 1,
- "fill_color", FILL_COLOR_NORMAL,
- "stroked", 1,
- "stroke_color", 0x000000ff,
- NULL);
+ a->ctrl = ControlManager::getManager().createControl(sp_desktop_controls(dt), Inkscape::CTRL_TYPE_ANCHOR);
SP_CTRL(a->ctrl)->moveto(delta);
+ ControlManager::getManager().track(a->ctrl);
+
return a;
}
@@ -72,8 +71,6 @@ SPDrawAnchor *sp_draw_anchor_destroy(SPDrawAnchor *anchor)
return NULL;
}
-#define A_SNAP 4.0
-
/**
* Test if point is near anchor, if so fill anchor on canvas and return
* pointer to it or NULL.
@@ -81,8 +78,9 @@ SPDrawAnchor *sp_draw_anchor_destroy(SPDrawAnchor *anchor)
SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, gboolean activate)
{
SPDesktop *dt = SP_EVENT_CONTEXT_DESKTOP(anchor->dc);
+ SPCtrl *ctrl = SP_CTRL(anchor->ctrl);
- if ( activate && ( Geom::LInfty( w - dt->d2w(anchor->dp) ) <= A_SNAP ) ) {
+ if ( activate && ( Geom::LInfty( w - dt->d2w(anchor->dp) ) <= (ctrl->box.width() / 2.0) ) ) {
if (!anchor->active) {
sp_canvas_item_set((GtkObject *) anchor->ctrl, "fill_color", FILL_COLOR_MOUSEOVER, NULL);
anchor->active = TRUE;