summaryrefslogtreecommitdiff
path: root/meme/gui.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-27 14:07:07 (GMT)
committerWerner Almesberger <werner@almesberger.net>2014-09-27 14:07:07 (GMT)
commitfaecddaef752d8ff47863b13cd5e7a1e960b89a9 (patch)
tree29283e58ba32f77ac443dcfed7bd13a04ce9d6a3 /meme/gui.c
parent41f21897cc736afb4a7c0ca28c16aae62274d1c2 (diff)
downloadmisc-faecddaef752d8ff47863b13cd5e7a1e960b89a9.zip
misc-faecddaef752d8ff47863b13cd5e7a1e960b89a9.tar.gz
misc-faecddaef752d8ff47863b13cd5e7a1e960b89a9.tar.bz2
meme/gui.c (button_event): move zoom in/out to separate functions
Diffstat (limited to 'meme/gui.c')
-rw-r--r--meme/gui.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/meme/gui.c b/meme/gui.c
index 4f54ce9..769e899 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -846,6 +846,34 @@ static void auto_scale(void)
}
+static void zoom_in(int x, int y)
+{
+ if (contrast_mode) {
+ contrast_change(0);
+ return;
+ }
+ if (zoom == 1)
+ return;
+ zoom--;
+ x_orig = (x_orig+x)/2;
+ y_orig = (y_orig+y)/2;
+}
+
+
+static void zoom_out(int x, int y)
+{
+ if (contrast_mode) {
+ contrast_change(1);
+ return;
+ }
+ if (1 << (zoom+1) > x_max-x_min && 1 << (zoom+1) > y_max-y_min)
+ return;
+ zoom++;
+ x_orig = 2*x_orig-x;
+ y_orig = 2*y_orig-y;
+}
+
+
/* ----- Event handling ---------------------------------------------------- */
@@ -885,26 +913,10 @@ static void button_event(SDL_MouseButtonEvent *button)
clear_markers();
break;
case 4: /* wheel forward */
- if (contrast_mode) {
- contrast_change(0);
- break;
- }
- if (zoom == 1)
- break;
- zoom--;
- x_orig = (x_orig+x)/2;
- y_orig = (y_orig+y)/2;
+ zoom_in(x, y);
break;
case 5: /* wheel backward */
- if (contrast_mode) {
- contrast_change(1);
- break;
- }
- if (1 << (zoom+1) > x_max-x_min && 1 << (zoom+1) > y_max-y_min)
- return;
- zoom++;
- x_orig = 2*x_orig-x;
- y_orig = 2*y_orig-y;
+ zoom_out(x, y);
break;
}
}