diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | image.c | 33 | ||||
-rw-r--r-- | image.h | 3 | ||||
-rw-r--r-- | main.c | 8 | ||||
-rw-r--r-- | sxiv.1 | 7 |
6 files changed, 52 insertions, 2 deletions
@@ -1,6 +1,6 @@ all: sxiv -VERSION=0.2 +VERSION=git-20110126 CC?=gcc PREFIX?=/usr/local @@ -42,5 +42,6 @@ Use the following keys to control sxiv: +,= Zoom in - Zoom out 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 window manager) @@ -104,7 +104,7 @@ void img_render(img_t *img, win_t *win) { if (!img || !win || !imlib_context_get_image()) 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 */ zw = (float) win->w / (float) img->w; 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; } + +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); +} @@ -56,4 +56,7 @@ int img_zoom_out(img_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 */ @@ -219,6 +219,14 @@ void on_keypress(XEvent *ev) { changed = img_pan(&img, &win, PAN_RIGHT); break; + /* rotation */ + case '<': + changed = img_rotate_left(&img, &win); + break; + case '>': + changed = img_rotate_right(&img, &win); + break; + /* Control window */ case 'f': win_toggle_fullscreen(&win); @@ -65,6 +65,13 @@ Pan up. .TP .B l Pan right. +.SS Rotation +.TP +.B < +Rotate image counter-clockwise by 90 degrees. +.TP +.B > +Rotate image clockwise by 90 degrees. .SS Control window .TP .B f |