Lumiverse  2.5
A framework for creating lighting control applications
Keyframe.h
1 #ifndef _KEYFRAME_H_
2 #define _KEYFRAME_H_
3 
4 #pragma once
5 
6 #include "LumiverseCore.h"
7 
8 namespace Lumiverse {
9 namespace ShowControl {
10 
17 struct Keyframe {
23  size_t t;
24 
28  shared_ptr<Lumiverse::LumiverseType> val;
29 
36 
40  string timelineID;
41 
46 
47  // Planned interpolation mode selection here. Additional parameters probably needed
48  // once this thing gets activated
49  // enum interpMode
50 
51  bool operator<(Keyframe other) const {
52  return t < other.t;
53  }
54 
56  Keyframe() { }
57 
64  Keyframe(size_t time, shared_ptr<Lumiverse::LumiverseType> v, bool upv) :
65  t(time), val(v), useCurrentState(upv) { }
66 
75  Keyframe(size_t time, string id, size_t offset) :
76  t(time), timelineID(id), timelineOffset(offset) { }
77 
81  Keyframe(size_t time) : t(time) { }
82 
84  Keyframe(JSONNode node);
85 
87  JSONNode toJSON();
88 };
89 
101 class Event {
102 public:
103  Event(function<void()> cb, string id = "");
104 
110  Event(JSONNode node);
111 
112  virtual ~Event();
113 
119  virtual void execute();
120 
127  virtual void reset();
128 
133  virtual void setCallback(function<void()> cb);
134 
138  string _id;
139 
143  virtual string getType() { return "event"; }
144 
148  virtual JSONNode toJSON();
149 
150 private:
154  function<void()> _callback;
155 };
156 
157 }
158 }
159 #endif
Include file for all of LumiverseCore in one conveninent location.
string _id
Optional identifier to make it easier to delete and find Events.
Definition: Keyframe.h:138
virtual JSONNode toJSON()
While this object may not be able to serialize itself, other Event types may be able to...
Definition: Keyframe.cpp:90
function< void()> _callback
Callback function to execute when the Event is encountered.
Definition: Keyframe.h:154
Events are special keyframes that call other functions when encountered.
Definition: Keyframe.h:101
size_t t
Time at which this keyframe is located. t=0 is start of timeline.
Definition: Keyframe.h:23
virtual void setCallback(function< void()> cb)
Changes the callback function.
Definition: Keyframe.cpp:86
string timelineID
If not blank, this keyframe pulls its value from the given keyframe at the given offset.
Definition: Keyframe.h:40
virtual void execute()
Executes the event.
Definition: Keyframe.cpp:78
size_t timelineOffset
Start time for the Timeline referenced by timelineID.
Definition: Keyframe.h:45
A Keyframe stores the value of a parameter at the specified time.
Definition: Keyframe.h:17
Keyframe(size_t time, shared_ptr< Lumiverse::LumiverseType > v, bool upv)
Constructor with all values filled in.
Definition: Keyframe.h:64
virtual string getType()
Returns the typename of this Event.
Definition: Keyframe.h:143
bool useCurrentState
If true, the value of this keyframe will be pulled from the state of the layer when playback starts...
Definition: Keyframe.h:35
shared_ptr< Lumiverse::LumiverseType > val
Value of the keyframe at time t.
Definition: Keyframe.h:28
Keyframe(size_t time)
Constructor creates a blank keyframe at specified time.
Definition: Keyframe.h:81
virtual void reset()
If there are any things that need to be reset when the Timeline starts, this function will do that...
Definition: Keyframe.cpp:82
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
JSONNode toJSON()
Returns the JSON representation of this keyframe.
Definition: Keyframe.cpp:49
Keyframe()
Empty constructor.
Definition: Keyframe.h:56
Keyframe(size_t time, string id, size_t offset)
Constructs a nested Timeline Keyframe.
Definition: Keyframe.h:75