1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:27:46 +00:00

VisualBuilder: Let's have getters and setters for properties.

This commit is contained in:
Andreas Kling 2019-04-14 04:14:23 +02:00
parent 6dc9a6ef42
commit f1b58d8d8c
3 changed files with 24 additions and 3 deletions

View file

@ -76,11 +76,15 @@ static GWidget* build_gwidget(VBWidgetType type, GWidget* parent)
GWidget* VBWidgetRegistry::build_gwidget(VBWidgetType type, GWidget* parent, Vector<OwnPtr<VBProperty>>& properties)
{
auto* gwidget = ::build_gwidget(type, parent);
auto add_property = [&properties] (const String& name, const GVariant& value = { }, bool is_readonly = false) {
auto add_readonly_property = [&properties] (const String& name, const GVariant& value) {
auto property = make<VBProperty>(name, value);
property->set_readonly(is_readonly);
property->set_readonly(true);
properties.append(move(property));
};
add_property("class", to_class_name(type), true);
auto add_property = [&properties] (const String& name, Function<GVariant(const GWidget&)>&& getter, Function<void(GWidget&, const GVariant&)>&& setter) {
auto property = make<VBProperty>(name, move(getter), move(setter));
properties.append(move(property));
};
add_readonly_property("class", to_class_name(type));
return gwidget;
}