-
Notifications
You must be signed in to change notification settings - Fork 1
/
GuiEvents.pde
210 lines (193 loc) · 7.61 KB
/
GuiEvents.pde
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
void controlEvent(ControlEvent event){
if(event.isGroup()){
// println(event.getGroup().getName()+" is Group");
/////////////////////////////////////////////////Clip Events
if(event.isFrom("clipList")){
if(!event.getGroup().isOpen()){
fill(20);
rect(0,0,500,300);
}
}
else if(event.isFrom("Clip_LectureMode")){
editClip.lectureMode = (int)event.getGroup().getValue();
if(editClip.lectureMode == 0 && editClip.movie != null) editClip.movie.loop();
// println("editClip.lectureMode: "+editClip.lectureMode);
}
else if(event.isFrom("Clip_Effect")){
editClip.blendMode = (int)event.getGroup().getValue();
// println("editClip.blendMode: "+editClip.blendMode);
}
else if(event.isFrom("Add_to_Layer")){
addTo = (int)event.getGroup().getValue();
// println("editClip.blendMode: "+editClip.blendMode);
}
/////////////////////////////////////////////////Edit Layer choice
else if((event.getGroup().getName().substring(0,5)).equals("Layer")){
String s = event.getGroup().getName();
// println(s);
editLayer = int(Character.toString(s.charAt(s.length()-1)));
// println(editLayer);
for (int i = 0; i<nbLayers; i++){
if(i==editLayer){
layers[i].isEditLayer = true;
}
else{
layers[i].isEditLayer = false;
layers[i].isPlaying = false;
}
}
}
}
else if (event.isController()){
// println(event.getController().getName()+" is Controller");
/////////////////////////////////////////////////Clips Events
if(event.isFrom("Clip_XY")){
if(editClip != null){
editClip.posX = map(event.getController().arrayValue()[0],-100,100,-1,1);
editClip.posY = map(event.getController().arrayValue()[1],-100,100,-1,1);
}
}
// choice of the clip to edit
else if((event.getController().getName().substring(0,4)).equals("Clip")){
for(int i=0; i<Playlist.length; i++){
if((event.getController().getName()).equals("Clip"+i)){
gui.getGroup("clipList").close();
fill(20);
rect(0,0,500,300);
editClip.movieNum=i;
editClip.isLoaded=false;
editClip.setVideo();
}
}
}
/////////////////////////////////////////////////Layers Events
else if((event.getController().getName().substring(0,5)).equals("Layer")){
String s = event.getController().getName();
// println(s);
// set edit Clip from a Layer Clip
if(s.length()>10 && (s.substring(6,10)).equals("Clip")){
// get number of the Layer
int n = int(s.substring(5,6));
// println("Layer: "+n);
layers[n].isEditLayer = true;
updateLayerClip = new int[]{n, int(Character.toString(s.charAt(s.length()-1)))};
println("updateLayerClip: Layer"+updateLayerClip[0]+" Clip"+updateLayerClip[1]);
if(gui.getGroup("clipList").isOpen()) gui.getGroup("clipList").close();
fill(20);
rect(0,0,500,300);
setEditClip(updateLayerClip);
}
else{
// get number of the Layer
int n = int(Character.toString(s.charAt(s.length()-1)));
// println("Layer: "+n);
layers[n].isEditLayer = true;
switch(event.controller().id()){
case(0): // Layer_Timeline
// layers[n].Timeline = event.controller().value();
break;
case(1): // Layer_Duration
// layers[n].Duration = event.controller().value();
break;
case(2): // Layer_PlayPause
if(layers[n].clips.size()>0 && !composition.isPlaying){
layers[n].isPlaying = boolean(int(event.controller().value()));
if(layers[n].isPlaying){
if(!layers[n].clips.get(layers[n].currentClip).movie.isPlaying()){
layers[n].clips.get(layers[n].currentClip).movie.play();
layers[n].clips.get(layers[n].currentClip).timer=millis();
}
layers[n].timer = millis();
}
else{
if((layers[n].clips).get(layers[n].currentClip).movie.isPlaying()){// if layer.currentClip is playing -> pause
(layers[n].clips).get(layers[n].currentClip).movie.pause();
}
}
}
// println("layers["+n+"].isPlaying: "+layers[n].isPlaying);
break;
case(3): // Layer_XY
layers[n].posX = map(event.getController().arrayValue()[0],-100,100,-1,1);
// println("layers["+n+"].posX: "+layers[n].posX);
layers[n].posY = map(event.getController().arrayValue()[1],-100,100,-1,1);
// println("layers["+n+"].posY: "+layers[n].posY);
break;
case(4): // Layer_Scale
layers[n].Scale = event.controller().value();
// println("layers["+n+"].Scale: "+layers[n].Scale);
break;
case(5): // Layer_Opacity
layers[n].TargetOpacity = event.controller().value();
// println("layers["+n+"].Opacity: "+layers[n].Opacity);
break;
case(6): // Layer_Delay
layers[n].Delay = event.controller().value();
// println("layers["+n+"].Delay: "+layers[n].Delay);
float MaxLayerDuration=0.0;
for(int i=0; i<nbLayers; i++){
if(layers[n].Delay+layers[n].duration>MaxLayerDuration){
MaxLayerDuration = layers[n].Delay+layers[n].duration;
}
}
composition.duration = MaxLayerDuration;
Composition_Duration.setText("DURATION: "+composition.duration);
break;
case(7): // Layer_fadeInAlpha
layers[n].fadeInAlpha = event.controller().value();
// println("layers["+n+"].fadeInAlpha: "+layers[n].fadeInAlpha);
break;
case(8): // Layer_fadeInDuration
layers[n].fadeInDuration = event.controller().value();
// println("layers["+n+"].fadeInDuration: "+layers[n].fadeInDuration);
break;
case(9): // Layer_fadeOutAlpha
layers[n].fadeOutAlpha = event.controller().value();
// println("layers["+n+"].fadeOutAlpha: "+layers[n].fadeOutAlpha);
break;
case(10):// Layer_fadeOutDuration
layers[n].fadeOutDuration = event.controller().value();
// println("layers["+n+"].fadeOutDuration: "+layers[n].fadeOutDuration);
break;
case(11):
layers[n].resetLayer();
break;
}
}
}
}
}
void setEditClip(int[] n) {
// stop editClip
if(editClip.movieNum!=999) editClip.movie.stop();
editClip.isEditClip = false;
editClip.movieNum = layers[n[0]].clips.get(n[1]).movieNum;
editClip.duration = layers[n[0]].clips.get(n[1]).duration;
editClip.lectureMode = layers[n[0]].clips.get(n[1]).lectureMode;
editClip.nbRepeat = layers[n[0]].clips.get(n[1]).nbRepeat;
editClip.movieSpeed = layers[n[0]].clips.get(n[1]).movieSpeed;
editClip.TargetOpacity = layers[n[0]].clips.get(n[1]).TargetOpacity;
editClip.posX = layers[n[0]].clips.get(n[1]).posX;
editClip.posY = layers[n[0]].clips.get(n[1]).posY;
editClip.Scale = layers[n[0]].clips.get(n[1]).Scale;
editClip.fadeInAlpha = layers[n[0]].clips.get(n[1]).fadeInAlpha;
editClip.fadeInDuration = layers[n[0]].clips.get(n[1]).fadeInDuration;
editClip.fadeOutAlpha = layers[n[0]].clips.get(n[1]).fadeOutAlpha;
editClip.fadeOutDuration = layers[n[0]].clips.get(n[1]).fadeOutDuration;
editClip.blendMode = layers[n[0]].clips.get(n[1]).blendMode;
editClip.isEditClip = true;
editClip.setVideo();
Clip_Duration.setText("DURATION: "+editClip.duration*editClip.nbRepeat/editClip.movieSpeed);
Clip_LectureMode.setIndex(editClip.lectureMode);
Clip_nbRepeat.setValue(editClip.nbRepeat);
Clip_Speed.setValue(editClip.movieSpeed);
Clip_XY.setArrayValue(new float[]{map(editClip.posX,-1,1,0,200), map(editClip.posY,-1,1,0,200)});
Clip_Scale.setValue(editClip.Scale);
Clip_fadeInAlpha.setValue(editClip.fadeInAlpha);
Clip_fadeInDuration.setValue(editClip.fadeInDuration);
Clip_fadeOutAlpha.setValue(editClip.fadeOutAlpha);
Clip_fadeOutDuration.setValue(editClip.fadeOutDuration);
Clip_Opacity.setValue(editClip.TargetOpacity);
Clip_Effect.setValue(editClip.blendMode);
Update_ClipId.setText("LAYER"+n[0]+" CLIP"+n[1]);
}