Minor fixes to label sizing/alignment in liblitz (this really needs a brush->padding)

This commit is contained in:
Kris Maglione 2006-06-27 20:59:09 -04:00
parent 4113e8eb5c
commit ab2ff71e8f
2 changed files with 7 additions and 5 deletions

View File

@ -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)

View File

@ -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;