Krolyxon
Commit 4c40cc2

Branches

Refs →

nsxiv4c40cc2

Slightly refactored flipping

Author
Bert Münnich
Date
2012-05-06 13:02 +0200
Parent
ba0a5b8
Commit
4c40cc24bc6b3e11fc9e6cf337ddb035fa750eb3

+19 −28

5 files changed

  1. M Makefile +1 −1
  2. M commands.c +5 −9
  3. M image.c +11 −14
  4. M image.h +1 −3
  5. M types.h +1 −1
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20120418
1+VERSION = git-20120506
22
33 CC = gcc
44 CFLAGS = -ansi -Wall -pedantic -O2
M commands.c View
@@ -343,18 +343,14 @@ bool i_rotate(arg_t a) {
343343 }
344344
345345 bool i_flip(arg_t a) {
346− flip_t flp = (flip_t) a;
346+ flipdir_t dir = (flipdir_t) a;
347347
348348 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− }
349+ img_flip(&img, dir);
350+ return true;
351+ } else {
352+ return false;
356353 }
357− return false;
358354 }
359355
360356 bool i_toggle_antialias(arg_t a) {
M image.c View
@@ -642,24 +642,21 @@ 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)
645+void img_flip(img_t *img, flipdir_t d) {
646+ if (img == NULL || img->im == NULL)
647647 return;
648648
649649 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−}
660650
661−void img_flip_vertical(img_t *img) {
662− img_flip(img, 1);
651+ switch (d) {
652+ case FLIP_HORIZONTAL:
653+ imlib_image_flip_horizontal();
654+ break;
655+ case FLIP_VERTICAL:
656+ imlib_image_flip_vertical();
657+ break;
658+ }
659+ img->dirty = true;
663660 }
664661
665662 void img_toggle_antialias(img_t *img) {
M image.h View
@@ -80,9 +80,7 @@ void img_rotate(img_t*, int);
8080 void img_rotate_left(img_t*);
8181 void img_rotate_right(img_t*);
8282
83−void img_flip(img_t*, int);
84−void img_flip_horizontal(img_t*);
85−void img_flip_vertical(img_t*);
83+void img_flip(img_t*, flipdir_t);
8684
8785 void img_toggle_antialias(img_t*);
8886
M types.h View
@@ -26,7 +26,7 @@ typedef enum {
2626 typedef enum {
2727 FLIP_HORIZONTAL,
2828 FLIP_VERTICAL
29−} flip_t;
29+} flipdir_t;
3030
3131 typedef enum {
3232 SCALE_DOWN,