Browse Source

Scale thumbnail selection border width with thumbnail size

master
Bert Münnich 10 years ago
parent
commit
0e4db69ff5
2 changed files with 11 additions and 7 deletions
  1. +10
    -7
      thumbs.c
  2. +1
    -0
      thumbs.h

+ 10
- 7
thumbs.c View File

@@ -419,8 +419,8 @@ void tns_render(tns_t *tns)
cnt -= r % tns->cols; cnt -= r % tns->cols;
} }
r = cnt % tns->cols ? 1 : 0; r = cnt % tns->cols ? 1 : 0;
tns->x = x = (win->w - MIN(cnt, tns->cols) * tns->dim) / 2 + 5;
tns->y = y = (win->h - (cnt / tns->cols + r) * tns->dim) / 2 + 5;
tns->x = x = (win->w - MIN(cnt, tns->cols) * tns->dim) / 2 + tns->bw + 3;
tns->y = y = (win->h - (cnt / tns->cols + r) * tns->dim) / 2 + tns->bw + 3;
tns->loadnext = tns->cnt; tns->loadnext = tns->cnt;
tns->end = tns->first + cnt; tns->end = tns->first + cnt;


@@ -465,13 +465,13 @@ void tns_mark(tns_t *tns, int n, bool mark)
unsigned long col = win->fullscreen ? win->fscol : win->bgcol; unsigned long col = win->fullscreen ? win->fscol : win->bgcol;
int x = t->x + t->w, y = t->y + t->h; int x = t->x + t->w, y = t->y + t->h;


win_draw_rect(win, x - 1, y + 1, 1, 2, true, 1, col);
win_draw_rect(win, x + 1, y - 1, 2, 1, true, 1, col);
win_draw_rect(win, x - 1, y + 1, 1, tns->bw, true, 1, col);
win_draw_rect(win, x + 1, y - 1, tns->bw, 1, true, 1, col);


if (mark) if (mark)
col = win->selcol; col = win->selcol;


win_draw_rect(win, x, y, 4, 4, true, 1, col);
win_draw_rect(win, x, y, tns->bw + 2, tns->bw + 2, true, 1, col);


if (!mark && n == *tns->sel) if (!mark && n == *tns->sel)
tns_highlight(tns, n, true); tns_highlight(tns, n, true);
@@ -487,13 +487,15 @@ void tns_highlight(tns_t *tns, int n, bool hl)
win_t *win = tns->win; win_t *win = tns->win;
thumb_t *t = &tns->thumbs[n]; thumb_t *t = &tns->thumbs[n];
unsigned long col; unsigned long col;
int oxy = (tns->bw + 1) / 2 + 1, owh = tns->bw + 2;


if (hl) if (hl)
col = win->selcol; col = win->selcol;
else else
col = win->fullscreen ? win->fscol : win->bgcol; col = win->fullscreen ? win->fscol : win->bgcol;


win_draw_rect(win, t->x - 2, t->y - 2, t->w + 4, t->h + 4, false, 2, col);
win_draw_rect(win, t->x - oxy, t->y - oxy, t->w + owh, t->h + owh,
false, tns->bw, col);


if (tns->files[n].marked) if (tns->files[n].marked)
tns_mark(tns, n, true); tns_mark(tns, n, true);
@@ -574,7 +576,8 @@ bool tns_zoom(tns_t *tns, int d)
tns->zl = MAX(tns->zl, 0); tns->zl = MAX(tns->zl, 0);
tns->zl = MIN(tns->zl, ARRLEN(thumb_sizes)-1); tns->zl = MIN(tns->zl, ARRLEN(thumb_sizes)-1);


tns->dim = thumb_sizes[tns->zl] + 10;
tns->bw = ((thumb_sizes[tns->zl] - 1) >> 5) + 1;
tns->dim = thumb_sizes[tns->zl] + 2 * tns->bw + 6;


if (tns->zl != oldzl) { if (tns->zl != oldzl) {
for (i = 0; i < tns->cnt; i++) for (i = 0; i < tns->cnt; i++)


+ 1
- 0
thumbs.h View File

@@ -48,6 +48,7 @@ typedef struct {
int cols; int cols;
int rows; int rows;
int zl; int zl;
int bw;
int dim; int dim;


bool dirty; bool dirty;


Loading…
Cancel
Save