diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2007-12-16 22:01:05 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2007-12-16 22:01:05 +0000 |
| commit | bd59d3f05937aa2ab65671d7885fbb6cd90f00e6 (patch) | |
| tree | 7eaec80d752fe5deaffb971209904e06f81b073f /src/display | |
| parent | * [INTL: it] Updated Italian translation (diff) | |
| download | inkscape-bd59d3f05937aa2ab65671d7885fbb6cd90f00e6.tar.gz inkscape-bd59d3f05937aa2ab65671d7885fbb6cd90f00e6.zip | |
start of getting angled guidelines.
define guide's normal instead of vertical/horizontal.
rendering is not implemented for angled guides yet.
(bzr r4243)
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/guideline.cpp | 13 | ||||
| -rw-r--r-- | src/display/guideline.h | 9 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index 36f51d3c6..b029be7a0 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -67,7 +67,7 @@ static void sp_guideline_init(SPGuideLine *gl) { gl->rgba = 0x0000ff7f; - gl->vertical = 0; + gl->normal = Geom::Point(0,1); gl->sensitive = 0; } @@ -90,7 +90,7 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) int p0, p1, step; unsigned char *d; - if (gl->vertical) { + if (gl->normal[Geom::Y] == 0.) { if (gl->position < buf->rect.x0 || gl->position >= buf->rect.x1) { return; @@ -129,7 +129,7 @@ static void sp_guideline_update(SPCanvasItem *item, NR::Matrix const &affine, un ((SPCanvasItemClass *) parent_class)->update(item, affine, flags); } - if (gl->vertical) { + if (gl->normal[Geom::Y] == 0.) { gl->position = (int) (affine[4] + 0.5); sp_canvas_update_bbox (item, gl->position, -1000000, gl->position + 1, 1000000); } else { @@ -148,20 +148,21 @@ static double sp_guideline_point(SPCanvasItem *item, NR::Point p, SPCanvasItem * *actual_item = item; - if (gl->vertical) { + if (gl->normal[Geom::Y] == 0.) { return MAX(fabs(gl->position - p[NR::X])-1, 0); } else { return MAX(fabs(gl->position - p[NR::Y])-1, 0); } } -SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, double position, unsigned int vertical) +SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, double position, Geom::Point normal) { SPCanvasItem *item = sp_canvas_item_new(parent, SP_TYPE_GUIDELINE, NULL); SPGuideLine *gl = SP_GUIDELINE(item); - gl->vertical = vertical; + normal.normalize(); + gl->normal = normal; sp_guideline_set_position(gl, position); return item; diff --git a/src/display/guideline.h b/src/display/guideline.h index 22f0af69a..85f39754b 100644 --- a/src/display/guideline.h +++ b/src/display/guideline.h @@ -13,6 +13,7 @@ */ #include "sp-canvas.h" +#include <2geom/point.h> #define SP_TYPE_GUIDELINE (sp_guideline_get_type()) #define SP_GUIDELINE(o) (GTK_CHECK_CAST((o), SP_TYPE_GUIDELINE, SPGuideLine)) @@ -22,10 +23,10 @@ struct SPGuideLine { SPCanvasItem item; guint32 rgba; - + int position; - - unsigned int vertical : 1; + Geom::Point normal; +// unsigned int vertical : 1; unsigned int sensitive : 1; }; @@ -35,7 +36,7 @@ struct SPGuideLineClass { GType sp_guideline_get_type(); -SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, double position, unsigned int vertical); +SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, double position, Geom::Point normal); void sp_guideline_set_position(SPGuideLine *gl, double position); void sp_guideline_set_color(SPGuideLine *gl, unsigned int rgba); |
