diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | image.c | 29 | ||||
-rw-r--r-- | image.h | 1 | ||||
-rw-r--r-- | main.c | 13 |
4 files changed, 44 insertions, 1 deletions
@@ -1,6 +1,6 @@ all: sxiv -VERSION=git-20110510 +VERSION=git-20110516 CC?=gcc DESTDIR?= @@ -293,6 +293,35 @@ int img_pan(img_t *img, win_t *win, pandir_t dir) { return 0; } +int img_pan_edge(img_t *img, win_t *win, pandir_t dir) { + int ox, oy; + + if (!img || !img->im || !win) + return 0; + + ox = img->x; + oy = img->y; + + switch (dir) { + case PAN_LEFT: + img->x = 0; + break; + case PAN_RIGHT: + img->x = win->w - img->w * img->zoom; + break; + case PAN_UP: + img->y = 0; + break; + case PAN_DOWN: + img->y = win->h - img->h * img->zoom; + break; + } + + img_check_pan(img, win); + + return ox != img->x || oy != img->y; +} + void img_rotate(img_t *img, win_t *win, int d) { int ox, oy, tmp; @@ -69,6 +69,7 @@ int img_zoom_out(img_t*, win_t*); int img_move(img_t*, win_t*, int, int); int img_pan(img_t*, win_t*, pandir_t); +int img_pan_edge(img_t*, win_t*, pandir_t); void img_rotate_left(img_t*, win_t*); void img_rotate_right(img_t*, win_t*); @@ -455,6 +455,19 @@ void on_keypress(XKeyEvent *kev) { changed = img_pan(&img, &win, PAN_RIGHT); break; + case XK_H: + changed = img_pan_edge(&img, &win, PAN_LEFT); + break; + case XK_J: + changed = img_pan_edge(&img, &win, PAN_DOWN); + break; + case XK_K: + changed = img_pan_edge(&img, &win, PAN_UP); + break; + case XK_L: + changed = img_pan_edge(&img, &win, PAN_RIGHT); + break; + /* rotation */ case XK_less: img_rotate_left(&img, &win); |