still draw the background when no text will fit
This commit is contained in:
parent
c7d4901f41
commit
afe1d9e3a8
1 changed files with 26 additions and 27 deletions
11
src/frame.cc
11
src/frame.cc
|
@ -437,8 +437,7 @@ void Frame::renderLabel()
|
||||||
otk::ustring t = _client->title(); // the actual text to draw
|
otk::ustring t = _client->title(); // the actual text to draw
|
||||||
int x = geom.bevel; // x coord for the text
|
int x = geom.bevel; // x coord for the text
|
||||||
|
|
||||||
if (x * 2 > geom.label_width) return; // no room at all
|
if (x * 2 < geom.label_width) {
|
||||||
|
|
||||||
// find a string that will fit inside the area for text
|
// find a string that will fit inside the area for text
|
||||||
otk::ustring::size_type text_len = t.size();
|
otk::ustring::size_type text_len = t.size();
|
||||||
int length;
|
int length;
|
||||||
|
@ -446,12 +445,10 @@ void Frame::renderLabel()
|
||||||
|
|
||||||
do {
|
do {
|
||||||
t.resize(text_len);
|
t.resize(text_len);
|
||||||
length = font->measureString(t); // this returns an unsigned, so check < 0
|
length = font->measureString(t);// this returns an unsigned, so check < 0
|
||||||
if (length < 0) length = maxsize; // if the string's that long just adjust
|
if (length < 0) length = maxsize;// if the string's that long just adjust
|
||||||
} while (length > maxsize && text_len-- > 0);
|
} while (length > maxsize && text_len-- > 0);
|
||||||
|
|
||||||
if (text_len <= 0) return; // won't fit anything
|
|
||||||
|
|
||||||
// justify the text
|
// justify the text
|
||||||
switch (style->labelTextJustify()) {
|
switch (style->labelTextJustify()) {
|
||||||
case otk::RenderStyle::RightBottomJustify:
|
case otk::RenderStyle::RightBottomJustify:
|
||||||
|
@ -464,9 +461,11 @@ void Frame::renderLabel()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (text_len > 0)
|
||||||
control->drawString(*s, *font, x, 0,
|
control->drawString(*s, *font, x, 0,
|
||||||
*(_client->focused() ? style->textFocusColor() :
|
*(_client->focused() ? style->textFocusColor() :
|
||||||
style->textUnfocusColor()), t);
|
style->textUnfocusColor()), t);
|
||||||
|
}
|
||||||
|
|
||||||
XSetWindowBackgroundPixmap(**otk::display, _label, s->pixmap());
|
XSetWindowBackgroundPixmap(**otk::display, _label, s->pixmap());
|
||||||
XClearWindow(**otk::display, _label);
|
XClearWindow(**otk::display, _label);
|
||||||
|
|
Loading…
Reference in a new issue