Krolyxon
Commit ba0a5b8

Branches

Refs →

nsxivba0a5b8

Added horizontal and vertical flip commands

Author
baskerville
Date
2012-05-06 09:39 +0200
Parent
56b6d23
Commit
ba0a5b89fa1e9147c60ddb8bbc2b1bcbe2995cd8

+57 −0

8 files changed

  1. M README.md +1 −0
  2. M commands.c +15 −0
  3. M commands.h +1 −0
  4. M config.def.h +3 −0
  5. M image.c +20 −0
  6. M image.h +5 −0
  7. M sxiv.1 +7 −0
  8. M types.h +5 −0
M README.md View
@@ -122,6 +122,7 @@ The following additional key commands are available in *image mode*:
122122 (also with Ctrl-arrow keys)
123123
124124 <,> Rotate image (counter-)clockwise by 90 degrees
125+ \,| Flip image horizontally/vertically
125126
126127 s Toggle slideshow
127128 Ctrl-'-' Decrease slideshow delay
M commands.c View
@@ -342,6 +342,21 @@ bool i_rotate(arg_t a) {
342342 return false;
343343 }
344344
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+
345360 bool i_toggle_antialias(arg_t a) {
346361 if (mode == MODE_IMAGE) {
347362 img_toggle_antialias(&img);
M commands.h View
@@ -61,6 +61,7 @@ bool i_set_zoom(arg_t);
6161 bool i_fit_to_win(arg_t);
6262 bool i_fit_to_img(arg_t);
6363 bool i_rotate(arg_t);
64+bool i_flip(arg_t);
6465 bool i_toggle_slideshow(arg_t);
6566 bool i_adjust_slideshow(arg_t);
6667 bool i_reset_slideshow(arg_t);
M config.def.h View
@@ -113,6 +113,9 @@ static const keymap_t keys[] = {
113113 { false, XK_less, i_rotate, (arg_t) DIR_LEFT },
114114 { false, XK_greater, i_rotate, (arg_t) DIR_RIGHT },
115115
116+ { false, XK_backslash, i_flip, (arg_t) FLIP_HORIZONTAL },
117+ { false, XK_bar, i_flip, (arg_t) FLIP_VERTICAL },
118+
116119 { false, XK_a, i_toggle_antialias, (arg_t) None },
117120 { false, XK_A, it_toggle_alpha, (arg_t) None },
118121
M image.c View
@@ -642,6 +642,26 @@ void img_rotate_right(img_t *img) {
642642 img_rotate(img, 1);
643643 }
644644
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+
645665 void img_toggle_antialias(img_t *img) {
646666 if (img == NULL || img->im == NULL)
647667 return;
M image.h View
@@ -76,9 +76,14 @@ bool img_move(img_t*, float, float);
7676 bool img_pan(img_t*, direction_t, int);
7777 bool img_pan_edge(img_t*, direction_t);
7878
79+void img_rotate(img_t*, int);
7980 void img_rotate_left(img_t*);
8081 void img_rotate_right(img_t*);
8182
83+void img_flip(img_t*, int);
84+void img_flip_horizontal(img_t*);
85+void img_flip_vertical(img_t*);
86+
8287 void img_toggle_antialias(img_t*);
8388
8489 bool img_frame_navigate(img_t*, int);
M sxiv.1 View
@@ -238,6 +238,13 @@ Rotate image counter-clockwise by 90 degrees.
238238 .TP
239239 .B >
240240 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.
241248 .SS Slideshow
242249 .TP
243250 .B s
M types.h View
@@ -23,6 +23,11 @@ typedef enum {
2323 DIR_DOWN
2424 } direction_t;
2525
26+typedef enum {
27+ FLIP_HORIZONTAL,
28+ FLIP_VERTICAL
29+} flip_t;
30+
2631 typedef enum {
2732 SCALE_DOWN,
2833 SCALE_FIT,