mirror of
https://github.com/0intro/wmii
synced 2024-12-25 04:46:51 +03:00
simplified BlitzBrush once again
This commit is contained in:
parent
92b0faadc2
commit
ff0f239614
@ -48,8 +48,6 @@ destroy_bar(Bar **b_link, Bar *b)
|
||||
*p = b->next;
|
||||
|
||||
b->next = free_bars;
|
||||
if(b->brush.text)
|
||||
free(b->brush.text);
|
||||
free_bars = b;
|
||||
}
|
||||
|
||||
@ -105,8 +103,8 @@ draw_bar()
|
||||
b->brush.rect.x = 0;
|
||||
b->brush.rect.y = 0;
|
||||
b->brush.rect.width = brect.height;
|
||||
if(b->brush.text && strlen(b->brush.text))
|
||||
b->brush.rect.width += blitz_textwidth(b->brush.font, b->brush.text);
|
||||
if(b->text && strlen(b->text))
|
||||
b->brush.rect.width += blitz_textwidth(b->brush.font, b->text);
|
||||
b->brush.rect.height = brect.height;
|
||||
w += b->brush.rect.width;
|
||||
}
|
||||
@ -136,7 +134,7 @@ draw_bar()
|
||||
for(; b; b=b->next) {
|
||||
if(b == rbar)
|
||||
b->brush.align = EAST;
|
||||
blitz_draw_input(&b->brush);
|
||||
blitz_draw_input(&b->brush, b->text);
|
||||
}
|
||||
MapBar:
|
||||
XCopyArea(blz.display, bbrush.drawable, barwin, bbrush.gc, 0, 0,
|
||||
|
@ -512,7 +512,6 @@ resize_client(Client *c, XRectangle *r, Bool ignore_xcall)
|
||||
else
|
||||
XMoveResizeWindow(blz.display, c->framewin, 2 * rect.width + f->rect.x,
|
||||
f->rect.y, f->rect.width, f->rect.height);
|
||||
resize_frame(f);
|
||||
}
|
||||
|
||||
c->rect.x = def.border;
|
||||
|
@ -30,9 +30,6 @@ create_frame(Area *a, Client *c)
|
||||
f->tile.font = &def.font;
|
||||
f->tile.color = def.normcolor;
|
||||
f->tagbar = f->titlebar = f->posbar = f->tile;
|
||||
f->tile.notch = &c->rect;
|
||||
f->tagbar.text = c->tags;
|
||||
f->titlebar.text = c->name;
|
||||
f->titlebar.align = WEST;
|
||||
f->tagbar.align = f->posbar.align = CENTER;
|
||||
|
||||
@ -79,8 +76,6 @@ destroy_frame(Frame *f)
|
||||
Area *a = f->area;
|
||||
Frame **ft, *pr = nil;
|
||||
|
||||
if(f->posbar.text)
|
||||
free(f->posbar.text);
|
||||
for(ft=&c->frame; *ft && *ft != f; pr = *ft, ft=&(*ft)->cnext);
|
||||
cext_assert(*ft == f);
|
||||
*ft = f->cnext;
|
||||
@ -138,7 +133,7 @@ update_frame_widget_colors(Frame *f)
|
||||
}
|
||||
|
||||
void
|
||||
resize_frame(Frame *f)
|
||||
draw_frame(Frame *f)
|
||||
{
|
||||
|
||||
Frame *p;
|
||||
@ -158,12 +153,9 @@ resize_frame(Frame *f)
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s%d/%d",
|
||||
(f->area == f->area->view->area) ? "~" : "", fidx + 1, size);
|
||||
if(f->posbar.text)
|
||||
free(f->posbar.text);
|
||||
f->posbar.text = strdup(buf);
|
||||
|
||||
w = f->posbar.rect.width =
|
||||
f->posbar.rect.height + blitz_textwidth(&def.font, f->posbar.text);
|
||||
f->posbar.rect.height + blitz_textwidth(&def.font, buf);
|
||||
|
||||
f->posbar.rect.x = f->rect.width - f->posbar.rect.width;
|
||||
|
||||
@ -171,7 +163,7 @@ resize_frame(Frame *f)
|
||||
f->tagbar.rect = f->posbar.rect;
|
||||
f->tagbar.rect.x = 0;
|
||||
f->tagbar.rect.width =
|
||||
f->tagbar.rect.height + blitz_textwidth(&def.font, f->tagbar.text);
|
||||
f->tagbar.rect.height + blitz_textwidth(&def.font, f->client->tags);
|
||||
|
||||
if(f->tagbar.rect.width > f->rect.width / 3)
|
||||
f->tagbar.rect.width = f->rect.width / 3;
|
||||
@ -179,15 +171,11 @@ resize_frame(Frame *f)
|
||||
f->titlebar.rect = f->tagbar.rect;
|
||||
f->titlebar.rect.x = f->tagbar.rect.x + f->tagbar.rect.width;
|
||||
f->titlebar.rect.width = f->rect.width - (f->tagbar.rect.width + f->posbar.rect.width);
|
||||
}
|
||||
|
||||
void
|
||||
draw_frame(Frame *f)
|
||||
{
|
||||
blitz_draw_input(&f->tile);
|
||||
blitz_draw_input(&f->tagbar);
|
||||
blitz_draw_input(&f->titlebar);
|
||||
blitz_draw_input(&f->posbar);
|
||||
blitz_draw_tile(&f->tile);
|
||||
blitz_draw_input(&f->tagbar, f->client->tags);
|
||||
blitz_draw_input(&f->titlebar, f->client->name);
|
||||
blitz_draw_input(&f->posbar, buf);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -828,9 +828,7 @@ fs_clunk(Req *r) {
|
||||
parse_colors(&buf, &i, &f->bar->brush.color);
|
||||
while(buf[i - 1] == '\n')
|
||||
buf[--i] = '\0';
|
||||
if(f->bar->brush.text)
|
||||
free(f->bar->brush.text);
|
||||
f->bar->brush.text = strdup(buf);
|
||||
cext_strlcpy(f->bar->text, buf, sizeof(f->bar->text));
|
||||
draw_bar();
|
||||
break;
|
||||
case FsFEvent:
|
||||
|
@ -126,6 +126,7 @@ typedef struct Bar Bar;
|
||||
struct Bar {
|
||||
Bar *next;
|
||||
char buf[280];
|
||||
char text[256];
|
||||
char name[256];
|
||||
unsigned short id;
|
||||
BlitzBrush brush;
|
||||
|
@ -134,40 +134,36 @@ draw_menu()
|
||||
brush.rect.x = 0;
|
||||
brush.rect.y = 0;
|
||||
brush.color = normcolor;
|
||||
brush.text = nil;
|
||||
blitz_draw_tile(&brush);
|
||||
|
||||
/* print command */
|
||||
if(!title || text[0]) {
|
||||
brush.text = text;
|
||||
brush.color = normcolor;
|
||||
cmdw = cwidth;
|
||||
if(cmdw && item.size)
|
||||
brush.rect.width = cmdw;
|
||||
blitz_draw_input(&brush, text);
|
||||
}
|
||||
else {
|
||||
cmdw = twidth;
|
||||
brush.text = title;
|
||||
brush.color = selcolor;
|
||||
brush.rect.width = cmdw;
|
||||
blitz_draw_input(&brush, title);
|
||||
}
|
||||
blitz_draw_input(&brush);
|
||||
offx += brush.rect.width;
|
||||
|
||||
brush.align = CENTER;
|
||||
if(item.size) {
|
||||
brush.color = normcolor;
|
||||
brush.text = prevoff < curroff ? "<" : nil;
|
||||
brush.rect.x = offx;
|
||||
brush.rect.width = seek;
|
||||
offx += brush.rect.width;
|
||||
blitz_draw_input(&brush);
|
||||
blitz_draw_input(&brush, prevoff < curroff ? "<" : nil);
|
||||
|
||||
/* determine maximum items */
|
||||
for(i = curroff; i < nextoff; i++) {
|
||||
brush.text = item.data[i];
|
||||
brush.rect.x = offx;
|
||||
brush.rect.width = blitz_textwidth(brush.font, brush.text);
|
||||
brush.rect.width = blitz_textwidth(brush.font, item.data[i]);
|
||||
if(brush.rect.width > irect.width / 3)
|
||||
brush.rect.width = irect.width / 3;
|
||||
brush.rect.width += irect.height;
|
||||
@ -175,15 +171,14 @@ draw_menu()
|
||||
brush.color = selcolor;
|
||||
else
|
||||
brush.color = normcolor;
|
||||
blitz_draw_input(&brush);
|
||||
blitz_draw_input(&brush, item.data[i]);
|
||||
offx += brush.rect.width;
|
||||
}
|
||||
|
||||
brush.color = normcolor;
|
||||
brush.text = item.size > nextoff ? ">" : nil;
|
||||
brush.rect.x = irect.width - seek;
|
||||
brush.rect.width = seek;
|
||||
blitz_draw_input(&brush);
|
||||
blitz_draw_input(&brush, item.size > nextoff ? ">" : nil);
|
||||
}
|
||||
XCopyArea(blz.display, brush.drawable, win, brush.gc, 0, 0, irect.width,
|
||||
irect.height, 0, 0);
|
||||
|
@ -57,15 +57,13 @@ struct BlitzBrush {
|
||||
BlitzAlign align;
|
||||
BlitzFont *font;
|
||||
XRectangle rect; /* relative rect */
|
||||
XRectangle *notch; /* relative notch rect */
|
||||
char *text;
|
||||
};
|
||||
|
||||
/* color.c */
|
||||
int blitz_loadcolor(Blitz *blitz, BlitzColor *c);
|
||||
|
||||
/* brush.c */
|
||||
void blitz_draw_input(BlitzBrush *b);
|
||||
void blitz_draw_input(BlitzBrush *b, char *text);
|
||||
void blitz_draw_tile(BlitzBrush *b);
|
||||
|
||||
/* font.c */
|
||||
|
Loading…
Reference in New Issue
Block a user