summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbaskerville <nihilhill@gmail.com>2012-05-06 09:39:45 +0200
committerbaskerville <nihilhill@gmail.com>2012-05-06 09:39:45 +0200
commitba0a5b89fa1e9147c60ddb8bbc2b1bcbe2995cd8 (patch)
treede37696ccd939fb4df934483b39f5e30071ab341
parent56b6d23c0cb05973415bdd2c66af26e8f7db2539 (diff)
downloadnsxiv-ba0a5b89fa1e9147c60ddb8bbc2b1bcbe2995cd8.tar.zst
Added horizontal and vertical flip commands
-rw-r--r--README.md1
-rw-r--r--commands.c15
-rw-r--r--commands.h1
-rw-r--r--config.def.h3
-rw-r--r--image.c20
-rw-r--r--image.h5
-rw-r--r--sxiv.17
-rw-r--r--types.h5
8 files changed, 57 insertions, 0 deletions
diff --git a/README.md b/README.md
index 5950ad1..e82a91d 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/commands.c b/commands.c
index c7c817f..92d5ca7 100644
--- a/commands.c
+++ b/commands.c
@@ -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);
diff --git a/commands.h b/commands.h
index aeaf884..4364722 100644
--- a/commands.h
+++ b/commands.h
@@ -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 },
diff --git a/image.c b/image.c
index 3410a0b..2267204 100644
--- a/image.c
+++ b/image.c
@@ -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;
diff --git a/image.h b/image.h
index bb4b548..5661b01 100644
--- a/image.h
+++ b/image.h
@@ -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);
diff --git a/sxiv.1 b/sxiv.1
index aa9e420..bf1ac32 100644
--- a/sxiv.1
+++ b/sxiv.1
@@ -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
diff --git a/types.h b/types.h
index 1d72c95..0a4214c 100644
--- a/types.h
+++ b/types.h
@@ -24,6 +24,11 @@ typedef enum {
} direction_t;
typedef enum {
+ FLIP_HORIZONTAL,
+ FLIP_VERTICAL
+} flip_t;
+
+typedef enum {
SCALE_DOWN,
SCALE_FIT,
SCALE_ZOOM