Krolyxon
Commit bda7086

Branches

Refs →

nsxivbda7086

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

Author
N-R-K
Date
2022-02-26 16:38 +0000
Committer
GitHub · 2022-02-26 16:38 +0000
Parent
9f12c79
Commit
bda70867ac50c35b3bb134cf408ce5ae3cf0c751

+11 −5

5 files changed

  1. M config.def.h +3 −0
  2. M image.c +2 −2
  3. M nsxiv.h +1 −0
  4. M thumbs.c +2 −1
  5. M window.c +3 −2
M config.def.h View
@@ -16,6 +16,9 @@ static const char *DEFAULT_BAR_FG = NULL; /* NULL means it will default to
1616 static const char *DEFAULT_FONT = "monospace-8";
1717 #endif
1818
19+/* if true, statusbar appears on top of the window */
20+static const bool TOP_STATUSBAR = false;
21+
1922 #endif
2023 #ifdef _IMAGE_CONFIG
2124
M image.c View
@@ -589,12 +589,12 @@ void img_render(img_t *img)
589589 if (img->y <= 0) {
590590 sy = -img->y / img->zoom + 0.5;
591591 sh = win->h / img->zoom;
592− dy = 0;
592+ dy = win->bar.top ? win->bar.h : 0;
593593 dh = win->h;
594594 } else {
595595 sy = 0;
596596 sh = img->h;
597− dy = img->y;
597+ dy = img->y + (win->bar.top ? win->bar.h : 0);
598598 dh = MAX(img->h * img->zoom, 1);
599599 }
600600
M nsxiv.h View
@@ -424,6 +424,7 @@ struct win {
424424
425425 struct {
426426 unsigned int h;
427+ bool top;
427428 win_bar_t l;
428429 win_bar_t r;
429430 } bar;
M thumbs.c View
@@ -428,7 +428,8 @@ void tns_render(tns_t *tns)
428428 }
429429 r = cnt % tns->cols ? 1 : 0;
430430 tns->x = x = (win->w - MIN(cnt, tns->cols) * tns->dim) / 2 + tns->bw + 3;
431− tns->y = y = (win->h - (cnt / tns->cols + r) * tns->dim) / 2 + tns->bw + 3;
431+ tns->y = y = (win->h - (cnt / tns->cols + r) * tns->dim) / 2 + tns->bw + 3 +
432+ (win->bar.top ? win->bar.h : 0);
432433 tns->loadnext = *tns->cnt;
433434 tns->end = tns->first + cnt;
434435
M window.c View
@@ -159,6 +159,7 @@ void win_init(win_t *win)
159159 win->bar.r.buf = emalloc(win->bar.r.size + 3);
160160 win->bar.r.buf[0] = '\0';
161161 win->bar.h = options->hide_bar ? 0 : barheight;
162+ win->bar.top = TOP_STATUSBAR;
162163 #endif /* HAVE_LIBFONTS */
163164
164165 XrmDestroyDatabase(db);
@@ -445,12 +446,12 @@ static void win_draw_bar(win_t *win)
445446 return;
446447
447448 e = &win->env;
448− y = win->h + font->ascent + V_TEXT_PAD;
449+ y = (win->bar.top ? 0 : win->h) + font->ascent + V_TEXT_PAD;
449450 w = win->w - 2*H_TEXT_PAD;
450451 d = XftDrawCreate(e->dpy, win->buf.pm, e->vis, e->cmap);
451452
452453 XSetForeground(e->dpy, gc, win->bar_bg.pixel);
453− XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h);
454+ XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->bar.top ? 0 : win->h, win->w, win->bar.h);
454455
455456 XSetForeground(e->dpy, gc, win->win_bg.pixel);
456457 XSetBackground(e->dpy, gc, win->bar_bg.pixel);