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

master
Bert 2011-09-04 13:29:17 +02:00
parent d585b86354
commit 26eae8be96
6 changed files with 15 additions and 10 deletions

View File

@ -1,6 +1,6 @@
all: sxiv
VERSION = git-20110903
VERSION = git-20110904
CC = gcc
DESTDIR =

View File

@ -327,13 +327,12 @@ int i_toggle_antialias(arg_t a) {
}
}
int i_toggle_alpha(arg_t a) {
if (mode == MODE_IMAGE) {
img.alpha ^= 1;
return 1;
} else {
return 0;
}
int it_toggle_alpha(arg_t a) {
img.alpha ^= 1;
tns.alpha = img.alpha;
if (mode == MODE_THUMB)
tns.dirty = 1;
return 1;
}
int it_open_with(arg_t a) {

View File

@ -58,7 +58,7 @@ int i_fit_to_win(arg_t);
int i_fit_to_img(arg_t);
int i_rotate(arg_t);
int i_toggle_antialias(arg_t);
int i_toggle_alpha(arg_t);
int it_toggle_alpha(arg_t);
int it_open_with(arg_t);
int it_shell_cmd(arg_t);

View File

@ -105,7 +105,7 @@ static const keymap_t keys[] = {
{ False, XK_greater, i_rotate, (arg_t) DIR_RIGHT },
{ False, XK_a, i_toggle_antialias, (arg_t) None },
{ False, XK_A, i_toggle_alpha, (arg_t) None },
{ False, XK_A, it_toggle_alpha, (arg_t) None },
/* open current image with given program: */
{ True, XK_g, it_open_with, (arg_t) "gimp" },

View File

@ -176,6 +176,7 @@ void tns_init(tns_t *tns, int cnt) {
tns->cnt = tns->first = tns->sel = 0;
tns->cap = cnt;
tns->alpha = 1;
tns->dirty = 0;
if ((homedir = getenv("HOME"))) {
@ -335,6 +336,10 @@ void tns_render(tns_t *tns, win_t *win) {
t->x = x + (THUMB_SIZE - t->w) / 2;
t->y = y + (THUMB_SIZE - t->h) / 2;
imlib_context_set_image(t->im);
if (imlib_image_has_alpha() && !tns->alpha)
win_draw_rect(win, win->pm, t->x, t->y, t->w, t->h, True, 0, win->white);
imlib_render_image_part_on_drawable_at_size(0, 0, t->w, t->h,
t->x, t->y, t->w, t->h);
if ((i + 1) % tns->cols == 0) {

View File

@ -44,6 +44,7 @@ typedef struct {
int rows;
int first;
int sel;
unsigned char alpha;
unsigned char dirty;
} tns_t;