add config.h option for top statusbar (#231)

Closes: https://github.com/nsxiv/nsxiv/issues/230
Co-authored-by: mamg22 <45301823+mamg22@users.noreply.github.com>
This commit is contained in:
N-R-K 2022-02-26 16:38:53 +00:00 committed by GitHub
parent 9f12c79d1b
commit bda70867ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 5 deletions

View file

@ -16,6 +16,9 @@ static const char *DEFAULT_BAR_FG = NULL; /* NULL means it will default to
static const char *DEFAULT_FONT = "monospace-8";
#endif
/* if true, statusbar appears on top of the window */
static const bool TOP_STATUSBAR = false;
#endif
#ifdef _IMAGE_CONFIG

View file

@ -589,12 +589,12 @@ void img_render(img_t *img)
if (img->y <= 0) {
sy = -img->y / img->zoom + 0.5;
sh = win->h / img->zoom;
dy = 0;
dy = win->bar.top ? win->bar.h : 0;
dh = win->h;
} else {
sy = 0;
sh = img->h;
dy = img->y;
dy = img->y + (win->bar.top ? win->bar.h : 0);
dh = MAX(img->h * img->zoom, 1);
}

View file

@ -424,6 +424,7 @@ struct win {
struct {
unsigned int h;
bool top;
win_bar_t l;
win_bar_t r;
} bar;

View file

@ -428,7 +428,8 @@ void tns_render(tns_t *tns)
}
r = cnt % tns->cols ? 1 : 0;
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->y = y = (win->h - (cnt / tns->cols + r) * tns->dim) / 2 + tns->bw + 3 +
(win->bar.top ? win->bar.h : 0);
tns->loadnext = *tns->cnt;
tns->end = tns->first + cnt;

View file

@ -159,6 +159,7 @@ void win_init(win_t *win)
win->bar.r.buf = emalloc(win->bar.r.size + 3);
win->bar.r.buf[0] = '\0';
win->bar.h = options->hide_bar ? 0 : barheight;
win->bar.top = TOP_STATUSBAR;
#endif /* HAVE_LIBFONTS */
XrmDestroyDatabase(db);
@ -445,12 +446,12 @@ static void win_draw_bar(win_t *win)
return;
e = &win->env;
y = win->h + font->ascent + V_TEXT_PAD;
y = (win->bar.top ? 0 : win->h) + font->ascent + V_TEXT_PAD;
w = win->w - 2*H_TEXT_PAD;
d = XftDrawCreate(e->dpy, win->buf.pm, e->vis, e->cmap);
XSetForeground(e->dpy, gc, win->bar_bg.pixel);
XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h);
XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->bar.top ? 0 : win->h, win->w, win->bar.h);
XSetForeground(e->dpy, gc, win->win_bg.pixel);
XSetBackground(e->dpy, gc, win->bar_bg.pixel);