shithub: lola

ref: 9c6036c190a4c6d39f89b1033214620ec9d19ba0
dir: /flat.c/

View raw version
#include "inc.h"

int bordersz = 4;
int titlesz = 18;

enum {
	TITLE,
	LTITLE,
	TITLEHOLD,
	LTITLEHOLD,
	TITLETEXT,
	LTITLETEXT,
	TITLEHOLDTEXT,
	LTITLEHOLDTEXT,

	NumWinColors
};

Image *wincolors[NumWinColors];

void
wdecor(Window *w)
{
	if(w->frame == nil)
		return;
	int c = wcolsel(w);
	int tc = TITLE + wcolsel(w);

	Rectangle r;
	int margin;

	if(!w->noborder){
		r = w->frame->r;
		border(w->frame, r, bordersz, wincolors[c], ZP);
	}

	if(!w->notitle){
		r = w->titlerect;
		r.max.y = r.min.y + titlesz;
		draw(w->frame, r, wincolors[tc], nil, ZP);

		margin = w->noborder ? titlesz : titlesz + bordersz;
		margin = (margin - font->height)/2;
		Point pt = Pt(r.min.x, w->frame->r.min.y + margin + 1);
		string(w->frame, pt, wincolors[TITLETEXT+c], pt, font, w->label);
	}
}

void
wtitlectl(Window *w)
{
	if(mctl->buttons & 7){
		wraise(w);
		wfocus(w);
		if(mctl->buttons & 1) {
			if(!w->maximized)
				grab(w, 1);
		}
		if(mctl->buttons & 4)
			btn3menu();
	}
}

void
inittheme(void)
{
	wincolors[TITLE] = getcolor("title", DGreygreen);
	wincolors[LTITLE] = getcolor("ltitle", DPalegreygreen);
//	wincolors[TITLE] = getcolor("title", 0x2F78EDFF);
//	wincolors[LTITLE] = getcolor("ltitle", 0x7C9DE3FF);

	wincolors[TITLEHOLD] = getcolor("titlehold", DMedblue);
	wincolors[LTITLEHOLD] = getcolor("ltitlehold", DPalegreyblue);


	wincolors[TITLETEXT] = getcolor("titletext", 0xFFFFFFFF);
	wincolors[LTITLETEXT] = getcolor("ltitletext", 0x808080FF);
	wincolors[TITLEHOLDTEXT] = getcolor("titleholdtext", 0xFFFFFFFF);
	wincolors[LTITLEHOLDTEXT] = getcolor("ltitleholdtext", 0xC0C0C0FF);
}