mirror of
https://github.com/0intro/wmii
synced 2025-01-27 04:23:22 +03:00
I think of only a BlitzBrush structure in the future, instead of all this crappy Widget/Color/Font stuff...
This commit is contained in:
parent
4c8870dda3
commit
ec1db9e2df
@ -95,8 +95,8 @@ draw_bar()
|
||||
{
|
||||
unsigned int i = 0, w = 0, nb, size = 0;
|
||||
Bar *b = nil, *prev = nil;
|
||||
blitz_draw_tile(bartile);
|
||||
|
||||
bartile->draw(bartile);
|
||||
if(!lbar && !rbar)
|
||||
goto MapBar;
|
||||
|
||||
@ -136,7 +136,7 @@ draw_bar()
|
||||
for(; b; b=b->next) {
|
||||
if(b == rbar)
|
||||
b->bar->align = EAST;
|
||||
b->bar->draw(b->bar);
|
||||
blitz_draw_input(b->bar);
|
||||
}
|
||||
MapBar:
|
||||
XCopyArea(dpy, barpmap, barwin, bargc, 0, 0, brect.width, brect.height, 0, 0);
|
||||
|
@ -187,10 +187,10 @@ resize_frame(Frame *f)
|
||||
void
|
||||
draw_frame(Frame *f)
|
||||
{
|
||||
f->tile->draw(f->tile);
|
||||
f->tagbar->draw(f->tagbar);
|
||||
f->titlebar->draw(f->titlebar);
|
||||
f->posbar->draw(f->posbar);
|
||||
blitz_draw_input(f->tile);
|
||||
blitz_draw_input(f->tagbar);
|
||||
blitz_draw_input(f->titlebar);
|
||||
blitz_draw_input(f->posbar);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -40,7 +40,7 @@ static unsigned int curroff = 0;
|
||||
static unsigned int cmdw = 0;
|
||||
static unsigned int twidth = 0;
|
||||
static unsigned int cwidth = 0;
|
||||
static BlitzWidget *draw = nil;
|
||||
static BlitzWidget *menu = nil;
|
||||
static const int seek = 30; /* 30px */
|
||||
|
||||
static void draw_menu(void);
|
||||
@ -71,7 +71,7 @@ update_offsets()
|
||||
return;
|
||||
|
||||
for(i = curroff; i < item.size; i++) {
|
||||
tw = blitz_textwidth(draw->font, item.data[i]);
|
||||
tw = blitz_textwidth(menu->font, item.data[i]);
|
||||
if(tw > irect.width / 3)
|
||||
tw = irect.width / 3;
|
||||
w += tw + irect.height;
|
||||
@ -82,7 +82,7 @@ update_offsets()
|
||||
|
||||
w = cmdw + 2 * seek;
|
||||
for(i = curroff; i > 0; i--) {
|
||||
tw = blitz_textwidth(draw->font, item.data[i]);
|
||||
tw = blitz_textwidth(menu->font, item.data[i]);
|
||||
if(tw > irect.width / 3)
|
||||
tw = irect.width / 3;
|
||||
w += tw + irect.height;
|
||||
@ -123,73 +123,70 @@ update_items(char *pattern)
|
||||
return item.size;
|
||||
}
|
||||
|
||||
/* creates draw structs for menu mode drawing */
|
||||
/* creates menu structs for menu mode drawing */
|
||||
static void
|
||||
draw_menu()
|
||||
{
|
||||
unsigned int i, offx = 0;
|
||||
|
||||
draw->align = WEST;
|
||||
menu->align = WEST;
|
||||
|
||||
draw->rect = irect;
|
||||
draw->rect.x = 0;
|
||||
draw->rect.y = 0;
|
||||
draw->color = normcolor;
|
||||
draw->text = nil;
|
||||
draw->draw(draw);
|
||||
menu->rect = irect;
|
||||
menu->rect.x = 0;
|
||||
menu->rect.y = 0;
|
||||
menu->color = normcolor;
|
||||
menu->text = nil;
|
||||
blitz_draw_tile(menu);
|
||||
|
||||
/* print command */
|
||||
if(!title || text[0]) {
|
||||
draw->text = text;
|
||||
draw->color = normcolor;
|
||||
menu->text = text;
|
||||
menu->color = normcolor;
|
||||
cmdw = cwidth;
|
||||
if(cmdw && item.size)
|
||||
draw->rect.width = cmdw;
|
||||
draw->draw(draw);
|
||||
menu->rect.width = cmdw;
|
||||
}
|
||||
else {
|
||||
cmdw = twidth;
|
||||
draw->text = title;
|
||||
draw->color = selcolor;
|
||||
draw->rect.width = cmdw;
|
||||
draw->draw(draw);
|
||||
menu->text = title;
|
||||
menu->color = selcolor;
|
||||
menu->rect.width = cmdw;
|
||||
}
|
||||
offx += draw->rect.width;
|
||||
blitz_draw_input(menu);
|
||||
offx += menu->rect.width;
|
||||
|
||||
draw->align = CENTER;
|
||||
menu->align = CENTER;
|
||||
if(item.size) {
|
||||
draw->color = normcolor;
|
||||
draw->text = prevoff < curroff ? "<" : nil;
|
||||
draw->rect.x = offx;
|
||||
draw->rect.width = seek;
|
||||
offx += draw->rect.width;
|
||||
draw->draw(draw);
|
||||
menu->color = normcolor;
|
||||
menu->text = prevoff < curroff ? "<" : nil;
|
||||
menu->rect.x = offx;
|
||||
menu->rect.width = seek;
|
||||
offx += menu->rect.width;
|
||||
blitz_draw_input(menu);
|
||||
|
||||
/* determine maximum items */
|
||||
for(i = curroff; i < nextoff; i++) {
|
||||
draw->text = item.data[i];
|
||||
draw->rect.x = offx;
|
||||
draw->rect.width = blitz_textwidth(draw->font, draw->text);
|
||||
if(draw->rect.width > irect.width / 3)
|
||||
draw->rect.width = irect.width / 3;
|
||||
draw->rect.width += irect.height;
|
||||
if(sel == i) {
|
||||
draw->color = selcolor;
|
||||
draw->draw(draw);
|
||||
} else {
|
||||
draw->color = normcolor;
|
||||
draw->draw(draw);
|
||||
}
|
||||
offx += draw->rect.width;
|
||||
menu->text = item.data[i];
|
||||
menu->rect.x = offx;
|
||||
menu->rect.width = blitz_textwidth(menu->font, menu->text);
|
||||
if(menu->rect.width > irect.width / 3)
|
||||
menu->rect.width = irect.width / 3;
|
||||
menu->rect.width += irect.height;
|
||||
if(sel == i)
|
||||
menu->color = selcolor;
|
||||
else
|
||||
menu->color = normcolor;
|
||||
blitz_draw_input(menu);
|
||||
offx += menu->rect.width;
|
||||
}
|
||||
|
||||
draw->color = normcolor;
|
||||
draw->text = item.size > nextoff ? ">" : nil;
|
||||
draw->rect.x = irect.width - seek;
|
||||
draw->rect.width = seek;
|
||||
draw->draw(draw);
|
||||
menu->color = normcolor;
|
||||
menu->text = item.size > nextoff ? ">" : nil;
|
||||
menu->rect.x = irect.width - seek;
|
||||
menu->rect.width = seek;
|
||||
blitz_draw_input(menu);
|
||||
}
|
||||
XCopyArea(dpy, draw->drawable, win, draw->gc, 0, 0, irect.width,
|
||||
XCopyArea(dpy, menu->drawable, win, menu->gc, 0, 0, irect.width,
|
||||
irect.height, 0, 0);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
@ -430,14 +427,14 @@ main(int argc, char *argv[])
|
||||
|
||||
XSync(dpy, False);
|
||||
|
||||
draw = blitz_create_input(pmap, gc, &font);
|
||||
menu = blitz_create_input(pmap, gc, &font);
|
||||
if(maxname)
|
||||
cwidth = blitz_textwidth(draw->font, maxname) + irect.height;
|
||||
cwidth = blitz_textwidth(menu->font, maxname) + irect.height;
|
||||
if(cwidth > irect.width / 3)
|
||||
cwidth = irect.width / 3;
|
||||
|
||||
if(title) {
|
||||
twidth = blitz_textwidth(draw->font, title) + irect.height;
|
||||
twidth = blitz_textwidth(menu->font, title) + irect.height;
|
||||
if(twidth > irect.width / 3)
|
||||
twidth = irect.width / 3;
|
||||
}
|
||||
|
@ -58,7 +58,6 @@ struct BlitzWidget {
|
||||
XRectangle rect; /* relative rect */
|
||||
XRectangle *notch; /* relative notch rect */
|
||||
char *text;
|
||||
void (*draw)(BlitzWidget *);
|
||||
};
|
||||
|
||||
Blitz __blitz;
|
||||
|
@ -15,7 +15,6 @@ blitz_create_input(Drawable drawable, GC gc, BlitzFont *font)
|
||||
i->drawable = drawable;
|
||||
i->gc = gc;
|
||||
i->font = font;
|
||||
i->draw = blitz_draw_input;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ blitz_create_tile(Drawable drawable, GC gc)
|
||||
BlitzWidget *t = cext_emallocz(sizeof(BlitzWidget));
|
||||
t->drawable = drawable;
|
||||
t->gc = gc;
|
||||
t->draw = blitz_draw_tile;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user