diff --git a/example/bin/data/ofxpimapper.xml b/example/bin/data/ofxpimapper.xml
index 84bd5b4..05362c2 100644
--- a/example/bin/data/ofxpimapper.xml
+++ b/example/bin/data/ofxpimapper.xml
@@ -81,10 +81,11 @@
1920
1080
- 0.5
+ 1
PING-PONG
+
FitProportionally
diff --git a/example/src/magSlide.cpp b/example/src/magSlide.cpp
index 95e94c9..1e50653 100644
--- a/example/src/magSlide.cpp
+++ b/example/src/magSlide.cpp
@@ -21,6 +21,7 @@ magSlide::magSlide(std::string type)
void magSlide::update(u_int64_t deltaTime)
{
+ transition->update(deltaTime);
runningTime += deltaTime;
switch (slideState)
@@ -37,11 +38,6 @@ void magSlide::update(u_int64_t deltaTime)
if (runningTime >= buildOutStartTime)
{
setState(BuildOut);
- if (buildOut != nullptr)
- {
- activeTransition = buildOut;
- activeTransition->start();
- }
}
break;
@@ -49,7 +45,6 @@ void magSlide::update(u_int64_t deltaTime)
if (runningTime >= endTime)
{
setState(Complete);
- activeTransition = nullptr;
}
break;
}
@@ -137,6 +132,10 @@ void magSlide::start(u_int64_t startTime)
void magSlide::draw()
{
ofSetColor(255, opacity);
+ if(transition->isActive())
+ {
+ transition->draw();
+ }
}
diff --git a/example/src/magSlide.h b/example/src/magSlide.h
index c0aafb5..74e1b2c 100644
--- a/example/src/magSlide.h
+++ b/example/src/magSlide.h
@@ -115,6 +115,7 @@ public:
* @param tDuration in milliseconds.
*/
void setTransitionDuration(u_int64_t tDuration);
+
ResizeOptions getResizeOption() const;
void setResizeOption(ResizeOptions resizeOption);
@@ -145,14 +146,39 @@ protected:
float width;
float height;
ofPoint position;
+public:
+ const ofPoint &getPosition() const
+ {
+ return position;
+ }
+
+ void setPosition(const ofPoint &position)
+ {
+ magSlide::position = position;
+ }
+
+ void setPosition(float x, float y)
+ {
+ position.set(x, y);
+ }
+
+
+protected:
float opacity = 255;
ResizeOptions resizeOption = NoResize;
SlideState slideState = Off;
bool isComplete = false;
// std::shared_ptr buildIn = nullptr;
- std::shared_ptr buildOut = nullptr;
- std::shared_ptr activeTransition = nullptr;
+// std::shared_ptr buildOut = nullptr;
+ std::shared_ptr transition = nullptr;
+public:
+ const shared_ptr &getTransition() const
+ {
+ return transition;
+ }
+
+protected:
/**
* The duration of the slide in millis, not counting builds
*/
diff --git a/example/src/magSlideShowSource.cpp b/example/src/magSlideShowSource.cpp
index 6d1bd52..1856f6a 100644
--- a/example/src/magSlideShowSource.cpp
+++ b/example/src/magSlideShowSource.cpp
@@ -73,10 +73,6 @@ void magSlideShowSource::update()
for (auto &slide : activeSlides)
{
- if (slide->activeTransition)
- {
- slide->activeTransition->update(deltaTime);
- }
slide->update(deltaTime);
}
@@ -112,10 +108,6 @@ void magSlideShowSource::draw()
ofSetColor(255, 255);
for (auto &slide : activeSlides)
{
- if (slide->activeTransition)
- {
- slide->activeTransition->draw();
- }
slide->draw();
}
ofPopStyle();
@@ -276,7 +268,6 @@ bool magSlideShowSource::loadFromXml()
initialize(settings);
return true;
-
}
void magSlideShowSource::addSlide(std::shared_ptr slide)
@@ -345,7 +336,7 @@ void magSlideShowSource::addSlide(std::shared_ptr slide)
// slide,
// bogusParamGroup,
// slide->buildInDuration);
- slide->buildOut = tf->createTransition(settings.transitionName,
+ slide->transition = tf->createTransition(settings.transitionName,
slide,
bogusParamGroup,
slide->buildOutDuration);
@@ -475,9 +466,6 @@ void magSlideShowSource::enqueueSlide(std::shared_ptr slide, u_int64_t
{
// ofLogVerbose() << "Enqueuing slide " << currentSlideIndex << " slide id: " << slide->getId();
slide->start(startTime);
- if (activeSlides.size() > 1)
- {
- }
activeSlides.insert(activeSlides.begin(), slide);
}
@@ -489,7 +477,13 @@ void magSlideShowSource::slideStateChanged(const void *sender, ofEventArgs &args
// << slide->getSlideStateName();
if (slide->getSlideState() == magSlide::SlideState::BuildOut)
{
+// slide->transition->start();
+// ofLogVerbose() << "BuildOut " << slide->getId();
playNextSlide();
+ if (activeSlides.size() > 1)
+ {
+ activeSlides[1]->transition->start(activeSlides[0]);
+ }
}
}
diff --git a/example/src/magSlideTransition.cpp b/example/src/magSlideTransition.cpp
index 1a2d992..6c4c9ac 100644
--- a/example/src/magSlideTransition.cpp
+++ b/example/src/magSlideTransition.cpp
@@ -6,22 +6,26 @@
#include "magSlideTransition.h"
-void magSlideTransition::start()
+void magSlideTransition::start(std::shared_ptr nextSlide)
{
runningTime = 0;
- isActive = true;
+ active = true;
+ this->nextSlide = nextSlide;
}
void magSlideTransition::update(u_int64_t timeDelta)
{
- if (!isActive) return;
+ if (!active) return;
runningTime += timeDelta;
if (runningTime >= duration)
{
ofEventArgs arghh; // arghhhh...
+ nextSlide->setOpacity(255);
+ nextSlide->setPosition(0, 0);
+ end();
transitionCompleteEvent.notify(this, arghh);
- isActive = false;
+ active = false;
}
}
@@ -36,20 +40,21 @@ float magSlideTransition::getNormalizedTime()
return (double)runningTime / (double)duration;
}
-void magFadeInTransition::draw()
+
+void magDissolveTransition::draw()
{
- ofLogVerbose() << "fade in draw";
- ofSetColor(255, getNormalizedTime() * 255);
+ slide->setOpacity(255 - (getNormalizedTime() * 255));
+ nextSlide->setOpacity(getNormalizedTime()*255);
}
-void magFadeOutTransition::draw()
+void magDissolveTransition::start(std::shared_ptr nextSlide)
{
- magSlideTransition::draw();
-
+ magSlideTransition::start(nextSlide);
+ nextSlide->setOpacity(0);
}
-void magDissolveTransition::draw()
+void magDissolveTransition::end()
{
- slide->setOpacity(255 - (getNormalizedTime() * 255));
- ofLogVerbose("opacity") << slide->getId() << " " << slide->getOpacity();
+ nextSlide->setOpacity(255);
+ slide->setOpacity(0);
}
diff --git a/example/src/magSlideTransition.h b/example/src/magSlideTransition.h
index 896b267..13ba424 100644
--- a/example/src/magSlideTransition.h
+++ b/example/src/magSlideTransition.h
@@ -19,11 +19,12 @@ public:
* Begins the transition. This must be called in order for the
* transition to actually do anything!
*/
- void start();
+ virtual void start(std::shared_ptr nextSlide);
+ virtual void end(){}
virtual void loadSettings(ofParameterGroup &settings){}
virtual void update(u_int64_t timeDelta);
virtual void draw(){
- ofLogVerbose() << "transiwiton draw " << getNormalizedTime();
+ ofLogNotice("magSlideTransition") << "transition draw - this should be overriden " << getNormalizedTime();
}
/**
@@ -44,40 +45,37 @@ public:
return name;
}
+ const shared_ptr &getNextSlide() const
+ {
+ return nextSlide;
+ }
+
+ void setNextSlide(shared_ptr nextSlide)
+ {
+ magSlideTransition::nextSlide = nextSlide;
+ }
+
+ bool isActive() const
+ {
+ return active;
+ }
+
ofEvent transitionCompleteEvent;
protected:
std::string name = "Void";
std::shared_ptr slide;
std::shared_ptr nextSlide;
+
u_int64_t runningTime;
u_int64_t duration;
u_int64_t endTime;
- bool isActive = false;
-
- friend class magSlideTransitionFactory;
-};
+ bool active = false;
-class magFadeInTransition : public magSlideTransition
-{
-public:
- magFadeInTransition()
- {
- name = "FadeIn";
- }
- void draw() override ;
-};
-
-class magFadeOutTransition : public magSlideTransition
-{
-public:
- magFadeOutTransition()
- {
- name = "FadeOut";
- }
+protected:
- void draw() override ;
+ friend class magSlideTransitionFactory;
};
class magDissolveTransition : public magSlideTransition
@@ -88,7 +86,10 @@ public:
name = "Dissolve";
}
+ void start(std::shared_ptr nextSlide) override;
+
void draw() override;
+ void end() override;
};
#endif