nsxiv535c18a
Uniform thumbnail selection border size
- Consistent handling of thumbnails - Makes it easier to select very small thumbnails with mouse
+8 −10
2 files changed
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | all: sxiv | |
| 2 | 2 | ||
| 3 | − | VERSION = git-20110818 | |
| 3 | + | VERSION = git-20110819 | |
| 4 | 4 | ||
| 5 | 5 | CC = gcc | |
| 6 | 6 | DESTDIR = | |
| @@ -349,6 +349,7 @@ void tns_render(tns_t *tns, win_t *win) { | |||
| 349 | 349 | ||
| 350 | 350 | void tns_highlight(tns_t *tns, win_t *win, int n, Bool hl) { | |
| 351 | 351 | thumb_t *t; | |
| 352 | + | int x, y; | |
| 352 | 353 | unsigned long col; | |
| 353 | 354 | ||
| 354 | 355 | if (!tns || !tns->thumbs || !win) | |
| @@ -364,7 +365,9 @@ void tns_highlight(tns_t *tns, win_t *win, int n, Bool hl) { | |||
| 364 | 365 | else | |
| 365 | 366 | col = win->bgcol; | |
| 366 | 367 | ||
| 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, | |
| 368 | 371 | False, 2, col); | |
| 369 | 372 | } | |
| 370 | 373 | ||
| @@ -431,7 +434,6 @@ int tns_scroll(tns_t *tns, direction_t dir) { | |||
| 431 | 434 | ||
| 432 | 435 | int tns_translate(tns_t *tns, int x, int y) { | |
| 433 | 436 | int n; | |
| 434 | − | thumb_t *t; | |
| 435 | 437 | ||
| 436 | 438 | if (!tns || !tns->thumbs) | |
| 437 | 439 | return -1; | |
| @@ -441,12 +443,8 @@ int tns_translate(tns_t *tns, int x, int y) { | |||
| 441 | 443 | ||
| 442 | 444 | n = tns->first + (y - tns->y) / thumb_dim * tns->cols + | |
| 443 | 445 | (x - tns->x) / thumb_dim; | |
| 446 | + | if (n >= tns->cnt) | |
| 447 | + | n = -1; | |
| 444 | 448 | ||
| 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; | |
| 452 | 450 | } | |