mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:57:47 +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:
parent
fd6d87df82
commit
0410414455
2 changed files with 19 additions and 0 deletions
|
@ -70,6 +70,8 @@ Widget::Widget()
|
||||||
REGISTER_INT_PROPERTY("font_size", m_font->presentation_size, set_font_size);
|
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_FONT_WEIGHT_PROPERTY("font_weight", m_font->weight, set_font_weight);
|
||||||
|
|
||||||
|
REGISTER_STRING_PROPERTY("title", title, set_title);
|
||||||
|
|
||||||
register_property(
|
register_property(
|
||||||
"font_type", [this] { return m_font->is_fixed_width() ? "FixedWidth" : "Normal"; },
|
"font_type", [this] { return m_font->is_fixed_width() ? "FixedWidth" : "Normal"; },
|
||||||
[this](auto& value) {
|
[this](auto& value) {
|
||||||
|
@ -976,6 +978,19 @@ void Widget::set_palette(Palette const& palette)
|
||||||
update();
|
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)
|
void Widget::set_background_role(ColorRole role)
|
||||||
{
|
{
|
||||||
m_background_role = role;
|
m_background_role = role;
|
||||||
|
|
|
@ -278,6 +278,9 @@ public:
|
||||||
Gfx::Palette palette() const;
|
Gfx::Palette palette() const;
|
||||||
void set_palette(Gfx::Palette const&);
|
void set_palette(Gfx::Palette const&);
|
||||||
|
|
||||||
|
String title() const;
|
||||||
|
void set_title(String);
|
||||||
|
|
||||||
Margins const& grabbable_margins() const { return m_grabbable_margins; }
|
Margins const& grabbable_margins() const { return m_grabbable_margins; }
|
||||||
void set_grabbable_margins(Margins const&);
|
void set_grabbable_margins(Margins const&);
|
||||||
|
|
||||||
|
@ -390,6 +393,7 @@ private:
|
||||||
bool m_default_font { true };
|
bool m_default_font { true };
|
||||||
|
|
||||||
NonnullRefPtr<Gfx::PaletteImpl> m_palette;
|
NonnullRefPtr<Gfx::PaletteImpl> m_palette;
|
||||||
|
String m_title { String::empty() };
|
||||||
|
|
||||||
WeakPtr<Widget> m_focus_proxy;
|
WeakPtr<Widget> m_focus_proxy;
|
||||||
FocusPolicy m_focus_policy { FocusPolicy::NoFocus };
|
FocusPolicy m_focus_policy { FocusPolicy::NoFocus };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue