shithub: lola

ref: 95fa0cb9868e932653e84533fe41691ad4e1579e
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 = w->holdmode ?
		w == focused ? TITLEHOLD : LTITLEHOLD :
		w == focused ? TITLE : LTITLE;

	Rectangle r = w->frame->r;

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

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

		Point pt = Pt(r.min.x, r.min.y);
		string(w->frame, pt, wincolors[c+4], 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);
}