nsxivba0a5b8
Added horizontal and vertical flip commands
+57 −0
8 files changed
- M README.md +1 −0
- M commands.c +15 −0
- M commands.h +1 −0
- M config.def.h +3 −0
- M image.c +20 −0
- M image.h +5 −0
- M sxiv.1 +7 −0
- M types.h +5 −0
| @@ -122,6 +122,7 @@ The following additional key commands are available in *image mode*: | |||
| 122 | 122 | (also with Ctrl-arrow keys) | |
| 123 | 123 | ||
| 124 | 124 | <,> Rotate image (counter-)clockwise by 90 degrees | |
| 125 | + | \,| Flip image horizontally/vertically | |
| 125 | 126 | ||
| 126 | 127 | s Toggle slideshow | |
| 127 | 128 | Ctrl-'-' Decrease slideshow delay | |
| @@ -342,6 +342,21 @@ bool i_rotate(arg_t a) { | |||
| 342 | 342 | return false; | |
| 343 | 343 | } | |
| 344 | 344 | ||
| 345 | + | bool i_flip(arg_t a) { | |
| 346 | + | flip_t flp = (flip_t) a; | |
| 347 | + | ||
| 348 | + | if (mode == MODE_IMAGE) { | |
| 349 | + | if (flp == FLIP_HORIZONTAL) { | |
| 350 | + | img_flip_horizontal(&img); | |
| 351 | + | return true; | |
| 352 | + | } else if (flp == FLIP_VERTICAL) { | |
| 353 | + | img_flip_vertical(&img); | |
| 354 | + | return true; | |
| 355 | + | } | |
| 356 | + | } | |
| 357 | + | return false; | |
| 358 | + | } | |
| 359 | + | ||
| 345 | 360 | bool i_toggle_antialias(arg_t a) { | |
| 346 | 361 | if (mode == MODE_IMAGE) { | |
| 347 | 362 | img_toggle_antialias(&img); | |
| @@ -61,6 +61,7 @@ bool i_set_zoom(arg_t); | |||
| 61 | 61 | bool i_fit_to_win(arg_t); | |
| 62 | 62 | bool i_fit_to_img(arg_t); | |
| 63 | 63 | bool i_rotate(arg_t); | |
| 64 | + | bool i_flip(arg_t); | |
| 64 | 65 | bool i_toggle_slideshow(arg_t); | |
| 65 | 66 | bool i_adjust_slideshow(arg_t); | |
| 66 | 67 | bool i_reset_slideshow(arg_t); | |
| @@ -113,6 +113,9 @@ static const keymap_t keys[] = { | |||
| 113 | 113 | { false, XK_less, i_rotate, (arg_t) DIR_LEFT }, | |
| 114 | 114 | { false, XK_greater, i_rotate, (arg_t) DIR_RIGHT }, | |
| 115 | 115 | ||
| 116 | + | { false, XK_backslash, i_flip, (arg_t) FLIP_HORIZONTAL }, | |
| 117 | + | { false, XK_bar, i_flip, (arg_t) FLIP_VERTICAL }, | |
| 118 | + | ||
| 116 | 119 | { false, XK_a, i_toggle_antialias, (arg_t) None }, | |
| 117 | 120 | { false, XK_A, it_toggle_alpha, (arg_t) None }, | |
| 118 | 121 | ||
| @@ -642,6 +642,26 @@ void img_rotate_right(img_t *img) { | |||
| 642 | 642 | img_rotate(img, 1); | |
| 643 | 643 | } | |
| 644 | 644 | ||
| 645 | + | void img_flip(img_t *img, int f) { | |
| 646 | + | if (img == NULL || img->im == NULL || img->win == NULL) | |
| 647 | + | return; | |
| 648 | + | ||
| 649 | + | imlib_context_set_image(img->im); | |
| 650 | + | if (f == 0) | |
| 651 | + | imlib_image_flip_horizontal(); | |
| 652 | + | else | |
| 653 | + | imlib_image_flip_vertical(); | |
| 654 | + | img->dirty = true; | |
| 655 | + | } | |
| 656 | + | ||
| 657 | + | void img_flip_horizontal(img_t *img) { | |
| 658 | + | img_flip(img, 0); | |
| 659 | + | } | |
| 660 | + | ||
| 661 | + | void img_flip_vertical(img_t *img) { | |
| 662 | + | img_flip(img, 1); | |
| 663 | + | } | |
| 664 | + | ||
| 645 | 665 | void img_toggle_antialias(img_t *img) { | |
| 646 | 666 | if (img == NULL || img->im == NULL) | |
| 647 | 667 | return; | |
| @@ -76,9 +76,14 @@ bool img_move(img_t*, float, float); | |||
| 76 | 76 | bool img_pan(img_t*, direction_t, int); | |
| 77 | 77 | bool img_pan_edge(img_t*, direction_t); | |
| 78 | 78 | ||
| 79 | + | void img_rotate(img_t*, int); | |
| 79 | 80 | void img_rotate_left(img_t*); | |
| 80 | 81 | void img_rotate_right(img_t*); | |
| 81 | 82 | ||
| 83 | + | void img_flip(img_t*, int); | |
| 84 | + | void img_flip_horizontal(img_t*); | |
| 85 | + | void img_flip_vertical(img_t*); | |
| 86 | + | ||
| 82 | 87 | void img_toggle_antialias(img_t*); | |
| 83 | 88 | ||
| 84 | 89 | bool img_frame_navigate(img_t*, int); | |
| @@ -238,6 +238,13 @@ Rotate image counter-clockwise by 90 degrees. | |||
| 238 | 238 | .TP | |
| 239 | 239 | .B > | |
| 240 | 240 | Rotate image clockwise by 90 degrees. | |
| 241 | + | .SS Flip | |
| 242 | + | .TP | |
| 243 | + | .B \\\\ | |
| 244 | + | Flip image horizontally. | |
| 245 | + | .TP | |
| 246 | + | .B | | |
| 247 | + | Flip image vertically. | |
| 241 | 248 | .SS Slideshow | |
| 242 | 249 | .TP | |
| 243 | 250 | .B s | |
| @@ -23,6 +23,11 @@ typedef enum { | |||
| 23 | 23 | DIR_DOWN | |
| 24 | 24 | } direction_t; | |
| 25 | 25 | ||
| 26 | + | typedef enum { | |
| 27 | + | FLIP_HORIZONTAL, | |
| 28 | + | FLIP_VERTICAL | |
| 29 | + | } flip_t; | |
| 30 | + | ||
| 26 | 31 | typedef enum { | |
| 27 | 32 | SCALE_DOWN, | |
| 28 | 33 | SCALE_FIT, | |