From 6f74f80e4c116c61b4734ffbae86aff881daaf5b Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sat, 26 Apr 2014 18:20:21 +0100 Subject: started GLFW version --- le_new/src/playlist.cpp | 127 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100755 le_new/src/playlist.cpp (limited to 'le_new/src/playlist.cpp') diff --git a/le_new/src/playlist.cpp b/le_new/src/playlist.cpp new file mode 100755 index 0000000..ce3beba --- /dev/null +++ b/le_new/src/playlist.cpp @@ -0,0 +1,127 @@ +#include "playlist.h" + +playlist::playlist() +{ + name=""; + thumbnail.allocate(128,128,GL_RGB); + thumbnailed=false; +} + +void playlist::load(string _name){ + //printf("loading %s\n",_name.c_str()); + + + if( !XML.loadFile(_name) ){ + printf("unable to load %s check data/ folder\n",_name.c_str()); + }else { + //printf("starting loader thread\n"); + loadimg(); //how to do this from the worker thread??? + startThread(false, false); //blocking, verbose + } + + + +} + +void playlist::threadedFunction(){ + if( lock() ){ + loadLayers(); + unlock(); + printf("unlocking thread\n"); + } +} + +void playlist::loadLayers(){ + int numLayers=0; + layers.clear(); + name=XML.getAttribute("playlist", "name", ""); + float speed=XML.getAttribute("playlist", "speed", 0); + if(XML.pushTag("playlist")) { + numLayers=XML.getNumTags("svglayer"); + if(numLayers) { + for (int i=0;inote) { + for (int j=note+1;jnote) { + for (int j=note+1;j<=endnote;j++) { + layers[j]=layers[note]; + } + } + } + thumbnailed=false; + } + XML.popTag(); + } + +} + +void playlist::makeThumbnail(){ + if (layers.size()) { + thumbnail.begin(); + ofBackground(0,0,0); + ofPushMatrix(); + ofTranslate(64,64); + ofScale(0.2,0.2,0.2); + ofTranslate(-64,-64); + map::iterator i=layers.begin(); + i->second->draw(1.0,64,64,0.0); + ofPopMatrix(); + thumbnail.end(); + thumbnailed=true; + } +} + + +void playlist::loadimg(){ + int numLayers=0; + layers.clear(); + if(XML.pushTag("playlist")) { + numLayers=XML.getNumTags("imglayer"); + if(numLayers) { + for (int i=0;i