diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-03-14 16:37:50 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2016-03-14 16:37:50 +0000 |
| commit | b8d22beef5345210ad27cdc2685083aeae6f8f3b (patch) | |
| tree | d69b8bfd19d3627a8425a1b265c2abf229b05354 /src/display/guideline.cpp | |
| parent | fixes for update to trunk (diff) | |
| parent | "Relative to" option for node alignment. (diff) | |
| download | inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.tar.gz inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.zip | |
update to trunk
(bzr r13708.1.39)
Diffstat (limited to 'src/display/guideline.cpp')
| -rw-r--r-- | src/display/guideline.cpp | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index 44bbd14bd..126fcf87c 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -17,17 +17,10 @@ #include <2geom/coord.h> #include <2geom/transforms.h> #include "sp-canvas-util.h" -#include "sp-ctrlpoint.h" #include "guideline.h" #include "display/cairo-utils.h" - -#include "inkscape.h" // for inkscape_active_desktop() -#include "desktop.h" -#include "sp-namedview.h" #include "display/sp-canvas.h" -#include "ui/control-manager.h" - -using Inkscape::ControlManager; +#include "display/sodipodi-ctrl.h" static void sp_guideline_destroy(SPCanvasItem *object); @@ -53,6 +46,7 @@ static void sp_guideline_init(SPGuideLine *gl) { gl->rgba = 0x0000ff7f; + gl->locked = false; gl->normal_to_line = Geom::Point(0,1); gl->angle = 3.14159265358979323846/2; gl->point_on_line = Geom::Point(0,0); @@ -66,16 +60,11 @@ static void sp_guideline_destroy(SPCanvasItem *object) { g_return_if_fail (object != NULL); g_return_if_fail (SP_IS_GUIDELINE (object)); - //g_return_if_fail (SP_GUIDELINE(object)->origin != NULL); - //g_return_if_fail (SP_IS_CTRLPOINT(SP_GUIDELINE(object)->origin)); SPGuideLine *gl = SP_GUIDELINE(object); - if (gl->origin != NULL && SP_IS_CTRLPOINT(gl->origin)) { - sp_canvas_item_destroy(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"); + if (gl->origin) { + sp_canvas_item_destroy(SP_CANVAS_ITEM(gl->origin)); } if (gl->label) { @@ -175,12 +164,22 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine, (SP_CANVAS_ITEM_CLASS(sp_guideline_parent_class))->update(item, affine, flags); } - gl->affine = affine; - - sp_ctrlpoint_set_coords(gl->origin, gl->point_on_line); - sp_canvas_item_request_update(SP_CANVAS_ITEM (gl->origin)); + if (item->visible) { + if (gl->locked) { + g_object_set(G_OBJECT(gl->origin), "stroke_color", 0x0000ff88, + "shape", SP_CTRL_SHAPE_CROSS, + "size", 6., NULL); + } else { + g_object_set(G_OBJECT(gl->origin), "stroke_color", 0xff000088, + "shape", SP_CTRL_SHAPE_CIRCLE, + "size", 4., NULL); + } + gl->origin->moveto(gl->point_on_line); + sp_canvas_item_request_update(SP_CANVAS_ITEM(gl->origin)); + } - Geom::Point pol_transformed = gl->point_on_line*affine; + gl->affine = affine; + Geom::Point pol_transformed = gl->point_on_line * affine; if (gl->is_horizontal()) { sp_canvas_update_bbox (item, -1000000, round(pol_transformed[Geom::Y] - 16), 1000000, round(pol_transformed[Geom::Y] + 1)); } else if (gl->is_vertical()) { @@ -210,20 +209,22 @@ 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; normal.normalize(); gl->label = label; + gl->locked = false; gl->normal_to_line = normal; 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); + gl->origin = (SPCtrl *) sp_canvas_item_new(parent, SP_TYPE_CTRL, + "anchor", SP_ANCHOR_CENTER, + "mode", SP_CTRL_MODE_COLOR, + "filled", FALSE, + "stroked", TRUE, + "stroke_color", 0x01000000, NULL); + gl->origin->pickable = false; return item; } @@ -238,6 +239,12 @@ void sp_guideline_set_label(SPGuideLine *gl, const char* label) sp_canvas_item_request_update(SP_CANVAS_ITEM (gl)); } +void sp_guideline_set_locked(SPGuideLine *gl, const bool locked) +{ + gl->locked = locked; + sp_canvas_item_request_update(SP_CANVAS_ITEM (gl)); +} + void sp_guideline_set_position(SPGuideLine *gl, Geom::Point point_on_line) { gl->point_on_line = point_on_line; @@ -255,8 +262,7 @@ 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); - + g_object_set(G_OBJECT(gl->origin), "stroke_color", rgba, NULL); sp_canvas_item_request_update(SP_CANVAS_ITEM(gl)); } @@ -267,7 +273,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)); } |
