Krolyxon
Commit 0e4db69

Branches

Refs →

nsxiv0e4db69

Scale thumbnail selection border width with thumbnail size

Author
Bert Münnich
Date
2014-09-29 09:36 +0200
Committer
Bert Münnich · 2014-09-29 09:36 +0200
Parent
39671a1
Commit
0e4db69ff5dc0ebc863af03117caab39c725893f

+11 −7

2 files changed

  1. M thumbs.c +10 −7
  2. M thumbs.h +1 −0
M thumbs.c View
@@ -419,8 +419,8 @@ void tns_render(tns_t *tns)
419419 cnt -= r % tns->cols;
420420 }
421421 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;
424424 tns->loadnext = tns->cnt;
425425 tns->end = tns->first + cnt;
426426
@@ -465,13 +465,13 @@ void tns_mark(tns_t *tns, int n, bool mark)
465465 unsigned long col = win->fullscreen ? win->fscol : win->bgcol;
466466 int x = t->x + t->w, y = t->y + t->h;
467467
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);
470470
471471 if (mark)
472472 col = win->selcol;
473473
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);
475475
476476 if (!mark && n == *tns->sel)
477477 tns_highlight(tns, n, true);
@@ -487,13 +487,15 @@ void tns_highlight(tns_t *tns, int n, bool hl)
487487 win_t *win = tns->win;
488488 thumb_t *t = &tns->thumbs[n];
489489 unsigned long col;
490+ int oxy = (tns->bw + 1) / 2 + 1, owh = tns->bw + 2;
490491
491492 if (hl)
492493 col = win->selcol;
493494 else
494495 col = win->fullscreen ? win->fscol : win->bgcol;
495496
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);
497499
498500 if (tns->files[n].marked)
499501 tns_mark(tns, n, true);
@@ -574,7 +576,8 @@ bool tns_zoom(tns_t *tns, int d)
574576 tns->zl = MAX(tns->zl, 0);
575577 tns->zl = MIN(tns->zl, ARRLEN(thumb_sizes)-1);
576578
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;
578581
579582 if (tns->zl != oldzl) {
580583 for (i = 0; i < tns->cnt; i++)
M thumbs.h View
@@ -48,6 +48,7 @@ typedef struct {
4848 int cols;
4949 int rows;
5050 int zl;
51+ int bw;
5152 int dim;
5253
5354 bool dirty;