瀏覽代碼

Generalized thumbnail loading, allows easier reloading of thumbnails later on

master
Bert Münnich 10 年之前
父節點
當前提交
61f61cae5f
共有 4 個文件被更改,包括 16 次插入10 次删除
  1. +1
    -1
      Makefile
  2. +11
    -8
      main.c
  3. +2
    -1
      thumbs.c
  4. +2
    -0
      thumbs.h

+ 1
- 1
Makefile 查看文件

@@ -1,4 +1,4 @@
VERSION = git-20140801 VERSION = git-20140816


PREFIX = /usr/local PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man MANPREFIX = $(PREFIX)/share/man


+ 11
- 8
main.c 查看文件

@@ -363,11 +363,11 @@ void update_info(void)
return; return;
mark = files[sel].marked ? "* " : ""; mark = files[sel].marked ? "* " : "";
if (mode == MODE_THUMB) { if (mode == MODE_THUMB) {
if (tns.cnt == filecnt) { if (tns.loadnext >= filecnt) {
n = snprintf(rt, rlen, "%s%0*d/%d", mark, fw, sel + 1, filecnt); n = snprintf(rt, rlen, "%s%0*d/%d", mark, fw, sel + 1, filecnt);
ow_info = true; ow_info = true;
} else { } else {
snprintf(lt, llen, "Loading... %0*d/%d", fw, tns.cnt, filecnt); snprintf(lt, llen, "Loading... %0*d/%d", fw, tns.loadnext, filecnt);
rt[0] = '\0'; rt[0] = '\0';
ow_info = false; ow_info = false;
} }
@@ -434,7 +434,7 @@ void reset_cursor(void)
} }
} }
} else { } else {
if (tns.cnt != filecnt) if (tns.loadnext < filecnt)
cursor = CURSOR_WATCH; cursor = CURSOR_WATCH;
else else
cursor = CURSOR_ARROW; cursor = CURSOR_ARROW;
@@ -655,19 +655,22 @@ void run(void)
set_timeout(redraw, 25, false); set_timeout(redraw, 25, false);


while (true) { while (true) {
while (mode == MODE_THUMB && tns.cnt < filecnt && while (mode == MODE_THUMB && tns.loadnext < filecnt &&
XPending(win.env.dpy) == 0) XPending(win.env.dpy) == 0)
{ {
/* load thumbnails */ /* load thumbnails */
set_timeout(redraw, TO_REDRAW_THUMBS, false); set_timeout(redraw, TO_REDRAW_THUMBS, false);
if (tns_load(&tns, tns.cnt, &files[tns.cnt], false, false)) { if (tns_load(&tns, tns.loadnext, &files[tns.loadnext], false, false)) {
tns.cnt++; if (tns.cnt == tns.loadnext)
tns.cnt++;
} else { } else {
remove_file(tns.cnt, false); remove_file(tns.loadnext, false);
if (tns.sel > 0 && tns.sel >= tns.cnt) if (tns.sel > 0 && tns.sel >= tns.cnt)
tns.sel--; tns.sel--;
} }
if (tns.cnt == filecnt) while (tns.loadnext < filecnt && tns.thumbs[tns.loadnext].loaded)
tns.loadnext++;
if (tns.loadnext >= filecnt)
redraw(); redraw();
else else
check_timeouts(NULL); check_timeouts(NULL);


+ 2
- 1
thumbs.c 查看文件

@@ -165,7 +165,7 @@ void tns_init(tns_t *tns, int cnt, win_t *win)
tns->thumbs = NULL; tns->thumbs = NULL;
} }
tns->cap = cnt; tns->cap = cnt;
tns->cnt = tns->first = tns->sel = 0; tns->cnt = tns->loadnext = tns->first = tns->sel = 0;
tns->win = win; tns->win = win;
tns->dirty = false; tns->dirty = false;


@@ -325,6 +325,7 @@ bool tns_load(tns_t *tns, int n, const fileinfo_t *file,
if (!cache_hit) if (!cache_hit)
tns_cache_write(t, true); tns_cache_write(t, true);


t->loaded = true;
tns->dirty = true; tns->dirty = true;
return true; return true;
} }


+ 2
- 0
thumbs.h 查看文件

@@ -32,12 +32,14 @@ typedef struct {
int h; int h;
int x; int x;
int y; int y;
bool loaded;
} thumb_t; } thumb_t;


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




||||||
x
 
000:0
Loading…
取消
儲存