summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b7b3147)
raw | patch | inline | side by side (parent: b7b3147)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 16 Dec 2007 22:01:05 +0000 (22:01 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 16 Dec 2007 22:01:05 +0000 (22:01 +0000) |
define guide's normal instead of vertical/horizontal.
rendering is not implemented for angled guides yet.
rendering is not implemented for angled guides yet.
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 98e96c38c166205d3686cdef20d6e7f46d4f0726..d3c521fec548850ec331c4608da1af09a9a83d9c 100644 (file)
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
double const guide_pos_dt = event_dt[ horiz
? NR::Y
: NR::X ];
- guide = sp_guideline_new(desktop->guides, guide_pos_dt, !horiz);
+ guide = sp_guideline_new(desktop->guides, guide_pos_dt, horiz ? Geom::Point(0.,1.) : Geom::Point(1.,0.));
sp_guideline_set_color(SP_GUIDELINE(guide), desktop->namedview->guidehicolor);
gdk_pointer_grab(widget->window, FALSE,
(GdkEventMask)(GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ),
index 36f51d3c613b636e76e2f1091fd892fc2a27632a..b029be7a0ee91f02ea162ff3151b314d7c87af26 100644 (file)
{
gl->rgba = 0x0000ff7f;
- gl->vertical = 0;
+ gl->normal = Geom::Point(0,1);
gl->sensitive = 0;
}
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;
index 22f0af69add5ad1be9fc06d95abfc91ad40ed74d..85f39754ba76681235cc812653084478803539d3 100644 (file)
--- a/src/display/guideline.h
+++ b/src/display/guideline.h
*/
#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))
SPCanvasItem item;
guint32 rgba;
-
+
int position;
-
- unsigned int vertical : 1;
+ Geom::Point normal;
+// unsigned int vertical : 1;
unsigned int sensitive : 1;
};
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);
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index d65c9997a1fadbe8a351b6ace9f34aa6008a8fd9..4fc5a0f85a474e996a34a3ea38dec4218b1d57b3 100644 (file)
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Peter Moulder <pmoulder@mail.csse.monash.edu.au>
+ * Johan Engelen
*
* Copyright (C) 2000-2002 authors
* Copyright (C) 2004 Monash University
+ * Copyright (C) 2007 Johan Engelen
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -172,7 +174,24 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value)
if (value && !strcmp(value, "horizontal")) {
/* Visual representation of a horizontal line, constrain vertically (y coordinate). */
guide->normal = component_vectors[NR::Y];
+ } else if (value && !strcmp(value, "vertical")) {
+ guide->normal = component_vectors[NR::X];
+ } else if (value) {
+ gchar ** strarray = g_strsplit(value, ",", 2);
+ double newx, newy;
+ unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
+ success += sp_svg_number_read_d(strarray[1], &newy);
+ g_strfreev (strarray);
+ if (success == 2) {
+ Geom::Point direction(newx, newy);
+ direction.normalize();
+ guide->normal = direction;
+ } else {
+ // default to vertical line for bad arguments
+ guide->normal = component_vectors[NR::X];
+ }
} else {
+ // default to vertical line for bad arguments
guide->normal = component_vectors[NR::X];
}
break;
bool const vertical_line_p = ( guide->normal == component_vectors[NR::X] );
g_assert(( guide->normal == component_vectors[NR::X] ) ||
( guide->normal == component_vectors[NR::Y] ) );
- SPCanvasItem *item = sp_guideline_new(group, guide->position, vertical_line_p);
+ SPCanvasItem *item = sp_guideline_new(group, guide->position, vertical_line_p ? Geom::Point(1.,0.) : Geom::Point(0.,1.));
sp_guideline_set_color(SP_GUIDELINE(item), guide->color);
g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), guide);
diff --git a/src/sp-guide.h b/src/sp-guide.h
index a3b87648396ccb48431372bff0e1a9e2e00450f2..5349921747bd69761053eedccdc27f020127c890 100644 (file)
--- a/src/sp-guide.h
+++ b/src/sp-guide.h
* A guideline
*
* Copyright (C) Lauris Kaplinski 2000
+ * Copyright (C) Johan Engelen 2007
*
*/
index 681b1dbbc3bc7a4bec9cb67f8fe7bf17a0339ed7..6a6bd826498349957842e9a595f81c111eda81b9 100644 (file)
--- a/src/ui/widget/ruler.cpp
+++ b/src/ui/widget/ruler.cpp
sp_repr_set_boolean(repr, "showguides", TRUE);
sp_repr_set_boolean(repr, "inkscape:guide-bbox", TRUE);
double const guide_pos_dt = event_dt[ _horiz_f ? NR::Y : NR::X ];
- _guide = sp_guideline_new(_dt->guides, guide_pos_dt, !_horiz_f);
+ _guide = sp_guideline_new(_dt->guides, guide_pos_dt, _horiz_f ? Geom::Point(0.,1.) : Geom::Point(1.,0.));
sp_guideline_set_color(SP_GUIDELINE(_guide), _dt->namedview->guidehicolor);
(void) get_window()->pointer_grab(false,
Gdk::BUTTON_RELEASE_MASK |