mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 21:21:17 +01:00
# Description fix for joystick controlled timelines not updating the time # Details If a state machine has a timeline controlling a nested remapped animation through keyframes, and that timeline is itself controlled by a joystick our update cycle would not apply the time updated by the joystick because the advance cycle has passed. This PR looks for joystick controlled animations, and stores which objects are nested remapped animations to advance them while they are being applied. Diffs= 038bd34aee add support for joystick time based dependents (#9272) Co-authored-by: hernan <hernan@rive.app>
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
#ifndef _RIVE_JOYSTICK_HPP_
|
|
#define _RIVE_JOYSTICK_HPP_
|
|
#include "rive/generated/joystick_base.hpp"
|
|
#include "rive/intrinsically_sizeable.hpp"
|
|
#include "rive/joystick_flags.hpp"
|
|
#include "rive/animation/nested_remap_animation.hpp"
|
|
#include "rive/math/mat2d.hpp"
|
|
#include <stdio.h>
|
|
|
|
namespace rive
|
|
{
|
|
class Artboard;
|
|
class LinearAnimation;
|
|
class TransformComponent;
|
|
class Joystick : public JoystickBase, public IntrinsicallySizeable
|
|
{
|
|
public:
|
|
void update(ComponentDirt value) override;
|
|
void apply(Artboard* artboard) const;
|
|
StatusCode onAddedClean(CoreContext* context) override;
|
|
StatusCode onAddedDirty(CoreContext* context) override;
|
|
void xChanged() override;
|
|
void yChanged() override;
|
|
void posXChanged() override;
|
|
void posYChanged() override;
|
|
void widthChanged() override;
|
|
void heightChanged() override;
|
|
|
|
bool isJoystickFlagged(JoystickFlags flag) const
|
|
{
|
|
return ((JoystickFlags)joystickFlags()) & flag;
|
|
}
|
|
|
|
bool canApplyBeforeUpdate() const { return m_handleSource == nullptr; }
|
|
|
|
void addDependents(Artboard* artboard);
|
|
|
|
Vec2D measureLayout(float width,
|
|
LayoutMeasureMode widthMode,
|
|
float height,
|
|
LayoutMeasureMode heightMode) override;
|
|
void controlSize(Vec2D size,
|
|
LayoutScaleType widthScaleType,
|
|
LayoutScaleType heightScaleType,
|
|
LayoutDirection direction) override;
|
|
bool shouldPropagateSizeToChildren() override { return false; }
|
|
|
|
protected:
|
|
void buildDependencies() override;
|
|
|
|
private:
|
|
Mat2D m_worldTransform;
|
|
Mat2D m_inverseWorldTransform;
|
|
LinearAnimation* m_xAnimation = nullptr;
|
|
LinearAnimation* m_yAnimation = nullptr;
|
|
TransformComponent* m_handleSource = nullptr;
|
|
std::vector<NestedRemapAnimation*> m_dependents;
|
|
|
|
void addAnimationDependents(Artboard* artboard, LinearAnimation* animation);
|
|
};
|
|
} // namespace rive
|
|
|
|
#endif
|