Krolyxon
Commit 38bc234

Branches

Refs →

nsxiv38bc234

Highlight edges of marked images in thumbnail mode

Author
Bert Münnich
Date
2013-11-14 14:37 +0100
Parent
450c1ed
Commit
38bc23405d619a7ba430731f141157104f2267f9

+50 −16

5 files changed

  1. M Makefile +1 −1
  2. M commands.c +3 −3
  3. M main.c +7 −1
  4. M thumbs.c +38 −11
  5. M thumbs.h +1 −0
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20131021
1+VERSION = git-20131114
22
33 PREFIX = /usr/local
44 MANPREFIX = $(PREFIX)/share/man
M commands.c View
@@ -48,7 +48,6 @@ extern win_t win;
4848
4949 extern fileinfo_t *files;
5050 extern int filecnt, fileidx;
51−extern int markcnt;
5251 extern int alternate;
5352
5453 extern int prefix;
@@ -61,7 +60,7 @@ bool it_quit(arg_t a)
6160 {
6261 unsigned int i;
6362
64− if (options->to_stdout && markcnt > 0) {
63+ if (options->to_stdout) {
6564 for (i = 0; i < filecnt; i++) {
6665 if (files[i].marked)
6766 printf("%s\n", files[i].name);
@@ -247,7 +246,8 @@ bool it_toggle_image_mark(arg_t a)
247246 int sel = mode == MODE_IMAGE ? fileidx : tns.sel;
248247
249248 files[sel].marked = !files[sel].marked;
250− markcnt += files[sel].marked ? 1 : -1;
249+ if (mode == MODE_THUMB)
250+ tns_mark(&tns, sel, files[sel].marked);
251251 return true;
252252 }
253253
M main.c View
@@ -65,7 +65,6 @@ win_t win;
6565
6666 fileinfo_t *files;
6767 int filecnt, fileidx;
68−int markcnt;
6968 int alternate;
7069
7170 int prefix;
@@ -493,6 +492,13 @@ void on_buttonpress(XButtonEvent *bev)
493492 break;
494493 }
495494 break;
495+ case Button3:
496+ if ((sel = tns_translate(&tns, bev->x, bev->y)) >= 0) {
497+ files[sel].marked = !files[sel].marked;
498+ tns_mark(&tns, sel, files[sel].marked);
499+ redraw();
500+ }
501+ break;
496502 case Button4:
497503 case Button5:
498504 if (tns_scroll(&tns, bev->button == Button4 ? DIR_UP : DIR_DOWN,
M thumbs.c View
@@ -363,6 +363,8 @@ void tns_render(tns_t *tns)
363363
364364 imlib_render_image_part_on_drawable_at_size(0, 0, t->w, t->h,
365365 t->x, t->y, t->w, t->h);
366+ if (t->file->marked)
367+ tns_mark(tns, tns->first + i, true);
366368 if ((i + 1) % tns->cols == 0) {
367369 x = tns->x;
368370 y += thumb_dim;
@@ -374,20 +376,44 @@ void tns_render(tns_t *tns)
374376 tns_highlight(tns, tns->sel, true);
375377 }
376378
377−void tns_highlight(tns_t *tns, int n, bool hl)
379+void tns_mark(tns_t *tns, int n, bool mark)
378380 {
379− thumb_t *t;
380− win_t *win;
381− int x, y;
382− unsigned long col;
383−
384381 if (tns == NULL || tns->thumbs == NULL || tns->win == NULL)
385382 return;
386383
387− win = tns->win;
384+ if (n >= 0 && n < tns->cnt) {
385+ unsigned long col;
386+ thumb_t *t = &tns->thumbs[n];
387+ win_t *win = tns->win;
388+ int x = t->x, y = t->y, w = t->w, h = t->h;
389+
390+ if (mark || n == tns->sel)
391+ col = win->selcol;
392+ else if (win->fullscreen)
393+ col = win->fscol;
394+ else
395+ col = win->bgcol;
396+
397+ win_draw_rect(win, win->pm, x - 4, y - 4, 8, 2, true, 0, col);
398+ win_draw_rect(win, win->pm, x - 4, y - 4, 2, 8, true, 0, col);
399+ win_draw_rect(win, win->pm, x + w - 4, y - 4, 8, 2, true, 0, col);
400+ win_draw_rect(win, win->pm, x + w + 2, y - 4, 2, 8, true, 0, col);
401+ win_draw_rect(win, win->pm, x - 4, y + h + 2, 8, 2, true, 0, col);
402+ win_draw_rect(win, win->pm, x - 4, y + h - 4, 2, 8, true, 0, col);
403+ win_draw_rect(win, win->pm, x + w - 4, y + h + 2, 8, 2, true, 0, col);
404+ win_draw_rect(win, win->pm, x + w + 2, y + h - 4, 2, 8, true, 0, col);
405+ }
406+}
407+
408+void tns_highlight(tns_t *tns, int n, bool hl)
409+{
410+ if (tns == NULL || tns->thumbs == NULL || tns->win == NULL)
411+ return;
388412
389413 if (n >= 0 && n < tns->cnt) {
390− t = &tns->thumbs[n];
414+ unsigned long col;
415+ thumb_t *t = &tns->thumbs[n];
416+ win_t *win = tns->win;
391417
392418 if (hl)
393419 col = win->selcol;
@@ -396,10 +422,11 @@ void tns_highlight(tns_t *tns, int n, bool hl)
396422 else
397423 col = win->bgcol;
398424
399− x = t->x - (THUMB_SIZE - t->w) / 2;
400− y = t->y - (THUMB_SIZE - t->h) / 2;
401− win_draw_rect(win, win->pm, x - 3, y - 3, THUMB_SIZE + 6, THUMB_SIZE + 6,
425+ win_draw_rect(win, win->pm, t->x - 3, t->y - 3, t->w + 6, t->h + 6,
402426 false, 2, col);
427+
428+ if (!hl && t->file->marked)
429+ tns_mark(tns, n, true);
403430 }
404431 }
405432
M thumbs.h View
@@ -59,6 +59,7 @@ void tns_free(tns_t*);
5959 bool tns_load(tns_t*, int, const fileinfo_t*, bool, bool);
6060
6161 void tns_render(tns_t*);
62+void tns_mark(tns_t*, int, bool);
6263 void tns_highlight(tns_t*, int, bool);
6364
6465 bool tns_move_selection(tns_t*, direction_t, int);