From 535c18afdaceaf79759621ccaeee4ec99da9cf5d Mon Sep 17 00:00:00 2001 From: Bert Date: Fri, 19 Aug 2011 12:20:00 +0200 Subject: Uniform thumbnail selection border size - Consistent handling of thumbnails - Makes it easier to select very small thumbnails with mouse --- Makefile | 2 +- thumbs.c | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 74235d9..991d1b4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: sxiv -VERSION = git-20110818 +VERSION = git-20110819 CC = gcc DESTDIR = 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; } -- cgit v1.2.3