summaryrefslogtreecommitdiff
path: root/gui/src/chainImage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src/chainImage.cpp')
-rw-r--r--gui/src/chainImage.cpp76
1 files changed, 51 insertions, 25 deletions
diff --git a/gui/src/chainImage.cpp b/gui/src/chainImage.cpp
index 275b107..6fdca96 100644
--- a/gui/src/chainImage.cpp
+++ b/gui/src/chainImage.cpp
@@ -14,13 +14,17 @@ void chainImage::init(ofPoint _linkPos,float _linkScale,float _linkRot){
setAnchorPercent(0.5,0.5);
}
-void chainImage::start(){
- transition=0.0f;
+void chainImage::start(bool reverse=false){
+ transition=reverse?1.0f:0.0f;
time=ofGetElapsedTimef();
setUseTexture(true);
- scale=linkScale;
+ scale=reverse?linkScale*link->linkScale:linkScale;
- //where there is rotation of the link, the path needs to be rotated?
+}
+
+int chainImage::update(float decayRatio){
+
+ //where there is rotation of the link, the path needs to be rotated
path.clear();
@@ -41,10 +45,7 @@ void chainImage::start(){
destination.x,destination.y);
//totalframes=log(1.0f/256)/log(decayRatio);
- //framecount=0;
-}
-bool chainImage::update(float decayRatio){
scale*=decayRatio;
@@ -62,12 +63,16 @@ bool chainImage::update(float decayRatio){
//transition=min(1.0f,((float)framecount)/totalframes);
-
- if (scale>linkScale*link->linkScale) return false;
- else {
- transition = 1.0f;
- return true;
+ if (scale>linkScale){
+ transition = 0.0f;
+ return SWITCH_REVERSE;
+ }
+ if (scale>linkScale*link->linkScale){
+ return SWITCH_NONE;
}
+ transition = 1.0f;
+ return SWITCH_FORWARD;
+
}
ofVec3f chainImage::getTransform(){
@@ -188,7 +193,7 @@ void chainImageSet::drawOutput(){
float camera_throw= (float)outputSize.y/(float)outputSize.x; //the ratio of z distance to x width
- camera_throw*=0.9; //fudge factor to allow tweening
+ camera_throw*=fitFactor; //fudge factor to allow tweening
if (images.size()){
@@ -216,15 +221,15 @@ void chainImageSet::drawOutput(){
}
-void chainImageSet::drawGui(){
-
- ofBackground(0,0,0);
+void chainImageSet::drawGui(int x,int y){
float t_xoffs=0.0;
float borderwidth=THUMB_SIZE*0.1; //ofGetWindowHeight()*(1.0-THUMB_BORDER_RATIO)*0.5;
glPushMatrix();
+
+
/*
float relscale=((float)ofGetWindowHeight())/THUMB_SIZE;
glScalef(relscale,relscale,relscale);
@@ -241,7 +246,9 @@ void chainImageSet::drawGui(){
float thumby=ii->thumbnail.getHeight()/2;
float thumbscale=ii->thumbnail.getWidth()/ii->getWidth();
+ glPushMatrix();
+ glTranslatef(x,y,0);
//why do I have to set this every time??
ii->thumbnail.setAnchorPercent(0.5,0.5);
@@ -252,8 +259,9 @@ void chainImageSet::drawGui(){
ii->thumbnail.getHeight()
);
+ ofSetColor(255,255,255);
if (ii==selected) ofSetColor(255,0,0);
- else ofSetColor(255,255,255);
+ if (&(*ii)==currentImage) ofSetColor(0,255,0);
ofDrawLine(t_xoffs+borderwidth,borderwidth,
t_xoffs+borderwidth+ii->thumbnail.getWidth(),borderwidth);
@@ -332,7 +340,7 @@ void chainImageSet::drawGui(){
t_xoffs+=ii->thumbnail.getWidth()+(borderwidth*2);
- //glPopMatrix();
+ glPopMatrix();
}
}
@@ -561,13 +569,31 @@ bool chainImageSet::loadJson(std::string _filename){
void chainImageSet::update(){
- if (images.size()){
- if (currentImage->update(decayFactor)){ //if returns true, switch images
- currentImage=currentImage->link;
- currentImage->start();
- ofLogNotice() << "Switched images";
- currentImage->update(decayFactor);
- }
+ if (images.size()){
+ int switchResponse=currentImage->update(decayFactor);
+ switch(switchResponse){
+ case SWITCH_FORWARD:{
+ currentImage=currentImage->link;
+ currentImage->start();
+ ofLogNotice() << "Switched images forward";
+ currentImage->update(decayFactor);
+ break;
+ }
+ case SWITCH_NONE:
+ break;
+ case SWITCH_REVERSE:{
+ for (auto ii=images.begin();ii!=images.end();++ii){
+ if (ii->link->filename==currentImage->filename){
+ currentImage=&(*ii);
+ currentImage->start(true);
+ ofLogNotice() << "Switched images reverse";
+ currentImage->update(decayFactor);
+ break;
+ }
+ }
+ break;
+ }
+ }
}
}