aboutsummaryrefslogtreecommitdiffstats
path: root/thumbs.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-08-19 12:20:00 +0200
committerBert <ber.t@gmx.com>2011-08-19 12:20:00 +0200
commit535c18afdaceaf79759621ccaeee4ec99da9cf5d (patch)
treeb3a96d7674d7aae4daccee8616807c06640bacdb /thumbs.c
parent27591b5a52a4ec703bf5d2e61a4f933a7938500f (diff)
downloadnsxiv-535c18afdaceaf79759621ccaeee4ec99da9cf5d.tar.zst
Uniform thumbnail selection border size
- Consistent handling of thumbnails - Makes it easier to select very small thumbnails with mouse
Diffstat (limited to 'thumbs.c')
-rw-r--r--thumbs.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/thumbs.c b/thumbs.c
index 6c76880..97bb2b2 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -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;
}