Krolyxon
Commit 26eae8b

Branches

Refs →

nsxiv26eae8b

Made i(t)_toggle_alpha command work in thumbnail mode too

Author
Bert
Date
2011-09-04 13:29 +0200
Parent
d585b86
Commit
26eae8be966ab8e7ef940806077b56bbc7c191bc

+15 −10

6 files changed

  1. M Makefile +1 −1
  2. M commands.c +6 −7
  3. M commands.h +1 −1
  4. M config.h +1 −1
  5. M thumbs.c +5 −0
  6. M thumbs.h +1 −0
M Makefile View
@@ -1,6 +1,6 @@
11 all: sxiv
22
3−VERSION = git-20110903
3+VERSION = git-20110904
44
55 CC = gcc
66 DESTDIR =
M commands.c View
@@ -327,13 +327,12 @@ int i_toggle_antialias(arg_t a) {
327327 }
328328 }
329329
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;
337336 }
338337
339338 int it_open_with(arg_t a) {
M commands.h View
@@ -58,7 +58,7 @@ int i_fit_to_win(arg_t);
5858 int i_fit_to_img(arg_t);
5959 int i_rotate(arg_t);
6060 int i_toggle_antialias(arg_t);
61−int i_toggle_alpha(arg_t);
61+int it_toggle_alpha(arg_t);
6262 int it_open_with(arg_t);
6363 int it_shell_cmd(arg_t);
6464
M config.h View
@@ -105,7 +105,7 @@ static const keymap_t keys[] = {
105105 { False, XK_greater, i_rotate, (arg_t) DIR_RIGHT },
106106
107107 { 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 },
109109
110110 /* open current image with given program: */
111111 { True, XK_g, it_open_with, (arg_t) "gimp" },
M thumbs.c View
@@ -176,6 +176,7 @@ void tns_init(tns_t *tns, int cnt) {
176176
177177 tns->cnt = tns->first = tns->sel = 0;
178178 tns->cap = cnt;
179+ tns->alpha = 1;
179180 tns->dirty = 0;
180181
181182 if ((homedir = getenv("HOME"))) {
@@ -335,6 +336,10 @@ void tns_render(tns_t *tns, win_t *win) {
335336 t->x = x + (THUMB_SIZE - t->w) / 2;
336337 t->y = y + (THUMB_SIZE - t->h) / 2;
337338 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+
338343 imlib_render_image_part_on_drawable_at_size(0, 0, t->w, t->h,
339344 t->x, t->y, t->w, t->h);
340345 if ((i + 1) % tns->cols == 0) {
M thumbs.h View
@@ -44,6 +44,7 @@ typedef struct {
4444 int rows;
4545 int first;
4646 int sel;
47+ unsigned char alpha;
4748 unsigned char dirty;
4849 } tns_t;
4950