summaryrefslogtreecommitdiffstats
path: root/src/display/guideline.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2015-12-10 05:43:23 +0000
committerMartin Owens <doctormo@gmail.com>2015-12-10 05:43:23 +0000
commit1b5e5271ae41e3ab4e2d352118e66ccafc608a6f (patch)
treefdb7bf33ae747cebb9428612bbd998723eb28aa6 /src/display/guideline.cpp
parentRemove unused header file. (diff)
downloadinkscape-1b5e5271ae41e3ab4e2d352118e66ccafc608a6f.tar.gz
inkscape-1b5e5271ae41e3ab4e2d352118e66ccafc608a6f.zip
Remove CtrlPoint and replace with SPKnot
(bzr r14523)
Diffstat (limited to 'src/display/guideline.cpp')
-rw-r--r--src/display/guideline.cpp49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp
index 4b7ea59ab..820a61d4d 100644
--- a/src/display/guideline.cpp
+++ b/src/display/guideline.cpp
@@ -17,7 +17,7 @@
#include <2geom/coord.h>
#include <2geom/transforms.h>
#include "sp-canvas-util.h"
-#include "sp-ctrlpoint.h"
+#include "knot.h"
#include "guideline.h"
#include "display/cairo-utils.h"
@@ -25,6 +25,7 @@
#include "desktop.h"
#include "sp-namedview.h"
#include "display/sp-canvas.h"
+#include "display/sodipodi-ctrl.h"
#include "ui/control-manager.h"
using Inkscape::ControlManager;
@@ -36,6 +37,7 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf);
static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
+static gboolean sp_guideline_origin_move(SPKnot *knot, Geom::Point *position, guint state, SPGuideLine *data);
static void sp_guideline_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba);
G_DEFINE_TYPE(SPGuideLine, sp_guideline, SP_TYPE_CANVAS_ITEM);
@@ -72,8 +74,8 @@ static void sp_guideline_destroy(SPCanvasItem *object)
SPGuideLine *gl = SP_GUIDELINE(object);
- if (gl->origin != NULL && SP_IS_CTRLPOINT(gl->origin)) {
- sp_canvas_item_destroy(gl->origin);
+ if (gl->origin != NULL && SP_IS_KNOT(gl->origin)) {
+ knot_unref(gl->origin);
} else {
// FIXME: This branch shouldn't be reached (although it seems to be harmless).
//g_error("Why can it be that gl->origin is not a valid SPCtrlPoint?\n");
@@ -179,14 +181,16 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine,
gl->affine = affine;
if (gl->locked) {
- sp_ctrlpoint_set_circle(gl->origin, false);
- sp_ctrlpoint_set_lenght(gl->origin, 6);
+ gl->origin->setStroke(0x0000ff88, 0x0000ff88, 0x0000ff88);
+ gl->origin->setShape(SP_CTRL_SHAPE_CROSS);
+ gl->origin->setSize(6);
} else {
- sp_ctrlpoint_set_circle(gl->origin, true);
- sp_ctrlpoint_set_lenght(gl->origin, 4);
+ gl->origin->setStroke(0xff000088, 0xff0000ff, 0xff0000ff);
+ gl->origin->setShape(SP_CTRL_SHAPE_CIRCLE);
+ gl->origin->setSize(4);
}
- sp_ctrlpoint_set_coords(gl->origin, gl->point_on_line);
- sp_canvas_item_request_update(SP_CANVAS_ITEM (gl->origin));
+ gl->origin->moveto(gl->point_on_line);
+ gl->origin->updateCtrl();
Geom::Point pol_transformed = gl->point_on_line*affine;
if (gl->is_horizontal()) {
@@ -219,12 +223,15 @@ static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem
SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, char* label, Geom::Point point_on_line, Geom::Point normal)
{
SPCanvasItem *item = sp_canvas_item_new(parent, SP_TYPE_GUIDELINE, NULL);
- SPCanvasItem *origin = ControlManager::getManager().createControl(parent, Inkscape::CTRL_TYPE_ORIGIN);
- ControlManager::getManager().track(origin);
-
SPGuideLine *gl = SP_GUIDELINE(item);
- SPCtrlPoint *cp = SP_CTRLPOINT(origin);
- gl->origin = cp;
+ gl->origin = new SPKnot(SP_ACTIVE_DESKTOP, "No tip yet!! XXX");
+
+ gl->origin->setAnchor(SP_ANCHOR_CENTER);
+ gl->origin->setMode(SP_CTRL_MODE_COLOR);
+ gl->origin->setFill(0xffffff80, 0xffffffff, 0xffffff80);
+ gl->origin->moveto(point_on_line);
+ gl->origin->request_signal.connect(sigc::bind(sigc::ptr_fun(sp_guideline_origin_move), gl));
+ gl->origin->updateCtrl();
normal.normalize();
gl->label = label;
@@ -233,11 +240,18 @@ SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, char* label, Geom::Point p
gl->angle = tan( -gl->normal_to_line[Geom::X] / gl->normal_to_line[Geom::Y]);
sp_guideline_set_position(gl, point_on_line);
- sp_ctrlpoint_set_coords(cp, point_on_line);
-
return item;
}
+static gboolean sp_guideline_origin_move(SPKnot *knot, Geom::Point *position, guint state, SPGuideLine *gl)
+{
+ if(gl->locked) {
+ return true;
+ }
+ sp_guideline_set_position(gl, *position);
+ return false;
+}
+
void sp_guideline_set_label(SPGuideLine *gl, const char* label)
{
if (gl->label) {
@@ -271,8 +285,6 @@ void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line)
void sp_guideline_set_color(SPGuideLine *gl, unsigned int rgba)
{
gl->rgba = rgba;
- sp_ctrlpoint_set_color(gl->origin, rgba);
-
sp_canvas_item_request_update(SP_CANVAS_ITEM(gl));
}
@@ -283,7 +295,6 @@ void sp_guideline_set_sensitive(SPGuideLine *gl, int sensitive)
void sp_guideline_delete(SPGuideLine *gl)
{
- //gtk_object_destroy(GTK_OBJECT(gl->origin));
sp_canvas_item_destroy(SP_CANVAS_ITEM(gl));
}