Rename event->listener and update defs.
diff --git a/dev/defs/animation/event_bool_change.json b/dev/defs/animation/event_bool_change.json
deleted file mode 100644
index 7a67cd7..0000000
--- a/dev/defs/animation/event_bool_change.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "EventBoolChange",
- "key": {
- "int": 117,
- "string": "event_bool_change"
- },
- "extends": "animation/event_input_change.json",
- "properties": {
- "value": {
- "type": "uint",
- "initialValue": "1",
- "key": {
- "int": 228,
- "string": "value"
- },
- "description": "Value to set the input to when the event occurs."
- }
- }
-}
\ No newline at end of file
diff --git a/dev/defs/animation/event_number_change.json b/dev/defs/animation/event_number_change.json
deleted file mode 100644
index cc96e0a..0000000
--- a/dev/defs/animation/event_number_change.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "EventNumberChange",
- "key": {
- "int": 118,
- "string": "event_number_change"
- },
- "extends": "animation/event_input_change.json",
- "properties": {
- "value": {
- "type": "double",
- "initialValue": "0",
- "key": {
- "int": 229,
- "string": "value"
- },
- "description": "Value to set the input to when the event occurs."
- }
- }
-}
\ No newline at end of file
diff --git a/dev/defs/animation/event_trigger_change.json b/dev/defs/animation/event_trigger_change.json
deleted file mode 100644
index 9aa6e0d..0000000
--- a/dev/defs/animation/event_trigger_change.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "EventTriggerChange",
- "key": {
- "int": 115,
- "string": "event_trigger_change"
- },
- "extends": "animation/event_input_change.json"
-}
\ No newline at end of file
diff --git a/dev/defs/animation/listener_bool_change.json b/dev/defs/animation/listener_bool_change.json
new file mode 100644
index 0000000..54b5ca0
--- /dev/null
+++ b/dev/defs/animation/listener_bool_change.json
@@ -0,0 +1,19 @@
+{
+ "name": "ListenerBoolChange",
+ "key": {
+ "int": 117,
+ "string": "listener_bool_change"
+ },
+ "extends": "animation/listener_input_change.json",
+ "properties": {
+ "value": {
+ "type": "uint",
+ "initialValue": "1",
+ "key": {
+ "int": 228,
+ "string": "value"
+ },
+ "description": "Value to set the input to when the listener occurs."
+ }
+ }
+}
\ No newline at end of file
diff --git a/dev/defs/animation/event_input_change.json b/dev/defs/animation/listener_input_change.json
similarity index 79%
rename from dev/defs/animation/event_input_change.json
rename to dev/defs/animation/listener_input_change.json
index 5dc1811..df4cd3b 100644
--- a/dev/defs/animation/event_input_change.json
+++ b/dev/defs/animation/listener_input_change.json
@@ -1,21 +1,21 @@
{
- "name": "EventInputChange",
+ "name": "ListenerInputChange",
"key": {
"int": 116,
- "string": "event_input_change"
+ "string": "listener_input_change"
},
"abstract": true,
"properties": {
- "eventId": {
+ "listenerId": {
"type": "Id",
"typeRuntime": "uint",
"initialValue": "Core.missingId",
"initialValueRuntime": "0",
"key": {
"int": 226,
- "string": "eventid"
+ "string": "listenerId"
},
- "description": "Identifier used to track the StateMachineEvent this result belongs to.",
+ "description": "Identifier used to track the StateMachineListener this result belongs to.",
"runtime": false
},
"inputId": {
diff --git a/dev/defs/animation/listener_number_change.json b/dev/defs/animation/listener_number_change.json
new file mode 100644
index 0000000..f980b3a
--- /dev/null
+++ b/dev/defs/animation/listener_number_change.json
@@ -0,0 +1,19 @@
+{
+ "name": "ListenerNumberChange",
+ "key": {
+ "int": 118,
+ "string": "listener_number_change"
+ },
+ "extends": "animation/listener_input_change.json",
+ "properties": {
+ "value": {
+ "type": "double",
+ "initialValue": "0",
+ "key": {
+ "int": 229,
+ "string": "value"
+ },
+ "description": "Value to set the input to when the listener occurs."
+ }
+ }
+}
\ No newline at end of file
diff --git a/dev/defs/animation/listener_trigger_change.json b/dev/defs/animation/listener_trigger_change.json
new file mode 100644
index 0000000..d3d0759
--- /dev/null
+++ b/dev/defs/animation/listener_trigger_change.json
@@ -0,0 +1,8 @@
+{
+ "name": "ListenerTriggerChange",
+ "key": {
+ "int": 115,
+ "string": "listener_trigger_change"
+ },
+ "extends": "animation/listener_input_change.json"
+}
\ No newline at end of file
diff --git a/dev/defs/animation/nested_state_machine.json b/dev/defs/animation/nested_state_machine.json
index 5b69e0a..1982515 100644
--- a/dev/defs/animation/nested_state_machine.json
+++ b/dev/defs/animation/nested_state_machine.json
@@ -2,7 +2,7 @@
"name": "NestedStateMachine",
"key": {
"int": 95,
- "string": "nestedstatemachine"
+ "string": "nestedStateMachine"
},
"extends": "nested_animation.json",
"generic": "animation/state_machine.json"
diff --git a/dev/defs/animation/state_machine.json b/dev/defs/animation/state_machine.json
index c28736f..c73a1cc 100644
--- a/dev/defs/animation/state_machine.json
+++ b/dev/defs/animation/state_machine.json
@@ -6,17 +6,6 @@
},
"extends": "animation/animation.json",
"properties": {
- "editingListValue": {
- "type": "uint",
- "initialValue": "0",
- "key": {
- "int": 136,
- "string": "editinglistvalue"
- },
- "description": "Backing value for enum representing which list being edited.",
- "runtime": false,
- "coop": false
- },
"editingLayerId": {
"type": "Id",
"initialValue": "Core.missingId",
diff --git a/dev/defs/animation/state_machine_event.json b/dev/defs/animation/state_machine_listener.json
similarity index 68%
rename from dev/defs/animation/state_machine_event.json
rename to dev/defs/animation/state_machine_listener.json
index 64a8ffe..12a6892 100644
--- a/dev/defs/animation/state_machine_event.json
+++ b/dev/defs/animation/state_machine_listener.json
@@ -1,8 +1,8 @@
{
- "name": "StateMachineEvent",
+ "name": "StateMachineListener",
"key": {
"int": 114,
- "string": "statemachineevent"
+ "string": "stateMachineListener"
},
"extends": "animation/state_machine_component.json",
"properties": {
@@ -15,16 +15,16 @@
"int": 224,
"string": "targetid"
},
- "description": "Identifier used to track the object use as a target fo this event."
+ "description": "Identifier used to track the object use as a target fo this listener."
},
- "eventTypeValue": {
+ "listenerTypeValue": {
"type": "uint",
"initialValue": "0",
"key": {
"int": 225,
- "string": "eventtypevalue"
+ "string": "listenertypevalue"
},
- "description": "Event type (hover, click, etc)."
+ "description": "Listener type (hover, click, etc)."
}
}
}
\ No newline at end of file
diff --git a/include/rive/animation/event_bool_change.hpp b/include/rive/animation/event_bool_change.hpp
deleted file mode 100644
index 61f79a2..0000000
--- a/include/rive/animation/event_bool_change.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef _RIVE_EVENT_BOOL_CHANGE_HPP_
-#define _RIVE_EVENT_BOOL_CHANGE_HPP_
-#include "rive/generated/animation/event_bool_change_base.hpp"
-
-namespace rive {
- class EventBoolChange : public EventBoolChangeBase {
- public:
- bool validateInputType(const StateMachineInput* input) const override;
- void perform(StateMachineInstance* stateMachineInstance) const override;
- };
-} // namespace rive
-
-#endif
\ No newline at end of file
diff --git a/include/rive/animation/event_number_change.hpp b/include/rive/animation/event_number_change.hpp
deleted file mode 100644
index 6e123d0..0000000
--- a/include/rive/animation/event_number_change.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef _RIVE_EVENT_NUMBER_CHANGE_HPP_
-#define _RIVE_EVENT_NUMBER_CHANGE_HPP_
-#include "rive/generated/animation/event_number_change_base.hpp"
-
-namespace rive {
- class EventNumberChange : public EventNumberChangeBase {
- public:
- bool validateInputType(const StateMachineInput* input) const override;
- void perform(StateMachineInstance* stateMachineInstance) const override;
- };
-} // namespace rive
-
-#endif
\ No newline at end of file
diff --git a/include/rive/animation/event_trigger_change.hpp b/include/rive/animation/event_trigger_change.hpp
deleted file mode 100644
index 20200b5..0000000
--- a/include/rive/animation/event_trigger_change.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef _RIVE_EVENT_TRIGGER_CHANGE_HPP_
-#define _RIVE_EVENT_TRIGGER_CHANGE_HPP_
-#include "rive/generated/animation/event_trigger_change_base.hpp"
-
-namespace rive {
- class EventTriggerChange : public EventTriggerChangeBase {
- public:
- bool validateInputType(const StateMachineInput* input) const override;
- void perform(StateMachineInstance* stateMachineInstance) const override;
- };
-} // namespace rive
-
-#endif
\ No newline at end of file
diff --git a/include/rive/animation/listener_bool_change.hpp b/include/rive/animation/listener_bool_change.hpp
new file mode 100644
index 0000000..2bc6efb
--- /dev/null
+++ b/include/rive/animation/listener_bool_change.hpp
@@ -0,0 +1,13 @@
+#ifndef _RIVE_LISTENER_BOOL_CHANGE_HPP_
+#define _RIVE_LISTENER_BOOL_CHANGE_HPP_
+#include "rive/generated/animation/listener_bool_change_base.hpp"
+
+namespace rive {
+ class ListenerBoolChange : public ListenerBoolChangeBase {
+ public:
+ bool validateInputType(const StateMachineInput* input) const override;
+ void perform(StateMachineInstance* stateMachineInstance) const override;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
diff --git a/include/rive/animation/event_input_change.hpp b/include/rive/animation/listener_input_change.hpp
similarity index 63%
rename from include/rive/animation/event_input_change.hpp
rename to include/rive/animation/listener_input_change.hpp
index b3ae0ce..c7ccc04 100644
--- a/include/rive/animation/event_input_change.hpp
+++ b/include/rive/animation/listener_input_change.hpp
@@ -1,11 +1,11 @@
-#ifndef _RIVE_EVENT_INPUT_CHANGE_HPP_
-#define _RIVE_EVENT_INPUT_CHANGE_HPP_
-#include "rive/generated/animation/event_input_change_base.hpp"
+#ifndef _RIVE_LISTENER_INPUT_CHANGE_HPP_
+#define _RIVE_LISTENER_INPUT_CHANGE_HPP_
+#include "rive/generated/animation/listener_input_change_base.hpp"
namespace rive {
class StateMachineInstance;
class StateMachineInput;
- class EventInputChange : public EventInputChangeBase {
+ class ListenerInputChange : public ListenerInputChangeBase {
public:
StatusCode import(ImportStack& importStack) override;
virtual void perform(StateMachineInstance* stateMachineInstance) const = 0;
diff --git a/include/rive/animation/listener_number_change.hpp b/include/rive/animation/listener_number_change.hpp
new file mode 100644
index 0000000..a20c911
--- /dev/null
+++ b/include/rive/animation/listener_number_change.hpp
@@ -0,0 +1,13 @@
+#ifndef _RIVE_LISTENER_NUMBER_CHANGE_HPP_
+#define _RIVE_LISTENER_NUMBER_CHANGE_HPP_
+#include "rive/generated/animation/listener_number_change_base.hpp"
+
+namespace rive {
+ class ListenerNumberChange : public ListenerNumberChangeBase {
+ public:
+ bool validateInputType(const StateMachineInput* input) const override;
+ void perform(StateMachineInstance* stateMachineInstance) const override;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
diff --git a/include/rive/animation/listener_trigger_change.hpp b/include/rive/animation/listener_trigger_change.hpp
new file mode 100644
index 0000000..ab89e1f
--- /dev/null
+++ b/include/rive/animation/listener_trigger_change.hpp
@@ -0,0 +1,13 @@
+#ifndef _RIVE_LISTENER_TRIGGER_CHANGE_HPP_
+#define _RIVE_LISTENER_TRIGGER_CHANGE_HPP_
+#include "rive/generated/animation/listener_trigger_change_base.hpp"
+
+namespace rive {
+ class ListenerTriggerChange : public ListenerTriggerChangeBase {
+ public:
+ bool validateInputType(const StateMachineInput* input) const override;
+ void perform(StateMachineInstance* stateMachineInstance) const override;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
diff --git a/include/rive/animation/state_machine.hpp b/include/rive/animation/state_machine.hpp
index c711878..ca6b5eb 100644
--- a/include/rive/animation/state_machine.hpp
+++ b/include/rive/animation/state_machine.hpp
@@ -7,7 +7,7 @@
namespace rive {
class StateMachineLayer;
class StateMachineInput;
- class StateMachineEvent;
+ class StateMachineListener;
class StateMachineImporter;
class StateMachine : public StateMachineBase {
friend class StateMachineImporter;
@@ -15,11 +15,11 @@
private:
std::vector<std::unique_ptr<StateMachineLayer>> m_Layers;
std::vector<std::unique_ptr<StateMachineInput>> m_Inputs;
- std::vector<std::unique_ptr<StateMachineEvent>> m_Events;
+ std::vector<std::unique_ptr<StateMachineListener>> m_Listeners;
void addLayer(std::unique_ptr<StateMachineLayer>);
void addInput(std::unique_ptr<StateMachineInput>);
- void addEvent(std::unique_ptr<StateMachineEvent>);
+ void addListener(std::unique_ptr<StateMachineListener>);
public:
StateMachine();
@@ -29,13 +29,13 @@
size_t layerCount() const { return m_Layers.size(); }
size_t inputCount() const { return m_Inputs.size(); }
- size_t eventCount() const { return m_Events.size(); }
+ size_t listenerCount() const { return m_Listeners.size(); }
const StateMachineInput* input(std::string name) const;
const StateMachineInput* input(size_t index) const;
const StateMachineLayer* layer(std::string name) const;
const StateMachineLayer* layer(size_t index) const;
- const StateMachineEvent* event(size_t index) const;
+ const StateMachineListener* listener(size_t index) const;
StatusCode onAddedDirty(CoreContext* context) override;
StatusCode onAddedClean(CoreContext* context) override;
diff --git a/include/rive/animation/state_machine_event.hpp b/include/rive/animation/state_machine_event.hpp
deleted file mode 100644
index ea6cb5a..0000000
--- a/include/rive/animation/state_machine_event.hpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef _RIVE_STATE_MACHINE_EVENT_HPP_
-#define _RIVE_STATE_MACHINE_EVENT_HPP_
-#include "rive/generated/animation/state_machine_event_base.hpp"
-#include "rive/event_type.hpp"
-
-namespace rive {
- class Shape;
- class StateMachineEventImporter;
- class EventInputChange;
- class StateMachineInstance;
- class StateMachineEvent : public StateMachineEventBase {
- friend class StateMachineEventImporter;
-
- private:
- std::vector<uint32_t> m_HitShapesIds;
- std::vector<EventInputChange*> m_InputChanges;
- void addInputChange(EventInputChange* inputChange);
-
- public:
- EventType eventType() const { return (EventType)eventTypeValue(); }
- size_t inputChangeCount() const { return m_InputChanges.size(); }
- const EventInputChange* inputChange(size_t index) const;
- StatusCode import(ImportStack& importStack) override;
- StatusCode onAddedClean(CoreContext* context) override;
-
- const std::vector<uint32_t>& hitShapeIds() const { return m_HitShapesIds; }
- void performChanges(StateMachineInstance* stateMachineInstance) const;
- };
-} // namespace rive
-
-#endif
\ No newline at end of file
diff --git a/include/rive/animation/state_machine_instance.hpp b/include/rive/animation/state_machine_instance.hpp
index 5b05aa6..fa8fe6f 100644
--- a/include/rive/animation/state_machine_instance.hpp
+++ b/include/rive/animation/state_machine_instance.hpp
@@ -5,7 +5,7 @@
#include <stddef.h>
#include <vector>
#include "rive/animation/linear_animation_instance.hpp"
-#include "rive/event_type.hpp"
+#include "rive/listener_type.hpp"
#include "rive/scene.hpp"
namespace rive {
@@ -37,8 +37,9 @@
std::vector<std::unique_ptr<HitShape>> m_HitShapes;
std::vector<NestedArtboard*> m_HitNestedArtboards;
- /// Provide a hitEvent if you want to process a down or an up for the pointer position too.
- void processEvent(Vec2D position, EventType hitEvent = EventType::updateHover);
+ /// Provide a hitListener if you want to process a down or an up for the pointer position
+ /// too.
+ void updateListeners(Vec2D position, ListenerType hitListener = ListenerType::updateHover);
template <typename SMType, typename InstType>
InstType* getNamedInput(const std::string& name) const;
diff --git a/include/rive/animation/state_machine_listener.hpp b/include/rive/animation/state_machine_listener.hpp
new file mode 100644
index 0000000..14bd60b
--- /dev/null
+++ b/include/rive/animation/state_machine_listener.hpp
@@ -0,0 +1,31 @@
+#ifndef _RIVE_STATE_MACHINE_LISTENER_HPP_
+#define _RIVE_STATE_MACHINE_LISTENER_HPP_
+#include "rive/generated/animation/state_machine_listener_base.hpp"
+#include "rive/listener_type.hpp"
+
+namespace rive {
+ class Shape;
+ class StateMachineListenerImporter;
+ class ListenerInputChange;
+ class StateMachineInstance;
+ class StateMachineListener : public StateMachineListenerBase {
+ friend class StateMachineListenerImporter;
+
+ private:
+ std::vector<uint32_t> m_HitShapesIds;
+ std::vector<ListenerInputChange*> m_InputChanges;
+ void addInputChange(ListenerInputChange* inputChange);
+
+ public:
+ ListenerType listenerType() const { return (ListenerType)listenerTypeValue(); }
+ size_t inputChangeCount() const { return m_InputChanges.size(); }
+ const ListenerInputChange* inputChange(size_t index) const;
+ StatusCode import(ImportStack& importStack) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+
+ const std::vector<uint32_t>& hitShapeIds() const { return m_HitShapesIds; }
+ void performChanges(StateMachineInstance* stateMachineInstance) const;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
diff --git a/include/rive/event_type.hpp b/include/rive/event_type.hpp
deleted file mode 100644
index deb1cea..0000000
--- a/include/rive/event_type.hpp
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _RIVE_EVENT_TYPE_HPP_
-#define _RIVE_EVENT_TYPE_HPP_
-namespace rive {
- enum class EventType : int {
- updateHover = -1,
- enter = 0,
- exit = 1,
- down = 2,
- up = 3,
- };
-}
-#endif
\ No newline at end of file
diff --git a/include/rive/generated/animation/event_bool_change_base.hpp b/include/rive/generated/animation/listener_bool_change_base.hpp
similarity index 71%
rename from include/rive/generated/animation/event_bool_change_base.hpp
rename to include/rive/generated/animation/listener_bool_change_base.hpp
index e0914b7..e4e667b 100644
--- a/include/rive/generated/animation/event_bool_change_base.hpp
+++ b/include/rive/generated/animation/listener_bool_change_base.hpp
@@ -1,11 +1,11 @@
-#ifndef _RIVE_EVENT_BOOL_CHANGE_BASE_HPP_
-#define _RIVE_EVENT_BOOL_CHANGE_BASE_HPP_
-#include "rive/animation/event_input_change.hpp"
+#ifndef _RIVE_LISTENER_BOOL_CHANGE_BASE_HPP_
+#define _RIVE_LISTENER_BOOL_CHANGE_BASE_HPP_
+#include "rive/animation/listener_input_change.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
- class EventBoolChangeBase : public EventInputChange {
+ class ListenerBoolChangeBase : public ListenerInputChange {
protected:
- typedef EventInputChange Super;
+ typedef ListenerInputChange Super;
public:
static const uint16_t typeKey = 117;
@@ -14,8 +14,8 @@
/// at runtime.
bool isTypeOf(uint16_t typeKey) const override {
switch (typeKey) {
- case EventBoolChangeBase::typeKey:
- case EventInputChangeBase::typeKey:
+ case ListenerBoolChangeBase::typeKey:
+ case ListenerInputChangeBase::typeKey:
return true;
default:
return false;
@@ -40,9 +40,9 @@
}
Core* clone() const override;
- void copy(const EventBoolChangeBase& object) {
+ void copy(const ListenerBoolChangeBase& object) {
m_Value = object.m_Value;
- EventInputChange::copy(object);
+ ListenerInputChange::copy(object);
}
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
@@ -51,7 +51,7 @@
m_Value = CoreUintType::deserialize(reader);
return true;
}
- return EventInputChange::deserialize(propertyKey, reader);
+ return ListenerInputChange::deserialize(propertyKey, reader);
}
protected:
diff --git a/include/rive/generated/animation/event_input_change_base.hpp b/include/rive/generated/animation/listener_input_change_base.hpp
similarity index 82%
rename from include/rive/generated/animation/event_input_change_base.hpp
rename to include/rive/generated/animation/listener_input_change_base.hpp
index 7212efb..f4dca8a 100644
--- a/include/rive/generated/animation/event_input_change_base.hpp
+++ b/include/rive/generated/animation/listener_input_change_base.hpp
@@ -1,9 +1,9 @@
-#ifndef _RIVE_EVENT_INPUT_CHANGE_BASE_HPP_
-#define _RIVE_EVENT_INPUT_CHANGE_BASE_HPP_
+#ifndef _RIVE_LISTENER_INPUT_CHANGE_BASE_HPP_
+#define _RIVE_LISTENER_INPUT_CHANGE_BASE_HPP_
#include "rive/core.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
- class EventInputChangeBase : public Core {
+ class ListenerInputChangeBase : public Core {
protected:
typedef Core Super;
@@ -14,7 +14,7 @@
/// at runtime.
bool isTypeOf(uint16_t typeKey) const override {
switch (typeKey) {
- case EventInputChangeBase::typeKey:
+ case ListenerInputChangeBase::typeKey:
return true;
default:
return false;
@@ -38,7 +38,7 @@
inputIdChanged();
}
- void copy(const EventInputChangeBase& object) { m_InputId = object.m_InputId; }
+ void copy(const ListenerInputChangeBase& object) { m_InputId = object.m_InputId; }
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
switch (propertyKey) {
diff --git a/include/rive/generated/animation/event_number_change_base.hpp b/include/rive/generated/animation/listener_number_change_base.hpp
similarity index 70%
rename from include/rive/generated/animation/event_number_change_base.hpp
rename to include/rive/generated/animation/listener_number_change_base.hpp
index 4c647ed..54a7209 100644
--- a/include/rive/generated/animation/event_number_change_base.hpp
+++ b/include/rive/generated/animation/listener_number_change_base.hpp
@@ -1,11 +1,11 @@
-#ifndef _RIVE_EVENT_NUMBER_CHANGE_BASE_HPP_
-#define _RIVE_EVENT_NUMBER_CHANGE_BASE_HPP_
-#include "rive/animation/event_input_change.hpp"
+#ifndef _RIVE_LISTENER_NUMBER_CHANGE_BASE_HPP_
+#define _RIVE_LISTENER_NUMBER_CHANGE_BASE_HPP_
+#include "rive/animation/listener_input_change.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
- class EventNumberChangeBase : public EventInputChange {
+ class ListenerNumberChangeBase : public ListenerInputChange {
protected:
- typedef EventInputChange Super;
+ typedef ListenerInputChange Super;
public:
static const uint16_t typeKey = 118;
@@ -14,8 +14,8 @@
/// at runtime.
bool isTypeOf(uint16_t typeKey) const override {
switch (typeKey) {
- case EventNumberChangeBase::typeKey:
- case EventInputChangeBase::typeKey:
+ case ListenerNumberChangeBase::typeKey:
+ case ListenerInputChangeBase::typeKey:
return true;
default:
return false;
@@ -40,9 +40,9 @@
}
Core* clone() const override;
- void copy(const EventNumberChangeBase& object) {
+ void copy(const ListenerNumberChangeBase& object) {
m_Value = object.m_Value;
- EventInputChange::copy(object);
+ ListenerInputChange::copy(object);
}
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
@@ -51,7 +51,7 @@
m_Value = CoreDoubleType::deserialize(reader);
return true;
}
- return EventInputChange::deserialize(propertyKey, reader);
+ return ListenerInputChange::deserialize(propertyKey, reader);
}
protected:
diff --git a/include/rive/generated/animation/event_trigger_change_base.hpp b/include/rive/generated/animation/listener_trigger_change_base.hpp
similarity index 60%
rename from include/rive/generated/animation/event_trigger_change_base.hpp
rename to include/rive/generated/animation/listener_trigger_change_base.hpp
index 7232825..14985b3 100644
--- a/include/rive/generated/animation/event_trigger_change_base.hpp
+++ b/include/rive/generated/animation/listener_trigger_change_base.hpp
@@ -1,10 +1,10 @@
-#ifndef _RIVE_EVENT_TRIGGER_CHANGE_BASE_HPP_
-#define _RIVE_EVENT_TRIGGER_CHANGE_BASE_HPP_
-#include "rive/animation/event_input_change.hpp"
+#ifndef _RIVE_LISTENER_TRIGGER_CHANGE_BASE_HPP_
+#define _RIVE_LISTENER_TRIGGER_CHANGE_BASE_HPP_
+#include "rive/animation/listener_input_change.hpp"
namespace rive {
- class EventTriggerChangeBase : public EventInputChange {
+ class ListenerTriggerChangeBase : public ListenerInputChange {
protected:
- typedef EventInputChange Super;
+ typedef ListenerInputChange Super;
public:
static const uint16_t typeKey = 115;
@@ -13,8 +13,8 @@
/// at runtime.
bool isTypeOf(uint16_t typeKey) const override {
switch (typeKey) {
- case EventTriggerChangeBase::typeKey:
- case EventInputChangeBase::typeKey:
+ case ListenerTriggerChangeBase::typeKey:
+ case ListenerInputChangeBase::typeKey:
return true;
default:
return false;
diff --git a/include/rive/generated/animation/state_machine_event_base.hpp b/include/rive/generated/animation/state_machine_listener_base.hpp
similarity index 65%
rename from include/rive/generated/animation/state_machine_event_base.hpp
rename to include/rive/generated/animation/state_machine_listener_base.hpp
index a67e39c..6811b29 100644
--- a/include/rive/generated/animation/state_machine_event_base.hpp
+++ b/include/rive/generated/animation/state_machine_listener_base.hpp
@@ -1,9 +1,9 @@
-#ifndef _RIVE_STATE_MACHINE_EVENT_BASE_HPP_
-#define _RIVE_STATE_MACHINE_EVENT_BASE_HPP_
+#ifndef _RIVE_STATE_MACHINE_LISTENER_BASE_HPP_
+#define _RIVE_STATE_MACHINE_LISTENER_BASE_HPP_
#include "rive/animation/state_machine_component.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
- class StateMachineEventBase : public StateMachineComponent {
+ class StateMachineListenerBase : public StateMachineComponent {
protected:
typedef StateMachineComponent Super;
@@ -14,7 +14,7 @@
/// at runtime.
bool isTypeOf(uint16_t typeKey) const override {
switch (typeKey) {
- case StateMachineEventBase::typeKey:
+ case StateMachineListenerBase::typeKey:
case StateMachineComponentBase::typeKey:
return true;
default:
@@ -25,11 +25,11 @@
uint16_t coreType() const override { return typeKey; }
static const uint16_t targetIdPropertyKey = 224;
- static const uint16_t eventTypeValuePropertyKey = 225;
+ static const uint16_t listenerTypeValuePropertyKey = 225;
private:
uint32_t m_TargetId = 0;
- uint32_t m_EventTypeValue = 0;
+ uint32_t m_ListenerTypeValue = 0;
public:
inline uint32_t targetId() const { return m_TargetId; }
@@ -41,19 +41,19 @@
targetIdChanged();
}
- inline uint32_t eventTypeValue() const { return m_EventTypeValue; }
- void eventTypeValue(uint32_t value) {
- if (m_EventTypeValue == value) {
+ inline uint32_t listenerTypeValue() const { return m_ListenerTypeValue; }
+ void listenerTypeValue(uint32_t value) {
+ if (m_ListenerTypeValue == value) {
return;
}
- m_EventTypeValue = value;
- eventTypeValueChanged();
+ m_ListenerTypeValue = value;
+ listenerTypeValueChanged();
}
Core* clone() const override;
- void copy(const StateMachineEventBase& object) {
+ void copy(const StateMachineListenerBase& object) {
m_TargetId = object.m_TargetId;
- m_EventTypeValue = object.m_EventTypeValue;
+ m_ListenerTypeValue = object.m_ListenerTypeValue;
StateMachineComponent::copy(object);
}
@@ -62,8 +62,8 @@
case targetIdPropertyKey:
m_TargetId = CoreUintType::deserialize(reader);
return true;
- case eventTypeValuePropertyKey:
- m_EventTypeValue = CoreUintType::deserialize(reader);
+ case listenerTypeValuePropertyKey:
+ m_ListenerTypeValue = CoreUintType::deserialize(reader);
return true;
}
return StateMachineComponent::deserialize(propertyKey, reader);
@@ -71,7 +71,7 @@
protected:
virtual void targetIdChanged() {}
- virtual void eventTypeValueChanged() {}
+ virtual void listenerTypeValueChanged() {}
};
} // namespace rive
diff --git a/include/rive/generated/core_registry.hpp b/include/rive/generated/core_registry.hpp
index bf06626..ed1a0f7 100644
--- a/include/rive/generated/core_registry.hpp
+++ b/include/rive/generated/core_registry.hpp
@@ -12,10 +12,6 @@
#include "rive/animation/blend_state_transition.hpp"
#include "rive/animation/cubic_interpolator.hpp"
#include "rive/animation/entry_state.hpp"
-#include "rive/animation/event_bool_change.hpp"
-#include "rive/animation/event_input_change.hpp"
-#include "rive/animation/event_number_change.hpp"
-#include "rive/animation/event_trigger_change.hpp"
#include "rive/animation/exit_state.hpp"
#include "rive/animation/keyed_object.hpp"
#include "rive/animation/keyed_property.hpp"
@@ -26,6 +22,10 @@
#include "rive/animation/keyframe_id.hpp"
#include "rive/animation/layer_state.hpp"
#include "rive/animation/linear_animation.hpp"
+#include "rive/animation/listener_bool_change.hpp"
+#include "rive/animation/listener_input_change.hpp"
+#include "rive/animation/listener_number_change.hpp"
+#include "rive/animation/listener_trigger_change.hpp"
#include "rive/animation/nested_linear_animation.hpp"
#include "rive/animation/nested_remap_animation.hpp"
#include "rive/animation/nested_simple_animation.hpp"
@@ -33,10 +33,10 @@
#include "rive/animation/state_machine.hpp"
#include "rive/animation/state_machine_bool.hpp"
#include "rive/animation/state_machine_component.hpp"
-#include "rive/animation/state_machine_event.hpp"
#include "rive/animation/state_machine_input.hpp"
#include "rive/animation/state_machine_layer.hpp"
#include "rive/animation/state_machine_layer_component.hpp"
+#include "rive/animation/state_machine_listener.hpp"
#include "rive/animation/state_machine_number.hpp"
#include "rive/animation/state_machine_trigger.hpp"
#include "rive/animation/state_transition.hpp"
@@ -133,14 +133,10 @@
return new Node();
case NestedArtboardBase::typeKey:
return new NestedArtboard();
- case EventNumberChangeBase::typeKey:
- return new EventNumberChange();
case NestedSimpleAnimationBase::typeKey:
return new NestedSimpleAnimation();
case AnimationStateBase::typeKey:
return new AnimationState();
- case StateMachineEventBase::typeKey:
- return new StateMachineEvent();
case KeyedObjectBase::typeKey:
return new KeyedObject();
case BlendAnimationDirectBase::typeKey:
@@ -151,22 +147,24 @@
return new TransitionTriggerCondition();
case KeyedPropertyBase::typeKey:
return new KeyedProperty();
+ case StateMachineListenerBase::typeKey:
+ return new StateMachineListener();
case KeyFrameIdBase::typeKey:
return new KeyFrameId();
case KeyFrameBoolBase::typeKey:
return new KeyFrameBool();
+ case ListenerBoolChangeBase::typeKey:
+ return new ListenerBoolChange();
case TransitionNumberConditionBase::typeKey:
return new TransitionNumberCondition();
- case EventBoolChangeBase::typeKey:
- return new EventBoolChange();
case AnyStateBase::typeKey:
return new AnyState();
- case EventTriggerChangeBase::typeKey:
- return new EventTriggerChange();
case StateMachineLayerBase::typeKey:
return new StateMachineLayer();
case AnimationBase::typeKey:
return new Animation();
+ case ListenerNumberChangeBase::typeKey:
+ return new ListenerNumberChange();
case CubicInterpolatorBase::typeKey:
return new CubicInterpolator();
case StateTransitionBase::typeKey:
@@ -183,6 +181,8 @@
return new LinearAnimation();
case StateMachineTriggerBase::typeKey:
return new StateMachineTrigger();
+ case ListenerTriggerChangeBase::typeKey:
+ return new ListenerTriggerChange();
case BlendStateDirectBase::typeKey:
return new BlendStateDirect();
case NestedStateMachineBase::typeKey:
@@ -331,18 +331,12 @@
case NestedAnimationBase::animationIdPropertyKey:
object->as<NestedAnimationBase>()->animationId(value);
break;
- case EventInputChangeBase::inputIdPropertyKey:
- object->as<EventInputChangeBase>()->inputId(value);
+ case ListenerInputChangeBase::inputIdPropertyKey:
+ object->as<ListenerInputChangeBase>()->inputId(value);
break;
case AnimationStateBase::animationIdPropertyKey:
object->as<AnimationStateBase>()->animationId(value);
break;
- case StateMachineEventBase::targetIdPropertyKey:
- object->as<StateMachineEventBase>()->targetId(value);
- break;
- case StateMachineEventBase::eventTypeValuePropertyKey:
- object->as<StateMachineEventBase>()->eventTypeValue(value);
- break;
case KeyedObjectBase::objectIdPropertyKey:
object->as<KeyedObjectBase>()->objectId(value);
break;
@@ -358,6 +352,12 @@
case KeyedPropertyBase::propertyKeyPropertyKey:
object->as<KeyedPropertyBase>()->propertyKey(value);
break;
+ case StateMachineListenerBase::targetIdPropertyKey:
+ object->as<StateMachineListenerBase>()->targetId(value);
+ break;
+ case StateMachineListenerBase::listenerTypeValuePropertyKey:
+ object->as<StateMachineListenerBase>()->listenerTypeValue(value);
+ break;
case KeyFrameBase::framePropertyKey:
object->as<KeyFrameBase>()->frame(value);
break;
@@ -370,12 +370,12 @@
case KeyFrameIdBase::valuePropertyKey:
object->as<KeyFrameIdBase>()->value(value);
break;
+ case ListenerBoolChangeBase::valuePropertyKey:
+ object->as<ListenerBoolChangeBase>()->value(value);
+ break;
case TransitionValueConditionBase::opValuePropertyKey:
object->as<TransitionValueConditionBase>()->opValue(value);
break;
- case EventBoolChangeBase::valuePropertyKey:
- object->as<EventBoolChangeBase>()->value(value);
- break;
case StateTransitionBase::stateToIdPropertyKey:
object->as<StateTransitionBase>()->stateToId(value);
break;
@@ -512,9 +512,6 @@
case NodeBase::yPropertyKey:
object->as<NodeBase>()->y(value);
break;
- case EventNumberChangeBase::valuePropertyKey:
- object->as<EventNumberChangeBase>()->value(value);
- break;
case NestedLinearAnimationBase::mixPropertyKey:
object->as<NestedLinearAnimationBase>()->mix(value);
break;
@@ -527,6 +524,9 @@
case TransitionNumberConditionBase::valuePropertyKey:
object->as<TransitionNumberConditionBase>()->value(value);
break;
+ case ListenerNumberChangeBase::valuePropertyKey:
+ object->as<ListenerNumberChangeBase>()->value(value);
+ break;
case CubicInterpolatorBase::x1PropertyKey:
object->as<CubicInterpolatorBase>()->x1(value);
break;
@@ -836,14 +836,10 @@
return object->as<NestedArtboardBase>()->artboardId();
case NestedAnimationBase::animationIdPropertyKey:
return object->as<NestedAnimationBase>()->animationId();
- case EventInputChangeBase::inputIdPropertyKey:
- return object->as<EventInputChangeBase>()->inputId();
+ case ListenerInputChangeBase::inputIdPropertyKey:
+ return object->as<ListenerInputChangeBase>()->inputId();
case AnimationStateBase::animationIdPropertyKey:
return object->as<AnimationStateBase>()->animationId();
- case StateMachineEventBase::targetIdPropertyKey:
- return object->as<StateMachineEventBase>()->targetId();
- case StateMachineEventBase::eventTypeValuePropertyKey:
- return object->as<StateMachineEventBase>()->eventTypeValue();
case KeyedObjectBase::objectIdPropertyKey:
return object->as<KeyedObjectBase>()->objectId();
case BlendAnimationBase::animationIdPropertyKey:
@@ -854,6 +850,10 @@
return object->as<TransitionConditionBase>()->inputId();
case KeyedPropertyBase::propertyKeyPropertyKey:
return object->as<KeyedPropertyBase>()->propertyKey();
+ case StateMachineListenerBase::targetIdPropertyKey:
+ return object->as<StateMachineListenerBase>()->targetId();
+ case StateMachineListenerBase::listenerTypeValuePropertyKey:
+ return object->as<StateMachineListenerBase>()->listenerTypeValue();
case KeyFrameBase::framePropertyKey:
return object->as<KeyFrameBase>()->frame();
case KeyFrameBase::interpolationTypePropertyKey:
@@ -862,10 +862,10 @@
return object->as<KeyFrameBase>()->interpolatorId();
case KeyFrameIdBase::valuePropertyKey:
return object->as<KeyFrameIdBase>()->value();
+ case ListenerBoolChangeBase::valuePropertyKey:
+ return object->as<ListenerBoolChangeBase>()->value();
case TransitionValueConditionBase::opValuePropertyKey:
return object->as<TransitionValueConditionBase>()->opValue();
- case EventBoolChangeBase::valuePropertyKey:
- return object->as<EventBoolChangeBase>()->value();
case StateTransitionBase::stateToIdPropertyKey:
return object->as<StateTransitionBase>()->stateToId();
case StateTransitionBase::flagsPropertyKey:
@@ -959,8 +959,6 @@
return object->as<NodeBase>()->x();
case NodeBase::yPropertyKey:
return object->as<NodeBase>()->y();
- case EventNumberChangeBase::valuePropertyKey:
- return object->as<EventNumberChangeBase>()->value();
case NestedLinearAnimationBase::mixPropertyKey:
return object->as<NestedLinearAnimationBase>()->mix();
case NestedSimpleAnimationBase::speedPropertyKey:
@@ -969,6 +967,8 @@
return object->as<StateMachineNumberBase>()->value();
case TransitionNumberConditionBase::valuePropertyKey:
return object->as<TransitionNumberConditionBase>()->value();
+ case ListenerNumberChangeBase::valuePropertyKey:
+ return object->as<ListenerNumberChangeBase>()->value();
case CubicInterpolatorBase::x1PropertyKey:
return object->as<CubicInterpolatorBase>()->x1();
case CubicInterpolatorBase::y1PropertyKey:
@@ -1174,21 +1174,21 @@
case DrawableBase::drawableFlagsPropertyKey:
case NestedArtboardBase::artboardIdPropertyKey:
case NestedAnimationBase::animationIdPropertyKey:
- case EventInputChangeBase::inputIdPropertyKey:
+ case ListenerInputChangeBase::inputIdPropertyKey:
case AnimationStateBase::animationIdPropertyKey:
- case StateMachineEventBase::targetIdPropertyKey:
- case StateMachineEventBase::eventTypeValuePropertyKey:
case KeyedObjectBase::objectIdPropertyKey:
case BlendAnimationBase::animationIdPropertyKey:
case BlendAnimationDirectBase::inputIdPropertyKey:
case TransitionConditionBase::inputIdPropertyKey:
case KeyedPropertyBase::propertyKeyPropertyKey:
+ case StateMachineListenerBase::targetIdPropertyKey:
+ case StateMachineListenerBase::listenerTypeValuePropertyKey:
case KeyFrameBase::framePropertyKey:
case KeyFrameBase::interpolationTypePropertyKey:
case KeyFrameBase::interpolatorIdPropertyKey:
case KeyFrameIdBase::valuePropertyKey:
+ case ListenerBoolChangeBase::valuePropertyKey:
case TransitionValueConditionBase::opValuePropertyKey:
- case EventBoolChangeBase::valuePropertyKey:
case StateTransitionBase::stateToIdPropertyKey:
case StateTransitionBase::flagsPropertyKey:
case StateTransitionBase::durationPropertyKey:
@@ -1234,11 +1234,11 @@
case TransformComponentBase::scaleYPropertyKey:
case NodeBase::xPropertyKey:
case NodeBase::yPropertyKey:
- case EventNumberChangeBase::valuePropertyKey:
case NestedLinearAnimationBase::mixPropertyKey:
case NestedSimpleAnimationBase::speedPropertyKey:
case StateMachineNumberBase::valuePropertyKey:
case TransitionNumberConditionBase::valuePropertyKey:
+ case ListenerNumberChangeBase::valuePropertyKey:
case CubicInterpolatorBase::x1PropertyKey:
case CubicInterpolatorBase::y1PropertyKey:
case CubicInterpolatorBase::x2PropertyKey:
diff --git a/include/rive/importers/state_machine_event_importer.hpp b/include/rive/importers/state_machine_event_importer.hpp
deleted file mode 100644
index 64ac249..0000000
--- a/include/rive/importers/state_machine_event_importer.hpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef _RIVE_STATE_MACHINE_EVENT_IMPORTER_HPP_
-#define _RIVE_STATE_MACHINE_EVENT_IMPORTER_HPP_
-
-#include "rive/importers/import_stack.hpp"
-
-namespace rive {
- class StateMachineEvent;
- class StateMachine;
- class EventInputChange;
- class StateMachineEventImporter : public ImportStackObject {
- private:
- StateMachineEvent* m_StateMachineEvent;
-
- public:
- StateMachineEventImporter(StateMachineEvent* event);
- const StateMachineEvent* stateMachineEvent() const { return m_StateMachineEvent; }
- void addInputChange(EventInputChange* change);
- StatusCode resolve() override;
- };
-} // namespace rive
-#endif
diff --git a/include/rive/importers/state_machine_importer.hpp b/include/rive/importers/state_machine_importer.hpp
index fb014ce..fa643ba 100644
--- a/include/rive/importers/state_machine_importer.hpp
+++ b/include/rive/importers/state_machine_importer.hpp
@@ -6,7 +6,7 @@
namespace rive {
class StateMachineInput;
class StateMachineLayer;
- class StateMachineEvent;
+ class StateMachineListener;
class StateMachine;
class StateMachineImporter : public ImportStackObject {
private:
@@ -18,7 +18,7 @@
void addLayer(std::unique_ptr<StateMachineLayer>);
void addInput(std::unique_ptr<StateMachineInput>);
- void addEvent(std::unique_ptr<StateMachineEvent>);
+ void addListener(std::unique_ptr<StateMachineListener>);
StatusCode resolve() override;
bool readNullObject() override;
diff --git a/include/rive/importers/state_machine_listener_importer.hpp b/include/rive/importers/state_machine_listener_importer.hpp
new file mode 100644
index 0000000..6702e44
--- /dev/null
+++ b/include/rive/importers/state_machine_listener_importer.hpp
@@ -0,0 +1,21 @@
+#ifndef _RIVE_STATE_MACHINE_LISTENER_IMPORTER_HPP_
+#define _RIVE_STATE_MACHINE_LISTENER_IMPORTER_HPP_
+
+#include "rive/importers/import_stack.hpp"
+
+namespace rive {
+ class StateMachineListener;
+ class StateMachine;
+ class ListenerInputChange;
+ class StateMachineListenerImporter : public ImportStackObject {
+ private:
+ StateMachineListener* m_StateMachineListener;
+
+ public:
+ StateMachineListenerImporter(StateMachineListener* listener);
+ const StateMachineListener* stateMachineListener() const { return m_StateMachineListener; }
+ void addInputChange(ListenerInputChange* change);
+ StatusCode resolve() override;
+ };
+} // namespace rive
+#endif
diff --git a/include/rive/listener_type.hpp b/include/rive/listener_type.hpp
new file mode 100644
index 0000000..a2c8471
--- /dev/null
+++ b/include/rive/listener_type.hpp
@@ -0,0 +1,12 @@
+#ifndef _RIVE_LISTENER_TYPE_HPP_
+#define _RIVE_LISTENER_TYPE_HPP_
+namespace rive {
+ enum class ListenerType : int {
+ updateHover = -1,
+ enter = 0,
+ exit = 1,
+ down = 2,
+ up = 3,
+ };
+}
+#endif
\ No newline at end of file
diff --git a/src/animation/event_input_change.cpp b/src/animation/event_input_change.cpp
deleted file mode 100644
index 7914ae3..0000000
--- a/src/animation/event_input_change.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "rive/animation/state_machine_event.hpp"
-#include "rive/importers/import_stack.hpp"
-#include "rive/importers/state_machine_event_importer.hpp"
-#include "rive/importers/state_machine_importer.hpp"
-#include "rive/animation/event_input_change.hpp"
-#include "rive/animation/state_machine.hpp"
-
-using namespace rive;
-
-StatusCode EventInputChange::import(ImportStack& importStack) {
- auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachine::typeKey);
- if (stateMachineImporter == nullptr) {
- return StatusCode::MissingObject;
- }
-
- auto stateMachineEventImporter =
- importStack.latest<StateMachineEventImporter>(StateMachineEventBase::typeKey);
- if (stateMachineEventImporter == nullptr) {
- return StatusCode::MissingObject;
- }
-
- if (!validateInputType(stateMachineImporter->stateMachine()->input((size_t)inputId()))) {
- return StatusCode::InvalidObject;
- }
- stateMachineEventImporter->addInputChange(this);
- return Super::import(importStack);
-}
diff --git a/src/animation/event_bool_change.cpp b/src/animation/listener_bool_change.cpp
similarity index 82%
rename from src/animation/event_bool_change.cpp
rename to src/animation/listener_bool_change.cpp
index 2d81753..a930b28 100644
--- a/src/animation/event_bool_change.cpp
+++ b/src/animation/listener_bool_change.cpp
@@ -1,17 +1,17 @@
-#include "rive/animation/event_bool_change.hpp"
+#include "rive/animation/listener_bool_change.hpp"
#include "rive/animation/state_machine_instance.hpp"
#include "rive/animation/state_machine_bool.hpp"
#include "rive/animation/state_machine_input_instance.hpp"
using namespace rive;
-bool EventBoolChange::validateInputType(const StateMachineInput* input) const {
+bool ListenerBoolChange::validateInputType(const StateMachineInput* input) const {
// A null input is valid as the StateMachine can attempt to limp along if we
// introduce new input types that old conditions are expected to handle in
// newer runtimes. The older runtimes will just evaluate them to true.
return input == nullptr || input->is<StateMachineBool>();
}
-void EventBoolChange::perform(StateMachineInstance* stateMachineInstance) const {
+void ListenerBoolChange::perform(StateMachineInstance* stateMachineInstance) const {
auto inputInstance = stateMachineInstance->input(inputId());
if (inputInstance == nullptr) {
return;
diff --git a/src/animation/listener_input_change.cpp b/src/animation/listener_input_change.cpp
new file mode 100644
index 0000000..a3e3e54
--- /dev/null
+++ b/src/animation/listener_input_change.cpp
@@ -0,0 +1,27 @@
+#include "rive/animation/state_machine_listener.hpp"
+#include "rive/importers/import_stack.hpp"
+#include "rive/importers/state_machine_listener_importer.hpp"
+#include "rive/importers/state_machine_importer.hpp"
+#include "rive/animation/listener_input_change.hpp"
+#include "rive/animation/state_machine.hpp"
+
+using namespace rive;
+
+StatusCode ListenerInputChange::import(ImportStack& importStack) {
+ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachine::typeKey);
+ if (stateMachineImporter == nullptr) {
+ return StatusCode::MissingObject;
+ }
+
+ auto stateMachineListenerImporter =
+ importStack.latest<StateMachineListenerImporter>(StateMachineListenerBase::typeKey);
+ if (stateMachineListenerImporter == nullptr) {
+ return StatusCode::MissingObject;
+ }
+
+ if (!validateInputType(stateMachineImporter->stateMachine()->input((size_t)inputId()))) {
+ return StatusCode::InvalidObject;
+ }
+ stateMachineListenerImporter->addInputChange(this);
+ return Super::import(importStack);
+}
diff --git a/src/animation/event_number_change.cpp b/src/animation/listener_number_change.cpp
similarity index 78%
rename from src/animation/event_number_change.cpp
rename to src/animation/listener_number_change.cpp
index a97d306..33c8316 100644
--- a/src/animation/event_number_change.cpp
+++ b/src/animation/listener_number_change.cpp
@@ -1,18 +1,18 @@
-#include "rive/animation/event_number_change.hpp"
+#include "rive/animation/listener_number_change.hpp"
#include "rive/animation/state_machine_instance.hpp"
#include "rive/animation/state_machine_number.hpp"
#include "rive/animation/state_machine_input_instance.hpp"
using namespace rive;
-bool EventNumberChange::validateInputType(const StateMachineInput* input) const {
+bool ListenerNumberChange::validateInputType(const StateMachineInput* input) const {
// A null input is valid as the StateMachine can attempt to limp along if we
// introduce new input types that old conditions are expected to handle in
// newer runtimes. The older runtimes will just evaluate them to true.
return input == nullptr || input->is<StateMachineNumber>();
}
-void EventNumberChange::perform(StateMachineInstance* stateMachineInstance) const {
+void ListenerNumberChange::perform(StateMachineInstance* stateMachineInstance) const {
auto inputInstance = stateMachineInstance->input(inputId());
if (inputInstance == nullptr) {
return;
diff --git a/src/animation/event_trigger_change.cpp b/src/animation/listener_trigger_change.cpp
similarity index 77%
rename from src/animation/event_trigger_change.cpp
rename to src/animation/listener_trigger_change.cpp
index e2b8d9d..f1939e0 100644
--- a/src/animation/event_trigger_change.cpp
+++ b/src/animation/listener_trigger_change.cpp
@@ -1,18 +1,18 @@
-#include "rive/animation/event_trigger_change.hpp"
+#include "rive/animation/listener_trigger_change.hpp"
#include "rive/animation/state_machine_instance.hpp"
#include "rive/animation/state_machine_trigger.hpp"
#include "rive/animation/state_machine_input_instance.hpp"
using namespace rive;
-bool EventTriggerChange::validateInputType(const StateMachineInput* input) const {
+bool ListenerTriggerChange::validateInputType(const StateMachineInput* input) const {
// A null input is valid as the StateMachine can attempt to limp along if we
// introduce new input types that old conditions are expected to handle in
// newer runtimes. The older runtimes will just evaluate them to true.
return input == nullptr || input->is<StateMachineTrigger>();
}
-void EventTriggerChange::perform(StateMachineInstance* stateMachineInstance) const {
+void ListenerTriggerChange::perform(StateMachineInstance* stateMachineInstance) const {
auto inputInstance = stateMachineInstance->input(inputId());
if (inputInstance == nullptr) {
return;
diff --git a/src/animation/state_machine.cpp b/src/animation/state_machine.cpp
index 0959b21..3d4a441 100644
--- a/src/animation/state_machine.cpp
+++ b/src/animation/state_machine.cpp
@@ -3,7 +3,7 @@
#include "rive/importers/artboard_importer.hpp"
#include "rive/animation/state_machine_layer.hpp"
#include "rive/animation/state_machine_input.hpp"
-#include "rive/animation/state_machine_event.hpp"
+#include "rive/animation/state_machine_listener.hpp"
using namespace rive;
@@ -23,7 +23,7 @@
return code;
}
}
- for (auto& object : m_Events) {
+ for (auto& object : m_Listeners) {
if ((code = object->onAddedDirty(context)) != StatusCode::Ok) {
return code;
}
@@ -43,7 +43,7 @@
return code;
}
}
- for (auto& object : m_Events) {
+ for (auto& object : m_Listeners) {
if ((code = object->onAddedClean(context)) != StatusCode::Ok) {
return code;
}
@@ -68,8 +68,8 @@
m_Inputs.push_back(std::move(input));
}
-void StateMachine::addEvent(std::unique_ptr<StateMachineEvent> event) {
- m_Events.push_back(std::move(event));
+void StateMachine::addListener(std::unique_ptr<StateMachineListener> listener) {
+ m_Listeners.push_back(std::move(listener));
}
const StateMachineInput* StateMachine::input(std::string name) const {
@@ -104,9 +104,9 @@
return nullptr;
}
-const StateMachineEvent* StateMachine::event(size_t index) const {
- if (index < m_Events.size()) {
- return m_Events[index].get();
+const StateMachineListener* StateMachine::listener(size_t index) const {
+ if (index < m_Listeners.size()) {
+ return m_Listeners[index].get();
}
return nullptr;
}
\ No newline at end of file
diff --git a/src/animation/state_machine_instance.cpp b/src/animation/state_machine_instance.cpp
index 30d34fb..d7bbe98 100644
--- a/src/animation/state_machine_instance.cpp
+++ b/src/animation/state_machine_instance.cpp
@@ -13,7 +13,7 @@
#include "rive/animation/animation_state.hpp"
#include "rive/animation/state_instance.hpp"
#include "rive/animation/animation_state_instance.hpp"
-#include "rive/animation/state_machine_event.hpp"
+#include "rive/animation/state_machine_listener.hpp"
#include "rive/shapes/shape.hpp"
#include "rive/math/aabb.hpp"
#include "rive/math/hit_test.hpp"
@@ -224,9 +224,9 @@
}
};
- /// Representation of a Shape from the Artboard Instance and all the events it
+ /// Representation of a Shape from the Artboard Instance and all the listeners it
/// triggers. Allows tracking hover and performing hit detection only once on
- /// shapes that trigger multiple events.
+ /// shapes that trigger multiple listeners.
class HitShape {
private:
Shape* m_Shape;
@@ -235,11 +235,11 @@
Shape* shape() const { return m_Shape; }
HitShape(Shape* shape) : m_Shape(shape) {}
bool isHovered = false;
- std::vector<const StateMachineEvent*> events;
+ std::vector<const StateMachineListener*> listeners;
};
} // namespace rive
-void StateMachineInstance::processEvent(Vec2D position, EventType hitEvent) {
+void StateMachineInstance::updateListeners(Vec2D position, ListenerType hitType) {
if (m_ArtboardInstance->frameOrigin()) {
position -= Vec2D(m_ArtboardInstance->originX() * m_ArtboardInstance->width(),
m_ArtboardInstance->originY() * m_ArtboardInstance->height());
@@ -261,21 +261,21 @@
bool hoverChange = hitShape->isHovered != isOver;
hitShape->isHovered = isOver;
- // iterate all events associated with this hit shape
- for (auto event : hitShape->events) {
- // Always update hover states regardless of which specific event type
+ // iterate all listeners associated with this hit shape
+ for (auto listener : hitShape->listeners) {
+ // Always update hover states regardless of which specific listener type
// we're trying to trigger.
if (hoverChange) {
- if (isOver && event->eventType() == EventType::enter) {
- event->performChanges(this);
+ if (isOver && listener->listenerType() == ListenerType::enter) {
+ listener->performChanges(this);
markNeedsAdvance();
- } else if (!isOver && event->eventType() == EventType::exit) {
- event->performChanges(this);
+ } else if (!isOver && listener->listenerType() == ListenerType::exit) {
+ listener->performChanges(this);
markNeedsAdvance();
}
}
- if (isOver && hitEvent == event->eventType()) {
- event->performChanges(this);
+ if (isOver && hitType == listener->listenerType()) {
+ listener->performChanges(this);
markNeedsAdvance();
}
}
@@ -295,14 +295,14 @@
for (auto nestedAnimation : nestedArtboard->nestedAnimations()) {
if (nestedAnimation->is<NestedStateMachine>()) {
auto nestedStateMachine = nestedAnimation->as<NestedStateMachine>();
- switch (hitEvent) {
- case EventType::down:
+ switch (hitType) {
+ case ListenerType::down:
nestedStateMachine->pointerDown(nestedPosition);
break;
- case EventType::up:
+ case ListenerType::up:
nestedStateMachine->pointerUp(nestedPosition);
break;
- case EventType::updateHover:
+ case ListenerType::updateHover:
nestedStateMachine->pointerMove(nestedPosition);
break;
default:
@@ -314,10 +314,14 @@
}
void StateMachineInstance::pointerMove(Vec2D position) {
- processEvent(position, EventType::updateHover);
+ updateListeners(position, ListenerType::updateHover);
}
-void StateMachineInstance::pointerDown(Vec2D position) { processEvent(position, EventType::down); }
-void StateMachineInstance::pointerUp(Vec2D position) { processEvent(position, EventType::up); }
+void StateMachineInstance::pointerDown(Vec2D position) {
+ updateListeners(position, ListenerType::down);
+}
+void StateMachineInstance::pointerUp(Vec2D position) {
+ updateListeners(position, ListenerType::up);
+}
StateMachineInstance::StateMachineInstance(const StateMachine* machine,
ArtboardInstance* instance) :
@@ -351,16 +355,16 @@
m_Layers[i].init(machine->layer(i), m_ArtboardInstance);
}
- // Initialize events. Store a lookup table of shape id to hit shape
- // representation (an object that stores all the events triggered by the
- // shape producing an event).
+ // Initialize listeners. Store a lookup table of shape id to hit shape
+ // representation (an object that stores all the listeners triggered by the
+ // shape producing a listener).
std::unordered_map<uint32_t, HitShape*> hitShapeLookup;
- for (std::size_t i = 0; i < machine->eventCount(); i++) {
- auto event = machine->event(i);
+ for (std::size_t i = 0; i < machine->listenerCount(); i++) {
+ auto listener = machine->listener(i);
- // Iterate actual leaf hittable shapes tied to this event and resolve
+ // Iterate actual leaf hittable shapes tied to this listener and resolve
// corresponding ones in the artboard instance.
- for (auto id : event->hitShapeIds()) {
+ for (auto id : listener->hitShapeIds()) {
HitShape* hitShape;
auto itr = hitShapeLookup.find(id);
if (itr == hitShapeLookup.end()) {
@@ -376,7 +380,7 @@
} else {
hitShape = itr->second;
}
- hitShape->events.push_back(event);
+ hitShape->listeners.push_back(listener);
}
}
diff --git a/src/animation/state_machine_event.cpp b/src/animation/state_machine_listenable.cpp
similarity index 73%
rename from src/animation/state_machine_event.cpp
rename to src/animation/state_machine_listenable.cpp
index bd17743..36e54b5 100644
--- a/src/animation/state_machine_event.cpp
+++ b/src/animation/state_machine_listenable.cpp
@@ -1,36 +1,36 @@
-#include "rive/animation/state_machine_event.hpp"
+#include "rive/animation/state_machine_listener.hpp"
#include "rive/importers/import_stack.hpp"
#include "rive/importers/state_machine_importer.hpp"
#include "rive/generated/animation/state_machine_base.hpp"
#include "rive/artboard.hpp"
#include "rive/shapes/shape.hpp"
#include "rive/animation/state_machine_instance.hpp"
-#include "rive/animation/event_input_change.hpp"
+#include "rive/animation/listener_input_change.hpp"
using namespace rive;
-void StateMachineEvent::addInputChange(EventInputChange* inputChange) {
+void StateMachineListener::addInputChange(ListenerInputChange* inputChange) {
m_InputChanges.push_back(inputChange);
}
-StatusCode StateMachineEvent::import(ImportStack& importStack) {
+StatusCode StateMachineListener::import(ImportStack& importStack) {
auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachineBase::typeKey);
if (stateMachineImporter == nullptr) {
return StatusCode::MissingObject;
}
// Handing off ownership of this!
- stateMachineImporter->addEvent(std::unique_ptr<StateMachineEvent>(this));
+ stateMachineImporter->addListener(std::unique_ptr<StateMachineListener>(this));
return Super::import(importStack);
}
-const EventInputChange* StateMachineEvent::inputChange(size_t index) const {
+const ListenerInputChange* StateMachineListener::inputChange(size_t index) const {
if (index < m_InputChanges.size()) {
return m_InputChanges[index];
}
return nullptr;
}
-StatusCode StateMachineEvent::onAddedClean(CoreContext* context) {
+StatusCode StateMachineListener::onAddedClean(CoreContext* context) {
auto artboard = static_cast<Artboard*>(context);
auto target = artboard->resolve(targetId());
@@ -59,7 +59,7 @@
return Super::onAddedClean(context);
}
-void StateMachineEvent::performChanges(StateMachineInstance* stateMachineInstance) const {
+void StateMachineListener::performChanges(StateMachineInstance* stateMachineInstance) const {
for (auto inputChange : m_InputChanges) {
inputChange->perform(stateMachineInstance);
}
diff --git a/src/artboard.cpp b/src/artboard.cpp
index 349e81e..dffdf8c 100644
--- a/src/artboard.cpp
+++ b/src/artboard.cpp
@@ -71,7 +71,7 @@
// Animations and StateMachines initialize only once on the source/origin
// Artboard. Instances will hold references to the original Animations and StateMachines, so
// running this code for instances will effectively initialize them twice. This can lead to
- // unpredictable behaviour. One such example was that resolved objects like event inputs were
+ // unpredictable behaviour. One such example was that resolved objects like listener inputs were
// being added to lists twice.
if (!isInstance()) {
for (auto object : m_Animations) {
diff --git a/src/file.cpp b/src/file.cpp
index 3f1bdb8..a231f9c 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -14,7 +14,7 @@
#include "rive/importers/keyed_property_importer.hpp"
#include "rive/importers/linear_animation_importer.hpp"
#include "rive/importers/state_machine_importer.hpp"
-#include "rive/importers/state_machine_event_importer.hpp"
+#include "rive/importers/state_machine_listener_importer.hpp"
#include "rive/importers/state_machine_layer_importer.hpp"
#include "rive/importers/layer_state_importer.hpp"
#include "rive/importers/state_transition_importer.hpp"
@@ -75,9 +75,8 @@
if (id == -1) {
// Still couldn't find it, give up.
- fprintf(stderr,
- "Unknown property key %d, missing from property ToC.\n",
- propertyKey);
+ fprintf(
+ stderr, "Unknown property key %d, missing from property ToC.\n", propertyKey);
delete object;
return nullptr;
}
@@ -108,18 +107,17 @@
return object;
}
-File::File(Factory* factory, FileAssetResolver* assetResolver)
- : m_Factory(factory)
- , m_AssetResolver(assetResolver)
-{
+File::File(Factory* factory, FileAssetResolver* assetResolver) :
+ m_Factory(factory), m_AssetResolver(assetResolver) {
assert(factory);
}
File::~File() {}
-std::unique_ptr<File>
-File::import(Span<const uint8_t> bytes, Factory* factory,
- ImportResult* result, FileAssetResolver* assetResolver) {
+std::unique_ptr<File> File::import(Span<const uint8_t> bytes,
+ Factory* factory,
+ ImportResult* result,
+ FileAssetResolver* assetResolver) {
BinaryReader reader(bytes);
RuntimeHeader header;
if (!RuntimeHeader::read(reader, header)) {
@@ -230,11 +228,12 @@
stackObject = new StateTransitionImporter(object->as<StateTransition>());
stackType = StateTransition::typeKey;
break;
- case StateMachineEvent::typeKey:
- stackObject = new StateMachineEventImporter(object->as<StateMachineEvent>());
+ case StateMachineListener::typeKey:
+ stackObject = new StateMachineListenerImporter(object->as<StateMachineListener>());
break;
case ImageAsset::typeKey:
- stackObject = new FileAssetImporter(object->as<FileAsset>(), m_AssetResolver, m_Factory);
+ stackObject =
+ new FileAssetImporter(object->as<FileAsset>(), m_AssetResolver, m_Factory);
stackType = FileAsset::typeKey;
break;
}
@@ -244,8 +243,8 @@
}
}
- return !reader.hasError() && importStack.resolve() == StatusCode::Ok
- ? ImportResult::success : ImportResult::malformed;
+ return !reader.hasError() && importStack.resolve() == StatusCode::Ok ? ImportResult::success
+ : ImportResult::malformed;
}
Artboard* File::artboard(std::string name) const {
diff --git a/src/generated/animation/event_bool_change_base.cpp b/src/generated/animation/event_bool_change_base.cpp
deleted file mode 100644
index 722a754..0000000
--- a/src/generated/animation/event_bool_change_base.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "rive/generated/animation/event_bool_change_base.hpp"
-#include "rive/animation/event_bool_change.hpp"
-
-using namespace rive;
-
-Core* EventBoolChangeBase::clone() const {
- auto cloned = new EventBoolChange();
- cloned->copy(*this);
- return cloned;
-}
diff --git a/src/generated/animation/event_number_change_base.cpp b/src/generated/animation/event_number_change_base.cpp
deleted file mode 100644
index 64eb85a..0000000
--- a/src/generated/animation/event_number_change_base.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "rive/generated/animation/event_number_change_base.hpp"
-#include "rive/animation/event_number_change.hpp"
-
-using namespace rive;
-
-Core* EventNumberChangeBase::clone() const {
- auto cloned = new EventNumberChange();
- cloned->copy(*this);
- return cloned;
-}
diff --git a/src/generated/animation/event_trigger_change_base.cpp b/src/generated/animation/event_trigger_change_base.cpp
deleted file mode 100644
index 4a78dfe..0000000
--- a/src/generated/animation/event_trigger_change_base.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "rive/generated/animation/event_trigger_change_base.hpp"
-#include "rive/animation/event_trigger_change.hpp"
-
-using namespace rive;
-
-Core* EventTriggerChangeBase::clone() const {
- auto cloned = new EventTriggerChange();
- cloned->copy(*this);
- return cloned;
-}
diff --git a/src/generated/animation/listener_bool_change_base.cpp b/src/generated/animation/listener_bool_change_base.cpp
new file mode 100644
index 0000000..0b756d5
--- /dev/null
+++ b/src/generated/animation/listener_bool_change_base.cpp
@@ -0,0 +1,10 @@
+#include "rive/generated/animation/listener_bool_change_base.hpp"
+#include "rive/animation/listener_bool_change.hpp"
+
+using namespace rive;
+
+Core* ListenerBoolChangeBase::clone() const {
+ auto cloned = new ListenerBoolChange();
+ cloned->copy(*this);
+ return cloned;
+}
diff --git a/src/generated/animation/listener_number_change_base.cpp b/src/generated/animation/listener_number_change_base.cpp
new file mode 100644
index 0000000..8051ae2
--- /dev/null
+++ b/src/generated/animation/listener_number_change_base.cpp
@@ -0,0 +1,10 @@
+#include "rive/generated/animation/listener_number_change_base.hpp"
+#include "rive/animation/listener_number_change.hpp"
+
+using namespace rive;
+
+Core* ListenerNumberChangeBase::clone() const {
+ auto cloned = new ListenerNumberChange();
+ cloned->copy(*this);
+ return cloned;
+}
diff --git a/src/generated/animation/listener_trigger_change_base.cpp b/src/generated/animation/listener_trigger_change_base.cpp
new file mode 100644
index 0000000..732933b
--- /dev/null
+++ b/src/generated/animation/listener_trigger_change_base.cpp
@@ -0,0 +1,10 @@
+#include "rive/generated/animation/listener_trigger_change_base.hpp"
+#include "rive/animation/listener_trigger_change.hpp"
+
+using namespace rive;
+
+Core* ListenerTriggerChangeBase::clone() const {
+ auto cloned = new ListenerTriggerChange();
+ cloned->copy(*this);
+ return cloned;
+}
diff --git a/src/generated/animation/state_machine_event_base.cpp b/src/generated/animation/state_machine_event_base.cpp
deleted file mode 100644
index 0ba8a2b..0000000
--- a/src/generated/animation/state_machine_event_base.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "rive/generated/animation/state_machine_event_base.hpp"
-#include "rive/animation/state_machine_event.hpp"
-
-using namespace rive;
-
-Core* StateMachineEventBase::clone() const {
- auto cloned = new StateMachineEvent();
- cloned->copy(*this);
- return cloned;
-}
diff --git a/src/generated/animation/state_machine_listener_base.cpp b/src/generated/animation/state_machine_listener_base.cpp
new file mode 100644
index 0000000..a5315fc
--- /dev/null
+++ b/src/generated/animation/state_machine_listener_base.cpp
@@ -0,0 +1,10 @@
+#include "rive/generated/animation/state_machine_listener_base.hpp"
+#include "rive/animation/state_machine_listener.hpp"
+
+using namespace rive;
+
+Core* StateMachineListenerBase::clone() const {
+ auto cloned = new StateMachineListener();
+ cloned->copy(*this);
+ return cloned;
+}
diff --git a/src/importers/state_machine_event_importer.cpp b/src/importers/state_machine_event_importer.cpp
deleted file mode 100644
index 9d8fd3c..0000000
--- a/src/importers/state_machine_event_importer.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "rive/importers/state_machine_event_importer.hpp"
-#include "rive/animation/state_machine_event.hpp"
-
-using namespace rive;
-
-StateMachineEventImporter::StateMachineEventImporter(StateMachineEvent* event) :
- m_StateMachineEvent(event) {}
-
-void StateMachineEventImporter::addInputChange(EventInputChange* change) {
- m_StateMachineEvent->addInputChange(change);
-}
-
-StatusCode StateMachineEventImporter::resolve() { return StatusCode::Ok; }
\ No newline at end of file
diff --git a/src/importers/state_machine_importer.cpp b/src/importers/state_machine_importer.cpp
index c6aa5a3..f5aa9aa 100644
--- a/src/importers/state_machine_importer.cpp
+++ b/src/importers/state_machine_importer.cpp
@@ -1,6 +1,6 @@
#include "rive/importers/state_machine_importer.hpp"
#include "rive/animation/state_machine.hpp"
-#include "rive/animation/state_machine_event.hpp"
+#include "rive/animation/state_machine_listener.hpp"
#include "rive/animation/state_machine_input.hpp"
#include "rive/animation/state_machine_layer.hpp"
@@ -16,8 +16,8 @@
m_StateMachine->addInput(std::move(input));
}
-void StateMachineImporter::addEvent(std::unique_ptr<StateMachineEvent> event) {
- m_StateMachine->addEvent(std::move(event));
+void StateMachineImporter::addListener(std::unique_ptr<StateMachineListener> listener) {
+ m_StateMachine->addListener(std::move(listener));
}
bool StateMachineImporter::readNullObject() {
diff --git a/src/importers/state_machine_listener_importer.cpp b/src/importers/state_machine_listener_importer.cpp
new file mode 100644
index 0000000..bf403af
--- /dev/null
+++ b/src/importers/state_machine_listener_importer.cpp
@@ -0,0 +1,13 @@
+#include "rive/importers/state_machine_listener_importer.hpp"
+#include "rive/animation/state_machine_listener.hpp"
+
+using namespace rive;
+
+StateMachineListenerImporter::StateMachineListenerImporter(StateMachineListener* listener) :
+ m_StateMachineListener(listener) {}
+
+void StateMachineListenerImporter::addInputChange(ListenerInputChange* change) {
+ m_StateMachineListener->addInputChange(change);
+}
+
+StatusCode StateMachineListenerImporter::resolve() { return StatusCode::Ok; }
\ No newline at end of file
diff --git a/test/state_machine_event_test.cpp b/test/state_machine_event_test.cpp
index 9bc81cf..5e9b462 100644
--- a/test/state_machine_event_test.cpp
+++ b/test/state_machine_event_test.cpp
@@ -2,7 +2,7 @@
#include <rive/file.hpp>
#include <rive/animation/state_machine_bool.hpp>
#include <rive/animation/state_machine_layer.hpp>
-#include <rive/animation/state_machine_event.hpp>
+#include <rive/animation/state_machine_listener.hpp>
#include <rive/animation/animation_state.hpp>
#include <rive/animation/entry_state.hpp>
#include <rive/animation/state_transition.hpp>
@@ -12,13 +12,13 @@
#include <rive/animation/blend_animation_1d.hpp>
#include <rive/animation/blend_state_direct.hpp>
#include <rive/animation/blend_state_transition.hpp>
-#include <rive/animation/event_input_change.hpp>
+#include <rive/animation/listener_input_change.hpp>
#include <rive/node.hpp>
#include "catch.hpp"
#include "rive_file_reader.hpp"
#include <cstdio>
-TEST_CASE("file with state machine events be read", "[file]") {
+TEST_CASE("file with state machine listeners be read", "[file]") {
auto file = ReadRiveFile("../../test/assets/bullet_man.riv");
auto artboard = file->artboard("Bullet Man");
@@ -28,34 +28,34 @@
auto stateMachine = artboard->stateMachine(0);
REQUIRE(stateMachine != nullptr);
- REQUIRE(stateMachine->eventCount() == 3);
+ REQUIRE(stateMachine->listenerCount() == 3);
REQUIRE(stateMachine->inputCount() == 4);
- // Expect each of the three events to have one input change each.
- auto event1 = stateMachine->event(0);
- auto target1 = artboard->resolve(event1->targetId());
+ // Expect each of the three listeners to have one input change each.
+ auto listener1 = stateMachine->listener(0);
+ auto target1 = artboard->resolve(listener1->targetId());
REQUIRE(target1->is<rive::Node>());
REQUIRE(target1->as<rive::Node>()->name() == "HandWickHit");
- REQUIRE(event1->inputChangeCount() == 1);
- auto inputChange1 = event1->inputChange(0);
+ REQUIRE(listener1->inputChangeCount() == 1);
+ auto inputChange1 = listener1->inputChange(0);
REQUIRE(inputChange1 != nullptr);
REQUIRE(inputChange1->inputId() == 0);
- auto event2 = stateMachine->event(1);
- auto target2 = artboard->resolve(event2->targetId());
+ auto listener2 = stateMachine->listener(1);
+ auto target2 = artboard->resolve(listener2->targetId());
REQUIRE(target2->is<rive::Node>());
REQUIRE(target2->as<rive::Node>()->name() == "HandCannonHit");
- REQUIRE(event2->inputChangeCount() == 1);
- auto inputChange2 = event2->inputChange(0);
+ REQUIRE(listener2->inputChangeCount() == 1);
+ auto inputChange2 = listener2->inputChange(0);
REQUIRE(inputChange2 != nullptr);
REQUIRE(inputChange2->inputId() == 1);
- auto event3 = stateMachine->event(2);
- auto target3 = artboard->resolve(event3->targetId());
+ auto listener3 = stateMachine->listener(2);
+ auto target3 = artboard->resolve(listener3->targetId());
REQUIRE(target3->is<rive::Node>());
REQUIRE(target3->as<rive::Node>()->name() == "HandHelmetHit");
- REQUIRE(event3->inputChangeCount() == 1);
- auto inputChange3 = event3->inputChange(0);
+ REQUIRE(listener3->inputChangeCount() == 1);
+ auto inputChange3 = listener3->inputChange(0);
REQUIRE(inputChange3 != nullptr);
REQUIRE(inputChange3->inputId() == 2);
}
@@ -82,7 +82,7 @@
REQUIRE(trigger->didFire());
}
-TEST_CASE("hit a toggle boolean event", "[file]") {
+TEST_CASE("hit a toggle boolean listener", "[file]") {
auto file = ReadRiveFile("../../test/assets/light_switch.riv");
auto artboard = file->artboard()->instance();