mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Milestone in SourceCallbacks and Keyboard callback trigger
Updated SourceCallback class to accept cloning, reversing, and visitors for saving./loading. New mechanism in Source to listen to key triggers for launching SourceCallbacks. Saving and loading in SessionVisitor and SessionCreator.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "Primitives.h"
|
||||
#include "Mesh.h"
|
||||
#include "Source.h"
|
||||
#include "SourceCallback.h"
|
||||
#include "CloneSource.h"
|
||||
#include "MediaSource.h"
|
||||
#include "SessionSource.h"
|
||||
@@ -899,6 +900,50 @@ void SessionLoader::visit (Source& s)
|
||||
groups_sources_id_.push_back(idlist);
|
||||
}
|
||||
|
||||
XMLElement* callbacksNode = sourceNode->FirstChildElement("Callbacks");
|
||||
if (callbacksNode) {
|
||||
// Loop over 'Callback' nodes
|
||||
xmlCurrent_ = callbacksNode->FirstChildElement("Callback");
|
||||
for ( ; xmlCurrent_ ; xmlCurrent_ = xmlCurrent_->NextSiblingElement()) {
|
||||
// what key triggers the callback ?
|
||||
int key = 0;
|
||||
xmlCurrent_->QueryIntAttribute("key", &key);
|
||||
// what type is the callback ?
|
||||
uint type = 0;
|
||||
xmlCurrent_->QueryUnsignedAttribute("type", &type);
|
||||
// instanciate the callback of that type
|
||||
SourceCallback *loadedcallback = nullptr;
|
||||
switch (type) {
|
||||
case SourceCallback::CALLBACK_ALPHA:
|
||||
loadedcallback = new GotoAlpha;
|
||||
break;
|
||||
case SourceCallback::CALLBACK_LOOM:
|
||||
loadedcallback = new Loom;
|
||||
break;
|
||||
case SourceCallback::CALLBACK_DEPTH:
|
||||
loadedcallback = new GotoDepth;
|
||||
break;
|
||||
case SourceCallback::CALLBACK_GRAB:
|
||||
loadedcallback = new Grab;
|
||||
break;
|
||||
case SourceCallback::CALLBACK_RESIZE:
|
||||
loadedcallback = new Resize;
|
||||
break;
|
||||
case SourceCallback::CALLBACK_TURN:
|
||||
loadedcallback = new Turn;
|
||||
break;
|
||||
}
|
||||
// successfully created a callback of saved type
|
||||
if (loadedcallback) {
|
||||
// apply specific parameters
|
||||
loadedcallback->accept(*this);
|
||||
// add callback to source
|
||||
s.setKeyCallback(key, loadedcallback);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// restore current
|
||||
xmlCurrent_ = sourceNode;
|
||||
}
|
||||
@@ -1121,3 +1166,74 @@ void SessionLoader::visit (CloneSource& s)
|
||||
s.setDelay(d);
|
||||
}
|
||||
|
||||
|
||||
void SessionLoader::visit (SourceCallback &)
|
||||
{
|
||||
}
|
||||
|
||||
void SessionLoader::visit (GotoAlpha &c)
|
||||
{
|
||||
float a = 0.f;
|
||||
xmlCurrent_->QueryFloatAttribute("alpha", &a);
|
||||
c.setAlpha(a);
|
||||
}
|
||||
|
||||
void SessionLoader::visit (GotoDepth &c)
|
||||
{
|
||||
float d = 0.f;
|
||||
xmlCurrent_->QueryFloatAttribute("depth", &d);
|
||||
c.setDepth(d);
|
||||
|
||||
d = 0.f;
|
||||
xmlCurrent_->QueryFloatAttribute("duration", &d);
|
||||
c.setDuration(d);
|
||||
}
|
||||
|
||||
void SessionLoader::visit (Loom &c)
|
||||
{
|
||||
float d = 0.f;
|
||||
xmlCurrent_->QueryFloatAttribute("delta", &d);
|
||||
c.setDelta(d);
|
||||
|
||||
d = 0.f;
|
||||
xmlCurrent_->QueryFloatAttribute("duration", &d);
|
||||
c.setDuration(d);
|
||||
}
|
||||
|
||||
void SessionLoader::visit (Grab &c)
|
||||
{
|
||||
float dx = 0.f, dy = 0.f;
|
||||
xmlCurrent_->QueryFloatAttribute("delta.x", &dx);
|
||||
xmlCurrent_->QueryFloatAttribute("delta.y", &dy);
|
||||
c.setDelta( glm::vec2(dx, dy) );
|
||||
|
||||
float d = 0.f;
|
||||
xmlCurrent_->QueryFloatAttribute("duration", &d);
|
||||
c.setDuration(d);
|
||||
}
|
||||
|
||||
void SessionLoader::visit (Resize &c)
|
||||
{
|
||||
float dx = 0.f, dy = 0.f;
|
||||
xmlCurrent_->QueryFloatAttribute("delta.x", &dx);
|
||||
xmlCurrent_->QueryFloatAttribute("delta.y", &dy);
|
||||
c.setDelta( glm::vec2(dx, dy) );
|
||||
|
||||
float d = 0.f;
|
||||
xmlCurrent_->QueryFloatAttribute("duration", &d);
|
||||
c.setDuration(d);
|
||||
}
|
||||
|
||||
void SessionLoader::visit (Turn &c)
|
||||
{
|
||||
float d = 0.f;
|
||||
xmlCurrent_->QueryFloatAttribute("delta", &d);
|
||||
c.setDelta(d);
|
||||
|
||||
d = 0.f;
|
||||
xmlCurrent_->QueryFloatAttribute("duration", &d);
|
||||
c.setDuration(d);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user