From 1cdbeb972a64e1fb12db5dc05fbaa1428e72bb12 Mon Sep 17 00:00:00 2001 From: Bert Münnich Date: Thu, 27 Oct 2011 16:21:01 +0200 Subject: Added screen-wise scrolling for thumbnail mode --- thumbs.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'thumbs.c') diff --git a/thumbs.c b/thumbs.c index 8f20336..69b2645 100644 --- a/thumbs.c +++ b/thumbs.c @@ -430,20 +430,25 @@ bool tns_move_selection(tns_t *tns, direction_t dir) { return tns->sel != old; } -bool tns_scroll(tns_t *tns, direction_t dir) { - int old; +bool tns_scroll(tns_t *tns, direction_t dir, bool screen) { + int d, max, old; if (tns == NULL) return false; old = tns->first; + d = tns->cols * (screen ? tns->rows : 1); + + if (dir == DIR_DOWN) { + max = tns->cnt - tns->cols * tns->rows; + if (tns->cnt % tns->cols != 0) + max += tns->cols - tns->cnt % tns->cols; + tns->first = MIN(tns->first + d, max); + } else if (dir == DIR_UP) { + tns->first = MAX(tns->first - d, 0); + } - if (dir == DIR_DOWN && tns->first + tns->cols * tns->rows < tns->cnt) { - tns->first += tns->cols; - tns_check_view(tns, true); - tns->dirty = true; - } else if (dir == DIR_UP && tns->first >= tns->cols) { - tns->first -= tns->cols; + if (tns->first != old) { tns_check_view(tns, true); tns->dirty = true; } -- cgit v1.2.3-54-g00ecf