Browse Source

Use win_t member in img_t & tns_t instead of parameters

master
Bert Münnich 13 years ago
parent
commit
515e410451
7 changed files with 150 additions and 135 deletions
  1. +1
    -1
      Makefile
  2. +14
    -14
      commands.c
  3. +80
    -74
      image.c
  4. +19
    -17
      image.h
  5. +6
    -7
      main.c
  6. +18
    -13
      thumbs.c
  7. +12
    -9
      thumbs.h

+ 1
- 1
Makefile View File

@@ -1,4 +1,4 @@
VERSION = git-20110912
VERSION = git-20110917


CC = gcc CC = gcc
CFLAGS = -Wall -pedantic -O2 CFLAGS = -Wall -pedantic -O2


+ 14
- 14
commands.c View File

@@ -54,7 +54,7 @@ bool it_quit(arg_t a) {
bool it_switch_mode(arg_t a) { bool it_switch_mode(arg_t a) {
if (mode == MODE_IMAGE) { if (mode == MODE_IMAGE) {
if (!tns.thumbs) if (!tns.thumbs)
tns_init(&tns, filecnt);
tns_init(&tns, filecnt, &win);
img_close(&img, false); img_close(&img, false);
reset_timeout(reset_cursor); reset_timeout(reset_cursor);
if (img.slideshow) { if (img.slideshow) {
@@ -180,16 +180,16 @@ bool it_move(arg_t a) {
direction_t dir = (direction_t) a; direction_t dir = (direction_t) a;


if (mode == MODE_IMAGE) if (mode == MODE_IMAGE)
return img_pan(&img, &win, dir, false);
return img_pan(&img, dir, false);
else else
return tns_move_selection(&tns, &win, dir);
return tns_move_selection(&tns, dir);
} }


bool i_pan_screen(arg_t a) { bool i_pan_screen(arg_t a) {
direction_t dir = (direction_t) a; direction_t dir = (direction_t) a;


if (mode == MODE_IMAGE) if (mode == MODE_IMAGE)
return img_pan(&img, &win, dir, true);
return img_pan(&img, dir, true);
else else
return false; return false;
} }
@@ -198,7 +198,7 @@ bool i_pan_edge(arg_t a) {
direction_t dir = (direction_t) a; direction_t dir = (direction_t) a;


if (mode == MODE_IMAGE) if (mode == MODE_IMAGE)
return img_pan_edge(&img, &win, dir);
return img_pan_edge(&img, dir);
else else
return false; return false;
} }
@@ -245,8 +245,8 @@ bool i_drag(arg_t a) {
if (dragging) if (dragging)
next = XCheckIfEvent(win.env.dpy, &e, is_motionnotify, None); next = XCheckIfEvent(win.env.dpy, &e, is_motionnotify, None);
if ((!dragging || !next) && (dx != 0 || dy != 0)) { if ((!dragging || !next) && (dx != 0 || dy != 0)) {
if (img_move(&img, &win, dx, dy))
img_render(&img, &win);
if (img_move(&img, dx, dy))
img_render(&img);
dx = dy = 0; dx = dy = 0;
} }
} }
@@ -265,19 +265,19 @@ bool i_zoom(arg_t a) {
return false; return false;


if (scale > 0) if (scale > 0)
return img_zoom_in(&img, &win);
return img_zoom_in(&img);
else if (scale < 0) else if (scale < 0)
return img_zoom_out(&img, &win);
return img_zoom_out(&img);
else else
return img_zoom(&img, &win, 1.0);
return img_zoom(&img, 1.0);
} }


bool i_fit_to_win(arg_t a) { bool i_fit_to_win(arg_t a) {
bool ret; bool ret;


if (mode == MODE_IMAGE) { if (mode == MODE_IMAGE) {
if ((ret = img_fit_win(&img, &win)))
img_center(&img, &win);
if ((ret = img_fit_win(&img)))
img_center(&img);
return ret; return ret;
} else { } else {
return false; return false;
@@ -309,10 +309,10 @@ bool i_rotate(arg_t a) {


if (mode == MODE_IMAGE) { if (mode == MODE_IMAGE) {
if (dir == DIR_LEFT) { if (dir == DIR_LEFT) {
img_rotate_left(&img, &win);
img_rotate_left(&img);
return true; return true;
} else if (dir == DIR_RIGHT) { } else if (dir == DIR_RIGHT) {
img_rotate_right(&img, &win);
img_rotate_right(&img);
return true; return true;
} }
} }


+ 80
- 74
image.c View File

@@ -49,26 +49,26 @@ void img_init(img_t *img, win_t *win) {
zoom_min = zoom_levels[0] / 100.0; zoom_min = zoom_levels[0] / 100.0;
zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0; zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0;


if (img) {
img->im = NULL;
img->multi.cap = img->multi.cnt = 0;
img->multi.animate = false;
img->zoom = options->zoom;
img->zoom = MAX(img->zoom, zoom_min);
img->zoom = MIN(img->zoom, zoom_max);
img->checkpan = false;
img->dirty = false;
img->aa = options->aa;
img->alpha = true;
img->slideshow = false;
img->ss_delay = SLIDESHOW_DELAY * 1000;
}
if (!img || !win)
return;


if (win) {
imlib_context_set_display(win->env.dpy);
imlib_context_set_visual(win->env.vis);
imlib_context_set_colormap(win->env.cmap);
}
imlib_context_set_display(win->env.dpy);
imlib_context_set_visual(win->env.vis);
imlib_context_set_colormap(win->env.cmap);

img->im = NULL;
img->win = win;
img->zoom = options->zoom;
img->zoom = MAX(img->zoom, zoom_min);
img->zoom = MIN(img->zoom, zoom_max);
img->checkpan = false;
img->dirty = false;
img->aa = options->aa;
img->alpha = true;
img->slideshow = false;
img->ss_delay = SLIDESHOW_DELAY * 1000;
img->multi.cap = img->multi.cnt = 0;
img->multi.animate = false;
} }


#if EXIF_SUPPORT #if EXIF_SUPPORT
@@ -311,14 +311,13 @@ bool img_load(img_t *img, const fileinfo_t *file) {
img_load_gif(img, file); img_load_gif(img, file);
#endif #endif


img->w = imlib_image_get_width();
img->h = imlib_image_get_height();
img->scalemode = options->scalemode; img->scalemode = options->scalemode;
img->re = false; img->re = false;
img->checkpan = false; img->checkpan = false;
img->dirty = true; img->dirty = true;


img->w = imlib_image_get_width();
img->h = imlib_image_get_height();

return true; return true;
} }


@@ -345,12 +344,14 @@ void img_close(img_t *img, bool decache) {
} }
} }


void img_check_pan(img_t *img, win_t *win, bool moved) {
void img_check_pan(img_t *img, bool moved) {
win_t *win;
int ox, oy; int ox, oy;


if (!img || !win)
if (!img || !img->im || !img->win)
return; return;


win = img->win;
ox = img->x; ox = img->x;
oy = img->y; oy = img->y;


@@ -375,15 +376,17 @@ void img_check_pan(img_t *img, win_t *win, bool moved) {
img->dirty = true; img->dirty = true;
} }


bool img_fit(img_t *img, win_t *win) {
bool img_fit(img_t *img) {
float z, zmax, zw, zh; float z, zmax, zw, zh;


if (!img || !win || img->scalemode == SCALE_ZOOM)
if (!img || !img->im || !img->win)
return false;
if (img->scalemode == SCALE_ZOOM)
return false; return false;


zmax = img->scalemode == SCALE_DOWN ? 1.0 : zoom_max; zmax = img->scalemode == SCALE_DOWN ? 1.0 : zoom_max;
zw = (float) win->w / (float) img->w;
zh = (float) win->h / (float) img->h;
zw = (float) img->win->w / (float) img->w;
zh = (float) img->win->h / (float) img->h;


z = MIN(zw, zh); z = MIN(zw, zh);
z = MAX(z, zoom_min); z = MAX(z, zoom_min);
@@ -398,14 +401,16 @@ bool img_fit(img_t *img, win_t *win) {
} }
} }


void img_render(img_t *img, win_t *win) {
void img_render(img_t *img) {
win_t *win;
int sx, sy, sw, sh; int sx, sy, sw, sh;
int dx, dy, dw, dh; int dx, dy, dw, dh;


if (!img || !img->im || !win)
if (!img || !img->im || !img->win)
return; return;


img_fit(img, win);
win = img->win;
img_fit(img);


if (!img->re) { if (!img->re) {
/* rendered for the first time */ /* rendered for the first time */
@@ -421,7 +426,7 @@ void img_render(img_t *img, win_t *win) {
} }
if (img->checkpan) { if (img->checkpan) {
img_check_pan(img, win, false);
img_check_pan(img, false);
img->checkpan = false; img->checkpan = false;
} }


@@ -467,25 +472,25 @@ void img_render(img_t *img, win_t *win) {
img->dirty = false; img->dirty = false;
} }


bool img_fit_win(img_t *img, win_t *win) {
if (!img || !img->im || !win)
bool img_fit_win(img_t *img) {
if (!img || !img->im)
return false; return false;


img->scalemode = SCALE_FIT; img->scalemode = SCALE_FIT;
return img_fit(img, win);
return img_fit(img);
} }


bool img_center(img_t *img, win_t *win) {
bool img_center(img_t *img) {
int ox, oy; int ox, oy;


if (!img || !win)
if (!img || !img->im || !img->win)
return false; return false;
ox = img->x; ox = img->x;
oy = img->y; oy = img->y;


img->x = (win->w - img->w * img->zoom) / 2;
img->y = (win->h - img->h * img->zoom) / 2;
img->x = (img->win->w - img->w * img->zoom) / 2;
img->y = (img->win->h - img->h * img->zoom) / 2;
if (ox != img->x || oy != img->y) { if (ox != img->x || oy != img->y) {
img->dirty = true; img->dirty = true;
@@ -495,8 +500,8 @@ bool img_center(img_t *img, win_t *win) {
} }
} }


bool img_zoom(img_t *img, win_t *win, float z) {
if (!img || !img->im || !win)
bool img_zoom(img_t *img, float z) {
if (!img || !img->im || !img->win)
return false; return false;


z = MAX(z, zoom_min); z = MAX(z, zoom_min);
@@ -505,8 +510,8 @@ bool img_zoom(img_t *img, win_t *win, float z) {
img->scalemode = SCALE_ZOOM; img->scalemode = SCALE_ZOOM;


if (ZOOMDIFF(z, img->zoom)) { if (ZOOMDIFF(z, img->zoom)) {
img->x = win->w / 2 - (win->w / 2 - img->x) * z / img->zoom;
img->y = win->h / 2 - (win->h / 2 - img->y) * z / img->zoom;
img->x = img->win->w / 2 - (img->win->w / 2 - img->x) * z / img->zoom;
img->y = img->win->h / 2 - (img->win->h / 2 - img->y) * z / img->zoom;
img->zoom = z; img->zoom = z;
img->checkpan = true; img->checkpan = true;
img->dirty = true; img->dirty = true;
@@ -516,36 +521,36 @@ bool img_zoom(img_t *img, win_t *win, float z) {
} }
} }


bool img_zoom_in(img_t *img, win_t *win) {
bool img_zoom_in(img_t *img) {
int i; int i;


if (!img || !img->im || !win)
if (!img || !img->im)
return false; return false;


for (i = 1; i < ARRLEN(zoom_levels); i++) { for (i = 1; i < ARRLEN(zoom_levels); i++) {
if (zoom_levels[i] > img->zoom * 100.0) if (zoom_levels[i] > img->zoom * 100.0)
return img_zoom(img, win, zoom_levels[i] / 100.0);
return img_zoom(img, zoom_levels[i] / 100.0);
} }
return false; return false;
} }


bool img_zoom_out(img_t *img, win_t *win) {
bool img_zoom_out(img_t *img) {
int i; int i;


if (!img || !img->im || !win)
if (!img || !img->im)
return false; return false;


for (i = ARRLEN(zoom_levels) - 2; i >= 0; i--) { for (i = ARRLEN(zoom_levels) - 2; i >= 0; i--) {
if (zoom_levels[i] < img->zoom * 100.0) if (zoom_levels[i] < img->zoom * 100.0)
return img_zoom(img, win, zoom_levels[i] / 100.0);
return img_zoom(img, zoom_levels[i] / 100.0);
} }
return false; return false;
} }


bool img_move(img_t *img, win_t *win, int dx, int dy) {
bool img_move(img_t *img, int dx, int dy) {
int ox, oy; int ox, oy;


if (!img || !img->im || !win)
if (!img || !img->im)
return false; return false;


ox = img->x; ox = img->x;
@@ -554,7 +559,7 @@ bool img_move(img_t *img, win_t *win, int dx, int dy) {
img->x += dx; img->x += dx;
img->y += dy; img->y += dy;


img_check_pan(img, win, true);
img_check_pan(img, true);


if (ox != img->x || oy != img->y) { if (ox != img->x || oy != img->y) {
img->dirty = true; img->dirty = true;
@@ -564,27 +569,27 @@ bool img_move(img_t *img, win_t *win, int dx, int dy) {
} }
} }


bool img_pan(img_t *img, win_t *win, direction_t dir, bool screen) {
if (!img || !img->im || !win)
bool img_pan(img_t *img, direction_t dir, bool screen) {
if (!img || !img->im || !img->win)
return false; return false;


switch (dir) { switch (dir) {
case DIR_LEFT: case DIR_LEFT:
return img_move(img, win, win->w / (screen ? 1 : 5), 0);
return img_move(img, img->win->w / (screen ? 1 : 5), 0);
case DIR_RIGHT: case DIR_RIGHT:
return img_move(img, win, win->w / (screen ? 1 : 5) * -1, 0);
return img_move(img, img->win->w / (screen ? 1 : 5) * -1, 0);
case DIR_UP: case DIR_UP:
return img_move(img, win, 0, win->h / (screen ? 1 : 5));
return img_move(img, 0, img->win->h / (screen ? 1 : 5));
case DIR_DOWN: case DIR_DOWN:
return img_move(img, win, 0, win->h / (screen ? 1 : 5) * -1);
return img_move(img, 0, img->win->h / (screen ? 1 : 5) * -1);
} }
return false; return false;
} }


bool img_pan_edge(img_t *img, win_t *win, direction_t dir) {
bool img_pan_edge(img_t *img, direction_t dir) {
int ox, oy; int ox, oy;


if (!img || !img->im || !win)
if (!img || !img->im || !img->win)
return false; return false;


ox = img->x; ox = img->x;
@@ -595,17 +600,17 @@ bool img_pan_edge(img_t *img, win_t *win, direction_t dir) {
img->x = 0; img->x = 0;
break; break;
case DIR_RIGHT: case DIR_RIGHT:
img->x = win->w - img->w * img->zoom;
img->x = img->win->w - img->w * img->zoom;
break; break;
case DIR_UP: case DIR_UP:
img->y = 0; img->y = 0;
break; break;
case DIR_DOWN: case DIR_DOWN:
img->y = win->h - img->h * img->zoom;
img->y = img->win->h - img->h * img->zoom;
break; break;
} }


img_check_pan(img, win, true);
img_check_pan(img, true);


if (ox != img->x || oy != img->y) { if (ox != img->x || oy != img->y) {
img->dirty = true; img->dirty = true;
@@ -615,12 +620,14 @@ bool img_pan_edge(img_t *img, win_t *win, direction_t dir) {
} }
} }


void img_rotate(img_t *img, win_t *win, int d) {
void img_rotate(img_t *img, int d) {
win_t *win;
int ox, oy, tmp; int ox, oy, tmp;


if (!img || !img->im || !win)
if (!img || !img->im || !img->win)
return; return;


win = img->win;
ox = d == 1 ? img->x : win->w - img->x - img->w * img->zoom; ox = d == 1 ? img->x : win->w - img->x - img->w * img->zoom;
oy = d == 3 ? img->y : win->h - img->y - img->h * img->zoom; oy = d == 3 ? img->y : win->h - img->y - img->h * img->zoom;


@@ -638,12 +645,12 @@ void img_rotate(img_t *img, win_t *win, int d) {
img->dirty = true; img->dirty = true;
} }


void img_rotate_left(img_t *img, win_t *win) {
img_rotate(img, win, 3);
void img_rotate_left(img_t *img) {
img_rotate(img, 3);
} }


void img_rotate_right(img_t *img, win_t *win) {
img_rotate(img, win, 1);
void img_rotate_right(img_t *img) {
img_rotate(img, 1);
} }


void img_toggle_antialias(img_t *img) { void img_toggle_antialias(img_t *img) {
@@ -657,10 +664,9 @@ void img_toggle_antialias(img_t *img) {
} }


bool img_frame_goto(img_t *img, int n) { bool img_frame_goto(img_t *img, int n) {
if (!img || n < 0 || n >= img->multi.cnt)
if (!img || !img->im)
return false; return false;

if (n == img->multi.sel)
if (n < 0 || n >= img->multi.cnt || n == img->multi.sel)
return false; return false;


img->multi.sel = n; img->multi.sel = n;
@@ -676,7 +682,7 @@ bool img_frame_goto(img_t *img, int n) {
} }


bool img_frame_navigate(img_t *img, int d) { bool img_frame_navigate(img_t *img, int d) {
if (!img || !img->multi.cnt || !d)
if (!img || !img->im || !img->multi.cnt || !d)
return false; return false;


d += img->multi.sel; d += img->multi.sel;
@@ -689,7 +695,7 @@ bool img_frame_navigate(img_t *img, int d) {
} }


bool img_frame_animate(img_t *img, bool restart) { bool img_frame_animate(img_t *img, bool restart) {
if (!img || !img->multi.cnt)
if (!img || !img->im || !img->multi.cnt)
return false; return false;


if (img->multi.sel + 1 >= img->multi.cnt) { if (img->multi.sel + 1 >= img->multi.cnt) {


+ 19
- 17
image.h View File

@@ -39,10 +39,15 @@ typedef struct {


typedef struct { typedef struct {
Imlib_Image *im; Imlib_Image *im;
multi_img_t multi;
int w;
int h;

win_t *win;
int x;
int y;


float zoom;
scalemode_t scalemode; scalemode_t scalemode;
float zoom;


bool re; bool re;
bool checkpan; bool checkpan;
@@ -53,10 +58,7 @@ typedef struct {
bool slideshow; bool slideshow;
int ss_delay; /* in ms */ int ss_delay; /* in ms */


int x;
int y;
int w;
int h;
multi_img_t multi;
} img_t; } img_t;


void img_init(img_t*, win_t*); void img_init(img_t*, win_t*);
@@ -64,21 +66,21 @@ void img_init(img_t*, win_t*);
bool img_load(img_t*, const fileinfo_t*); bool img_load(img_t*, const fileinfo_t*);
void img_close(img_t*, bool); void img_close(img_t*, bool);


void img_render(img_t*, win_t*);
void img_render(img_t*);


bool img_fit_win(img_t*, win_t*);
bool img_center(img_t*, win_t*);
bool img_fit_win(img_t*);
bool img_center(img_t*);


bool img_zoom(img_t*, win_t*, float);
bool img_zoom_in(img_t*, win_t*);
bool img_zoom_out(img_t*, win_t*);
bool img_zoom(img_t*, float);
bool img_zoom_in(img_t*);
bool img_zoom_out(img_t*);


bool img_move(img_t*, win_t*, int, int);
bool img_pan(img_t*, win_t*, direction_t, bool);
bool img_pan_edge(img_t*, win_t*, direction_t);
bool img_move(img_t*, int, int);
bool img_pan(img_t*, direction_t, bool);
bool img_pan_edge(img_t*, direction_t);


void img_rotate_left(img_t*, win_t*);
void img_rotate_right(img_t*, win_t*);
void img_rotate_left(img_t*);
void img_rotate_right(img_t*);


void img_toggle_antialias(img_t*); void img_toggle_antialias(img_t*);




+ 6
- 7
main.c View File

@@ -261,7 +261,7 @@ void update_title() {


void redraw() { void redraw() {
if (mode == MODE_IMAGE) { if (mode == MODE_IMAGE) {
img_render(&img, &win);
img_render(&img);
if (img.slideshow && !img.multi.animate) { if (img.slideshow && !img.multi.animate) {
if (fileidx + 1 < filecnt) if (fileidx + 1 < filecnt)
set_timeout(slideshow, img.ss_delay, true); set_timeout(slideshow, img.ss_delay, true);
@@ -269,7 +269,7 @@ void redraw() {
img.slideshow = false; img.slideshow = false;
} }
} else { } else {
tns_render(&tns, &win);
tns_render(&tns);
} }
update_title(); update_title();
reset_timeout(redraw); reset_timeout(redraw);
@@ -372,8 +372,8 @@ void on_buttonpress(XButtonEvent *bev) {
set_timeout(reset_cursor, TO_CURSOR_HIDE, true); set_timeout(reset_cursor, TO_CURSOR_HIDE, true);
load_image(tns.sel); load_image(tns.sel);
} else { } else {
tns_highlight(&tns, &win, tns.sel, false);
tns_highlight(&tns, &win, sel, true);
tns_highlight(&tns, tns.sel, false);
tns_highlight(&tns, sel, true);
tns.sel = sel; tns.sel = sel;
} }
redraw(); redraw();
@@ -469,7 +469,7 @@ int main(int argc, char **argv) {
parse_options(argc, argv); parse_options(argc, argv);


if (options->clean_cache) { if (options->clean_cache) {
tns_init(&tns, 0);
tns_init(&tns, 0, NULL);
tns_clean_cache(&tns); tns_clean_cache(&tns);
exit(0); exit(0);
} }
@@ -513,7 +513,6 @@ int main(int argc, char **argv) {
continue; continue;
} }
start = fileidx; start = fileidx;
printf("reading dir: %s\n", filename);
while ((filename = r_readdir(&dir))) { while ((filename = r_readdir(&dir))) {
check_add_file(filename); check_add_file(filename);
free((void*) filename); free((void*) filename);
@@ -538,7 +537,7 @@ int main(int argc, char **argv) {


if (options->thumb_mode) { if (options->thumb_mode) {
mode = MODE_THUMB; mode = MODE_THUMB;
tns_init(&tns, filecnt);
tns_init(&tns, filecnt, &win);
while (!tns_load(&tns, 0, &files[0], false, false)) while (!tns_load(&tns, 0, &files[0], false, false))
remove_file(0, false); remove_file(0, false);
tns.cnt = 1; tns.cnt = 1;


+ 18
- 13
thumbs.c View File

@@ -156,7 +156,7 @@ void tns_clean_cache(tns_t *tns) {
} }




void tns_init(tns_t *tns, int cnt) {
void tns_init(tns_t *tns, int cnt, win_t *win) {
int len; int len;
char *homedir; char *homedir;


@@ -170,8 +170,9 @@ void tns_init(tns_t *tns, int cnt) {
tns->thumbs = NULL; tns->thumbs = NULL;
} }


tns->cnt = tns->first = tns->sel = 0;
tns->cap = cnt; tns->cap = cnt;
tns->cnt = tns->first = tns->sel = 0;
tns->win = win;
tns->alpha = true; tns->alpha = true;
tns->dirty = false; tns->dirty = false;


@@ -305,16 +306,17 @@ void tns_check_view(tns_t *tns, bool scrolled) {
} }
} }


void tns_render(tns_t *tns, win_t *win) {
int i, cnt, r, x, y;
void tns_render(tns_t *tns) {
thumb_t *t; thumb_t *t;
win_t *win;
int i, cnt, r, x, y;


if (!tns || !tns->thumbs || !win)
if (!tns || !tns->thumbs || !tns->win)
return; return;

if (!tns->dirty) if (!tns->dirty)
return; return;


win = tns->win;
win_clear(win); win_clear(win);
imlib_context_set_drawable(win->pm); imlib_context_set_drawable(win->pm);


@@ -357,17 +359,20 @@ void tns_render(tns_t *tns, win_t *win) {
} }


tns->dirty = false; tns->dirty = false;
tns_highlight(tns, win, tns->sel, true);
tns_highlight(tns, tns->sel, true);
} }


void tns_highlight(tns_t *tns, win_t *win, int n, bool hl) {
void tns_highlight(tns_t *tns, int n, bool hl) {
thumb_t *t; thumb_t *t;
win_t *win;
int x, y; int x, y;
unsigned long col; unsigned long col;


if (!tns || !tns->thumbs || !win)
if (!tns || !tns->thumbs || !tns->win)
return; return;


win = tns->win;

if (n >= 0 && n < tns->cnt) { if (n >= 0 && n < tns->cnt) {
t = &tns->thumbs[n]; t = &tns->thumbs[n];


@@ -387,10 +392,10 @@ void tns_highlight(tns_t *tns, win_t *win, int n, bool hl) {
win_draw(win); win_draw(win);
} }


bool tns_move_selection(tns_t *tns, win_t *win, direction_t dir) {
bool tns_move_selection(tns_t *tns, direction_t dir) {
int old; int old;


if (!tns || !tns->thumbs || !win)
if (!tns || !tns->thumbs)
return false; return false;


old = tns->sel; old = tns->sel;
@@ -415,10 +420,10 @@ bool tns_move_selection(tns_t *tns, win_t *win, direction_t dir) {
} }


if (tns->sel != old) { if (tns->sel != old) {
tns_highlight(tns, win, old, false);
tns_highlight(tns, old, false);
tns_check_view(tns, false); tns_check_view(tns, false);
if (!tns->dirty) if (!tns->dirty)
tns_highlight(tns, win, tns->sel, true);
tns_highlight(tns, tns->sel, true);
} }


return tns->sel != old; return tns->sel != old;


+ 12
- 9
thumbs.h View File

@@ -26,39 +26,42 @@
#include "window.h" #include "window.h"


typedef struct { typedef struct {
Imlib_Image *im;
const fileinfo_t *file; const fileinfo_t *file;
int x;
int y;
Imlib_Image *im;
int w; int w;
int h; int h;
int x;
int y;
} thumb_t; } thumb_t;


typedef struct { typedef struct {
thumb_t *thumbs; thumb_t *thumbs;
int cap; int cap;
int cnt; int cnt;
int first;
int sel;

win_t *win;
int x; int x;
int y; int y;
int cols; int cols;
int rows; int rows;
int first;
int sel;

bool alpha; bool alpha;
bool dirty; bool dirty;
} tns_t; } tns_t;


void tns_clean_cache(tns_t*); void tns_clean_cache(tns_t*);


void tns_init(tns_t*, int);
void tns_init(tns_t*, int, win_t*);
void tns_free(tns_t*); void tns_free(tns_t*);


bool tns_load(tns_t*, int, const fileinfo_t*, bool, bool); bool tns_load(tns_t*, int, const fileinfo_t*, bool, bool);


void tns_render(tns_t*, win_t*);
void tns_highlight(tns_t*, win_t*, int, bool);
void tns_render(tns_t*);
void tns_highlight(tns_t*, int, bool);


bool tns_move_selection(tns_t*, win_t*, direction_t);
bool tns_move_selection(tns_t*, direction_t);
bool tns_scroll(tns_t*, direction_t); bool tns_scroll(tns_t*, direction_t);


int tns_translate(tns_t*, int, int); int tns_translate(tns_t*, int, int);


Loading…
Cancel
Save