summaryrefslogtreecommitdiffstats
path: root/image.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-01-26 14:42:10 +0100
committerBert <ber.t@gmx.com>2011-01-26 14:42:10 +0100
commit64a5366508142ad938e4a6f9f8bdb5f375b1336c (patch)
treef20b66d2e17c0db5107ff95f35bfb9c707f9866f /image.c
parentd2f9fb89e5517212ac92c00263b57df86c344ee7 (diff)
downloadnsxiv-64a5366508142ad938e4a6f9f8bdb5f375b1336c.tar.zst
Added <,> mappings to rotate image
Diffstat (limited to 'image.c')
-rw-r--r--image.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/image.c b/image.c
index 5187d51..beff925 100644
--- a/image.c
+++ b/image.c
@@ -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);
+}