Highlight edges of marked images in thumbnail mode
This commit is contained in:
parent
450c1ed9b5
commit
38bc23405d
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
||||||
VERSION = git-20131021
|
VERSION = git-20131114
|
||||||
|
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
MANPREFIX = $(PREFIX)/share/man
|
MANPREFIX = $(PREFIX)/share/man
|
||||||
|
|
|
@ -48,7 +48,6 @@ extern win_t win;
|
||||||
|
|
||||||
extern fileinfo_t *files;
|
extern fileinfo_t *files;
|
||||||
extern int filecnt, fileidx;
|
extern int filecnt, fileidx;
|
||||||
extern int markcnt;
|
|
||||||
extern int alternate;
|
extern int alternate;
|
||||||
|
|
||||||
extern int prefix;
|
extern int prefix;
|
||||||
|
@ -61,7 +60,7 @@ bool it_quit(arg_t a)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (options->to_stdout && markcnt > 0) {
|
if (options->to_stdout) {
|
||||||
for (i = 0; i < filecnt; i++) {
|
for (i = 0; i < filecnt; i++) {
|
||||||
if (files[i].marked)
|
if (files[i].marked)
|
||||||
printf("%s\n", files[i].name);
|
printf("%s\n", files[i].name);
|
||||||
|
@ -247,7 +246,8 @@ bool it_toggle_image_mark(arg_t a)
|
||||||
int sel = mode == MODE_IMAGE ? fileidx : tns.sel;
|
int sel = mode == MODE_IMAGE ? fileidx : tns.sel;
|
||||||
|
|
||||||
files[sel].marked = !files[sel].marked;
|
files[sel].marked = !files[sel].marked;
|
||||||
markcnt += files[sel].marked ? 1 : -1;
|
if (mode == MODE_THUMB)
|
||||||
|
tns_mark(&tns, sel, files[sel].marked);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
main.c
8
main.c
|
@ -65,7 +65,6 @@ win_t win;
|
||||||
|
|
||||||
fileinfo_t *files;
|
fileinfo_t *files;
|
||||||
int filecnt, fileidx;
|
int filecnt, fileidx;
|
||||||
int markcnt;
|
|
||||||
int alternate;
|
int alternate;
|
||||||
|
|
||||||
int prefix;
|
int prefix;
|
||||||
|
@ -493,6 +492,13 @@ void on_buttonpress(XButtonEvent *bev)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Button3:
|
||||||
|
if ((sel = tns_translate(&tns, bev->x, bev->y)) >= 0) {
|
||||||
|
files[sel].marked = !files[sel].marked;
|
||||||
|
tns_mark(&tns, sel, files[sel].marked);
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case Button4:
|
case Button4:
|
||||||
case Button5:
|
case Button5:
|
||||||
if (tns_scroll(&tns, bev->button == Button4 ? DIR_UP : DIR_DOWN,
|
if (tns_scroll(&tns, bev->button == Button4 ? DIR_UP : DIR_DOWN,
|
||||||
|
|
49
thumbs.c
49
thumbs.c
|
@ -363,6 +363,8 @@ void tns_render(tns_t *tns)
|
||||||
|
|
||||||
imlib_render_image_part_on_drawable_at_size(0, 0, t->w, t->h,
|
imlib_render_image_part_on_drawable_at_size(0, 0, t->w, t->h,
|
||||||
t->x, t->y, t->w, t->h);
|
t->x, t->y, t->w, t->h);
|
||||||
|
if (t->file->marked)
|
||||||
|
tns_mark(tns, tns->first + i, true);
|
||||||
if ((i + 1) % tns->cols == 0) {
|
if ((i + 1) % tns->cols == 0) {
|
||||||
x = tns->x;
|
x = tns->x;
|
||||||
y += thumb_dim;
|
y += thumb_dim;
|
||||||
|
@ -374,20 +376,44 @@ void tns_render(tns_t *tns)
|
||||||
tns_highlight(tns, tns->sel, true);
|
tns_highlight(tns, tns->sel, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tns_highlight(tns_t *tns, int n, bool hl)
|
void tns_mark(tns_t *tns, int n, bool mark)
|
||||||
{
|
{
|
||||||
thumb_t *t;
|
|
||||||
win_t *win;
|
|
||||||
int x, y;
|
|
||||||
unsigned long col;
|
|
||||||
|
|
||||||
if (tns == NULL || tns->thumbs == NULL || tns->win == NULL)
|
if (tns == NULL || tns->thumbs == NULL || tns->win == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
win = tns->win;
|
if (n >= 0 && n < tns->cnt) {
|
||||||
|
unsigned long col;
|
||||||
|
thumb_t *t = &tns->thumbs[n];
|
||||||
|
win_t *win = tns->win;
|
||||||
|
int x = t->x, y = t->y, w = t->w, h = t->h;
|
||||||
|
|
||||||
|
if (mark || n == tns->sel)
|
||||||
|
col = win->selcol;
|
||||||
|
else if (win->fullscreen)
|
||||||
|
col = win->fscol;
|
||||||
|
else
|
||||||
|
col = win->bgcol;
|
||||||
|
|
||||||
|
win_draw_rect(win, win->pm, x - 4, y - 4, 8, 2, true, 0, col);
|
||||||
|
win_draw_rect(win, win->pm, x - 4, y - 4, 2, 8, true, 0, col);
|
||||||
|
win_draw_rect(win, win->pm, x + w - 4, y - 4, 8, 2, true, 0, col);
|
||||||
|
win_draw_rect(win, win->pm, x + w + 2, y - 4, 2, 8, true, 0, col);
|
||||||
|
win_draw_rect(win, win->pm, x - 4, y + h + 2, 8, 2, true, 0, col);
|
||||||
|
win_draw_rect(win, win->pm, x - 4, y + h - 4, 2, 8, true, 0, col);
|
||||||
|
win_draw_rect(win, win->pm, x + w - 4, y + h + 2, 8, 2, true, 0, col);
|
||||||
|
win_draw_rect(win, win->pm, x + w + 2, y + h - 4, 2, 8, true, 0, col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tns_highlight(tns_t *tns, int n, bool hl)
|
||||||
|
{
|
||||||
|
if (tns == NULL || tns->thumbs == NULL || tns->win == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (n >= 0 && n < tns->cnt) {
|
if (n >= 0 && n < tns->cnt) {
|
||||||
t = &tns->thumbs[n];
|
unsigned long col;
|
||||||
|
thumb_t *t = &tns->thumbs[n];
|
||||||
|
win_t *win = tns->win;
|
||||||
|
|
||||||
if (hl)
|
if (hl)
|
||||||
col = win->selcol;
|
col = win->selcol;
|
||||||
|
@ -396,10 +422,11 @@ void tns_highlight(tns_t *tns, int n, bool hl)
|
||||||
else
|
else
|
||||||
col = win->bgcol;
|
col = win->bgcol;
|
||||||
|
|
||||||
x = t->x - (THUMB_SIZE - t->w) / 2;
|
win_draw_rect(win, win->pm, t->x - 3, t->y - 3, t->w + 6, t->h + 6,
|
||||||
y = t->y - (THUMB_SIZE - t->h) / 2;
|
|
||||||
win_draw_rect(win, win->pm, x - 3, y - 3, THUMB_SIZE + 6, THUMB_SIZE + 6,
|
|
||||||
false, 2, col);
|
false, 2, col);
|
||||||
|
|
||||||
|
if (!hl && t->file->marked)
|
||||||
|
tns_mark(tns, n, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
thumbs.h
1
thumbs.h
|
@ -59,6 +59,7 @@ void tns_free(tns_t*);
|
||||||
bool tns_load(tns_t*, int, const fileinfo_t*, bool, bool);
|
bool tns_load(tns_t*, int, const fileinfo_t*, bool, bool);
|
||||||
|
|
||||||
void tns_render(tns_t*);
|
void tns_render(tns_t*);
|
||||||
|
void tns_mark(tns_t*, int, bool);
|
||||||
void tns_highlight(tns_t*, int, bool);
|
void tns_highlight(tns_t*, int, bool);
|
||||||
|
|
||||||
bool tns_move_selection(tns_t*, direction_t, int);
|
bool tns_move_selection(tns_t*, direction_t, int);
|
||||||
|
|
Loading…
Reference in a new issue