Skip to content

Commit

Permalink
Don't fade out unless there is another image to fade to.
Browse files Browse the repository at this point in the history
If no images loaded the slideshow will now be skipped.
  • Loading branch information
acaudwell committed Jan 15, 2010
1 parent db59a9e commit c4c6931
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/apps/slideapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ void SlideShow::logic(float t, float dt) {
elapsed = 0.0;
}

if(elapsed >= duration) {
//dont fade out if only one image
if(elapsed >= duration && images.size()>1) {
alpha = std::max(0.0f, alpha - dt);
} else {
alpha = std::min(1.0f, alpha + dt);
elapsed += dt;
}

}

vec2f SlideShow::getAspectRatio() {
Expand Down Expand Up @@ -176,6 +178,8 @@ void SlideShowApp::init() {
app = new SlideShow(duration);
app->init();

int image_count = 0;

if(imagedir.size()) {
//append slash
if(imagedir[imagedir.size()-1] != '/') {
Expand Down Expand Up @@ -203,11 +207,12 @@ void SlideShowApp::init() {
std::string imagefile = imagedir + dirfile;

((SlideShow*)app)->addImageFile(imagefile);
image_count++;
}

closedir(dp);
}

ready=true;
if(image_count>0) ready=true;
}

0 comments on commit c4c6931

Please sign in to comment.