Krolyxon
Commit d0ba2c5

Branches

Refs →

nsxivd0ba2c5

Simplified thumbnail selection and marks

Author
Bert Münnich
Date
2014-08-17 22:58 +0200
Committer
Bert Münnich · 2014-08-17 23:01 +0200
Parent
4310b84
Commit
d0ba2c585d966959c02c6d8ddc2365222d310ae6

+15 −19

3 files changed

  1. M thumbs.c +9 −12
  2. M window.c +5 −5
  3. M window.h +1 −2
M thumbs.c View
@@ -422,23 +422,21 @@ void tns_mark(tns_t *tns, int n, bool mark)
422422 unsigned long col;
423423 thumb_t *t = &tns->thumbs[n];
424424 win_t *win = tns->win;
425− int x = t->x, y = t->y, w = t->w, h = t->h;
426425
427− if (mark || n == *tns->sel)
426+ if (mark)
428427 col = win->selcol;
429428 else if (win->fullscreen)
430429 col = win->fscol;
431430 else
432431 col = win->bgcol;
433432
434− win_draw_rect(win, win->buf.pm, x - 4, y - 4, 8, 2, true, 0, col);
435− win_draw_rect(win, win->buf.pm, x - 4, y - 4, 2, 8, true, 0, col);
436− win_draw_rect(win, win->buf.pm, x + w - 4, y - 4, 8, 2, true, 0, col);
437− win_draw_rect(win, win->buf.pm, x + w + 2, y - 4, 2, 8, true, 0, col);
438− win_draw_rect(win, win->buf.pm, x - 4, y + h + 2, 8, 2, true, 0, col);
439− win_draw_rect(win, win->buf.pm, x - 4, y + h - 4, 2, 8, true, 0, col);
440− win_draw_rect(win, win->buf.pm, x + w - 4, y + h + 2, 8, 2, true, 0, col);
441− win_draw_rect(win, win->buf.pm, x + w + 2, y + h - 4, 2, 8, true, 0, col);
433+ win_draw_rect(win, t->x - 4, t->y - 4, 4, 4, true, 1, col);
434+ win_draw_rect(win, t->x + t->w, t->y - 4, 4, 4, true, 1, col);
435+ win_draw_rect(win, t->x - 4, t->y + t->h, 4, 4, true, 1, col);
436+ win_draw_rect(win, t->x + t->w, t->y + t->h, 4, 4, true, 1, col);
437+
438+ if (!mark && n == *tns->sel)
439+ tns_highlight(tns, n, true);
442440 }
443441 }
444442
@@ -459,8 +457,7 @@ void tns_highlight(tns_t *tns, int n, bool hl)
459457 else
460458 col = win->bgcol;
461459
462− win_draw_rect(win, win->buf.pm, t->x - 3, t->y - 3, t->w + 6, t->h + 6,
463− false, 2, col);
460+ win_draw_rect(win, t->x - 3, t->y - 3, t->w + 6, t->h + 6, false, 2, col);
464461
465462 if (!hl && tns->files[n].marked)
466463 tns_mark(tns, n, true);
M window.c View
@@ -476,12 +476,12 @@ void win_draw(win_t *win)
476476 XFlush(win->env.dpy);
477477 }
478478
479−void win_draw_rect(win_t *win, Pixmap pm, int x, int y, int w, int h,
480− bool fill, int lw, unsigned long col)
479+void win_draw_rect(win_t *win, int x, int y, int w, int h, bool fill, int lw,
480+ unsigned long col)
481481 {
482482 XGCValues gcval;
483483
484− if (win == NULL || pm == None)
484+ if (win == NULL || win->buf.pm == None)
485485 return;
486486
487487 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,
489489 XChangeGC(win->env.dpy, gc, GCForeground | GCLineWidth, &gcval);
490490
491491 if (fill)
492− XFillRectangle(win->env.dpy, pm, gc, x, y, w, h);
492+ XFillRectangle(win->env.dpy, win->buf.pm, gc, x, y, w, h);
493493 else
494− XDrawRectangle(win->env.dpy, pm, gc, x, y, w, h);
494+ XDrawRectangle(win->env.dpy, win->buf.pm, gc, x, y, w, h);
495495 }
496496
497497 int win_textwidth(const char *text, unsigned int len, bool with_padding)
M window.h View
@@ -93,8 +93,7 @@ void win_toggle_bar(win_t*);
9393
9494 void win_clear(win_t*);
9595 void win_draw(win_t*);
96−void win_draw_rect(win_t*, Pixmap, int, int, int, int, bool, int,
97− unsigned long);
96+void win_draw_rect(win_t*, int, int, int, int, bool, int, unsigned long);
9897
9998 int win_textwidth(const char*, unsigned int, bool);
10099