-
Notifications
You must be signed in to change notification settings - Fork 1
/
ClipGui.pde
428 lines (378 loc) · 12.3 KB
/
ClipGui.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
int currentButton=0;
Slider Clip_Timeline;
Textlabel Clip_Duration;
DropdownList Clip_LectureMode;
Slider Clip_nbRepeat;
Slider Clip_Speed;
Slider2D Clip_XY;
Slider Clip_Scale;
Slider Clip_fadeInAlpha;
Slider Clip_fadeInDuration;
Slider Clip_fadeOutAlpha;
Slider Clip_fadeOutDuration;
Slider Clip_Opacity;
DropdownList Clip_Effect;
DropdownList Add_to_Layer;
int addTo=0;
Button Update_Clip;
Textlabel Update_ClipId;
class ImageButton implements ControllerView<Button> {
PImage img = thumbnails[currentButton];
public void display(PApplet theApplet, Button theButton) {
theApplet.pushMatrix();
image(img,0,0);
if (theButton.isInside()) {
if (theButton.isPressed()) { // button is pressed
theApplet.fill(0,0);
} else { // mouse hovers the button
theApplet.fill(0, 0);
}
} else { // the mouse is located outside the button area
theApplet.fill(0, 120);
}
theApplet.rect(0, 0, 45, 45);
theApplet.popMatrix();
}
}
void initClipGui() {
Group clipList = gui.addGroup("clipList")
.setBackgroundColor(color(0))
.setPosition(5,10)
.setWidth(490)
.setBackgroundHeight(280)
.activateEvent(true)
;
for(int i=0; i<Playlist.length; i++){
currentButton=i;
gui.addButton("Clip"+i)
.setPosition(15+46*(i%10), 15+46*int(i/10))
.setSize(45,45)
.setImage(thumbnails[i])
.setView(new ImageButton())
.moveTo(clipList)
;
}
Group clipGui = gui.addGroup("Clip")
.setBackgroundColor(color(0))
.setPosition(5,310)
.setWidth(490)
.setBackgroundHeight(490)
.disableCollapse()
;
Clip_Timeline = gui.addSlider("Clip_Timeline")
.setPosition(10,10)
.setSize(470,10)
.setMin(0.0)
.setMax(1.0)
.moveTo(clipGui)
;
Clip_Timeline.getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
Clip_Duration = gui.addTextlabel("Clip_Duration")
.setText("DURATION: 0.00")
.setPosition(380,23)
.moveTo(clipGui)
;
gui.addToggle("Clip_PlayPause")
.setPosition(10,40)
.setSize(60,10)
.moveTo(clipGui)
;
Clip_LectureMode = gui.addDropdownList("Clip_LectureMode")
.setPosition(90,50)
.setSize(85,40)
.setItemHeight(15)
.moveTo(clipGui)
;
Clip_LectureMode.addItem("Lecture",0);
Clip_LectureMode.addItem("Aller Retour",1);
Clip_LectureMode.setIndex(0);
Clip_nbRepeat = gui.addSlider("Clip_nbRepeat")
.setPosition(185,40)
.setSize(85,10)
.setMin(1)
.setMax(20)
.setValue(1)
.moveTo(clipGui)
;
Clip_nbRepeat.getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
Clip_Speed = gui.addSlider("Clip_Speed")
.setPosition(295,40)
.setSize(185,10)
.setMin(0.1)
.setMax(6.0)
.setValue(1)
.moveTo(clipGui)
;
Clip_Speed.getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
Clip_XY = gui.addSlider2D("Clip_XY")
.setPosition(10,90)
.setSize(260,140)
.setMinX(-100)
.setMaxX(100)
.setMinY(-100)
.setMaxY(100)
.setArrayValue(new float[] {100,100})
.moveTo(clipGui)
;
Clip_Scale = gui.addSlider("Clip_Scale")
.setPosition(295,90)
.setSize(185,10)
.setMin(0.1)
.setMax(10)
.setValue(1)
.moveTo(clipGui)
;
Clip_Scale.getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
Clip_Opacity = gui.addSlider("Clip_Opacity")
.setPosition(295,140)
.setSize(185,10)
.setMin(0.0)
.setMax(1.0)
.setValue(1.0)
.moveTo(clipGui)
;
Clip_Opacity.getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
Clip_Effect = gui.addDropdownList("Clip_Effect")
.setPosition(295,200)
.setSize(180,200)
.setItemHeight(15)
.moveTo(clipGui)
;
/*
//English Version
Clip_Effect.addItem( "Normal (Unpremultiplied, Photo Mask)", 0 );
Clip_Effect.addItem( "Normal (Premultiplied, CG Alpha)", 1 );
Clip_Effect.addItem( "Color", 2 );
Clip_Effect.addItem( "Luminance", 3 );
Clip_Effect.addItem( "Multiply", 4 );
Clip_Effect.addItem( "Subtract", 5 );
Clip_Effect.addItem( "Linear Dodge (Add)", 6 );
Clip_Effect.addItem( "ColorDodge", 7 );
Clip_Effect.addItem( "ColorBurn", 8 );
Clip_Effect.addItem( "Darken", 9 );
Clip_Effect.addItem( "Lighten", 10 );
Clip_Effect.addItem( "Difference", 11 );
Clip_Effect.addItem( "InverseDifference", 12 );
Clip_Effect.addItem( "Exclusion", 13 );
Clip_Effect.addItem( "Screen", 14 );
Clip_Effect.addItem( "SoftLight", 15 );
Clip_Effect.addItem( "Overlay", 16 );
Clip_Effect.addItem( "HardLight", 17 );
*/
//French Version
Clip_Effect.addItem( "Normal (Unpremultiplied, Photo Mask)", 0 );
Clip_Effect.addItem( "Normal (Premultiplied, CG Alpha)", 1 );
Clip_Effect.addItem( "Couleur", 2 );// Color
Clip_Effect.addItem( "Luminance", 3 );// ?
Clip_Effect.addItem( "Produit", 4 );// Multiply
Clip_Effect.addItem( "Difference", 5 );// Subtract
Clip_Effect.addItem( "Densite Lineaire -", 6 );// Linear Dodge (Add)
Clip_Effect.addItem( "Densite Couleur -", 7 );// ColorDodge
Clip_Effect.addItem( "Densite Couleur +", 8 );// ColorBurn
Clip_Effect.addItem( "Obscurcir", 9 );// Darken
Clip_Effect.addItem( "Eclaircir", 10 );// Lighten
Clip_Effect.addItem( "Difference", 11 );// Difference
Clip_Effect.addItem( "InverseDifference", 12 );// ?
Clip_Effect.addItem( "Exclusion", 13 );// Exclusion
Clip_Effect.addItem( "Superposition", 14 );// Screen
Clip_Effect.addItem( "Lumière Tamisee", 15 );// SoftLight
Clip_Effect.addItem( "Incrustation", 16 );// Overlay
Clip_Effect.addItem( "Lumière Crue", 17 );// HardLight
Clip_Effect.setIndex(0);
Clip_fadeInAlpha = gui.addSlider("Clip_fadeInAlpha")
.setPosition(10,260)
.setSize(185,10)
.setMin(0.0)
.setMax(1.0)
.setValue(1.0)
.moveTo(clipGui)
;
Clip_fadeInAlpha.getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
Clip_fadeInDuration = gui.addSlider("Clip_fadeInDuration")
.setPosition(10,290)
.setSize(185,10)
.setMin(0.0)
.setMax(20.0)
.setValue(0.0)
.moveTo(clipGui)
;
Clip_fadeInDuration.getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
Clip_fadeOutAlpha = gui.addSlider("Clip_fadeOutAlpha")
.setPosition(10,350)
.setSize(185,10)
.setMin(0.0)
.setMax(1.0)
.setValue(1.0)
.moveTo(clipGui)
;
Clip_fadeOutAlpha.getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
Clip_fadeOutDuration = gui.addSlider("Clip_fadeOutDuration")
.setPosition(10,380)
.setSize(185,10)
.setMin(0.0)
.setMax(20.0)
.setValue(0.0)
.moveTo(clipGui)
;
Clip_fadeOutDuration.getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
Update_Clip = gui.addButton("Update_Clip")
.setPosition(375,440)
.setSize(100,10)
.moveTo(clipGui)
;
Update_Clip.getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
Update_ClipId = gui.addTextlabel("Update_ClipId")
.setText("LAYER_ CLIP_")
.setPosition(371,466)
.moveTo(clipGui)
;
Add_to_Layer = gui.addDropdownList("Add_to_Layer")
.setPosition(295,420)
.setSize(120,50)
.setItemHeight(15)
.moveTo(clipGui)
;
for (int i = 0; i<8; i++){
Add_to_Layer.addItem("Layer"+i,i);
}
gui.addButton("Add_Clip")
.setPosition(425,410)
.setSize(50,10)
.moveTo(clipGui)
;
}
void Clip_Timeline(float f){
/* if(editClip.movie!=null){
float t = f;
if (0.1 < abs(t - editClip.movie.time())) {
boolean b = editClip.movie.isPlaying();
if (!b) editClip.movie.play();
editClip.movie.jump(t);
if (!b) editClip.movie.pause();
}
}*/
}
void Clip_PlayPause(boolean b){
if (editClip.movie!=null){
if(b){
editClip.movie.play();
editClip.timer=millis();
}
else editClip.movie.pause();
}
}
void Clip_nbRepeat(int f){
editClip.nbRepeat=f;
Clip_Duration.setText("DURATION: "+editClip.duration*editClip.nbRepeat/editClip.movieSpeed);
}
void Clip_Speed(float f){
editClip.movieSpeed = f;
if (editClip.movie!=null){
editClip.movie.goToBeginning();
editClip.timelineValue = 0.0;
editClip.movie.speed(f);
editClip.movie.play();
}
// println("setSpeed: "+editClip.movieSpeed);
}
void Clip_Scale(float f){
editClip.Scale=f;
}
void Clip_fadeInAlpha(float f){
editClip.fadeInAlpha=f;
}
void Clip_fadeInDuration(float f){
editClip.fadeInDuration=f;
}
void Clip_fadeOutAlpha(float f){
editClip.fadeOutAlpha=f;
}
void Clip_fadeOutDuration(float f){
editClip.fadeOutDuration=f;
}
void Clip_Opacity(float f){
editClip.TargetOpacity=f;
}
void Add_Clip(){
if(editClip.movie != null){
// Create a new Video Clip, copying calculated infos from editClip
Clip c = new Clip(this);
c.movieNum = editClip.movieNum;
c.duration = editClip.duration;
c.lectureMode = editClip.lectureMode;
c.nbRepeat = editClip.nbRepeat;
c.movieSpeed = editClip.movieSpeed;
c.TargetOpacity = editClip.TargetOpacity;
c.posX = editClip.posX;
c.posY = editClip.posY;
c.Scale = editClip.Scale;
c.fadeInAlpha = editClip.fadeInAlpha;
c.fadeInDuration = editClip.fadeInDuration;
c.fadeOutAlpha = editClip.fadeOutAlpha;
c.fadeOutDuration = editClip.fadeOutDuration;
c.blendMode = editClip.blendMode;
c.setVideo();
layers[addTo].clips.add(c);
currentButton = c.movieNum;
gui.addButton("Layer"+addTo+"Clip"+(layers[addTo].clips.size()-1))
.setPosition(10+46*(layers[addTo].clips.size()-1), 75)
.setSize(45,45)
.setImage(thumbnails[c.movieNum])
.setView(new ImageButton())
.moveTo(layerG[addTo])
;
println("Clip added to Layer "+addTo);
println("layers["+addTo+"].clips.size(): "+layers[addTo].clips.size());
layers[addTo].duration += c.duration;
Layer_Duration[addTo].setText("DURATION: "+layers[addTo].duration);
// check if layer duration superior to composition duration
if(layers[addTo].duration>composition.duration){
composition.duration = layers[addTo].duration;
Composition_Duration.setText("DURATION: "+composition.duration);
}
}
}
void Update_Clip(){
if(updateLayerClip[0] != 999 && !updatingClip){
updatingClip=true;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).movie.stop();
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).movieNum = editClip.movieNum;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).duration = editClip.duration;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).lectureMode = editClip.lectureMode;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).nbRepeat = editClip.nbRepeat;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).movieSpeed = editClip.movieSpeed;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).TargetOpacity = editClip.TargetOpacity;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).posX = editClip.posX;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).posY = editClip.posY;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).Scale = editClip.Scale;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).fadeInAlpha = editClip.fadeInAlpha;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).fadeInDuration = editClip.fadeInDuration;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).fadeOutAlpha = editClip.fadeOutAlpha;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).fadeOutDuration = editClip.fadeOutDuration;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).blendMode = editClip.blendMode;
layers[updateLayerClip[0]].clips.get(updateLayerClip[1]).setVideo();
// calcul new LayerDuration
float updateLayerDuration=0.0;
for(int i=0; i<layers[updateLayerClip[0]].clips.size(); i++){
updateLayerDuration+=layers[updateLayerClip[0]].clips.get(i).duration*layers[updateLayerClip[0]].clips.get(i).nbRepeat/layers[updateLayerClip[0]].clips.get(i).movieSpeed;
}
layers[updateLayerClip[0]].duration = updateLayerDuration;
Layer_Duration[updateLayerClip[0]].setText("DURATION: "+updateLayerDuration);
// check if layer duration superior to composition duration
if(updateLayerDuration>composition.duration){
composition.duration = updateLayerDuration;
Composition_Duration.setText("DURATION: "+composition.duration);
}
updateLayerClip = new int[]{999,999};
Update_ClipId.setText("LAYER_ CLIP_");
updatingClip=false;
}
}
void resetEditClip(){
editClip.movie.stop();
editClip.tex.delete();
editClip.texFiltered.delete();
editClip = new Clip(this);
editClip.isEditClip = true;
initClipGui();
}