Added <,> mappings to rotate image
This commit is contained in:
parent
d2f9fb89e5
commit
64a5366508
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
||||||
all: sxiv
|
all: sxiv
|
||||||
|
|
||||||
VERSION=0.2
|
VERSION=git-20110126
|
||||||
|
|
||||||
CC?=gcc
|
CC?=gcc
|
||||||
PREFIX?=/usr/local
|
PREFIX?=/usr/local
|
||||||
|
|
|
@ -42,5 +42,6 @@ Use the following keys to control sxiv:
|
||||||
+,= Zoom in
|
+,= Zoom in
|
||||||
- Zoom out
|
- Zoom out
|
||||||
h,j,k,l Scroll left/down/up/right
|
h,j,k,l Scroll left/down/up/right
|
||||||
|
<,> Rotate image (counter-)clockwise by 90 degrees
|
||||||
f Toggle fullscreen mode (requires an EWMH/NetWM compliant
|
f Toggle fullscreen mode (requires an EWMH/NetWM compliant
|
||||||
window manager)
|
window manager)
|
||||||
|
|
33
image.c
33
image.c
|
@ -104,7 +104,7 @@ void img_render(img_t *img, win_t *win) {
|
||||||
if (!img || !win || !imlib_context_get_image())
|
if (!img || !win || !imlib_context_get_image())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((!img->re || !img->zoomed) && SCALE_MODE != SCALE_ZOOM) {
|
if (!img->zoomed && SCALE_MODE != SCALE_ZOOM) {
|
||||||
/* set zoom level to fit image into window */
|
/* set zoom level to fit image into window */
|
||||||
zw = (float) win->w / (float) img->w;
|
zw = (float) win->w / (float) img->w;
|
||||||
zh = (float) win->h / (float) img->h;
|
zh = (float) win->h / (float) img->h;
|
||||||
|
@ -241,3 +241,34 @@ int img_pan(img_t *img, win_t *win, pandir_t dir) {
|
||||||
|
|
||||||
return ox != img->x || oy != img->y;
|
return ox != img->x || oy != img->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int img_rotate(img_t *img, win_t *win, int d) {
|
||||||
|
int ox, oy, tmp;
|
||||||
|
|
||||||
|
if (!img || !win)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ox = d == 1 ? img->x : win->w - img->x - img->w * img->zoom;
|
||||||
|
oy = d == 3 ? img->y : win->h - img->y - img->h * img->zoom;
|
||||||
|
|
||||||
|
imlib_image_orientate(d);
|
||||||
|
|
||||||
|
img->x = oy + (win->w - win->h) / 2;
|
||||||
|
img->y = ox + (win->h - win->w) / 2;
|
||||||
|
|
||||||
|
tmp = img->w;
|
||||||
|
img->w = img->h;
|
||||||
|
img->h = tmp;
|
||||||
|
|
||||||
|
img->checkpan = 1;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int img_rotate_left(img_t *img, win_t *win) {
|
||||||
|
return img_rotate(img, win, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
int img_rotate_right(img_t *img, win_t *win) {
|
||||||
|
return img_rotate(img, win, 1);
|
||||||
|
}
|
||||||
|
|
3
image.h
3
image.h
|
@ -56,4 +56,7 @@ int img_zoom_out(img_t*);
|
||||||
|
|
||||||
int img_pan(img_t*, win_t*, pandir_t);
|
int img_pan(img_t*, win_t*, pandir_t);
|
||||||
|
|
||||||
|
int img_rotate_left(img_t*, win_t*);
|
||||||
|
int img_rotate_right(img_t*, win_t*);
|
||||||
|
|
||||||
#endif /* IMAGE_H */
|
#endif /* IMAGE_H */
|
||||||
|
|
8
main.c
8
main.c
|
@ -219,6 +219,14 @@ void on_keypress(XEvent *ev) {
|
||||||
changed = img_pan(&img, &win, PAN_RIGHT);
|
changed = img_pan(&img, &win, PAN_RIGHT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* rotation */
|
||||||
|
case '<':
|
||||||
|
changed = img_rotate_left(&img, &win);
|
||||||
|
break;
|
||||||
|
case '>':
|
||||||
|
changed = img_rotate_right(&img, &win);
|
||||||
|
break;
|
||||||
|
|
||||||
/* Control window */
|
/* Control window */
|
||||||
case 'f':
|
case 'f':
|
||||||
win_toggle_fullscreen(&win);
|
win_toggle_fullscreen(&win);
|
||||||
|
|
Loading…
Reference in a new issue