Пример #1
0
/**
 * A shortcut function to set all attributes simultaneously.
 */
void WidgetLabel::set(int _x, int _y, int _justify, int _valign, const std::string& _text, const Color& _color, const std::string& _font) {

	bool changed = false;
	bool changed_pos = false;

	if (justify != _justify) {
		justify = _justify;
		changed = true;
	}
	if (valign != _valign) {
		valign = _valign;
		changed = true;
	}
	if (text != _text) {
		text = _text;
		changed = true;
	}
	if (color.r != _color.r || color.g != _color.g || color.b != _color.b) {
		color = _color;
		changed = true;
	}
	if (pos.x != _x) {
		pos.x = _x;
		changed_pos = true;
	}
	if (pos.y != _y) {
		pos.y = _y;
		changed_pos = true;
	}
	if (font_style != _font) {
		font_style = _font;
		changed = true;
	}

	if (changed) {
		recacheTextSprite();
	}
	else if (changed_pos) {
		applyOffsets();
	}
}
Пример #2
0
/**
 * Update the label text only
 */
void WidgetLabel::set(const std::string& _text) {
	if (text != _text) {
		this->text = _text;
		recacheTextSprite();
	}
}
Пример #3
0
/**
 * Set justify value.
 */
void WidgetLabel::setJustify(int _justify) {
	if (justify != _justify) {
		justify = _justify;
		recacheTextSprite();
	}
}
Пример #4
0
void WidgetLabel::setMaxWidth(int width) {
    if (width != max_width) {
        max_width = width;
        recacheTextSprite();
    }
}