aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2011-01-09 05:32:08 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2011-01-09 05:32:08 +0100
commit3aeedd37b69514d3279b0ebfb9abb43a359c3450 (patch)
treebc2d39cf3abce3de889f5e83cfd4bc41e51a3193
parente83cadd03b3cc72a0096cf3c16e751df93348a83 (diff)
downloadlogdiag-3aeedd37b69514d3279b0ebfb9abb43a359c3450.tar.gz
logdiag-3aeedd37b69514d3279b0ebfb9abb43a359c3450.tar.xz
logdiag-3aeedd37b69514d3279b0ebfb9abb43a359c3450.zip
When zooming, focus on the cursor.
-rw-r--r--src/ld-canvas.c13
1 files changed, 13 insertions, 0 deletions
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);