summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f67dc0e)
raw | patch | inline | side by side (parent: f67dc0e)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 23 Dec 2007 23:46:26 +0000 (23:46 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 23 Dec 2007 23:46:26 +0000 (23:46 +0000) |
src/desktop-events.cpp | patch | blob | history |
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index eeb0881603e9cd52341f4be49b1e27cda05d89e8..24d94b5a32ee61eb7c47a546669d2b388d4386fc 100644 (file)
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
gdk_window_get_pointer(GTK_WIDGET(dtw->canvas)->window, &wx, &wy, NULL);
NR::Point const event_win(wx, wy);
+ gint width, height;
+ gdk_window_get_geometry(GTK_WIDGET(dtw->canvas)->window, NULL /*x*/, NULL /*y*/, &width, &height, NULL/*depth*/);
+
switch (event->type) {
- case GDK_BUTTON_PRESS:
+ case GDK_BUTTON_PRESS:
if (event->button.button == 1) {
dragging = true;
NR::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
sp_repr_set_boolean(repr, "showguides", TRUE);
sp_repr_set_boolean(repr, "inkscape:guide-bbox", TRUE);
- normal = horiz ? Geom::Point(0.,1.) : Geom::Point(1.,0.);
+ if (horiz) {
+ if (wx < 50) {
+ normal = Geom::Point(-1.,1.);
+ normal.normalize();
+ } else if (wx > width - 50) {
+ normal = Geom::Point(1.,1.);
+ normal.normalize();
+ } else {
+ normal = Geom::Point(0.,1.);
+ }
+ } else {
+ if (wy < 50) {
+ normal = Geom::Point(-1.,1.);
+ normal.normalize();
+ } else if (wy > height - 50) {
+ normal = Geom::Point(1.,1.);
+ normal.normalize();
+ } else {
+ normal = Geom::Point(1.,0.);
+ }
+ }
+
guide = sp_guideline_new(desktop->guides, event_dt.to_2geom(), normal);
sp_guideline_set_color(SP_GUIDELINE(guide), desktop->namedview->guidehicolor);
gdk_pointer_grab(widget->window, FALSE,
event->button.time);
}
break;
- case GDK_MOTION_NOTIFY:
+ case GDK_MOTION_NOTIFY:
if (dragging) {
NR::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
NR::Point event_dt(desktop->w2d(event_w));
desktop->setPosition (event_dt);
}
break;
- case GDK_BUTTON_RELEASE:
+ case GDK_BUTTON_RELEASE:
if (dragging && event->button.button == 1) {
gdk_pointer_ungrab(event->button.time);
NR::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));