1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +00:00

LibCore: Make Core::Object properties more dynamic

Instead of everyone overriding save_to() and set_property() and doing
a pretty asymmetric job of implementing the various properties, let's
add a bit of structure here.

Object properties are now represented by a Core::Property. Properties
are registered with a getter and setter (optional) in constructors.
I've added some convenience macros for creating and registering
properties, but this does still feel a bit bulky. We'll have to
iterate on this and see where it goes.
This commit is contained in:
Andreas Kling 2020-09-15 21:33:37 +02:00
parent 1e96e46a81
commit e2f32b8f9d
23 changed files with 373 additions and 250 deletions

View file

@ -76,6 +76,7 @@ public:
void set_text_alignment(Gfx::TextAlignment alignment) { m_text_alignment = alignment; }
Gfx::TextAlignment text_alignment() const { return m_text_alignment; }
bool uniform_tabs() const { return m_uniform_tabs; }
void set_uniform_tabs(bool uniform_tabs) { m_uniform_tabs = uniform_tabs; }
int uniform_tab_width() const;
@ -86,8 +87,6 @@ public:
Function<void(Widget&)> on_middle_click;
Function<void(Widget&, const ContextMenuEvent&)> on_context_menu_request;
virtual bool set_property(const StringView& name, const JsonValue& value) override;
protected:
TabWidget();