summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorkleines Filmröllchen <filmroellchen@serenityos.org>2022-03-24 15:56:09 +0100
committerAndreas Kling <kling@serenityos.org>2022-04-03 12:21:05 +0200
commit452bbcaa84b364cb76e99c46950ad2bedf0ca7be (patch)
tree3a164f2c6087087586e6b49db9f956ce4c4b1251 /Userland
parentee4cec4ea944b965ad8a0da799a404ce2675ff10 (diff)
downloadserenity-452bbcaa84b364cb76e99c46950ad2bedf0ca7be.zip
LibCore: Turn size properties from an object into a size 2 array
Previously, size properties were a JSON object of the form { "width": x, "height": y }. Now they are a JSON array [x, y]. Reasons for this change: - Much more concise. - More intuitive, as existing multi-dimensional properties (like margins) already use this array format.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibCore/Object.h36
1 files changed, 18 insertions, 18 deletions
diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h
index bad2ae50de..9faee795fc 100644
--- a/Userland/Libraries/LibCore/Object.h
+++ b/Userland/Libraries/LibCore/Object.h
@@ -318,24 +318,24 @@ T* Object::find_descendant_of_type_named(String const& name) requires IsBaseOf<O
return true; \
});
-#define REGISTER_SIZE_PROPERTY(property_name, getter, setter) \
- register_property( \
- property_name, \
- [this] { \
- auto size = this->getter(); \
- JsonObject size_object; \
- size_object.set("width", size.width()); \
- size_object.set("height", size.height()); \
- return size_object; \
- }, \
- [this](auto& value) { \
- if (!value.is_object()) \
- return false; \
- Gfx::IntSize size; \
- size.set_width(value.as_object().get("width").to_i32()); \
- size.set_height(value.as_object().get("height").to_i32()); \
- setter(size); \
- return true; \
+#define REGISTER_SIZE_PROPERTY(property_name, getter, setter) \
+ register_property( \
+ property_name, \
+ [this] { \
+ auto size = this->getter(); \
+ JsonArray size_array; \
+ size_array.append(size.width()); \
+ size_array.append(size.height()); \
+ return size_array; \
+ }, \
+ [this](auto& value) { \
+ if (!value.is_array()) \
+ return false; \
+ Gfx::IntSize size; \
+ size.set_width(value.as_array()[0].to_i32()); \
+ size.set_height(value.as_array()[1].to_i32()); \
+ setter(size); \
+ return true; \
});
#define REGISTER_ENUM_PROPERTY(property_name, getter, setter, EnumType, ...) \