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:
		@@ -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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								image.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								image.c
									
									
									
									
									
								
							@@ -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);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								nsxiv.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								nsxiv.h
									
									
									
									
									
								
							@@ -424,6 +424,7 @@ struct win {
 | 
			
		||||
 | 
			
		||||
	struct {
 | 
			
		||||
		unsigned int h;
 | 
			
		||||
		bool top;
 | 
			
		||||
		win_bar_t l;
 | 
			
		||||
		win_bar_t r;
 | 
			
		||||
	} bar;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								thumbs.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								thumbs.c
									
									
									
									
									
								
							@@ -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;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								window.c
									
									
									
									
									
								
							@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user