Fix for bug in Runtime LayoutComponent proxy This bug caused layout proxies to be drawn out of order causing layout rendering issues in the runtimes. Diffs= 85343a4e1 Fix for bug in Runtime LayoutComponent proxy (#7867) Co-authored-by: Philip Chung <philterdesign@gmail.com>
diff --git a/.rive_head b/.rive_head index 7e901c4..b68cbc7 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -93cc33b45086e528b22d1245a8f7855bac299a21 +85343a4e1c287922f872d14172167af72b4c3358
diff --git a/include/rive/drawable.hpp b/include/rive/drawable.hpp index b4e79b8..28220df 100644 --- a/include/rive/drawable.hpp +++ b/include/rive/drawable.hpp
@@ -12,6 +12,7 @@ class ClippingShape; class Artboard; class DrawRules; +class LayoutComponent; class Drawable : public DrawableBase { @@ -47,6 +48,8 @@ DrawableFlag::Opaque; } + bool isChildOfLayout(LayoutComponent* layout); + StatusCode onAddedDirty(CoreContext* context) override; };
diff --git a/src/artboard.cpp b/src/artboard.cpp index b0576d9..b153350 100644 --- a/src/artboard.cpp +++ b/src/artboard.cpp
@@ -247,20 +247,12 @@ for (int i = 0; i < m_Drawables.size(); i++) { auto drawable = m_Drawables[i]; - LayoutComponent* currentLayout; + LayoutComponent* currentLayout = nullptr; bool isInCurrentLayout = true; if (!layouts.empty()) { currentLayout = layouts.back(); - isInCurrentLayout = false; - } - for (ContainerComponent* parent = drawable; parent != nullptr; parent = parent->parent()) - { - if (parent == currentLayout) - { - isInCurrentLayout = true; - break; - } + isInCurrentLayout = drawable->isChildOfLayout(currentLayout); } // We inject a DrawableProxy after all of the children of a LayoutComponent // so that we can draw a stroke above and background below the children @@ -269,9 +261,16 @@ { // This is the first item in the list of drawables that isn't a child // of the layout, so we insert a proxy before it - m_Drawables.insert(m_Drawables.begin() + i, currentLayout->proxy()); - layouts.pop_back(); - i += 1; + do + { + m_Drawables.insert(m_Drawables.begin() + i, currentLayout->proxy()); + layouts.pop_back(); + if (!layouts.empty()) + { + currentLayout = layouts.back(); + } + i += 1; + } while (!layouts.empty() && !drawable->isChildOfLayout(currentLayout)); } if (drawable->is<LayoutComponent>()) {
diff --git a/src/drawable.cpp b/src/drawable.cpp index 522bd5f..0dc9ca0 100644 --- a/src/drawable.cpp +++ b/src/drawable.cpp
@@ -1,5 +1,6 @@ #include "rive/drawable.hpp" #include "rive/artboard.hpp" +#include "rive/layout_component.hpp" #include "rive/shapes/clipping_shape.hpp" #include "rive/shapes/path_composer.hpp" #include "rive/shapes/shape.hpp" @@ -70,4 +71,16 @@ } } return ClipResult::clip; +} + +bool Drawable::isChildOfLayout(LayoutComponent* layout) +{ + for (ContainerComponent* parent = this; parent != nullptr; parent = parent->parent()) + { + if (parent->is<LayoutComponent>() && parent->as<LayoutComponent>() == layout) + { + return true; + } + } + return false; } \ No newline at end of file