add artboards shapes to updates when RenderOpacity has dirt Fixes nested artboards not applying inherited opacity to their backgrounds Issue #5887 Diffs= 0dcbdade4 add artboards shapes to updates when RenderOpacity has dirt (#5971) Co-authored-by: hernan <hernantorrisi@gmail.com>
diff --git a/.rive_head b/.rive_head index b5177a6..ea5fdcd 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -85b2b6ed1965d66f5f268993e54f5f89f30a2e29 +0dcbdade49885fcae4de304972ae37f6283f19d1
diff --git a/include/rive/shapes/shape_paint_container.hpp b/include/rive/shapes/shape_paint_container.hpp index f5200fa..ceccbf4 100644 --- a/include/rive/shapes/shape_paint_container.hpp +++ b/include/rive/shapes/shape_paint_container.hpp
@@ -38,6 +38,10 @@ std::unique_ptr<CommandPath> makeCommandPath(PathSpace space); void propagateOpacity(float opacity); + + #ifdef TESTING + const std::vector<ShapePaint*>& shapePaints() const { return m_ShapePaints; } + #endif }; } // namespace rive
diff --git a/src/artboard.cpp b/src/artboard.cpp index 4f09ab0..8b37215 100644 --- a/src/artboard.cpp +++ b/src/artboard.cpp
@@ -427,6 +427,10 @@ m_ClipPath = factory()->makeRenderPath(clip); m_BackgroundPath = factory()->makeRenderPath(bg); } + if (hasDirt(value, ComponentDirt::RenderOpacity)) + { + propagateOpacity(childOpacity()); + } } bool Artboard::updateComponents()
diff --git a/test/assets/nested_artboard_opacity.riv b/test/assets/nested_artboard_opacity.riv new file mode 100644 index 0000000..128cc95 --- /dev/null +++ b/test/assets/nested_artboard_opacity.riv Binary files differ
diff --git a/test/nested_artboard_opacity_test.cpp b/test/nested_artboard_opacity_test.cpp new file mode 100644 index 0000000..e3c2b73 --- /dev/null +++ b/test/nested_artboard_opacity_test.cpp
@@ -0,0 +1,26 @@ +#include <rive/file.hpp> +#include <rive/node.hpp> +#include <rive/nested_artboard.hpp> +#include <rive/shapes/paint/shape_paint.hpp> +#include "rive_file_reader.hpp" + +TEST_CASE("Nested artboard background renders with opacity", "[file]") +{ + auto file = ReadRiveFile("../../test/assets/nested_artboard_opacity.riv"); + + auto mainArtboard = file->artboard()->instance(); + REQUIRE(mainArtboard->find("Parent Artboard") != nullptr); + auto artboard = mainArtboard->find<rive::Artboard>("Parent Artboard"); + artboard->updateComponents(); + REQUIRE(artboard->is<rive::Artboard>()); + REQUIRE(artboard->find("Nested artboard container") != nullptr); + auto nestedArtboardContainer = artboard->find<rive::NestedArtboard>("Nested artboard container"); + REQUIRE(nestedArtboardContainer->artboard() != nullptr); + auto nestedArtboard = nestedArtboardContainer->artboard(); + nestedArtboard->updateComponents(); + auto paints = nestedArtboard->shapePaints(); + REQUIRE(paints.size() == 1); + auto paint = paints[0]; + REQUIRE(paint->is<rive::ShapePaint>()); + REQUIRE(paint->renderOpacity() == 0.3275f); +}