aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--image.c29
-rw-r--r--image.h1
-rw-r--r--main.c13
4 files changed, 44 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 3f439f6..bb66592 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
all: sxiv
-VERSION=git-20110510
+VERSION=git-20110516
CC?=gcc
DESTDIR?=
diff --git a/image.c b/image.c
index 7368854..25e85b3 100644
--- a/image.c
+++ b/image.c
@@ -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;
diff --git a/image.h b/image.h
index 0bc7b9d..2f9ffce 100644
--- a/image.h
+++ b/image.h
@@ -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*);
diff --git a/main.c b/main.c
index 2fe743a..292c3bb 100644
--- a/main.c
+++ b/main.c
@@ -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);