From f08c24bbb31ae0e3f7001d5d4d0e8f31b0c817f8 Mon Sep 17 00:00:00 2001 From: Bert Date: Thu, 17 Feb 2011 16:57:55 +0100 Subject: Select and open thumbnails --- thumbs.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'thumbs.c') 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; + } } -- cgit v1.2.3-70-g09d2