Krolyxon
Commit 535c18a

Branches

Refs →

nsxiv535c18a

Uniform thumbnail selection border size

- Consistent handling of thumbnails
- Makes it easier to select very small thumbnails with mouse
Author
Bert
Date
2011-08-19 12:20 +0200
Parent
27591b5
Commit
535c18afdaceaf79759621ccaeee4ec99da9cf5d

+8 −10

2 files changed

  1. M Makefile +1 −1
  2. M thumbs.c +7 −9
M Makefile View
@@ -1,6 +1,6 @@
11 all: sxiv
22
3−VERSION = git-20110818
3+VERSION = git-20110819
44
55 CC = gcc
66 DESTDIR =
M thumbs.c View
@@ -349,6 +349,7 @@ void tns_render(tns_t *tns, win_t *win) {
349349
350350 void tns_highlight(tns_t *tns, win_t *win, int n, Bool hl) {
351351 thumb_t *t;
352+ int x, y;
352353 unsigned long col;
353354
354355 if (!tns || !tns->thumbs || !win)
@@ -364,7 +365,9 @@ void tns_highlight(tns_t *tns, win_t *win, int n, Bool hl) {
364365 else
365366 col = win->bgcol;
366367
367− win_draw_rect(win, win->pm, t->x - 4, t->y - 4, t->w + 8, t->h + 8,
368+ x = t->x - (THUMB_SIZE - t->w) / 2;
369+ y = t->y - (THUMB_SIZE - t->h) / 2;
370+ win_draw_rect(win, win->pm, x - 3, y - 3, THUMB_SIZE + 6, THUMB_SIZE + 6,
368371 False, 2, col);
369372 }
370373
@@ -431,7 +434,6 @@ int tns_scroll(tns_t *tns, direction_t dir) {
431434
432435 int tns_translate(tns_t *tns, int x, int y) {
433436 int n;
434− thumb_t *t;
435437
436438 if (!tns || !tns->thumbs)
437439 return -1;
@@ -441,12 +443,8 @@ int tns_translate(tns_t *tns, int x, int y) {
441443
442444 n = tns->first + (y - tns->y) / thumb_dim * tns->cols +
443445 (x - tns->x) / thumb_dim;
446+ if (n >= tns->cnt)
447+ n = -1;
444448
445− if (n < tns->cnt) {
446− t = &tns->thumbs[n];
447− if (x >= t->x && x <= t->x + t->w && y >= t->y && y <= t->y + t->h)
448− return n;
449− }
450−
451− return -1;
449+ return n;
452450 }