commit ab2ff71e8f794c83dd8492223e3f39074bfdd0d8
parent 4113e8eb5c7953ebf453416b03f7ccac5f28b046
Author: Kris Maglione <bsdaemon@wmii.de>
Date: Tue, 27 Jun 2006 20:59:09 -0400
Minor fixes to label sizing/alignment in liblitz (this really needs a brush->padding)
Diffstat:
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/cmd/wm/bar.c b/cmd/wm/bar.c
@@ -30,7 +30,6 @@ create_bar(Bar **b_link, char *name)
cext_strlcpy(b->name, name, sizeof(b->name));
b->brush = bbrush;
b->brush.color = def.normcolor;
- b->brush.align = CENTER;
for(i=b_link; *i; i=&(*i)->next)
if(strcmp((*i)->name, name) >= 0)
diff --git a/liblitz/brush.c b/liblitz/brush.c
@@ -45,9 +45,8 @@ blitz_draw_label(BlitzBrush *b, char *text)
y = b->rect.y + b->rect.height / 2 - h / 2 + b->font->ascent;
/* shorten text if necessary */
- while (len && (w = blitz_textwidth(b->font, buf)) > b->rect.width) {
- buf[len - 1] = 0;
- len--;
+ while (len && (w = blitz_textwidth(b->font, buf)) > b->rect.width - h) {
+ buf[--len] = 0;
shortened = 1;
}
@@ -63,12 +62,16 @@ blitz_draw_label(BlitzBrush *b, char *text)
if (len > 1)
buf[len - 1] = '.';
}
+ /* shorten text more if necessary */
+ while (len && (w = blitz_textwidth(b->font, buf)) > b->rect.width - h)
+ buf[--len] = 0;
+
switch (b->align) {
case EAST:
x = b->rect.x + b->rect.width - (h / 2 + w);
break;
case CENTER:
- x = b->rect.x + (b->rect.width - w) / 2;
+ x = b->rect.x + h / 2 + (b->rect.width - h - w) / 2;
break;
default:
x = b->rect.x + h / 2;