diff options
author | N-R-K <79544946+N-R-K@users.noreply.github.com> | 2022-02-26 16:38:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-26 16:38:53 +0000 |
commit | bda70867ac50c35b3bb134cf408ce5ae3cf0c751 (patch) | |
tree | e8380d33cf0f00bee892e6c66cc79649ef0c82d6 | |
parent | 9f12c79d1bfb64cbe006d26cc19af6c375cebbd1 (diff) |
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>
-rw-r--r-- | config.def.h | 3 | ||||
-rw-r--r-- | image.c | 4 | ||||
-rw-r--r-- | nsxiv.h | 1 | ||||
-rw-r--r-- | thumbs.c | 3 | ||||
-rw-r--r-- | window.c | 5 |
5 files changed, 11 insertions, 5 deletions
diff --git a/config.def.h b/config.def.h index 49ca504..65837bf 100644 --- a/config.def.h +++ b/config.def.h @@ -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 @@ -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); } @@ -424,6 +424,7 @@ struct win { struct { unsigned int h; + bool top; win_bar_t l; win_bar_t r; } bar; @@ -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; @@ -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); |