aboutsummaryrefslogtreecommitdiffstats
path: root/thumbs.c
diff options
context:
space:
mode:
authorBert Münnich <ber.t@gmx.com>2011-10-27 16:21:01 +0200
committerBert Münnich <ber.t@gmx.com>2011-10-27 16:21:01 +0200
commit1cdbeb972a64e1fb12db5dc05fbaa1428e72bb12 (patch)
tree9e0d12081ff6f8b9708422f10e0f3e1047ccf6ae /thumbs.c
parent3e2523818b2420a86d71ac7c908ddcbb800abd38 (diff)
downloadnsxiv-1cdbeb972a64e1fb12db5dc05fbaa1428e72bb12.tar.zst
Added screen-wise scrolling for thumbnail mode
Diffstat (limited to 'thumbs.c')
-rw-r--r--thumbs.c21
1 files changed, 13 insertions, 8 deletions
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;
}