diff options
author | Bert <ber.t@gmx.com> | 2011-08-19 12:20:00 +0200 |
---|---|---|
committer | Bert <ber.t@gmx.com> | 2011-08-19 12:20:00 +0200 |
commit | 535c18afdaceaf79759621ccaeee4ec99da9cf5d (patch) | |
tree | b3a96d7674d7aae4daccee8616807c06640bacdb | |
parent | 27591b5a52a4ec703bf5d2e61a4f933a7938500f (diff) |
Uniform thumbnail selection border size
- Consistent handling of thumbnails
- Makes it easier to select very small thumbnails with mouse
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | thumbs.c | 16 |
2 files changed, 8 insertions, 10 deletions
@@ -1,6 +1,6 @@ all: sxiv -VERSION = git-20110818 +VERSION = git-20110819 CC = gcc DESTDIR = @@ -349,6 +349,7 @@ void tns_render(tns_t *tns, win_t *win) { void tns_highlight(tns_t *tns, win_t *win, int n, Bool hl) { thumb_t *t; + int x, y; unsigned long col; if (!tns || !tns->thumbs || !win) @@ -364,7 +365,9 @@ void tns_highlight(tns_t *tns, win_t *win, int n, Bool hl) { else col = win->bgcol; - win_draw_rect(win, win->pm, t->x - 4, t->y - 4, t->w + 8, t->h + 8, + x = t->x - (THUMB_SIZE - t->w) / 2; + y = t->y - (THUMB_SIZE - t->h) / 2; + win_draw_rect(win, win->pm, x - 3, y - 3, THUMB_SIZE + 6, THUMB_SIZE + 6, False, 2, col); } @@ -431,7 +434,6 @@ int tns_scroll(tns_t *tns, direction_t dir) { int tns_translate(tns_t *tns, int x, int y) { int n; - thumb_t *t; if (!tns || !tns->thumbs) return -1; @@ -441,12 +443,8 @@ int tns_translate(tns_t *tns, int x, int y) { n = tns->first + (y - tns->y) / thumb_dim * tns->cols + (x - tns->x) / thumb_dim; + if (n >= tns->cnt) + n = -1; - if (n < tns->cnt) { - t = &tns->thumbs[n]; - if (x >= t->x && x <= t->x + t->w && y >= t->y && y <= t->y + t->h) - return n; - } - - return -1; + return n; } |