mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-18 23:42:17 +00:00
GMLCompiler+LibGUI: Add support for object properties and undo hack
Previously the GML compiler did not support object properties such as `content_widget: @GUI::Widget{}` for GUI::ScrollableContainerWidget; this commit adds support for such properties by simply calling `set_<key>(<TProperty>&)` on the object. This commit also removes the previous hack where ScrollableContainerWidget was special-cased to have its singular child used as the content widget; the only GML file using this behaviour was also changed to be in line with 'proper' GML as handled by the GML Playground.
This commit is contained in:
parent
5c17b61378
commit
f3a4118aee
Notes:
sideshowbarker
2024-07-16 22:24:48 +09:00
Author: https://github.com/alimpfard
Commit: f3a4118aee
Pull-request: https://github.com/SerenityOS/serenity/pull/24098
Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 55 additions and 5 deletions
|
@ -188,6 +188,18 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_object_property(Callback callback) const
|
||||
{
|
||||
for (auto const& child : m_properties) {
|
||||
if (is<KeyValuePair>(child)) {
|
||||
auto const& property = static_cast<KeyValuePair const&>(*child);
|
||||
if (is<Object>(property.value().ptr()))
|
||||
callback(property.key(), static_ptr_cast<Object>(property.value()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<FallibleFunction<StringView, NonnullRefPtr<JsonValueNode>> Callback>
|
||||
ErrorOr<void> try_for_each_property(Callback callback) const
|
||||
{
|
||||
|
@ -201,6 +213,19 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
template<FallibleFunction<StringView, NonnullRefPtr<Object>> Callback>
|
||||
ErrorOr<void> try_for_each_object_property(Callback callback) const
|
||||
{
|
||||
for (auto const& child : m_properties) {
|
||||
if (is<KeyValuePair>(child)) {
|
||||
auto const& property = static_cast<KeyValuePair const&>(*child);
|
||||
if (is<Object>(property.value().ptr()))
|
||||
TRY(callback(property.key(), static_ptr_cast<Object>(property.value())));
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_child_object(Callback callback) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue