diff options
author | baskerville <nihilhill@gmail.com> | 2012-05-06 09:39:45 +0200 |
---|---|---|
committer | baskerville <nihilhill@gmail.com> | 2012-05-06 09:39:45 +0200 |
commit | ba0a5b89fa1e9147c60ddb8bbc2b1bcbe2995cd8 (patch) | |
tree | de37696ccd939fb4df934483b39f5e30071ab341 | |
parent | 56b6d23c0cb05973415bdd2c66af26e8f7db2539 (diff) |
Added horizontal and vertical flip commands
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | commands.c | 15 | ||||
-rw-r--r-- | commands.h | 1 | ||||
-rw-r--r-- | config.def.h | 3 | ||||
-rw-r--r-- | image.c | 20 | ||||
-rw-r--r-- | image.h | 5 | ||||
-rw-r--r-- | sxiv.1 | 7 | ||||
-rw-r--r-- | types.h | 5 |
8 files changed, 57 insertions, 0 deletions
@@ -122,6 +122,7 @@ The following additional key commands are available in *image mode*: (also with Ctrl-arrow keys) <,> Rotate image (counter-)clockwise by 90 degrees + \,| Flip image horizontally/vertically s Toggle slideshow Ctrl-'-' Decrease slideshow delay @@ -342,6 +342,21 @@ bool i_rotate(arg_t a) { return false; } +bool i_flip(arg_t a) { + flip_t flp = (flip_t) a; + + if (mode == MODE_IMAGE) { + if (flp == FLIP_HORIZONTAL) { + img_flip_horizontal(&img); + return true; + } else if (flp == FLIP_VERTICAL) { + img_flip_vertical(&img); + return true; + } + } + return false; +} + bool i_toggle_antialias(arg_t a) { if (mode == MODE_IMAGE) { img_toggle_antialias(&img); @@ -61,6 +61,7 @@ bool i_set_zoom(arg_t); bool i_fit_to_win(arg_t); bool i_fit_to_img(arg_t); bool i_rotate(arg_t); +bool i_flip(arg_t); bool i_toggle_slideshow(arg_t); bool i_adjust_slideshow(arg_t); bool i_reset_slideshow(arg_t); diff --git a/config.def.h b/config.def.h index 95562a3..f711405 100644 --- a/config.def.h +++ b/config.def.h @@ -113,6 +113,9 @@ static const keymap_t keys[] = { { false, XK_less, i_rotate, (arg_t) DIR_LEFT }, { false, XK_greater, i_rotate, (arg_t) DIR_RIGHT }, + { false, XK_backslash, i_flip, (arg_t) FLIP_HORIZONTAL }, + { false, XK_bar, i_flip, (arg_t) FLIP_VERTICAL }, + { false, XK_a, i_toggle_antialias, (arg_t) None }, { false, XK_A, it_toggle_alpha, (arg_t) None }, @@ -642,6 +642,26 @@ void img_rotate_right(img_t *img) { img_rotate(img, 1); } +void img_flip(img_t *img, int f) { + if (img == NULL || img->im == NULL || img->win == NULL) + return; + + imlib_context_set_image(img->im); + if (f == 0) + imlib_image_flip_horizontal(); + else + imlib_image_flip_vertical(); + img->dirty = true; +} + +void img_flip_horizontal(img_t *img) { + img_flip(img, 0); +} + +void img_flip_vertical(img_t *img) { + img_flip(img, 1); +} + void img_toggle_antialias(img_t *img) { if (img == NULL || img->im == NULL) return; @@ -76,9 +76,14 @@ bool img_move(img_t*, float, float); 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*, int); +void img_flip_horizontal(img_t*); +void img_flip_vertical(img_t*); + void img_toggle_antialias(img_t*); bool img_frame_navigate(img_t*, int); @@ -238,6 +238,13 @@ Rotate image counter-clockwise by 90 degrees. .TP .B > Rotate image clockwise by 90 degrees. +.SS Flip +.TP +.B \\\\ +Flip image horizontally. +.TP +.B | +Flip image vertically. .SS Slideshow .TP .B s @@ -24,6 +24,11 @@ typedef enum { } direction_t; typedef enum { + FLIP_HORIZONTAL, + FLIP_VERTICAL +} flip_t; + +typedef enum { SCALE_DOWN, SCALE_FIT, SCALE_ZOOM |