mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 21:21:17 +01:00
Layout animation time bindable (#11264) c95fe9334e
Co-authored-by: Philip Chung <philterdesign@gmail.com>
This commit is contained in:
BIN
tests/unit_tests/assets/layout/layout_anim_bound.riv
Normal file
BIN
tests/unit_tests/assets/layout/layout_anim_bound.riv
Normal file
Binary file not shown.
@@ -517,4 +517,36 @@ TEST_CASE("Layout background & foreground shape paints.", "[silver]")
|
||||
}
|
||||
|
||||
CHECK(silver.matches("layout_paint"));
|
||||
}
|
||||
|
||||
TEST_CASE("Layout animation time databound", "[silver]")
|
||||
{
|
||||
rive::SerializingFactory silver;
|
||||
auto file = ReadRiveFile("assets/layout/layout_anim_bound.riv", &silver);
|
||||
|
||||
auto artboard = file->artboardDefault();
|
||||
|
||||
silver.frameSize(artboard->width(), artboard->height());
|
||||
|
||||
REQUIRE(artboard != nullptr);
|
||||
auto viewModelInstance =
|
||||
file->createDefaultViewModelInstance(artboard.get());
|
||||
REQUIRE(viewModelInstance != nullptr);
|
||||
artboard->bindViewModelInstance(viewModelInstance);
|
||||
auto stateMachine = artboard->stateMachineAt(0);
|
||||
|
||||
stateMachine->advanceAndApply(0.1f);
|
||||
|
||||
auto renderer = silver.makeRenderer();
|
||||
artboard->draw(renderer.get());
|
||||
|
||||
int frames = 32;
|
||||
for (int i = 0; i < frames; i++)
|
||||
{
|
||||
silver.addFrame();
|
||||
stateMachine->advanceAndApply(0.016f);
|
||||
artboard->draw(renderer.get());
|
||||
}
|
||||
|
||||
CHECK(silver.matches("layout_anim_bound"));
|
||||
}
|
||||
BIN
tests/unit_tests/silvers/layout_anim_bound.sriv
Normal file
BIN
tests/unit_tests/silvers/layout_anim_bound.sriv
Normal file
Binary file not shown.
Reference in New Issue
Block a user