summaryrefslogtreecommitdiffstats
path: root/thumbs.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-02-17 16:57:55 +0100
committerBert <ber.t@gmx.com>2011-02-17 16:57:55 +0100
commitf08c24bbb31ae0e3f7001d5d4d0e8f31b0c817f8 (patch)
treef04ddf698c7171b4ece3cca004ea45a6e8837c21 /thumbs.c
parentef24ded6afeb185192e815868c28a31c4c2e6d97 (diff)
downloadnsxiv-f08c24bbb31ae0e3f7001d5d4d0e8f31b0c817f8.tar.zst
Select and open thumbnails
Diffstat (limited to 'thumbs.c')
-rw-r--r--thumbs.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/thumbs.c b/thumbs.c
index f1703e8..c369395 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -115,7 +115,6 @@ 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) {
@@ -132,4 +131,42 @@ void tns_highlight(tns_t *tns, win_t *win, int old) {
t = &tns->thumbs[tns->sel];
win_draw_rect(win, t->x - 2, t->y - 2, t->w + 4, t->h + 4, True);
}
+
+ win_draw(win);
+}
+
+void tns_move_selection(tns_t *tns, win_t *win, movedir_t dir) {
+ int sel;
+
+ if (!tns || !win)
+ return;
+
+ sel = tns->sel;
+
+ switch (dir) {
+ case MOVE_LEFT:
+ if (sel % tns->cols > 0) {
+ --tns->sel;
+ tns_highlight(tns, win, sel);
+ }
+ break;
+ case MOVE_RIGHT:
+ if (sel % tns->cols < tns->cols - 1 && sel < tns->cnt - 1) {
+ ++tns->sel;
+ tns_highlight(tns, win, sel);
+ }
+ break;
+ case MOVE_UP:
+ if (sel / tns->cols > 0) {
+ tns->sel -= tns->cols;
+ tns_highlight(tns, win, sel);
+ }
+ break;
+ case MOVE_DOWN:
+ if (sel / tns->cols < tns->rows - 1 && sel + tns->cols < tns->cnt) {
+ tns->sel += tns->cols;
+ tns_highlight(tns, win, sel);
+ }
+ break;
+ }
}