Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows viewer #339

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,21 @@ skia/**/build/android
/build/android
/skia/dependencies/skia_rive_optimized
/skia/dependencies/skia-experimental
build/windows/obj
dev/test
skia/renderer/build
skia/viewer/build/windows/dependencies/imgui
skia/viewer/build/windows/dependencies/gl3w
skia/viewer/build/windows/dependencies/skia
skia/viewer/build/windows/dependencies/glfw
skia/viewer/build/windows/dependencies/glfw_build
skia/viewer/build/windows/dependencies/bin
skia/viewer/build/windows/bin
skia/viewer/build/windows/obj
skia/viewer/build/windows/*.sln
skia/viewer/build/windows/*.vcxproj
skia/viewer/build/windows/*.vcxproj.filters
skia/viewer/build/*.sln
skia/viewer/build/*.vcxproj
skia/viewer/build/*.vcxproj.filters
*.pdb
33 changes: 33 additions & 0 deletions dev/defs/animation/listener_action.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "ListenerAction",
"key": {
"int": 125,
"string": "listener_action"
},
"abstract": true,
"properties": {
"listenerId": {
"type": "Id",
"typeRuntime": "uint",
"initialValue": "Core.missingId",
"initialValueRuntime": "0",
"key": {
"int": 226,
"string": "listenerId"
},
"description": "Identifier used to track the StateMachineListener this result belongs to.",
"runtime": false
},
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"initialValueRuntime": "0",
"key": {
"int": 230,
"string": "order"
},
"description": "Order value for condition in a transition.",
"runtime": false
}
}
}
21 changes: 21 additions & 0 deletions dev/defs/animation/listener_align_target.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "ListenerAlignTarget",
"key": {
"int": 126,
"string": "listeneraligntarget"
},
"extends": "animation/listener_action.json",
"properties": {
"targetId": {
"type": "Id",
"typeRuntime": "uint",
"initialValue": "Core.missingId",
"initialValueRuntime": "0",
"key": {
"int": 240,
"string": "targetid"
},
"description": "Identifier used to track the object use as a target fo this listener action."
}
}
}
24 changes: 1 addition & 23 deletions dev/defs/animation/listener_input_change.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,8 @@
"string": "listener_input_change"
},
"abstract": true,
"extends": "animation/listener_action.json",
"properties": {
"listenerId": {
"type": "Id",
"typeRuntime": "uint",
"initialValue": "Core.missingId",
"initialValueRuntime": "0",
"key": {
"int": 226,
"string": "listenerId"
},
"description": "Identifier used to track the StateMachineListener this result belongs to.",
"runtime": false
},
"inputId": {
"type": "Id",
"typeRuntime": "uint",
Expand All @@ -28,17 +17,6 @@
"string": "inputid"
},
"description": "Id of the StateMachineInput referenced."
},
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"initialValueRuntime": "0",
"key": {
"int": 230,
"string": "order"
},
"description": "Order value for condition in a transition.",
"runtime": false
}
}
}
19 changes: 19 additions & 0 deletions dev/defs/animation/nested_bool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "NestedBool",
"key": {
"int": 123,
"string": "nestedBool"
},
"extends": "animation/nested_input.json",
"properties": {
"nestedValue": {
"type": "bool",
"initialValue": "false",
"animates": true,
"key": {
"int": 238,
"string": "value"
}
}
}
}
22 changes: 22 additions & 0 deletions dev/defs/animation/nested_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "NestedInput",
"key": {
"int": 121,
"string": "nestedinput"
},
"abstract": true,
"extends": "component.json",
"properties": {
"inputId": {
"type": "Id",
"typeRuntime": "uint",
"initialValue": "Core.missingId",
"initialValueRuntime": "-1",
"key": {
"int": 237,
"string": "inputid"
},
"description": "Identifier used to track the actual backing state machine input."
}
}
}
19 changes: 19 additions & 0 deletions dev/defs/animation/nested_number.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "NestedNumber",
"key": {
"int": 124,
"string": "nestedNumber"
},
"extends": "animation/nested_input.json",
"properties": {
"nestedValue": {
"type": "double",
"initialValue": "0",
"animates": true,
"key": {
"int": 239,
"string": "nestedValue"
}
}
}
}
8 changes: 8 additions & 0 deletions dev/defs/animation/nested_trigger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "NestedTrigger",
"key": {
"int": 122,
"string": "nestedTrigger"
},
"extends": "animation/nested_input.json"
}
4 changes: 2 additions & 2 deletions dev/defs/assets/layered_asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"int": 119,
"string": "layeredasset"
},
"runtime": false,
"extends": "assets/drawable_asset.json"
"extends": "assets/drawable_asset.json",
"runtime": false
}
2 changes: 1 addition & 1 deletion dev/defs/nested_animation.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"string": "nestedanimation"
},
"abstract": true,
"extends": "component.json",
"extends": "container_component.json",
"properties": {
"animationId": {
"type": "Id",
Expand Down
15 changes: 15 additions & 0 deletions include/rive/animation/listener_action.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef _RIVE_LISTENER_ACTION_HPP_
#define _RIVE_LISTENER_ACTION_HPP_
#include "rive/generated/animation/listener_action_base.hpp"
#include "rive/math/vec2d.hpp"

namespace rive {
class StateMachineInstance;
class ListenerAction : public ListenerActionBase {
public:
StatusCode import(ImportStack& importStack) override;
virtual void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const = 0;
};
} // namespace rive

#endif
12 changes: 12 additions & 0 deletions include/rive/animation/listener_align_target.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef _RIVE_LISTENER_ALIGN_TARGET_HPP_
#define _RIVE_LISTENER_ALIGN_TARGET_HPP_
#include "rive/generated/animation/listener_align_target_base.hpp"
#include <stdio.h>
namespace rive {
class ListenerAlignTarget : public ListenerAlignTargetBase {
public:
void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
};
} // namespace rive

#endif
2 changes: 1 addition & 1 deletion include/rive/animation/listener_bool_change.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace rive {
class ListenerBoolChange : public ListenerBoolChangeBase {
public:
bool validateInputType(const StateMachineInput* input) const override;
void perform(StateMachineInstance* stateMachineInstance) const override;
void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
};
} // namespace rive

Expand Down
2 changes: 0 additions & 2 deletions include/rive/animation/listener_input_change.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
#include "rive/generated/animation/listener_input_change_base.hpp"

namespace rive {
class StateMachineInstance;
class StateMachineInput;
class ListenerInputChange : public ListenerInputChangeBase {
public:
StatusCode import(ImportStack& importStack) override;
virtual void perform(StateMachineInstance* stateMachineInstance) const = 0;
virtual bool validateInputType(const StateMachineInput* input) const { return true; }
};
} // namespace rive
Expand Down
2 changes: 1 addition & 1 deletion include/rive/animation/listener_number_change.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace rive {
class ListenerNumberChange : public ListenerNumberChangeBase {
public:
bool validateInputType(const StateMachineInput* input) const override;
void perform(StateMachineInstance* stateMachineInstance) const override;
void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
};
} // namespace rive

Expand Down
2 changes: 1 addition & 1 deletion include/rive/animation/listener_trigger_change.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace rive {
class ListenerTriggerChange : public ListenerTriggerChangeBase {
public:
bool validateInputType(const StateMachineInput* input) const override;
void perform(StateMachineInstance* stateMachineInstance) const override;
void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
};
} // namespace rive

Expand Down
11 changes: 11 additions & 0 deletions include/rive/animation/nested_bool.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef _RIVE_NESTED_BOOL_HPP_
#define _RIVE_NESTED_BOOL_HPP_
#include "rive/generated/animation/nested_bool_base.hpp"
#include <stdio.h>
namespace rive {
class NestedBool : public NestedBoolBase {
public:
};
} // namespace rive

#endif
11 changes: 11 additions & 0 deletions include/rive/animation/nested_input.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef _RIVE_NESTED_INPUT_HPP_
#define _RIVE_NESTED_INPUT_HPP_
#include "rive/generated/animation/nested_input_base.hpp"
#include <stdio.h>
namespace rive {
class NestedInput : public NestedInputBase {
public:
};
} // namespace rive

#endif
11 changes: 11 additions & 0 deletions include/rive/animation/nested_number.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef _RIVE_NESTED_NUMBER_HPP_
#define _RIVE_NESTED_NUMBER_HPP_
#include "rive/generated/animation/nested_number_base.hpp"
#include <stdio.h>
namespace rive {
class NestedNumber : public NestedNumberBase {
public:
};
} // namespace rive

#endif
11 changes: 11 additions & 0 deletions include/rive/animation/nested_trigger.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef _RIVE_NESTED_TRIGGER_HPP_
#define _RIVE_NESTED_TRIGGER_HPP_
#include "rive/generated/animation/nested_trigger_base.hpp"
#include <stdio.h>
namespace rive {
class NestedTrigger : public NestedTriggerBase {
public:
};
} // namespace rive

#endif
6 changes: 5 additions & 1 deletion include/rive/animation/state_machine_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace rive {

/// 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);
void updateListeners(Vec2D position, ListenerType hitListener);

template <typename SMType, typename InstType>
InstType* getNamedInput(const std::string& name) const;
Expand Down Expand Up @@ -85,6 +85,10 @@ namespace rive {
float durationSeconds() const override { return -1; }
Loop loop() const override { return Loop::oneShot; }
bool isTranslucent() const override { return true; }

/// Allow anything referencing a concrete StateMachineInstace access to
/// the backing artboard (explicitly not allowed on Scenes).
Artboard* artboard() { return m_ArtboardInstance; }
};
} // namespace rive
#endif
14 changes: 8 additions & 6 deletions include/rive/animation/state_machine_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@
#define _RIVE_STATE_MACHINE_LISTENER_HPP_
#include "rive/generated/animation/state_machine_listener_base.hpp"
#include "rive/listener_type.hpp"
#include "rive/math/vec2d.hpp"

namespace rive {
class Shape;
class StateMachineListenerImporter;
class ListenerInputChange;
class ListenerAction;
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);
std::vector<ListenerAction*> m_Actions;
void addAction(ListenerAction* action);

public:
ListenerType listenerType() const { return (ListenerType)listenerTypeValue(); }
size_t inputChangeCount() const { return m_InputChanges.size(); }
const ListenerInputChange* inputChange(size_t index) const;
size_t actionCount() const { return m_Actions.size(); }

const ListenerAction* action(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;
void performChanges(StateMachineInstance* stateMachineInstance, Vec2D position) const;
};
} // namespace rive

Expand Down
Loading