1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

LibGUI: Add a title to all Widgets

This title is a generic user-facing name for the widget. For now, it's
only used by TabWidget for tab names.
This commit is contained in:
kleines Filmröllchen 2022-03-18 22:54:30 +01:00 committed by Andreas Kling
parent fd6d87df82
commit 0410414455
2 changed files with 19 additions and 0 deletions

View file

@ -70,6 +70,8 @@ Widget::Widget()
REGISTER_INT_PROPERTY("font_size", m_font->presentation_size, set_font_size);
REGISTER_FONT_WEIGHT_PROPERTY("font_weight", m_font->weight, set_font_weight);
REGISTER_STRING_PROPERTY("title", title, set_title);
register_property(
"font_type", [this] { return m_font->is_fixed_width() ? "FixedWidth" : "Normal"; },
[this](auto& value) {
@ -976,6 +978,19 @@ void Widget::set_palette(Palette const& palette)
update();
}
void Widget::set_title(String title)
{
m_title = move(title);
// For tab widget children, our change in title also affects the parent.
if (parent_widget())
parent_widget()->update();
}
String Widget::title() const
{
return m_title;
}
void Widget::set_background_role(ColorRole role)
{
m_background_role = role;