diff options
| author | Tim Redfern <tim@getdrop.com> | 2017-08-31 00:34:32 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2017-08-31 00:34:32 +0100 |
| commit | b0d54aadaf9dfb3b2f14974f55b3a725619ea445 (patch) | |
| tree | ad882b21f92f3124cb0713494d15fbc4614ecfc7 /gui/src/chainImage.cpp | |
| parent | 52f12dfc10edfc4dd063b610f65dd2e901d3080c (diff) | |
correct window scale
Diffstat (limited to 'gui/src/chainImage.cpp')
| -rw-r--r-- | gui/src/chainImage.cpp | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/gui/src/chainImage.cpp b/gui/src/chainImage.cpp index 67fbad6..643bb2e 100644 --- a/gui/src/chainImage.cpp +++ b/gui/src/chainImage.cpp @@ -47,15 +47,15 @@ float chainImage::getScale(){ void chainImage::makeThumbnail(){ thumbnail=(const ofImage)*this; //copy the ofImage itself - float thumbheight=ofGetHeight()*THUMB_BORDER_RATIO; + float thumbheight=THUMB_SIZE; //ofGetWindowHeight()*THUMB_BORDER_RATIO; float thumbwidth=(thumbnail.getWidth()/thumbnail.getHeight())*thumbheight; - float borderwidth=ofGetHeight()*(1.0-THUMB_BORDER_RATIO)*0.5; + float borderwidth=ofGetWindowHeight()*(1.0-THUMB_BORDER_RATIO)*0.5; printf("Rescaling: %fx%f to %fx%f for screen %fx%f, border %f\n", thumbnail.getWidth(),thumbnail.getHeight(), thumbwidth,thumbheight, - (float)ofGetWidth(),(float)ofGetHeight(), + (float)ofGetWindowWidth(),(float)ofGetWindowHeight(), borderwidth); thumbnail.resize(thumbwidth,thumbheight); @@ -71,6 +71,8 @@ void chainImage::drawChain(float fadeIn){ ofSetColor(255,255,255,255); + setAnchorPoint(getWidth()/2,getHeight()/2); + draw(0,0,getWidth(),getHeight()); glTranslatef(linkPos.x,linkPos.y,0); @@ -81,6 +83,8 @@ void chainImage::drawChain(float fadeIn){ ofSetColor(255,255,255,255*min(1.0,transition/fadeIn)); + link->setAnchorPoint(link->getWidth()/2,link->getHeight()/2); + link->draw(0,0,link->getWidth(),link->getHeight()); glPopMatrix(); @@ -107,9 +111,42 @@ bool chainImage::fromJson(Json::Value json){ return false; } +void chainImageSet::drawOutput(){ + + float camera_throw= (float)outputSize.y/(float)outputSize.x; //the ratio of z distance to x width + + if (images.size()){ + + glMatrixMode ( GL_MODELVIEW ); + glLoadIdentity ( ); + gluLookAt( currentImage->getTransform().x, + currentImage->getTransform().y, // i1.linkPos.y+(xform.y*intervalpoint), + currentImage->getWidth()*camera_throw*currentImage->getScale(), + currentImage->getTransform().x, + currentImage->getTransform().y, // i1.linkPos.y+(xform.y*intervalpoint), + 0, + 0,1,0); + + currentImage->drawChain(); + + } + +} + void chainImageSet::drawGui(){ + + ofBackground(0,0,0); + float t_xoffs=0.0; - float borderwidth=ofGetHeight()*(1.0-THUMB_BORDER_RATIO)*0.5; + 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); + //scale view by distance betweeen thumnail size and window size: doesn't work + */ //draw each image, outlined @@ -210,7 +247,9 @@ void chainImageSet::drawGui(){ } - t_xoffs+=ii->thumbnail.getWidth()+(borderwidth*2) ; + t_xoffs+=ii->thumbnail.getWidth()+(borderwidth*2); + + //glPopMatrix(); } } @@ -249,6 +288,8 @@ if not make a symbolic link } else { selected=images.begin(); + currentImage=&(*images.begin()); + currentImage->start(); } @@ -334,7 +375,7 @@ void chainImageSet::keyPressed(ofKeyEventArgs &keyargs){ void chainImageSet::mouseDragged(int x, int y, int button){ switch (button){ case OF_MOUSE_BUTTON_1: - dragPoint=ofPoint(x-clickPoint.x,y-clickPoint.y)*(selected->getHeight()/ofGetHeight()); + dragPoint=ofPoint(x-clickPoint.x,y-clickPoint.y)*(selected->getHeight()/ofGetWindowHeight()); break; case OF_MOUSE_BUTTON_2: //alt-click @@ -402,6 +443,8 @@ bool chainImageSet::loadJson(std::string _filename){ } selected=images.begin(); + currentImage=&(*images.begin()); + currentImage->start(); filename=_filename; return true; @@ -410,7 +453,17 @@ bool chainImageSet::loadJson(std::string _filename){ ofLogVerbose("JSON load: parsing unsuccesful\n"); return false; } - - + +void chainImageSet::update(){ + float decay_factor=0.995; + if (images.size()){ + if (currentImage->update(decay_factor)){ //if returns true, switch images + currentImage=currentImage->link; + currentImage->start(); + ofLogNotice() << "Switched images"; + currentImage->update(decay_factor); + } + } +} |
