nsxiv0e4db69
Scale thumbnail selection border width with thumbnail size
+11 −7
2 files changed
| @@ -419,8 +419,8 @@ void tns_render(tns_t *tns) | |||
| 419 | 419 | cnt -= r % tns->cols; | |
| 420 | 420 | } | |
| 421 | 421 | r = cnt % tns->cols ? 1 : 0; | |
| 422 | − | tns->x = x = (win->w - MIN(cnt, tns->cols) * tns->dim) / 2 + 5; | |
| 423 | − | tns->y = y = (win->h - (cnt / tns->cols + r) * tns->dim) / 2 + 5; | |
| 422 | + | tns->x = x = (win->w - MIN(cnt, tns->cols) * tns->dim) / 2 + tns->bw + 3; | |
| 423 | + | tns->y = y = (win->h - (cnt / tns->cols + r) * tns->dim) / 2 + tns->bw + 3; | |
| 424 | 424 | tns->loadnext = tns->cnt; | |
| 425 | 425 | tns->end = tns->first + cnt; | |
| 426 | 426 | ||
| @@ -465,13 +465,13 @@ void tns_mark(tns_t *tns, int n, bool mark) | |||
| 465 | 465 | unsigned long col = win->fullscreen ? win->fscol : win->bgcol; | |
| 466 | 466 | int x = t->x + t->w, y = t->y + t->h; | |
| 467 | 467 | ||
| 468 | − | win_draw_rect(win, x - 1, y + 1, 1, 2, true, 1, col); | |
| 469 | − | win_draw_rect(win, x + 1, y - 1, 2, 1, true, 1, col); | |
| 468 | + | win_draw_rect(win, x - 1, y + 1, 1, tns->bw, true, 1, col); | |
| 469 | + | win_draw_rect(win, x + 1, y - 1, tns->bw, 1, true, 1, col); | |
| 470 | 470 | ||
| 471 | 471 | if (mark) | |
| 472 | 472 | col = win->selcol; | |
| 473 | 473 | ||
| 474 | − | win_draw_rect(win, x, y, 4, 4, true, 1, col); | |
| 474 | + | win_draw_rect(win, x, y, tns->bw + 2, tns->bw + 2, true, 1, col); | |
| 475 | 475 | ||
| 476 | 476 | if (!mark && n == *tns->sel) | |
| 477 | 477 | tns_highlight(tns, n, true); | |
| @@ -487,13 +487,15 @@ void tns_highlight(tns_t *tns, int n, bool hl) | |||
| 487 | 487 | win_t *win = tns->win; | |
| 488 | 488 | thumb_t *t = &tns->thumbs[n]; | |
| 489 | 489 | unsigned long col; | |
| 490 | + | int oxy = (tns->bw + 1) / 2 + 1, owh = tns->bw + 2; | |
| 490 | 491 | ||
| 491 | 492 | if (hl) | |
| 492 | 493 | col = win->selcol; | |
| 493 | 494 | else | |
| 494 | 495 | col = win->fullscreen ? win->fscol : win->bgcol; | |
| 495 | 496 | ||
| 496 | − | win_draw_rect(win, t->x - 2, t->y - 2, t->w + 4, t->h + 4, false, 2, col); | |
| 497 | + | win_draw_rect(win, t->x - oxy, t->y - oxy, t->w + owh, t->h + owh, | |
| 498 | + | false, tns->bw, col); | |
| 497 | 499 | ||
| 498 | 500 | if (tns->files[n].marked) | |
| 499 | 501 | tns_mark(tns, n, true); | |
| @@ -574,7 +576,8 @@ bool tns_zoom(tns_t *tns, int d) | |||
| 574 | 576 | tns->zl = MAX(tns->zl, 0); | |
| 575 | 577 | tns->zl = MIN(tns->zl, ARRLEN(thumb_sizes)-1); | |
| 576 | 578 | ||
| 577 | − | tns->dim = thumb_sizes[tns->zl] + 10; | |
| 579 | + | tns->bw = ((thumb_sizes[tns->zl] - 1) >> 5) + 1; | |
| 580 | + | tns->dim = thumb_sizes[tns->zl] + 2 * tns->bw + 6; | |
| 578 | 581 | ||
| 579 | 582 | if (tns->zl != oldzl) { | |
| 580 | 583 | for (i = 0; i < tns->cnt; i++) | |
| @@ -48,6 +48,7 @@ typedef struct { | |||
| 48 | 48 | int cols; | |
| 49 | 49 | int rows; | |
| 50 | 50 | int zl; | |
| 51 | + | int bw; | |
| 51 | 52 | int dim; | |
| 52 | 53 | ||
| 53 | 54 | bool dirty; | |