X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Flabelwidget.cc;h=4fd48b59ab3275f259fe292cdbdb8b6fd034dd38;hb=509e6a8f439bba220d71393b4da9597b7f8fa180;hp=491deadccdf75120f0c938b664acb3b7f4e1d94a;hpb=5fdd493d0d2255f134114e69f028371366f4dfd3;p=chaz%2Fopenbox diff --git a/src/labelwidget.cc b/src/labelwidget.cc index 491deadc..4fd48b59 100644 --- a/src/labelwidget.cc +++ b/src/labelwidget.cc @@ -72,44 +72,48 @@ void OBLabelWidget::unfocus() void OBLabelWidget::update() { - OtkWidget::update(); + bool draw = _dirty; - std::string t = _text; - int x = _sidemargin; // x coord for the text + OtkWidget::update(); - // find a string that will fit inside the area for text - int max_length = width() - _sidemargin * 2; - if (max_length <= 0) { - t = ""; // can't fit anything - } else { - size_t text_len = t.size(); - int length; + if (draw) { + std::string t = _text; + int x = _sidemargin; // x coord for the text + + // find a string that will fit inside the area for text + int max_length = width() - _sidemargin * 2; + if (max_length <= 0) { + t = ""; // can't fit anything + } else { + size_t text_len = t.size(); + int length; - do { - t.resize(text_len); - length = _font->measureString(t); - } while (length > max_length && text_len-- > 0); - - // justify the text - switch (_justify) { - case otk::Style::RightJustify: - x += max_length - length; - break; - case otk::Style::CenterJustify: - x += (max_length - length) / 2; - break; - case otk::Style::LeftJustify: - break; + do { + t.resize(text_len); + length = _font->measureString(t); + } while (length > max_length && text_len-- > 0); + + // justify the text + switch (_justify) { + case otk::Style::RightJustify: + x += max_length - length; + break; + case otk::Style::CenterJustify: + x += (max_length - length) / 2; + break; + case otk::Style::LeftJustify: + break; + } } - } - _font->drawString(_xftdraw, x, 0, *_text_color, t); + _font->drawString(_xftdraw, x, 0, *_text_color, t); + } } void OBLabelWidget::adjust() { - // XXX: adjust shit + // nothing to adjust. no children. } }