[gegl] gegl-binary: center scroll-wheel zoom on cursor
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl-binary: center scroll-wheel zoom on cursor
- Date: Wed, 9 Mar 2016 17:16:34 +0000 (UTC)
commit 2c267ed04c4c1bc4334f0e7067c41d007f4bf38b
Author: Øyvind Kolås <pippin gimp org>
Date: Wed Mar 9 18:16:08 2016 +0100
gegl-binary: center scroll-wheel zoom on cursor
bin/ui.c | 43 ++++++++++++++++++++++---------------------
1 files changed, 22 insertions(+), 21 deletions(-)
---
diff --git a/bin/ui.c b/bin/ui.c
index 3433546..42437db 100644
--- a/bin/ui.c
+++ b/bin/ui.c
@@ -893,14 +893,7 @@ static int slide_cb (Mrg *mrg, void *data)
return 0;
}
-static void scroll_cb (MrgEvent *event, void *data1, void *data2)
-{
- /* XXX: should zoom in/out around cursor (event->x , event->y) */
- if (event->scroll_direction)
- zoom_out_cb (event, data1, data2);
- else
- zoom_in_cb (event, data1, data2);
-}
+static void scroll_cb (MrgEvent *event, void *data1, void *data2);
static void ui_viewer (State *o)
{
@@ -1722,26 +1715,34 @@ static void zoom_1_cb (MrgEvent *event, void *data1, void *data2)
mrg_queue_draw (o->mrg, NULL);
}
-static void zoom_in_cb (MrgEvent *event, void *data1, void *data2)
+static void zoom_at (State *o, float screen_cx, float screen_cy, float factor)
{
- State *o = data1;
float x, y;
- get_coords (o, mrg_width(o->mrg)/2, mrg_height(o->mrg)/2, &x, &y);
- o->scale = o->scale * 1.1;
- o->u = x * o->scale - mrg_width(o->mrg)/2;
- o->v = y * o->scale - mrg_height(o->mrg)/2;
+ get_coords (o, screen_cx, screen_cy, &x, &y);
+ o->scale *= factor;
+ o->u = x * o->scale - screen_cx;
+ o->v = y * o->scale - screen_cy;
mrg_queue_draw (o->mrg, NULL);
}
+static void zoom_in_cb (MrgEvent *event, void *data1, void *data2)
+{
+ State *o = data1;
+ zoom_at (data1, mrg_width(o->mrg)/2, mrg_height(o->mrg)/2, 1.1);
+}
+
static void zoom_out_cb (MrgEvent *event, void *data1, void *data2)
{
- State *o = data1;
- float x, y;
- get_coords (o, mrg_width(o->mrg)/2, mrg_height(o->mrg)/2, &x, &y);
- o->scale = o->scale / 1.1;
- o->u = x * o->scale - mrg_width(o->mrg)/2;
- o->v = y * o->scale - mrg_height(o->mrg)/2;
- mrg_queue_draw (o->mrg, NULL);
+ State *o = data1;
+ zoom_at (data1, mrg_width(o->mrg)/2, mrg_height(o->mrg)/2, 1.0/1.1);
+}
+
+static void scroll_cb (MrgEvent *event, void *data1, void *data2)
+{
+ if (event->scroll_direction)
+ zoom_at (data1, event->device_x, event->device_y, 1.0/1.05);
+ else
+ zoom_at (data1, event->device_x, event->device_y, 1.05);
}
static void toggle_actions_cb (MrgEvent *event, void *data1, void *data2)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]