1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#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() ){
loadsvg();
unlock();
}
}
void playlist::loadsvg(){
int numLayers=0;
layers.clear();
name=XML.getAttribute("playlist", "name", "");
if(XML.pushTag("playlist")) {
numLayers=XML.getNumTags("svglayer");
if(numLayers) {
for (int i=0;i<numLayers;i++) {
string s=XML.getAttribute("svglayer", "file", "",i);
printf("loading %s: ",s.c_str());
layers[XML.getAttribute("svglayer", "note", 0,i)]=new svglayer(XML.getAttribute("svglayer", "file", "",i));
}
thumbnailed=false;
}
else printf("no SVG layers loaded!\n");
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<int,layer*>::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<numLayers;i++) {
string s=XML.getAttribute("imglayer", "file", "",i);
printf("%s: ",s.c_str());
layers[XML.getAttribute("imglayer", "note", 0,i)]=new imglayer(XML.getAttribute("imglayer", "file", "",i));
}
}
else printf("no IMG layers loaded!\n");
XML.popTag();
}
}
playlist::~playlist()
{
//dtor
}
|