mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:27:35 +00:00
LibGUI: Allow Label icons to be set from GML
This is similar to dd17df76e9
, which
did the same thing for the Button widget.
This commit is contained in:
parent
1aa8f73ddb
commit
1c18261f8b
2 changed files with 12 additions and 0 deletions
|
@ -30,6 +30,7 @@ Label::Label(String text)
|
|||
|
||||
REGISTER_STRING_PROPERTY("text", text, set_text);
|
||||
REGISTER_BOOL_PROPERTY("autosize", is_autosize, set_autosize);
|
||||
REGISTER_STRING_PROPERTY("icon", icon, set_icon_from_path);
|
||||
}
|
||||
|
||||
Label::~Label()
|
||||
|
@ -53,6 +54,16 @@ void Label::set_icon(const Gfx::Bitmap* icon)
|
|||
update();
|
||||
}
|
||||
|
||||
void Label::set_icon_from_path(String const& path)
|
||||
{
|
||||
auto maybe_bitmap = Gfx::Bitmap::try_load_from_file(path);
|
||||
if (maybe_bitmap.is_error()) {
|
||||
dbgln("Unable to load bitmap `{}` for label icon", path);
|
||||
return;
|
||||
}
|
||||
set_icon(maybe_bitmap.release_value());
|
||||
}
|
||||
|
||||
void Label::set_text(String text)
|
||||
{
|
||||
if (text == m_text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue