From c88c5ccca9c4bd0d5ef52d6d09598ae9b54231c0 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Sun, 16 Dec 2007 23:28:17 +0000 Subject: [PATCH] prepare for adding angled guideline rendering --- src/display/guideline.cpp | 49 +++++++++++++++++++++------------------ src/display/guideline.h | 8 ++++--- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index b029be7a0..154b7c3b8 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -1,12 +1,14 @@ #define __SP_GUIDELINE_C__ /* - * Infinite horizontal/vertical line + * Horizontal/vertical but can also be angled line * - * Author: + * Authors: * Lauris Kaplinski + * Johan Engelen * * Copyright (C) 2000-2002 Lauris Kaplinski + * Copyright (C) 2007 Johan Engelen * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -87,37 +89,40 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) unsigned int const b = NR_RGBA32_B (gl->rgba); unsigned int const a = NR_RGBA32_A (gl->rgba); - int p0, p1, step; - unsigned char *d; - if (gl->normal[Geom::Y] == 0.) { - if (gl->position < buf->rect.x0 || gl->position >= buf->rect.x1) { return; } - p0 = buf->rect.y0; - p1 = buf->rect.y1; - step = buf->buf_rowstride; - d = buf->buf + 3 * (gl->position - buf->rect.x0); - - } else { + int p0 = buf->rect.y0; + int p1 = buf->rect.y1; + int step = buf->buf_rowstride; + unsigned char *d = buf->buf + 3 * (gl->position - buf->rect.x0); + for (int p = p0; p < p1; p++) { + d[0] = NR_COMPOSEN11_1111(r, a, d[0]); + d[1] = NR_COMPOSEN11_1111(g, a, d[1]); + d[2] = NR_COMPOSEN11_1111(b, a, d[2]); + d += step; + } + } else if (gl->normal[Geom::X] == 0.) { if (gl->position < buf->rect.y0 || gl->position >= buf->rect.y1) { return; } - p0 = buf->rect.x0; - p1 = buf->rect.x1; - step = 3; - d = buf->buf + (gl->position - buf->rect.y0) * buf->buf_rowstride; - } + int p0 = buf->rect.x0; + int p1 = buf->rect.x1; + int step = 3; + unsigned char *d = buf->buf + (gl->position - buf->rect.y0) * buf->buf_rowstride; - for (int p = p0; p < p1; p++) { - d[0] = NR_COMPOSEN11_1111(r, a, d[0]); - d[1] = NR_COMPOSEN11_1111(g, a, d[1]); - d[2] = NR_COMPOSEN11_1111(b, a, d[2]); - d += step; + for (int p = p0; p < p1; p++) { + d[0] = NR_COMPOSEN11_1111(r, a, d[0]); + d[1] = NR_COMPOSEN11_1111(g, a, d[1]); + d[2] = NR_COMPOSEN11_1111(b, a, d[2]); + d += step; + } + } else { + // render angled line } } diff --git a/src/display/guideline.h b/src/display/guideline.h index 85f39754b..a9bfc809b 100644 --- a/src/display/guideline.h +++ b/src/display/guideline.h @@ -2,12 +2,14 @@ #define __SP_GUIDELINE_H__ /* - * Infinite horizontal/vertical line; the visual representation of SPGuide. + * The visual representation of SPGuide. * - * Author: + * Authors: * Lauris Kaplinski + * Johan Engelen * * Copyright (C) 2000-2002 Lauris Kaplinski + * Copyright (C) 2007 Johan Engelen * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -26,7 +28,7 @@ struct SPGuideLine { int position; Geom::Point normal; -// unsigned int vertical : 1; + unsigned int sensitive : 1; }; -- 2.30.2