Propagate layout's display to children in runtime
This fixes a bug noticed at runtime where toggling layout display on/off would not respect its children's display values if they were different than the parent. We need to make sure to consider the layout's display value when calling collapse() on its children. The dart implementation works as expected.
Diffs=
24d9162103 Propagate layout's display to children in runtime (#8908)
Co-authored-by: Philip Chung <philterdesign@gmail.com>
diff --git a/.rive_head b/.rive_head
index 6dd81aa..62d82cc 100644
--- a/.rive_head
+++ b/.rive_head
@@ -1 +1 @@
-90da85fbb4151a7a4a1c30cf2f6738929debe925
+24d9162103a73712ba3c80cfc909fee6948a0089
diff --git a/include/rive/layout_component.hpp b/include/rive/layout_component.hpp
index 34b6874..843a4c1 100644
--- a/include/rive/layout_component.hpp
+++ b/include/rive/layout_component.hpp
@@ -136,6 +136,7 @@
}
bool isDisplayHidden() const;
void propagateCollapse(bool collapse);
+ bool collapse(bool value) override;
private:
float m_widthOverride = NAN;
diff --git a/src/layout_component.cpp b/src/layout_component.cpp
index 381d317..ffe2d4e 100644
--- a/src/layout_component.cpp
+++ b/src/layout_component.cpp
@@ -206,6 +206,19 @@
}
}
+bool LayoutComponent::collapse(bool value)
+{
+ if (!Component::collapse(value))
+ {
+ return false;
+ }
+ for (Component* child : children())
+ {
+ child->collapse(value || isDisplayHidden());
+ }
+ return true;
+}
+
#ifdef WITH_RIVE_LAYOUT
LayoutComponent::LayoutComponent() :