mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +00:00
LibGUI: Make a macro for registering a GUI::Margins object property
This will allow anyone to register a margins property without having to duplicate the parsing logic.
This commit is contained in:
parent
f20c5e1872
commit
46a7e1b372
2 changed files with 22 additions and 20 deletions
|
@ -14,26 +14,7 @@ namespace GUI {
|
|||
Layout::Layout()
|
||||
{
|
||||
REGISTER_INT_PROPERTY("spacing", spacing, set_spacing);
|
||||
|
||||
register_property(
|
||||
"margins",
|
||||
[this] {
|
||||
JsonObject margins_object;
|
||||
margins_object.set("left", m_margins.left());
|
||||
margins_object.set("right", m_margins.right());
|
||||
margins_object.set("top", m_margins.top());
|
||||
margins_object.set("bottom", m_margins.bottom());
|
||||
return margins_object;
|
||||
},
|
||||
[this](auto value) {
|
||||
if (!value.is_array() || value.as_array().size() != 4)
|
||||
return false;
|
||||
int m[4];
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
m[i] = value.as_array().at(i).to_i32();
|
||||
set_margins({ m[0], m[1], m[2], m[3] });
|
||||
return true;
|
||||
});
|
||||
REGISTER_MARGINS_PROPERTY("margins", margins, set_margins);
|
||||
|
||||
register_property("entries",
|
||||
[this] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue