From 3aeedd37b69514d3279b0ebfb9abb43a359c3450 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Sun, 9 Jan 2011 05:32:08 +0100 Subject: When zooming, focus on the cursor. --- src/ld-canvas.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/ld-canvas.c b/src/ld-canvas.c index 7d79fec..394746d 100644 --- a/src/ld-canvas.c +++ b/src/ld-canvas.c @@ -1129,9 +1129,15 @@ on_button_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data) static gboolean on_scroll (GtkWidget *widget, GdkEventScroll *event, gpointer user_data) { + gdouble prev_x, prev_y; + gdouble new_x, new_y; LdCanvas *self; self = LD_CANVAS (widget); + + ld_canvas_widget_to_diagram_coords (self, + event->x, event->y, &prev_x, &prev_y); + switch (event->direction) { case GDK_SCROLL_UP: @@ -1144,6 +1150,13 @@ on_scroll (GtkWidget *widget, GdkEventScroll *event, gpointer user_data) return FALSE; } + ld_canvas_widget_to_diagram_coords (self, + event->x, event->y, &new_x, &new_y); + + /* Focus on the point under the cursor. */ + self->priv->x += prev_x - new_x; + self->priv->y += prev_y - new_y; + update_adjustments (self); check_terminals (self, event->x, event->y); gtk_widget_queue_draw (widget); -- cgit v1.2.3-70-g09d2