summaryrefslogtreecommitdiffstats
path: root/src/desktop-events.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-12-24 00:48:00 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-12-24 00:48:00 +0000
commit69a418d14f6ef094347ab878ffa66331e1aa9839 (patch)
tree241d3f227ed58833ea75f5246de00414cf8c2485 /src/desktop-events.cpp
parentwhen dragging from rulers close to the edges, one gets 45 degree angled guide... (diff)
downloadinkscape-69a418d14f6ef094347ab878ffa66331e1aa9839.tar.gz
inkscape-69a418d14f6ef094347ab878ffa66331e1aa9839.zip
angled guidelines: create angled line when dragging from edge of rulers
(bzr r4296)
Diffstat (limited to 'src/desktop-events.cpp')
-rw-r--r--src/desktop-events.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 24d94b5a3..d5158255a 100644
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
@@ -31,6 +31,9 @@
#include "xml/repr.h"
#include "dialogs/guidelinedialog.h"
#include "snap.h"
+#include "display/canvas-grid.h"
+#include "display/canvas-axonomgrid.h"
+#include <2geom/point.h>
/* Root item handler */
@@ -67,23 +70,36 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
sp_repr_set_boolean(repr, "showguides", TRUE);
sp_repr_set_boolean(repr, "inkscape:guide-bbox", TRUE);
+ // calculate the normal of the guidelines when dragged from the edges of rulers.
+ Geom::Point normal_bl_to_tr(-1.,1.); //bottomleft to topright
+ Geom::Point normal_tr_to_bl(1.,1.); //topright to bottomleft
+ normal_bl_to_tr.normalize();
+ normal_tr_to_bl.normalize();
+ Inkscape::CanvasGrid * grid = sp_namedview_get_first_enabled_grid(desktop->namedview);
+ if ( grid && grid->getGridType() == Inkscape::GRID_AXONOMETRIC ) {
+ Inkscape::CanvasAxonomGrid *axonomgrid = dynamic_cast<Inkscape::CanvasAxonomGrid *>(grid);
+ if (event->button.state & GDK_CONTROL_MASK) {
+ // guidelines normal to gridlines
+ normal_bl_to_tr = Geom::Point::polar(-axonomgrid->angle_rad[0], 1.0);
+ normal_tr_to_bl = Geom::Point::polar(axonomgrid->angle_rad[2], 1.0);
+ } else {
+ normal_bl_to_tr = rot90(Geom::Point::polar(axonomgrid->angle_rad[2], 1.0));
+ normal_tr_to_bl = rot90(Geom::Point::polar(-axonomgrid->angle_rad[0], 1.0));
+ }
+ }
if (horiz) {
if (wx < 50) {
- normal = Geom::Point(-1.,1.);
- normal.normalize();
+ normal = normal_bl_to_tr;
} else if (wx > width - 50) {
- normal = Geom::Point(1.,1.);
- normal.normalize();
+ normal = normal_tr_to_bl;
} else {
normal = Geom::Point(0.,1.);
}
} else {
if (wy < 50) {
- normal = Geom::Point(-1.,1.);
- normal.normalize();
+ normal = normal_bl_to_tr;
} else if (wy > height - 50) {
- normal = Geom::Point(1.,1.);
- normal.normalize();
+ normal = normal_tr_to_bl;
} else {
normal = Geom::Point(1.,0.);
}