nsxivbda7086
add config.h option for top statusbar (#231)
+11 −5
5 files changed
- M config.def.h +3 −0
- M image.c +2 −2
- M nsxiv.h +1 −0
- M thumbs.c +2 −1
- M window.c +3 −2
| @@ -16,6 +16,9 @@ static const char *DEFAULT_BAR_FG = NULL; /* NULL means it will default to | |||
| 16 | 16 | static const char *DEFAULT_FONT = "monospace-8"; | |
| 17 | 17 | #endif | |
| 18 | 18 | ||
| 19 | + | /* if true, statusbar appears on top of the window */ | |
| 20 | + | static const bool TOP_STATUSBAR = false; | |
| 21 | + | ||
| 19 | 22 | #endif | |
| 20 | 23 | #ifdef _IMAGE_CONFIG | |
| 21 | 24 | ||
| @@ -589,12 +589,12 @@ void img_render(img_t *img) | |||
| 589 | 589 | if (img->y <= 0) { | |
| 590 | 590 | sy = -img->y / img->zoom + 0.5; | |
| 591 | 591 | sh = win->h / img->zoom; | |
| 592 | − | dy = 0; | |
| 592 | + | dy = win->bar.top ? win->bar.h : 0; | |
| 593 | 593 | dh = win->h; | |
| 594 | 594 | } else { | |
| 595 | 595 | sy = 0; | |
| 596 | 596 | sh = img->h; | |
| 597 | − | dy = img->y; | |
| 597 | + | dy = img->y + (win->bar.top ? win->bar.h : 0); | |
| 598 | 598 | dh = MAX(img->h * img->zoom, 1); | |
| 599 | 599 | } | |
| 600 | 600 | ||
| @@ -424,6 +424,7 @@ struct win { | |||
| 424 | 424 | ||
| 425 | 425 | struct { | |
| 426 | 426 | unsigned int h; | |
| 427 | + | bool top; | |
| 427 | 428 | win_bar_t l; | |
| 428 | 429 | win_bar_t r; | |
| 429 | 430 | } bar; | |
| @@ -428,7 +428,8 @@ void tns_render(tns_t *tns) | |||
| 428 | 428 | } | |
| 429 | 429 | r = cnt % tns->cols ? 1 : 0; | |
| 430 | 430 | 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); | |
| 432 | 433 | tns->loadnext = *tns->cnt; | |
| 433 | 434 | tns->end = tns->first + cnt; | |
| 434 | 435 | ||
| @@ -159,6 +159,7 @@ void win_init(win_t *win) | |||
| 159 | 159 | win->bar.r.buf = emalloc(win->bar.r.size + 3); | |
| 160 | 160 | win->bar.r.buf[0] = '\0'; | |
| 161 | 161 | win->bar.h = options->hide_bar ? 0 : barheight; | |
| 162 | + | win->bar.top = TOP_STATUSBAR; | |
| 162 | 163 | #endif /* HAVE_LIBFONTS */ | |
| 163 | 164 | ||
| 164 | 165 | XrmDestroyDatabase(db); | |
| @@ -445,12 +446,12 @@ static void win_draw_bar(win_t *win) | |||
| 445 | 446 | return; | |
| 446 | 447 | ||
| 447 | 448 | 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; | |
| 449 | 450 | w = win->w - 2*H_TEXT_PAD; | |
| 450 | 451 | d = XftDrawCreate(e->dpy, win->buf.pm, e->vis, e->cmap); | |
| 451 | 452 | ||
| 452 | 453 | 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); | |
| 454 | 455 | ||
| 455 | 456 | XSetForeground(e->dpy, gc, win->win_bg.pixel); | |
| 456 | 457 | XSetBackground(e->dpy, gc, win->bar_bg.pixel); | |