Simplified thumbnail selection and marks

This commit is contained in:
Bert Münnich 2014-08-17 22:58:02 +02:00
parent 4310b846c1
commit d0ba2c585d
3 changed files with 15 additions and 19 deletions

View File

@ -422,23 +422,21 @@ void tns_mark(tns_t *tns, int n, bool mark)
unsigned long col; unsigned long col;
thumb_t *t = &tns->thumbs[n]; thumb_t *t = &tns->thumbs[n];
win_t *win = tns->win; win_t *win = tns->win;
int x = t->x, y = t->y, w = t->w, h = t->h;
if (mark || n == *tns->sel) if (mark)
col = win->selcol; col = win->selcol;
else if (win->fullscreen) else if (win->fullscreen)
col = win->fscol; col = win->fscol;
else else
col = win->bgcol; col = win->bgcol;
win_draw_rect(win, win->buf.pm, x - 4, y - 4, 8, 2, true, 0, col); win_draw_rect(win, t->x - 4, t->y - 4, 4, 4, true, 1, col);
win_draw_rect(win, win->buf.pm, x - 4, y - 4, 2, 8, true, 0, col); win_draw_rect(win, t->x + t->w, t->y - 4, 4, 4, true, 1, col);
win_draw_rect(win, win->buf.pm, x + w - 4, y - 4, 8, 2, true, 0, col); win_draw_rect(win, t->x - 4, t->y + t->h, 4, 4, true, 1, col);
win_draw_rect(win, win->buf.pm, x + w + 2, y - 4, 2, 8, true, 0, col); win_draw_rect(win, t->x + t->w, t->y + t->h, 4, 4, true, 1, col);
win_draw_rect(win, win->buf.pm, x - 4, y + h + 2, 8, 2, true, 0, col);
win_draw_rect(win, win->buf.pm, x - 4, y + h - 4, 2, 8, true, 0, col); if (!mark && n == *tns->sel)
win_draw_rect(win, win->buf.pm, x + w - 4, y + h + 2, 8, 2, true, 0, col); tns_highlight(tns, n, true);
win_draw_rect(win, win->buf.pm, x + w + 2, y + h - 4, 2, 8, true, 0, col);
} }
} }
@ -459,8 +457,7 @@ void tns_highlight(tns_t *tns, int n, bool hl)
else else
col = win->bgcol; col = win->bgcol;
win_draw_rect(win, win->buf.pm, t->x - 3, t->y - 3, t->w + 6, t->h + 6, win_draw_rect(win, t->x - 3, t->y - 3, t->w + 6, t->h + 6, false, 2, col);
false, 2, col);
if (!hl && tns->files[n].marked) if (!hl && tns->files[n].marked)
tns_mark(tns, n, true); tns_mark(tns, n, true);

View File

@ -476,12 +476,12 @@ void win_draw(win_t *win)
XFlush(win->env.dpy); XFlush(win->env.dpy);
} }
void win_draw_rect(win_t *win, Pixmap pm, int x, int y, int w, int h, void win_draw_rect(win_t *win, int x, int y, int w, int h, bool fill, int lw,
bool fill, int lw, unsigned long col) unsigned long col)
{ {
XGCValues gcval; XGCValues gcval;
if (win == NULL || pm == None) if (win == NULL || win->buf.pm == None)
return; return;
gcval.line_width = lw; gcval.line_width = lw;
@ -489,9 +489,9 @@ void win_draw_rect(win_t *win, Pixmap pm, int x, int y, int w, int h,
XChangeGC(win->env.dpy, gc, GCForeground | GCLineWidth, &gcval); XChangeGC(win->env.dpy, gc, GCForeground | GCLineWidth, &gcval);
if (fill) if (fill)
XFillRectangle(win->env.dpy, pm, gc, x, y, w, h); XFillRectangle(win->env.dpy, win->buf.pm, gc, x, y, w, h);
else else
XDrawRectangle(win->env.dpy, pm, gc, x, y, w, h); XDrawRectangle(win->env.dpy, win->buf.pm, gc, x, y, w, h);
} }
int win_textwidth(const char *text, unsigned int len, bool with_padding) int win_textwidth(const char *text, unsigned int len, bool with_padding)

View File

@ -93,8 +93,7 @@ void win_toggle_bar(win_t*);
void win_clear(win_t*); void win_clear(win_t*);
void win_draw(win_t*); void win_draw(win_t*);
void win_draw_rect(win_t*, Pixmap, int, int, int, int, bool, int, void win_draw_rect(win_t*, int, int, int, int, bool, int, unsigned long);
unsigned long);
int win_textwidth(const char*, unsigned int, bool); int win_textwidth(const char*, unsigned int, bool);