@checksub_team/peaks_timeline 1.16.0-alpha.2 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/peaks.js +444 -470
- package/src/line-indicator.js +10 -0
- package/src/line.js +225 -222
- package/src/lines.js +56 -162
- package/src/main.js +8 -7
- package/src/segments-group.js +0 -4
- package/src/source-group.js +74 -84
- package/src/source.js +64 -18
- package/src/sources-layer.js +118 -92
- package/src/timeline-sources.js +12 -10
- package/src/timeline-zoomview.js +0 -4
package/src/lines.js
CHANGED
|
@@ -22,15 +22,12 @@ define([
|
|
|
22
22
|
this._peaks = peaks;
|
|
23
23
|
this._view = view;
|
|
24
24
|
this._layer = layer;
|
|
25
|
+
this._linesBySourceId = {};
|
|
25
26
|
this._linesByPosition = {};
|
|
26
27
|
this._autoAddToLayer = false;
|
|
27
28
|
this._areSourceInteractionsAllowed = true;
|
|
28
29
|
this._areSegmentInteractionsAllowed = true;
|
|
29
30
|
|
|
30
|
-
this._automaticallyCreatedLineId = null;
|
|
31
|
-
this._automaticLineCreationPosition = null;
|
|
32
|
-
this._automaticLineCreationTimeout = null;
|
|
33
|
-
|
|
34
31
|
this._segmentsGroups = {};
|
|
35
32
|
this._segmentsGroupToLine = {};
|
|
36
33
|
|
|
@@ -43,11 +40,9 @@ define([
|
|
|
43
40
|
);
|
|
44
41
|
|
|
45
42
|
this._peaks.on('line.heightChanged', this._onLineHeightChanged.bind(this));
|
|
43
|
+
this._peaks.on('line.add', this._onLineAdd.bind(this));
|
|
46
44
|
this._peaks.on('line.remove', this._onLineRemove.bind(this));
|
|
47
45
|
|
|
48
|
-
this._peaks.on('sources.show', this._onSourcesWrappingChanged.bind(this));
|
|
49
|
-
this._peaks.on('sources.hide', this._onSourcesWrappingChanged.bind(this));
|
|
50
|
-
|
|
51
46
|
this._peaks.on('segment.updated', this._onSegmentsUpdate.bind(this));
|
|
52
47
|
this._peaks.on('segments.add', this._onSegmentsAdd.bind(this));
|
|
53
48
|
this._peaks.on('segments.remove', this._onSegmentsRemove.bind(this));
|
|
@@ -103,27 +98,38 @@ define([
|
|
|
103
98
|
this._view.updateTimeline();
|
|
104
99
|
};
|
|
105
100
|
|
|
106
|
-
Lines.prototype.
|
|
107
|
-
this.
|
|
101
|
+
Lines.prototype._onLineAdd = function(position) {
|
|
102
|
+
this._createLine(position);
|
|
103
|
+
this._setInteractions(position);
|
|
108
104
|
this._updateLinesPosition(position);
|
|
109
105
|
};
|
|
110
106
|
|
|
111
|
-
Lines.prototype.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
Lines.prototype._onLineRemove = function(position) {
|
|
108
|
+
var oldLine = this.removeLine(position);
|
|
109
|
+
var lineNewY = oldLine.getY();
|
|
110
|
+
|
|
111
|
+
this._updateLinesPosition(position, lineNewY);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
Lines.prototype.changeLineHeight = function(from, to) {
|
|
115
|
+
for (var position in this._linesByPosition) {
|
|
116
|
+
if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
117
|
+
if (!this._linesByPosition[position].isSegmentsLine()) {
|
|
118
|
+
this._linesByPosition[position].changeHeight(from, to);
|
|
119
|
+
}
|
|
115
120
|
}
|
|
116
|
-
}
|
|
121
|
+
}
|
|
117
122
|
};
|
|
118
123
|
|
|
119
|
-
Lines.prototype.addSourceGroup = function(
|
|
124
|
+
Lines.prototype.addSourceGroup = function(sourceGroup, position) {
|
|
120
125
|
if (!this._linesByPosition[position] || this._linesByPosition[position].isSegmentsLine()) {
|
|
121
126
|
this._createLine(position);
|
|
122
127
|
this._setInteractions(position);
|
|
123
128
|
}
|
|
124
129
|
|
|
125
|
-
|
|
126
|
-
this._linesByPosition[position].addSourceGroup(
|
|
130
|
+
sourceGroup.getSource().position = position;
|
|
131
|
+
this._linesByPosition[position].addSourceGroup(sourceGroup);
|
|
132
|
+
this._linesBySourceId[sourceGroup.getSource().id] = this._linesByPosition[position];
|
|
127
133
|
};
|
|
128
134
|
|
|
129
135
|
Lines.prototype.addSegments = function(lineId, position) {
|
|
@@ -140,37 +146,30 @@ define([
|
|
|
140
146
|
};
|
|
141
147
|
|
|
142
148
|
Lines.prototype.removeSourceGroup = function(source, isPermanent) {
|
|
143
|
-
if (!this._linesByPosition[source.position]) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
149
|
var sourceGroup = this._linesByPosition[source.position].removeSourceGroup(source, isPermanent);
|
|
148
150
|
|
|
149
151
|
if (isPermanent) {
|
|
152
|
+
delete this._linesBySourceId[source.id];
|
|
150
153
|
this._updateLinesPosition(source.position);
|
|
151
154
|
}
|
|
152
155
|
|
|
153
156
|
return sourceGroup;
|
|
154
157
|
};
|
|
155
158
|
|
|
156
|
-
Lines.prototype.
|
|
159
|
+
Lines.prototype.removeLine = function(pos) {
|
|
157
160
|
var oldLine = this._linesByPosition[pos];
|
|
158
|
-
var lineId = oldLine.getId();
|
|
159
161
|
|
|
160
|
-
if (this._automaticallyCreatedLineId === lineId) {
|
|
161
|
-
this._automaticallyCreatedLineId = null;
|
|
162
|
-
}
|
|
163
162
|
oldLine.destroy();
|
|
164
163
|
|
|
165
164
|
delete this._linesByPosition[pos];
|
|
166
165
|
|
|
167
|
-
this._lineIndicator.removeIndicator(
|
|
166
|
+
this._lineIndicator.removeIndicator(oldLine.getId(), false);
|
|
168
167
|
|
|
169
168
|
return oldLine;
|
|
170
169
|
};
|
|
171
170
|
|
|
172
171
|
Lines.prototype.isLineVisible = function(position) {
|
|
173
|
-
return this._linesByPosition[position]
|
|
172
|
+
return this._linesByPosition[position].isVisible();
|
|
174
173
|
};
|
|
175
174
|
|
|
176
175
|
Lines.prototype.getVisibleLines = function() {
|
|
@@ -208,22 +207,16 @@ define([
|
|
|
208
207
|
this._updateLinesPosition(position);
|
|
209
208
|
};
|
|
210
209
|
|
|
211
|
-
Lines.prototype._updateLinesPosition = function(position) {
|
|
210
|
+
Lines.prototype._updateLinesPosition = function(position, forceNewY) {
|
|
212
211
|
var line = this._linesByPosition[position];
|
|
213
212
|
var dy = null;
|
|
214
213
|
var newY;
|
|
215
214
|
|
|
216
|
-
if (
|
|
217
|
-
newY =
|
|
215
|
+
if (forceNewY) {
|
|
216
|
+
newY = forceNewY;
|
|
218
217
|
}
|
|
219
218
|
else {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
while ((previousLine === undefined || previousLine === null) && position > 0) {
|
|
223
|
-
previousLine = this._linesByPosition[--position];
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
newY = previousLine ? previousLine.getY() + previousLine.lineHeight() + this._peaks.options.interline : 0;
|
|
219
|
+
newY = line.getY() + line.lineHeight() + this._peaks.options.interline;
|
|
227
220
|
}
|
|
228
221
|
|
|
229
222
|
for (var pos in this._linesByPosition) {
|
|
@@ -242,7 +235,8 @@ define([
|
|
|
242
235
|
|
|
243
236
|
this._lineIndicator.updateIndicators();
|
|
244
237
|
this._lineIndicator.draw();
|
|
245
|
-
|
|
238
|
+
|
|
239
|
+
this._view.drawSourcesLayer();
|
|
246
240
|
};
|
|
247
241
|
|
|
248
242
|
Lines.prototype.setOffsetY = function(frameOffset) {
|
|
@@ -288,112 +282,25 @@ define([
|
|
|
288
282
|
return length;
|
|
289
283
|
};
|
|
290
284
|
|
|
291
|
-
Lines.prototype.
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
this._automaticLineCreationTimeout = null;
|
|
296
|
-
this._automaticLineCreationPosition = null;
|
|
297
|
-
this._automaticallyCreatedLineId = null;
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
Lines.prototype.manageAutomaticLineCreation = function(newLinePosition, initialPosition, sources) {
|
|
301
|
-
if (this._automaticallyCreatedLineId !== null) {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
else if (
|
|
305
|
-
this._automaticLineCreationPosition !== null
|
|
306
|
-
&& this._automaticLineCreationPosition !== newLinePosition
|
|
307
|
-
) {
|
|
308
|
-
this.stopAutomaticLineCreation();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (this._automaticLineCreationTimeout) {
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
this._automaticLineCreationPosition = newLinePosition;
|
|
316
|
-
this._automaticLineCreationTimeout = setTimeout(function() {
|
|
317
|
-
this._automaticLineCreationTimeout = null;
|
|
318
|
-
|
|
319
|
-
var currentLine = this._linesByPosition[initialPosition];
|
|
320
|
-
|
|
321
|
-
if (currentLine.countRemainingElements() === sources.length) {
|
|
322
|
-
this.stopAutomaticLineCreation();
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
this._automaticallyCreatedLineId = this._createLine(newLinePosition);
|
|
327
|
-
this._setInteractions(newLinePosition);
|
|
328
|
-
this.moveSourcesToPosition(sources, currentLine.getPosition(), newLinePosition);
|
|
329
|
-
}.bind(this), this._peaks.options.automaticLineCreationDelay);
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
Lines.prototype.manageVerticalPosition = function(sources, startTime, endTime, mouseX, mouseY) {
|
|
333
|
-
if (mouseX === null || mouseX === undefined) {
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
const position = sources[0].position;
|
|
338
|
-
const linePos = this.getLinesUnderY(mouseY);
|
|
285
|
+
Lines.prototype.manageVerticalPosition = function(source, newY) {
|
|
286
|
+
if (newY !== null && newY !== undefined) {
|
|
287
|
+
var pos = this.getLineOnPosition(newY);
|
|
339
288
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
this.stopAutomaticLineCreation();
|
|
345
|
-
|
|
346
|
-
if (
|
|
347
|
-
mouseX !== null && mouseX !== undefined
|
|
348
|
-
&& linePos[0] !== position
|
|
349
|
-
&& !this._linesByPosition[linePos[0]].isSegmentsLine()
|
|
350
|
-
) {
|
|
351
|
-
var mouseTime = this._view.pixelsToTime(mouseX + this._view.getFrameOffset());
|
|
352
|
-
var sourceDuration = Utils.roundTime(endTime - startTime);
|
|
353
|
-
|
|
354
|
-
if (this._hasSpaceForSourceAt(linePos[0], mouseTime, sourceDuration)) {
|
|
355
|
-
this.moveSourcesToPosition(sources, position, linePos[0]);
|
|
356
|
-
}
|
|
289
|
+
if (pos[0] === pos[1]
|
|
290
|
+
&& pos[0] !== source.position
|
|
291
|
+
&& !this._linesByPosition[pos[0]].isSegmentsLine()) {
|
|
292
|
+
this.moveSourceToPosition(source, pos[0]);
|
|
357
293
|
}
|
|
358
294
|
}
|
|
359
295
|
};
|
|
360
296
|
|
|
361
|
-
Lines.prototype._hasSpaceForSourceAt = function(linePosition, mouseTime, sourceDuration) {
|
|
362
|
-
var line = this._linesByPosition[linePosition];
|
|
363
|
-
|
|
364
|
-
if (!line || line.isSegmentsLine()) {
|
|
365
|
-
return false;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
var sourcesAround = line.getSourcesAround(mouseTime);
|
|
369
|
-
|
|
370
|
-
if (sourcesAround.overlapping) {
|
|
371
|
-
return false;
|
|
372
|
-
}
|
|
373
|
-
else if (!sourcesAround.right) {
|
|
374
|
-
return true;
|
|
375
|
-
}
|
|
376
|
-
else {
|
|
377
|
-
var leftLimit = sourcesAround.left ? sourcesAround.left.endTime : 0;
|
|
378
|
-
var rightLimit = sourcesAround.right.startTime;
|
|
379
|
-
|
|
380
|
-
return sourceDuration <= Utils.roundTime(rightLimit - leftLimit);
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
|
|
384
297
|
Lines.prototype.getLineByPosition = function(pos) {
|
|
385
298
|
return this._linesByPosition[pos];
|
|
386
299
|
};
|
|
387
300
|
|
|
388
|
-
Lines.prototype.
|
|
389
|
-
var keys = Object.keys(this._linesByPosition);
|
|
390
|
-
|
|
391
|
-
return keys.pop();
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
Lines.prototype.getLinesUnderY = function(y) {
|
|
301
|
+
Lines.prototype.getLineOnPosition = function(y) {
|
|
395
302
|
var height;
|
|
396
|
-
var pos = [-1,
|
|
303
|
+
var pos = [-1, Number.MAX_VALUE];
|
|
397
304
|
|
|
398
305
|
for (var position in this._linesByPosition) {
|
|
399
306
|
if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
@@ -412,18 +319,16 @@ define([
|
|
|
412
319
|
return pos;
|
|
413
320
|
};
|
|
414
321
|
|
|
415
|
-
Lines.prototype.
|
|
416
|
-
|
|
417
|
-
var sourceGroup = this._linesByPosition[initialPosition].removeSourceGroup(source, true);
|
|
322
|
+
Lines.prototype.moveSourceToPosition = function(source, pos) {
|
|
323
|
+
var sourceGroup = this._linesByPosition[source.position].removeSourceGroup(source, true);
|
|
418
324
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
325
|
+
delete this._linesBySourceId[source.id];
|
|
326
|
+
|
|
327
|
+
sourceGroup.moveTo(this._linesByPosition[pos].getKonvaGroup());
|
|
422
328
|
|
|
423
|
-
|
|
424
|
-
}.bind(this));
|
|
329
|
+
this._updateLinesPosition(source.position);
|
|
425
330
|
|
|
426
|
-
this.
|
|
331
|
+
this.addSourceGroup(sourceGroup, pos);
|
|
427
332
|
};
|
|
428
333
|
|
|
429
334
|
Lines.prototype._getNextLineId = function() {
|
|
@@ -443,17 +348,9 @@ define([
|
|
|
443
348
|
y += this._linesByPosition[pos].lineHeight() + this._peaks.options.interline;
|
|
444
349
|
}
|
|
445
350
|
else {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
var newPosition = currentPos + 1;
|
|
450
|
-
|
|
451
|
-
this._linesByPosition[currentPos].updatePosition(newPosition);
|
|
452
|
-
newLinesByPosition[newPosition] = this._linesByPosition[currentPos];
|
|
453
|
-
|
|
454
|
-
if (!this._linesByPosition[newPosition]) {
|
|
455
|
-
break;
|
|
456
|
-
}
|
|
351
|
+
if (this._linesByPosition[position]) {
|
|
352
|
+
this._linesByPosition[currentPos].updatePosition(currentPos + 1);
|
|
353
|
+
newLinesByPosition[currentPos + 1] = this._linesByPosition[currentPos];
|
|
457
354
|
}
|
|
458
355
|
}
|
|
459
356
|
}
|
|
@@ -469,8 +366,6 @@ define([
|
|
|
469
366
|
|
|
470
367
|
newLinesByPosition[position] = line;
|
|
471
368
|
this._linesByPosition = newLinesByPosition;
|
|
472
|
-
|
|
473
|
-
return line.getId();
|
|
474
369
|
};
|
|
475
370
|
|
|
476
371
|
Lines.prototype.updateSegments = function(frameStartTime, frameEndTime) {
|
|
@@ -481,13 +376,12 @@ define([
|
|
|
481
376
|
}
|
|
482
377
|
};
|
|
483
378
|
|
|
484
|
-
Lines.prototype.manageCollision = function(
|
|
485
|
-
return this.
|
|
379
|
+
Lines.prototype.manageCollision = function(source, newTimes) {
|
|
380
|
+
return this._linesBySourceId[source.id].manageCollision(source, newTimes);
|
|
486
381
|
};
|
|
487
382
|
|
|
488
|
-
Lines.prototype.
|
|
489
|
-
|
|
490
|
-
return this._linesByPosition[sources[0].position].manageOrder(sources, startTime, endTime);
|
|
383
|
+
Lines.prototype.manageSourceOrder = function(source, newTimes) {
|
|
384
|
+
return this._linesBySourceId[source.id].manageSourceOrder(source, newTimes);
|
|
491
385
|
};
|
|
492
386
|
|
|
493
387
|
Lines.prototype._setInteractions = function(position) {
|
package/src/main.js
CHANGED
|
@@ -409,13 +409,7 @@ define([
|
|
|
409
409
|
* Indicates whether or not sources can be dragged
|
|
410
410
|
* from one line to another
|
|
411
411
|
*/
|
|
412
|
-
canMoveSourcesBetweenLines: true
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Delay in milliseconds before a new line is created
|
|
416
|
-
* when dragging a source between 2 lines.
|
|
417
|
-
*/
|
|
418
|
-
automaticLineCreationDelay: 100
|
|
412
|
+
canMoveSourcesBetweenLines: true
|
|
419
413
|
};
|
|
420
414
|
|
|
421
415
|
/**
|
|
@@ -777,6 +771,13 @@ define([
|
|
|
777
771
|
window.removeEventListener('resize', this._onResize);
|
|
778
772
|
};
|
|
779
773
|
|
|
774
|
+
Peaks.prototype.setLineHeight = function(newLineHeight) {
|
|
775
|
+
var oldHeight = this.options.lineHeight;
|
|
776
|
+
|
|
777
|
+
this.options.lineHeight = newLineHeight;
|
|
778
|
+
this.emit('options.set.line_height', oldHeight);
|
|
779
|
+
};
|
|
780
|
+
|
|
780
781
|
Peaks.prototype.zoomIn = function() {
|
|
781
782
|
this.view.setZoom(
|
|
782
783
|
this.view.getTimeToPixelsScale() + Math.floor(this.view.getTimeToPixelsScale() / 10) + 1
|
package/src/segments-group.js
CHANGED
package/src/source-group.js
CHANGED
|
@@ -47,13 +47,15 @@ define([
|
|
|
47
47
|
var self = this;
|
|
48
48
|
|
|
49
49
|
this._x = this._view.timeToPixels(source.startTime);
|
|
50
|
+
this._roundedX = Math.round(this._x);
|
|
50
51
|
this._width = this._view.timeToPixels(source.endTime - source.startTime);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.
|
|
52
|
+
this._roundedWidth = Math.round(this._width);
|
|
53
|
+
this._unwrappedHeight = source.binaryHeight && source.previewHeight ?
|
|
54
|
+
source.binaryHeight + source.previewHeight :
|
|
55
|
+
this._peaks.options.lineHeight;
|
|
56
|
+
this._wrappedHeight = this._peaks.options.wrappedLineHeight;
|
|
56
57
|
this._borderWidth = this._source.borderWidth || 0;
|
|
58
|
+
this._height = this._unwrappedHeight;
|
|
57
59
|
this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
|
|
58
60
|
this._selected = this._source.selected;
|
|
59
61
|
this._isDragged = false;
|
|
@@ -79,6 +81,7 @@ define([
|
|
|
79
81
|
|
|
80
82
|
this._cursor = null;
|
|
81
83
|
this._group.on('mouseenter', function() {
|
|
84
|
+
self._hovered = true;
|
|
82
85
|
self._view.setHoveredElement(self);
|
|
83
86
|
if (!self._source.loading) {
|
|
84
87
|
self._showButtons();
|
|
@@ -86,6 +89,7 @@ define([
|
|
|
86
89
|
});
|
|
87
90
|
|
|
88
91
|
this._group.on('mouseleave', function() {
|
|
92
|
+
self._hovered = false;
|
|
89
93
|
self._view.setHoveredElement(null);
|
|
90
94
|
self._hideButtons();
|
|
91
95
|
});
|
|
@@ -172,8 +176,8 @@ define([
|
|
|
172
176
|
|
|
173
177
|
this._view.updateWithAutoScroll(
|
|
174
178
|
function() {
|
|
175
|
-
if (this._layer.
|
|
176
|
-
|
|
179
|
+
if (this._layer.updateSource(
|
|
180
|
+
this._source,
|
|
177
181
|
leftHandle ? start + diff + timeOffsetDiff : null,
|
|
178
182
|
leftHandle ? null : end + diff + timeOffsetDiff
|
|
179
183
|
)) {
|
|
@@ -182,6 +186,10 @@ define([
|
|
|
182
186
|
}.bind(this)
|
|
183
187
|
);
|
|
184
188
|
|
|
189
|
+
this._view.setTimelineLength(
|
|
190
|
+
this._view.timeToPixels(this._source.endTime) + this._view.getWidth()
|
|
191
|
+
);
|
|
192
|
+
|
|
185
193
|
return {
|
|
186
194
|
x: draggedElement.absolutePosition().x,
|
|
187
195
|
y: draggedElement.absolutePosition().y
|
|
@@ -197,11 +205,13 @@ define([
|
|
|
197
205
|
this._group.x(startPixel - frameOffset);
|
|
198
206
|
|
|
199
207
|
this._x = startPixel;
|
|
208
|
+
this._roundedX = Math.round(this._x);
|
|
200
209
|
|
|
201
210
|
const newWidth = endPixel - startPixel;
|
|
202
211
|
|
|
203
212
|
if (newWidth !== this._width) {
|
|
204
213
|
this._width = newWidth;
|
|
214
|
+
this._roundedWidth = Math.round(this._width);
|
|
205
215
|
|
|
206
216
|
// the zoom was changed
|
|
207
217
|
if (newTimeToPixelsScale !== this._currentTimeToPixelsScaleUsed) {
|
|
@@ -269,13 +279,11 @@ define([
|
|
|
269
279
|
start: this._source.startTime,
|
|
270
280
|
end: this._source.endTime
|
|
271
281
|
};
|
|
272
|
-
this._isDragged = true;
|
|
273
282
|
|
|
274
283
|
this._hideButtons();
|
|
275
284
|
};
|
|
276
285
|
|
|
277
286
|
SourceGroup.prototype._onHandleDragEnd = function() {
|
|
278
|
-
this._isDragged = false;
|
|
279
287
|
this._showButtons();
|
|
280
288
|
};
|
|
281
289
|
|
|
@@ -380,7 +388,7 @@ define([
|
|
|
380
388
|
Math.max(
|
|
381
389
|
1,
|
|
382
390
|
Math.min(
|
|
383
|
-
this.
|
|
391
|
+
this._roundedWidth / 2,
|
|
384
392
|
Math.min(
|
|
385
393
|
CORNER_RADIUS,
|
|
386
394
|
this._height / 2
|
|
@@ -389,66 +397,76 @@ define([
|
|
|
389
397
|
);
|
|
390
398
|
var x = Math.max(
|
|
391
399
|
0,
|
|
392
|
-
this._view.getFrameOffset() - this.
|
|
400
|
+
this._view.getFrameOffset() - this._roundedX - radius
|
|
393
401
|
);
|
|
394
402
|
var width = Math.min(
|
|
395
|
-
this.
|
|
396
|
-
this._view.getWidth() +
|
|
403
|
+
this._roundedWidth - x,
|
|
404
|
+
this._view.getWidth() + radius - Math.max(
|
|
397
405
|
0,
|
|
398
|
-
this.
|
|
406
|
+
this._roundedX - this._view.getFrameOffset()
|
|
399
407
|
)
|
|
400
408
|
);
|
|
401
409
|
var xWidth = x + width;
|
|
402
410
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
ctx.closePath();
|
|
420
|
-
|
|
421
|
-
if (fill) {
|
|
422
|
-
if (this._source.shouldShowWarning()) {
|
|
423
|
-
var gradient = ctx.createLinearGradient(0, 0, this._width, 0);
|
|
411
|
+
ctx.beginPath();
|
|
412
|
+
ctx.moveTo(x + radius, offset);
|
|
413
|
+
ctx.lineTo(xWidth - radius, offset);
|
|
414
|
+
ctx.quadraticCurveTo(xWidth - offset, offset, xWidth - offset, radius);
|
|
415
|
+
ctx.lineTo(xWidth - offset, this._height - radius);
|
|
416
|
+
ctx.quadraticCurveTo(
|
|
417
|
+
xWidth - offset,
|
|
418
|
+
this._height - offset,
|
|
419
|
+
xWidth - radius,
|
|
420
|
+
this._height - offset
|
|
421
|
+
);
|
|
422
|
+
ctx.lineTo(x + radius, this._height - offset);
|
|
423
|
+
ctx.quadraticCurveTo(x + offset, this._height - offset, x + offset, this._height - radius);
|
|
424
|
+
ctx.lineTo(x + offset, radius);
|
|
425
|
+
ctx.quadraticCurveTo(x + offset, offset, x + radius, offset);
|
|
426
|
+
ctx.closePath();
|
|
424
427
|
|
|
425
|
-
|
|
426
|
-
|
|
428
|
+
if (fill) {
|
|
429
|
+
var backgroundColor;
|
|
427
430
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
+
if (this._selected) {
|
|
432
|
+
backgroundColor = this._source.selectedBackgroundColor;
|
|
433
|
+
}
|
|
434
|
+
else if (this._hovered) {
|
|
435
|
+
backgroundColor = this._source.hoverBackgroundColor;
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
backgroundColor = this._source.backgroundColor;
|
|
439
|
+
}
|
|
431
440
|
|
|
432
|
-
|
|
433
|
-
|
|
441
|
+
if (this._source.shouldShowWarning()) {
|
|
442
|
+
var gradient = ctx.createLinearGradient(0, 0, this._roundedWidth, 0);
|
|
434
443
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
}
|
|
444
|
+
if (this._source.mediaEndTime < this._source.duration) {
|
|
445
|
+
var rightStopPosition = Math.max(1 - (this._source.warningWidth / this._roundedWidth), 0.5);
|
|
438
446
|
|
|
439
|
-
|
|
440
|
-
|
|
447
|
+
gradient.addColorStop(rightStopPosition, backgroundColor);
|
|
448
|
+
gradient.addColorStop(1, this._source.warningColor);
|
|
441
449
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
450
|
+
|
|
451
|
+
if (this._source.mediaStartTime > 0) {
|
|
452
|
+
var leftStopPosition = Math.min(this._source.warningWidth / this._roundedWidth, 0.5);
|
|
453
|
+
|
|
454
|
+
gradient.addColorStop(0, this._source.warningColor);
|
|
455
|
+
gradient.addColorStop(leftStopPosition, backgroundColor);
|
|
445
456
|
}
|
|
446
|
-
}
|
|
447
457
|
|
|
448
|
-
|
|
449
|
-
ctx.
|
|
458
|
+
ctx.fillStyle = gradient;
|
|
459
|
+
ctx.fill();
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
ctx.fillStyle = backgroundColor;
|
|
463
|
+
ctx.fill();
|
|
450
464
|
}
|
|
451
465
|
}
|
|
466
|
+
|
|
467
|
+
if (shape) {
|
|
468
|
+
ctx.fillStrokeShape(shape);
|
|
469
|
+
}
|
|
452
470
|
};
|
|
453
471
|
|
|
454
472
|
SourceGroup.prototype._addUnwrap = function(forceCreate) {
|
|
@@ -878,7 +896,7 @@ define([
|
|
|
878
896
|
this._selected = this._source.selected;
|
|
879
897
|
if (this._border) {
|
|
880
898
|
if (this._selected) {
|
|
881
|
-
this._border.fill(this._source.
|
|
899
|
+
this._border.fill(this._source.selectedBorderColor);
|
|
882
900
|
this._borderWidth = this._peaks.options.sourceSelectedBorderWidth;
|
|
883
901
|
}
|
|
884
902
|
else {
|
|
@@ -895,7 +913,7 @@ define([
|
|
|
895
913
|
|
|
896
914
|
if (unwrap_background) {
|
|
897
915
|
if (this._selected) {
|
|
898
|
-
unwrap_background.stroke(this._source.
|
|
916
|
+
unwrap_background.stroke(this._source.selectedBorderColor);
|
|
899
917
|
unwrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
|
|
900
918
|
}
|
|
901
919
|
else {
|
|
@@ -912,7 +930,7 @@ define([
|
|
|
912
930
|
|
|
913
931
|
if (wrap_background) {
|
|
914
932
|
if (this._selected) {
|
|
915
|
-
wrap_background.stroke(this._source.
|
|
933
|
+
wrap_background.stroke(this._source.selectedBorderColor);
|
|
916
934
|
wrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
|
|
917
935
|
}
|
|
918
936
|
else {
|
|
@@ -1113,14 +1131,6 @@ define([
|
|
|
1113
1131
|
return this._height;
|
|
1114
1132
|
};
|
|
1115
1133
|
|
|
1116
|
-
SourceGroup.prototype.getHeights = function() {
|
|
1117
|
-
return {
|
|
1118
|
-
unwrapped: this._unwrappedHeight,
|
|
1119
|
-
wrapped: this._wrappedHeight,
|
|
1120
|
-
current: this._height
|
|
1121
|
-
};
|
|
1122
|
-
};
|
|
1123
|
-
|
|
1124
1134
|
SourceGroup.prototype.setVisible = function(boolean) {
|
|
1125
1135
|
this._group.visible(boolean);
|
|
1126
1136
|
};
|
|
@@ -1621,25 +1631,5 @@ define([
|
|
|
1621
1631
|
this._group.destroy();
|
|
1622
1632
|
};
|
|
1623
1633
|
|
|
1624
|
-
/**
|
|
1625
|
-
* Static method to get height for a source
|
|
1626
|
-
* @param {Source} source - The source object
|
|
1627
|
-
* @param {Object} peaks - The peaks instance (for options)
|
|
1628
|
-
* @returns {number} The calculated height
|
|
1629
|
-
*/
|
|
1630
|
-
SourceGroup.getHeights = function(source, peaks) {
|
|
1631
|
-
var unwrappedHeight = source.binaryHeight && source.previewHeight ?
|
|
1632
|
-
source.binaryHeight + source.previewHeight :
|
|
1633
|
-
peaks.options.lineHeight;
|
|
1634
|
-
var wrappedHeight = peaks.options.wrappedLineHeight;
|
|
1635
|
-
var height = source.wrapped ? wrappedHeight : unwrappedHeight;
|
|
1636
|
-
|
|
1637
|
-
return {
|
|
1638
|
-
unwrapped: unwrappedHeight,
|
|
1639
|
-
wrapped: wrappedHeight,
|
|
1640
|
-
current: height
|
|
1641
|
-
};
|
|
1642
|
-
};
|
|
1643
|
-
|
|
1644
1634
|
return SourceGroup;
|
|
1645
1635
|
});
|