nsxiv26eae8b
Made i(t)_toggle_alpha command work in thumbnail mode too
+15 −10
6 files changed
- M Makefile +1 −1
- M commands.c +6 −7
- M commands.h +1 −1
- M config.h +1 −1
- M thumbs.c +5 −0
- M thumbs.h +1 −0
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | all: sxiv | |
| 2 | 2 | ||
| 3 | − | VERSION = git-20110903 | |
| 3 | + | VERSION = git-20110904 | |
| 4 | 4 | ||
| 5 | 5 | CC = gcc | |
| 6 | 6 | DESTDIR = | |
| @@ -327,13 +327,12 @@ int i_toggle_antialias(arg_t a) { | |||
| 327 | 327 | } | |
| 328 | 328 | } | |
| 329 | 329 | ||
| 330 | − | int i_toggle_alpha(arg_t a) { | |
| 331 | − | if (mode == MODE_IMAGE) { | |
| 332 | − | img.alpha ^= 1; | |
| 333 | − | return 1; | |
| 334 | − | } else { | |
| 335 | − | return 0; | |
| 336 | − | } | |
| 330 | + | int it_toggle_alpha(arg_t a) { | |
| 331 | + | img.alpha ^= 1; | |
| 332 | + | tns.alpha = img.alpha; | |
| 333 | + | if (mode == MODE_THUMB) | |
| 334 | + | tns.dirty = 1; | |
| 335 | + | return 1; | |
| 337 | 336 | } | |
| 338 | 337 | ||
| 339 | 338 | int it_open_with(arg_t a) { | |
| @@ -58,7 +58,7 @@ int i_fit_to_win(arg_t); | |||
| 58 | 58 | int i_fit_to_img(arg_t); | |
| 59 | 59 | int i_rotate(arg_t); | |
| 60 | 60 | int i_toggle_antialias(arg_t); | |
| 61 | − | int i_toggle_alpha(arg_t); | |
| 61 | + | int it_toggle_alpha(arg_t); | |
| 62 | 62 | int it_open_with(arg_t); | |
| 63 | 63 | int it_shell_cmd(arg_t); | |
| 64 | 64 | ||
| @@ -105,7 +105,7 @@ static const keymap_t keys[] = { | |||
| 105 | 105 | { False, XK_greater, i_rotate, (arg_t) DIR_RIGHT }, | |
| 106 | 106 | ||
| 107 | 107 | { False, XK_a, i_toggle_antialias, (arg_t) None }, | |
| 108 | − | { False, XK_A, i_toggle_alpha, (arg_t) None }, | |
| 108 | + | { False, XK_A, it_toggle_alpha, (arg_t) None }, | |
| 109 | 109 | ||
| 110 | 110 | /* open current image with given program: */ | |
| 111 | 111 | { True, XK_g, it_open_with, (arg_t) "gimp" }, | |
| @@ -176,6 +176,7 @@ void tns_init(tns_t *tns, int cnt) { | |||
| 176 | 176 | ||
| 177 | 177 | tns->cnt = tns->first = tns->sel = 0; | |
| 178 | 178 | tns->cap = cnt; | |
| 179 | + | tns->alpha = 1; | |
| 179 | 180 | tns->dirty = 0; | |
| 180 | 181 | ||
| 181 | 182 | if ((homedir = getenv("HOME"))) { | |
| @@ -335,6 +336,10 @@ void tns_render(tns_t *tns, win_t *win) { | |||
| 335 | 336 | t->x = x + (THUMB_SIZE - t->w) / 2; | |
| 336 | 337 | t->y = y + (THUMB_SIZE - t->h) / 2; | |
| 337 | 338 | imlib_context_set_image(t->im); | |
| 339 | + | ||
| 340 | + | if (imlib_image_has_alpha() && !tns->alpha) | |
| 341 | + | win_draw_rect(win, win->pm, t->x, t->y, t->w, t->h, True, 0, win->white); | |
| 342 | + | ||
| 338 | 343 | imlib_render_image_part_on_drawable_at_size(0, 0, t->w, t->h, | |
| 339 | 344 | t->x, t->y, t->w, t->h); | |
| 340 | 345 | if ((i + 1) % tns->cols == 0) { | |
| @@ -44,6 +44,7 @@ typedef struct { | |||
| 44 | 44 | int rows; | |
| 45 | 45 | int first; | |
| 46 | 46 | int sel; | |
| 47 | + | unsigned char alpha; | |
| 47 | 48 | unsigned char dirty; | |
| 48 | 49 | } tns_t; | |
| 49 | 50 | ||