Skip to content

Commit

Permalink
Propagate layout's display to children in runtime
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
philter and philter committed Jan 22, 2025
1 parent 11e9c65 commit 26dd69f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
90da85fbb4151a7a4a1c30cf2f6738929debe925
24d9162103a73712ba3c80cfc909fee6948a0089
1 change: 1 addition & 0 deletions include/rive/layout_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class LayoutComponent : public LayoutComponentBase,
}
bool isDisplayHidden() const;
void propagateCollapse(bool collapse);
bool collapse(bool value) override;

private:
float m_widthOverride = NAN;
Expand Down
13 changes: 13 additions & 0 deletions src/layout_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@ void LayoutComponent::propagateCollapse(bool collapse)
}
}

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() :
Expand Down

0 comments on commit 26dd69f

Please sign in to comment.