summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}
}