diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | commands.c | 13 | ||||
-rw-r--r-- | config.def.h | 9 | ||||
-rw-r--r-- | image.c | 25 | ||||
-rw-r--r-- | image.h | 3 | ||||
-rw-r--r-- | sxiv.1 | 3 | ||||
-rw-r--r-- | types.h | 6 |
7 files changed, 34 insertions, 26 deletions
@@ -136,6 +136,7 @@ of small previews is displayed, making it easy to choose an image to open. (also with Ctrl-arrow keys) <,> Rotate image (counter-)clockwise by 90 degrees + ? Rotate image by 180 degrees \,| Flip image horizontally/vertically a Toggle anti-aliasing @@ -397,14 +397,17 @@ bool i_fit_to_img(arg_t a) bool i_rotate(arg_t a) { - direction_t dir = (direction_t) a; + rotate_t rot = (rotate_t) a; if (mode == MODE_IMAGE) { - if (dir == DIR_LEFT) { - img_rotate_left(&img); + if (rot == ROTATE_90) { + img_rotate(&img, 1); + return true; + } else if (rot == ROTATE_270) { + img_rotate(&img, 3); return true; - } else if (dir == DIR_RIGHT) { - img_rotate_right(&img); + } else if (rot == ROTATE_180) { + img_rotate(&img, 2); return true; } } diff --git a/config.def.h b/config.def.h index cd89b5f..7a50cf6 100644 --- a/config.def.h +++ b/config.def.h @@ -114,8 +114,9 @@ static const keymap_t keys[] = { { false, XK_E, i_fit_to_win, (arg_t) SCALE_HEIGHT }, { false, XK_W, i_fit_to_img, (arg_t) None }, - { false, XK_less, i_rotate, (arg_t) DIR_LEFT }, - { false, XK_greater, i_rotate, (arg_t) DIR_RIGHT }, + { false, XK_less, i_rotate, (arg_t) ROTATE_270 }, + { false, XK_greater, i_rotate, (arg_t) ROTATE_90 }, + { false, XK_question, i_rotate, (arg_t) ROTATE_180 }, { false, XK_backslash, i_flip, (arg_t) FLIP_HORIZONTAL }, { false, XK_bar, i_flip, (arg_t) FLIP_VERTICAL }, @@ -131,10 +132,14 @@ static const keymap_t keys[] = { "mogrify -rotate -90 \"$SXIV_IMG\"" }, { true, XK_greater, it_shell_cmd, (arg_t) \ "mogrify -rotate +90 \"$SXIV_IMG\"" }, + { true, XK_question, it_shell_cmd, (arg_t) \ + "mogrify -rotate 180 \"$SXIV_IMG\"" }, { true, XK_comma, it_shell_cmd, (arg_t) \ "jpegtran -rotate 270 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" }, { true, XK_period, it_shell_cmd, (arg_t) \ "jpegtran -rotate 90 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" }, + { true, XK_slash, it_shell_cmd, (arg_t) \ + "jpegtran -rotate 180 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" }, }; /* mouse button mappings for image mode: */ @@ -663,29 +663,22 @@ void img_rotate(img_t *img, int d) oy = d == 3 ? img->y : win->h - img->y - img->h * img->zoom; imlib_context_set_image(img->im); + /* rotates by `90 * d` degrees in the clockwise direction */ imlib_image_orientate(d); - img->x = oy + (win->w - win->h) / 2; - img->y = ox + (win->h - win->w) / 2; + if (d == 1 || d == 3) { + 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; + tmp = img->w; + img->w = img->h; + img->h = tmp; + img->checkpan = true; + } - img->checkpan = true; img->dirty = true; } -void img_rotate_left(img_t *img) -{ - img_rotate(img, 3); -} - -void img_rotate_right(img_t *img) -{ - img_rotate(img, 1); -} - void img_flip(img_t *img, flipdir_t d) { if (img == NULL || img->im == NULL) @@ -77,9 +77,6 @@ bool img_pan(img_t*, direction_t, int); bool img_pan_edge(img_t*, direction_t); void img_rotate(img_t*, int); -void img_rotate_left(img_t*); -void img_rotate_right(img_t*); - void img_flip(img_t*, flipdir_t); void img_toggle_antialias(img_t*); @@ -261,6 +261,9 @@ Rotate image counter-clockwise by 90 degrees. .TP .B > Rotate image clockwise by 90 degrees. +.TP +.B ? +Rotate image by 180 degrees. .SS Flip .TP .B \\\\ @@ -39,6 +39,12 @@ typedef enum { } direction_t; typedef enum { + ROTATE_90, + ROTATE_270, + ROTATE_180 +} rotate_t; + +typedef enum { FLIP_HORIZONTAL, FLIP_VERTICAL } flipdir_t; |