Krolyxon
Commit 62f4ab0

Branches

Refs →

nsxiv62f4ab0

Fixed moving of selection while loading thumbnails

Author
Bert
Date
2011-02-18 15:21 +0100
Parent
637be49
Commit
62f4ab037aad918d5b6c92b423e54f29b5c1ecf8

+4 −5

2 files changed

  1. M thumbs.c +3 −3
  2. M thumbs.h +1 −2
M thumbs.c View
@@ -32,7 +32,7 @@ void tns_init(tns_t *tns, int cnt) {
3232 if (!tns)
3333 return;
3434
35− tns->cnt = tns->first = tns->sel = 0;
35+ tns->cnt = tns->first = tns->sel = tns->vis = 0;
3636 tns->thumbs = (thumb_t*) s_malloc(cnt * sizeof(thumb_t));
3737 }
3838
@@ -115,8 +115,8 @@ void tns_render(tns_t *tns, win_t *win) {
115115 x += thumb_dim;
116116 }
117117 }
118+ tns->vis = i - tns->first;
118119
119− printf("%d, %d\n", tns->sel, tns->cnt);
120120 tns_highlight(tns, win, -1);
121121 }
122122
@@ -166,7 +166,7 @@ void tns_move_selection(tns_t *tns, win_t *win, movedir_t dir) {
166166 }
167167 break;
168168 case MOVE_DOWN:
169− if (sel / tns->cols < tns->rows - 1 && sel + tns->cols < tns->cnt) {
169+ if (sel / tns->cols < tns->rows - 1 && sel + tns->cols < tns->vis) {
170170 tns->sel += tns->cols;
171171 tns_highlight(tns, win, sel);
172172 }
M thumbs.h View
@@ -45,10 +45,9 @@ typedef struct tns_s {
4545 int rows;
4646 int first;
4747 int sel;
48+ int vis;
4849 } tns_t;
4950
50−extern const int thumb_dim;
51−
5251 void tns_init(tns_t*, int);
5352 void tns_free(tns_t*, win_t*);
5453