mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
LibGUI: Implement set_property() on Widget and AbstractButton
This makes it possible for an RPC client to modify some interesting widget properties.
This commit is contained in:
parent
42f2696355
commit
3edcaa9b99
4 changed files with 50 additions and 0 deletions
|
@ -206,4 +206,26 @@ void AbstractButton::save_to(JsonObject& json)
|
|||
Widget::save_to(json);
|
||||
}
|
||||
|
||||
bool AbstractButton::set_property(const StringView& name, const JsonValue& value)
|
||||
{
|
||||
if (name == "text") {
|
||||
set_text(value.to_string());
|
||||
return true;
|
||||
}
|
||||
if (name == "checked") {
|
||||
set_checked(value.to_bool());
|
||||
return true;
|
||||
}
|
||||
if (name == "checkable") {
|
||||
set_checkable(value.to_bool());
|
||||
return true;
|
||||
}
|
||||
if (name == "exclusive") {
|
||||
set_exclusive(value.to_bool());
|
||||
return true;
|
||||
}
|
||||
|
||||
return Widget::set_property(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ protected:
|
|||
virtual void change_event(Event&) override;
|
||||
|
||||
virtual void save_to(JsonObject&) override;
|
||||
virtual bool set_property(const StringView& name, const JsonValue& value) override;
|
||||
|
||||
void paint_text(Painter&, const Gfx::Rect&, const Gfx::Font&, Gfx::TextAlignment);
|
||||
|
||||
|
|
|
@ -739,6 +739,31 @@ void Widget::save_to(AK::JsonObject& json)
|
|||
Core::Object::save_to(json);
|
||||
}
|
||||
|
||||
bool Widget::set_property(const StringView& name, const JsonValue& value)
|
||||
{
|
||||
if (name == "fill_with_background_color") {
|
||||
set_fill_with_background_color(value.to_bool());
|
||||
return true;
|
||||
}
|
||||
if (name == "tooltip") {
|
||||
set_tooltip(value.to_string());
|
||||
return true;
|
||||
}
|
||||
if (name == "enable") {
|
||||
set_enabled(value.to_bool());
|
||||
return true;
|
||||
}
|
||||
if (name == "focused") {
|
||||
set_focus(value.to_bool());
|
||||
return true;
|
||||
}
|
||||
if (name == "visible") {
|
||||
set_visible(value.to_bool());
|
||||
return true;
|
||||
}
|
||||
return Core::Object::set_property(name, value);
|
||||
}
|
||||
|
||||
Vector<Widget*> Widget::child_widgets() const
|
||||
{
|
||||
Vector<Widget*> widgets;
|
||||
|
|
|
@ -296,6 +296,8 @@ protected:
|
|||
virtual void did_begin_inspection() override;
|
||||
virtual void did_end_inspection() override;
|
||||
|
||||
virtual bool set_property(const StringView& name, const JsonValue& value) override;
|
||||
|
||||
private:
|
||||
void handle_paint_event(PaintEvent&);
|
||||
void handle_resize_event(ResizeEvent&);
|
||||
|
|
Loading…
Add table
Reference in a new issue