diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-09-28 17:30:10 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-09-28 17:30:10 +0200 |
commit | 2963a156abf75542a3171dad45ddc9bcce2eb37f (patch) | |
tree | 14f8e3f5c7ddb610b83a409b700cdd3da721ce03 /src | |
parent | 4807123ba77c4018a1fcfa31cee04001c07ba4c5 (diff) |
Set max/min zoom for both key and mouse zooming
Diffstat (limited to 'src')
-rw-r--r-- | src/events.c | 8 | ||||
-rw-r--r-- | src/feh.h | 3 | ||||
-rw-r--r-- | src/keyevents.c | 8 |
3 files changed, 15 insertions, 4 deletions
diff --git a/src/events.c b/src/events.c index def4651..2b8abdd 100644 --- a/src/events.c +++ b/src/events.c @@ -336,15 +336,15 @@ static void feh_event_handle_MotionNotify(XEvent * ev) winwid->zoom = winwid->old_zoom + ( ((double) ev->xmotion.x - (double) winwid->click_offset_x) / 128.0); - /*/ ((double) (winwid->click_offset_x + 1)));*/ else winwid->zoom = winwid->old_zoom - ( ((double) winwid->click_offset_x - (double) ev->xmotion.x) / 128.0); - /*/ ((double) (winwid->click_offset_x + 1)));*/ - if (winwid->zoom < 0.01) - winwid->zoom = 0.01; + if (winwid->zoom < ZOOM_MIN) + winwid->zoom = ZOOM_MIN; + else if (winwid->zoom > ZOOM_MAX) + winwid->zoom = ZOOM_MAX; /* center around click_offset */ winwid->im_x = winwid->click_offset_x @@ -107,6 +107,9 @@ enum image_bg { IMAGE_BG_CHECKS = 0, IMAGE_BG_BLACK, IMAGE_BG_WHITE }; #define INPLACE_EDIT_FLIP -1 #define INPLACE_EDIT_MIRROR -2 +#define ZOOM_MIN 0.002 +#define ZOOM_MAX 2000 + typedef void (*sighandler_t) (int); int feh_main_iteration(int block); diff --git a/src/keyevents.c b/src/keyevents.c index 60663db..942a88b 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -561,6 +561,10 @@ void feh_event_handle_keypress(XEvent * ev) else if (feh_is_kp(&keys.zoom_in, keysym, state)) { winwid->old_zoom = winwid->zoom; winwid->zoom = winwid->zoom * 1.25; + + if (winwid->zoom > ZOOM_MAX) + winwid->zoom = ZOOM_MAX; + winwid->im_x = (winwid->w / 2) - (((winwid->w / 2) - winwid->im_x) / winwid->old_zoom * winwid->zoom); winwid->im_y = (winwid->h / 2) - (((winwid->h / 2) - winwid->im_y) / @@ -571,6 +575,10 @@ void feh_event_handle_keypress(XEvent * ev) else if (feh_is_kp(&keys.zoom_out, keysym, state)) { winwid->old_zoom = winwid->zoom; winwid->zoom = winwid->zoom * 0.80; + + if (winwid->zoom < ZOOM_MIN) + winwid->zoom = ZOOM_MIN; + winwid->im_x = (winwid->w / 2) - (((winwid->w / 2) - winwid->im_x) / winwid->old_zoom * winwid->zoom); winwid->im_y = (winwid->h / 2) - (((winwid->h / 2) - winwid->im_y) / |