-
Notifications
You must be signed in to change notification settings - Fork 1
/
UI_Draws.pde
352 lines (313 loc) · 10.4 KB
/
UI_Draws.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
void drawInput() {
fill(0,0,0,162);
rect(0,0,width,height);
if (inputTarget == "COMMENT") {
commentButt.visible = true;
commentButt.t = inputText;
commentButt.caret = blink;
commentButt.w = int(stringButtSize(commentButt.t)+20);
if (commentButt.w < 100) {
commentButt.w = 100;
}
commentButt.x = int((videoWidth / 2) - (commentButt.w / 2));
delCommentButt.x = commentButt.x - 17;
commentButt.drawMe();
commentButt.visible = false;
}
}
void drawAnimInput() {
fill(0,0,0,162);
rect(0,0,width,height);
for (int i = 0; i < buttMenu.size(); i++) {
if (buttMenu.get(i).visible) {
buttMenu.get(i).drawMe();
}
}
}
void drawAnimPosInput() {
if (inputTarget == "NEW") {
for (int i = 0; i < buttMenu.size(); i++) {
if (buttMenu.get(i).visible) {
buttMenu.get(i).drawMe();
}
}
}
fill(0,0,0,128);
rect(0,0,width,height);
if (inputTarget == "NEW") {
stroke(color5);
} else {
stroke(color3);
}
strokeWeight(2);
if (inputPositioning == 0 || inputPositioning == 1) {
dashedLine((inputLastX + 0.5) * videoWidth, videoY, (inputLastX + 0.5) * videoWidth, videoHeight + videoY, 3);
} else {
inputLastX = 0.0;
}
if (inputPositioning == 0 || inputPositioning == 2) {
dashedLine(0, videoY + ((inputLastY + 0.5) * videoHeight), videoWidth, videoY + ((inputLastY + 0.5) * videoHeight), 3);
} else {
inputLastY = 0.0;
}
drawAniPosReminder();
stroke(color2);
if (inputPositioning == 0 || inputPositioning == 1) {
inputX = mouseX / videoWidth;
inputX = constrain(inputX, 0.0, 1.0) - 0.5;
line((inputX + 0.5) * videoWidth, videoY, (inputX + 0.5) * videoWidth, videoHeight + videoY);
} else {
inputX = 0.0;
}
if (inputPositioning == 0 || inputPositioning == 2) {
inputY = (mouseY - videoY) / videoHeight;
inputY = constrain(inputY, 0.0, 1.0) - 0.5;
line(0, videoY + ((inputY + 0.5) * videoHeight), videoWidth, videoY + ((inputY + 0.5) * videoHeight));
} else {
inputY = 0.0;
}
}
// This draws the video tracker bar
// Not sure if this this the right name
// I mean the progress bar below the video
// Where you can see how far into the video you are
void drawTrackerBar() {
float mousePos;
// this is the y position of the actual progress bar line
float _lineY = trackerBarY + 18;
// draw background
noStroke();
fill(color1c);
rect(trackerBarX, trackerBarY, trackerBarWidth, trackerBarHeight);
// Draw timecode / time remaining
noStroke();
textSize(11);
fill(color1b);
textFont(smallRobotoMono);
textAlign(LEFT);
text(formatTimeCode(headPos), trackerBarX + 10, _lineY + 20);
textAlign(RIGHT);
text("-" + formatTimeCode(myMovie.duration()-headPos), trackerBarWidth-10, _lineY + 20);
// Draw bar
fill(color1d);
rect(trackerBarX + 10, _lineY, trackerBarWidth-20, trackerLineThickness);
// Draw progress
fill(color1b);
if (myMovie.duration() > 0) {
rect(trackerBarX + 10, _lineY, (trackerBarWidth-20) * (headPos/myMovie.duration()), trackerLineThickness);
}
// Draw keyframe ticks
fill(color3);
noStroke();
if (keyframes != null) {
for (int i = 0; i < keyframes.size(); i++) {
float _tickPos = keyframes.get(i).time;
rect(int(trackerBarX + 10 + ((trackerBarWidth-20) * (_tickPos/myMovie.duration()))), _lineY - 10, 1, 5);
}
}
// Draw mouse over info
if (trackerMousePos!=-1) {
fill(color2, 255);
mousePos = 10 + (trackerMousePos * (trackerBarWidth-20));
triangle(mousePos, _lineY+trackerLineThickness+1, mousePos-4, _lineY+trackerLineThickness+5, mousePos+4, _lineY+trackerLineThickness+5);
rect(mousePos, _lineY, 1, trackerLineThickness);
//ellipse(mousePos, _lineY + (trackerLineThickness/2), trackerLineThickness, trackerLineThickness);
fill(color1);
stroke(color1b);
strokeWeight(1.2);
rect(mousePos - (64/2), trackerBarY - 8 , 64, 18, 2);
fill(color1b);
noStroke();
textFont(smallRobotoMono);
textAlign(CENTER);
text(formatTimeCode(trackerMousePos * myMovie.duration()),mousePos,trackerBarY+5);
}
}
// This draws the Detail bar
// Detail bar is a zoomed-in timeline above the tracker bar
void drawDetailBar() {
int _thisx;
float _ticksY = detailBarY + 20; // this is the y position of ticks of the timeline
float _keysY = _ticksY - 14; // this is the y position of the top corner of the keyframe diamonds
float _realdWidth = detailBarWidth - 20; // adding padding to the edges;
float mouseline = -20; // A mouse line is a selection line showing up one mouse over.
float mouseTime = -1; // The timecode underneath the mouse
float mouseKeyTime = -1; // The timecode of the keyframe currently being hovered on my the mouse
// Deal with mouse selection.
if (detailMousePos!=-1) {
mouseline = detailMousePos * detailBarWidth;
mouseTime = detailBarScroll + (((mouseline-10) / _realdWidth) * detailBarZoom);
mouseTime = constrain(mouseTime, 0, myMovie.duration());
// Snap to keyframes
float bestDist = myMovie.duration()*2;
float bestTime = -1;
if (keyframes != null) {
for (int i = 0; i < keyframes.size(); i++) {
float dist = abs(keyframes.get(i).time - mouseTime);
if (dist < bestDist) {
bestDist = dist;
bestTime = keyframes.get(i).time;
}
}
}
if (bestDist < 0.25) {
mouseKeyTime = bestTime;
}
} else {
// Show a mouse line if the mouse is over the tracker bar too!
if (trackerMousePos!=-1) {
mouseTime = trackerMousePos * myMovie.duration();
if (mouseTime > detailBarScroll-1 && mouseTime < detailBarScroll + detailBarZoom) {
mouseline = 10 + int(((mouseTime-detailBarScroll) / detailBarZoom) * _realdWidth);
}
}
}
// draw background
noStroke();
fill(color1);
rect(detailBarX, detailBarY, detailBarWidth, detailBarHeight);
// draw second ticks
noStroke();
fill(color1d);
for (float i = int(detailBarScroll-1); i < detailBarScroll + detailBarZoom + 1; i=i+0.5) {
if (i >= 0 && i <= myMovie.duration()) {
int _tickH = 6;
if (i != int(i)) {
_tickH = 1;
}
_thisx = 10 + int(((i-detailBarScroll) / detailBarZoom) * _realdWidth);
rect(_thisx, _ticksY, 1, _tickH);
}
}
// draw mouseline
fill(color2);
noStroke();
if (mouseKeyTime == -1) {
rect(mouseline, detailBarY, 1, detailBarHeight);
} else {
_thisx = 10 + int(((mouseKeyTime-detailBarScroll) / detailBarZoom) * _realdWidth);
rect(_thisx, detailBarY, 1, detailBarHeight);
}
// draw keyframe diamonds
fill(color3);
noStroke();
if (keyframes != null) {
for (int i = 0; i < keyframes.size(); i++) {
float _keyPos = keyframes.get(i).time;
if (_keyPos == mouseKeyTime) {
fill(color2);
} else if (_keyPos == headPos) {
fill(color4);
} else if (selFrameComment != null && selFrameComment == keyframes.get(i)) {
fill(color4);
} else {
fill(color3);
}
if (_keyPos > detailBarScroll-1 && _keyPos < detailBarScroll + detailBarZoom) {
_thisx = 10 + int(((_keyPos-detailBarScroll) / detailBarZoom) * _realdWidth);
quad(_thisx, _keysY, _thisx-4, _keysY+4, _thisx, _keysY+8, _thisx+4, _keysY+4);
//rect(int(trackerBarX + 10 + ((trackerBarWidth-20) * (_tickPos/myMovie.duration()))), _lineY - 10, 1, 5);
}
}
}
// draw cursor
noStroke();
fill(color2);
if (headPos > detailBarScroll-1 && headPos < detailBarScroll + detailBarZoom) {
_thisx = 10 + int(((headPos-detailBarScroll) / detailBarZoom) * _realdWidth);
triangle(_thisx, _ticksY, _thisx-4, _ticksY+4, _thisx+4, _ticksY+4);
rect(_thisx-4, _ticksY+4, 7.8, 5);
}
// draw tooltip
if (detailMousePos!=-1) {
float _showTime = mouseTime;
float _showX = mouseline;
if (mouseKeyTime != -1) {
_showTime = mouseKeyTime;
_showX = 10 + int(((mouseKeyTime-detailBarScroll) / detailBarZoom) * _realdWidth);
} else {
}
fill(color1);
stroke(color1b);
strokeWeight(1.2);
rect(_showX - (64/2), detailBarY - 15 , 64, 18, 2);
fill(color1b);
noStroke();
textFont(smallRobotoMono);
textAlign(CENTER);
text(formatTimeCode(_showTime),_showX,detailBarY-3);
}
}
// Draws buttons next to overlay buttons to indicate
// if you are currently on a keyframe
// You can click the buttons to delete a keyframe
void drawKeyframes() {
fill(color5);
noStroke();
delAgendaButtL.visible = false;
delAgendaButtR.visible = false;
delCreditButtL.visible = false;
delCreditButtR.visible = false;
if (selFrameAgendaLeft != null) {
delAgendaButtL.visible = true;
}
if (selFrameAgendaRight != null) {
delAgendaButtR.visible = true;
}
if (selFrameCreditLeft != null) {
delCreditButtL.visible = true;
}
if (selFrameCreditRight != null) {
delCreditButtR.visible = true;
}
}
// Draws a Debug Overlay
void drawDebugOverlay() {
float thisWidth = 200;
float thisHeight = 150;
float thisX = (videoWidth/2)-(thisWidth/2);
float thisY = videoY+100;
float thisPadding = 15;
noStroke();
fill(color1, 230);
rect(thisX, thisY, thisWidth, thisHeight, 2);
fill(color1b);
textFont(smallRobotoMono);
textAlign(LEFT);
String t = "UIMode - " + UIMode + "\n";
t += "InputMode - " + inputMode + "\n";
t += "logUndo - " + logUndo + "\n";
t += "undoLevel - " + undoLevel + "\n";
t += "keyShift - " + keyShift + "\n";
t += "keyControl - " + keyControl + "\n";
t += "keyAlt - " + keyAlt + "\n";
t += "key - " + key + "\n";
t += "keyCode - " + keyCode + "\n";
text(t, thisX + thisPadding, thisY + thisPadding, thisWidth - (thisPadding * 2), thisHeight-(thisPadding*2));
}
// Draws the Volume Slider
void drawVolume() {
float barY = 16;
float barH = 2;
color filledBar;
color tick;
fill(color1d);
//rect(width-volumeSliderWidth, menuY, volumeSliderWidth, menuHeight);
rect((width - volumeSliderWidth) + volBarX, menuY + barY, volBarW, barH);
float sliderX = (width - volumeSliderWidth) + volBarX;
sliderX += volBarW * movieVol;
if (volumeSliderOver && !volumeSliderClicked) {
filledBar = color2;
tick = color5;
} else if (volumeSliderClicked) {
tick = color5;
filledBar = color2;
} else {
tick = color1b;
filledBar = color1d;
}
fill(filledBar);
rect((width - volumeSliderWidth) + volBarX, menuY + barY -1, volBarW * movieVol, barH+2);
fill(tick);
rect(sliderX - 1, (menuY + barY) - 4, 2, barH + 8);
}