summaryrefslogtreecommitdiffstats
path: root/thumbs.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-02-17 16:22:54 +0100
committerBert <ber.t@gmx.com>2011-02-17 16:22:54 +0100
commitef24ded6afeb185192e815868c28a31c4c2e6d97 (patch)
tree54d055b7dcdc7ea064df57e56eafc0452dcd9d8b /thumbs.c
parent095217b26f43b711c8ebc281110553ec788f7ebe (diff)
downloadnsxiv-ef24ded6afeb185192e815868c28a31c4c2e6d97.tar.zst
Highlight selected thumbnail
Diffstat (limited to 'thumbs.c')
-rw-r--r--thumbs.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/thumbs.c b/thumbs.c
index e66dd1c..f1703e8 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -88,8 +88,8 @@ void tns_render(tns_t *tns, win_t *win) {
if (!tns || !win)
return;
- tns->cols = win->w / thumb_dim;
- tns->rows = win->h / thumb_dim;
+ tns->cols = MAX(1, win->w / thumb_dim);
+ tns->rows = MAX(1, win->h / thumb_dim);
cnt = tns->cols * tns->rows;
if (tns->first && tns->first + cnt > tns->cnt)
@@ -114,6 +114,22 @@ void tns_render(tns_t *tns, win_t *win) {
}
}
+ tns_highlight(tns, win, -1);
win_draw(win);
}
+void tns_highlight(tns_t *tns, win_t *win, int old) {
+ thumb_t *t;
+
+ if (!tns || !win)
+ return;
+
+ if (old >= 0 && old < tns->cnt) {
+ t = &tns->thumbs[old];
+ win_draw_rect(win, t->x - 2, t->y - 2, t->w + 4, t->h + 4, False);
+ }
+ if (tns->sel < tns->cnt) {
+ t = &tns->thumbs[tns->sel];
+ win_draw_rect(win, t->x - 2, t->y - 2, t->w + 4, t->h + 4, True);
+ }
+}