mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 13:11:19 +01:00
fix: trigger change on solid color change (#11399) b5a73917b1
Co-authored-by: hernan <hernan@rive.app>
This commit is contained in:
@@ -1 +1 @@
|
||||
0488666fb001738ea7ceeca04038932feed69973
|
||||
b5a73917b1822c022c03e17aac08d482cdeaa23d
|
||||
|
||||
@@ -241,6 +241,7 @@ public:
|
||||
void addToRenderPath(RenderPath* path, const Mat2D& transform);
|
||||
void addToRawPath(RawPath& path, const Mat2D* transform);
|
||||
|
||||
void changed();
|
||||
#ifdef TESTING
|
||||
ShapePaintPath* clipPath() { return &m_worldPath; }
|
||||
ShapePaintPath* backgroundPath() { return &m_localPath; }
|
||||
|
||||
@@ -1913,6 +1913,18 @@ bool Artboard::isAncestor(const Artboard* artboard)
|
||||
return false;
|
||||
}
|
||||
|
||||
void Artboard::changed()
|
||||
{
|
||||
if (!m_didChange)
|
||||
{
|
||||
m_didChange = true;
|
||||
if (parentArtboard())
|
||||
{
|
||||
parentArtboard()->changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////// ArtboardInstance
|
||||
|
||||
#include "rive/animation/linear_animation_instance.hpp"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "rive/container_component.hpp"
|
||||
#include "rive/renderer.hpp"
|
||||
#include "rive/shapes/paint/color.hpp"
|
||||
#include "rive/artboard.hpp"
|
||||
|
||||
using namespace rive;
|
||||
|
||||
@@ -38,6 +39,10 @@ void SolidColor::renderOpacityChanged()
|
||||
{
|
||||
m_flags |= ShapePaintMutator::Flags::translucent;
|
||||
}
|
||||
if (artboard())
|
||||
{
|
||||
artboard()->changed();
|
||||
}
|
||||
}
|
||||
|
||||
void SolidColor::applyTo(RenderPaint* renderPaint, float opacityModifier)
|
||||
|
||||
BIN
tests/unit_tests/assets/solid_affects_has_changed.riv
Normal file
BIN
tests/unit_tests/assets/solid_affects_has_changed.riv
Normal file
Binary file not shown.
37
tests/unit_tests/runtime/render_test.cpp
Normal file
37
tests/unit_tests/runtime/render_test.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "rive/file.hpp"
|
||||
#include "rive/animation/state_machine_instance.hpp"
|
||||
#include "rive/viewmodel/viewmodel.hpp"
|
||||
#include "utils/serializing_factory.hpp"
|
||||
#include "rive_file_reader.hpp"
|
||||
#include "utils/no_op_renderer.hpp"
|
||||
#include <catch.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
using namespace rive;
|
||||
|
||||
TEST_CASE("file with only solid color animating triggers change on artboard",
|
||||
"[silver]")
|
||||
{
|
||||
auto file = ReadRiveFile("assets/solid_affects_has_changed.riv");
|
||||
|
||||
auto artboard = file->artboardDefault();
|
||||
NoOpRenderer renderer;
|
||||
|
||||
REQUIRE(artboard != nullptr);
|
||||
auto stateMachine = artboard->stateMachineAt(0);
|
||||
|
||||
auto vmi = file->createViewModelInstance(artboard.get());
|
||||
|
||||
stateMachine->bindViewModelInstance(vmi);
|
||||
stateMachine->advanceAndApply(0.1f);
|
||||
artboard->draw(&renderer);
|
||||
|
||||
int frames = 10;
|
||||
for (int i = 0; i < frames; i++)
|
||||
{
|
||||
stateMachine->advanceAndApply(0.1f);
|
||||
REQUIRE(artboard->didChange() == true);
|
||||
artboard->draw(&renderer);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user