H/J/K/L mappings to pan to edges
This commit is contained in:
parent
1763e9f253
commit
485e6c863a
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
|||
all: sxiv
|
||||
|
||||
VERSION=git-20110510
|
||||
VERSION=git-20110516
|
||||
|
||||
CC?=gcc
|
||||
DESTDIR?=
|
||||
|
|
29
image.c
29
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;
|
||||
|
||||
|
|
1
image.h
1
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*);
|
||||
|
|
13
main.c
13
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);
|
||||
|
|
Loading…
Reference in a new issue