@checksub_team/peaks_timeline 1.14.0 → 1.15.0-alpha.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checksub_team/peaks_timeline",
3
- "version": "1.14.0",
3
+ "version": "1.15.0-alpha.0",
4
4
  "description": "JavaScript UI component for displaying audio waveforms",
5
5
  "main": "./peaks.js",
6
6
  "types": "./peaks.js.d.ts",
package/peaks.js CHANGED
@@ -15916,6 +15916,8 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
15916
15916
  sourceTextYOffset: 10,
15917
15917
  sourceIndicatorsXOffset: 8,
15918
15918
  sourceIndicatorsYOffset: 12,
15919
+ sourceButtonsGap: 2,
15920
+ sourceButtonsPadding: 4,
15919
15921
  autoScrollThreshold: 0.05,
15920
15922
  enableLineIndicatorContextMenu: true,
15921
15923
  minSourceSize: 0.05,
@@ -18122,6 +18124,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18122
18124
  this._borderWidth = this._source.borderWidth || 0;
18123
18125
  this._height = this._unwrappedHeight;
18124
18126
  this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
18127
+ this._selected = this._source.selected;
18125
18128
  this._previewList = [];
18126
18129
  this._markersGroup = this._createMarkers();
18127
18130
  this._group = new Konva.Group({
@@ -18144,6 +18147,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18144
18147
  self.toggleDragging(false);
18145
18148
  self.toggleResizing(false);
18146
18149
  }
18150
+ if (!self._selected) {
18151
+ self._showButtons();
18152
+ }
18147
18153
  });
18148
18154
  this._group.on('mouseout', function () {
18149
18155
  self._view.setHoveredElement(null);
@@ -18152,6 +18158,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18152
18158
  self.toggleDragging(true);
18153
18159
  self.toggleResizing(true);
18154
18160
  }
18161
+ if (!self._selected) {
18162
+ self._hideButtons();
18163
+ }
18155
18164
  });
18156
18165
  this._group.add(new Konva.Group());
18157
18166
  if (this._borderWidth) {
@@ -18212,6 +18221,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18212
18221
  }
18213
18222
  }
18214
18223
  this._updateVolumeSlider();
18224
+ this._updateButtons();
18215
18225
  this.updatePreviews();
18216
18226
  }
18217
18227
  };
@@ -18379,6 +18389,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18379
18389
  if (this._source.volumeRange && this._source.volume !== undefined) {
18380
18390
  unwrap.add(this._getVolumeSlider());
18381
18391
  }
18392
+ if (this._source.buttons.length > 0) {
18393
+ unwrap.add(this._getButtons());
18394
+ }
18382
18395
  unwrap.add(this._createTitle(false));
18383
18396
  return unwrap;
18384
18397
  };
@@ -18420,6 +18433,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18420
18433
  if (this._source.volumeRange && this._source.volume !== undefined) {
18421
18434
  wrap.add(this._getVolumeSlider());
18422
18435
  }
18436
+ if (this._source.buttons.length > 0) {
18437
+ wrap.add(this._getButtons());
18438
+ }
18423
18439
  wrap.add(this._createTitle(true));
18424
18440
  return wrap;
18425
18441
  };
@@ -18676,13 +18692,16 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18676
18692
  });
18677
18693
  };
18678
18694
  SourceGroup.prototype.setSelected = function () {
18695
+ this._selected = this._source.selected;
18679
18696
  if (this._border) {
18680
- if (this._source.selected) {
18697
+ if (this._selected) {
18681
18698
  this._border.fill(this._source.selectedColor);
18682
18699
  this._borderWidth = this._peaks.options.sourceSelectedBorderWidth;
18700
+ this._showButtons();
18683
18701
  } else {
18684
18702
  this._border.fill(this._source.borderColor);
18685
18703
  this._borderWidth = this._source.borderWidth;
18704
+ this._hideButtons();
18686
18705
  }
18687
18706
  } else {
18688
18707
  if (this._unwrap) {
@@ -18690,7 +18709,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18690
18709
  return node.getClassName() === 'Shape';
18691
18710
  })[0];
18692
18711
  if (unwrap_background) {
18693
- if (this._source.selected) {
18712
+ if (this._selected) {
18694
18713
  unwrap_background.stroke(this._source.selectedColor);
18695
18714
  unwrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
18696
18715
  } else {
@@ -18703,7 +18722,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18703
18722
  return node.getClassName() === 'Shape';
18704
18723
  })[0];
18705
18724
  if (wrap_background) {
18706
- if (this._source.selected) {
18725
+ if (this._selected) {
18707
18726
  wrap_background.stroke(this._source.selectedColor);
18708
18727
  wrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
18709
18728
  } else {
@@ -18887,6 +18906,71 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18887
18906
  }.bind(this));
18888
18907
  return markersGroup;
18889
18908
  };
18909
+ SourceGroup.prototype._createButtons = function () {
18910
+ var buttonsGroup = new Konva.Group({
18911
+ listening: true,
18912
+ x: this._width,
18913
+ visible: false
18914
+ });
18915
+ var buttonsGroupWidth = 0;
18916
+ var buttonsGap = this._peaks.options.sourceButtonsGap;
18917
+ var self = this;
18918
+ this._source.buttons.forEach(function (button) {
18919
+ const {id, width, height, cornerRadius, color, borderColor, borderWidth, svg, image} = button;
18920
+ if (buttonsGroupWidth > 0) {
18921
+ buttonsGroupWidth += buttonsGap;
18922
+ }
18923
+ var buttonGroup = new Konva.Group({
18924
+ x: buttonsGroupWidth,
18925
+ y: 0,
18926
+ listening: true
18927
+ });
18928
+ var buttonRect = new Konva.Rect({
18929
+ width: width,
18930
+ height: height,
18931
+ fill: color,
18932
+ stroke: borderColor,
18933
+ strokeWidth: borderWidth,
18934
+ cornerRadius: cornerRadius
18935
+ });
18936
+ buttonsGroupWidth += width;
18937
+ buttonGroup.add(buttonRect);
18938
+ if (svg) {
18939
+ var svgIcon = new Konva.Path({
18940
+ x: width / 2,
18941
+ y: height / 2,
18942
+ data: svg.path,
18943
+ fill: svg.color,
18944
+ offsetX: svg.width / 2,
18945
+ offsetY: svg.height / 2,
18946
+ listening: false
18947
+ });
18948
+ buttonGroup.add(svgIcon);
18949
+ } else if (image) {
18950
+ var imageObj = new Image();
18951
+ imageObj.onload = function () {
18952
+ var imageIcon = new Konva.Image({
18953
+ x: width / 2,
18954
+ y: height / 2,
18955
+ image: imageObj,
18956
+ offsetX: image.width / 2,
18957
+ offsetY: image.height / 2,
18958
+ listening: false
18959
+ });
18960
+ buttonGroup.add(imageIcon);
18961
+ buttonGroup.draw();
18962
+ };
18963
+ imageObj.src = image.data;
18964
+ }
18965
+ buttonGroup.on('click', function () {
18966
+ self._peaks.emit('source.buttonClicked', self._source, id);
18967
+ });
18968
+ buttonsGroup.add(buttonGroup);
18969
+ });
18970
+ buttonsGroup.offsetX(buttonsGroupWidth + this._borderWidth + this._peaks.options.sourceButtonsPadding);
18971
+ buttonsGroup.offsetY(-this._borderWidth - this._peaks.options.sourceButtonsPadding);
18972
+ return buttonsGroup;
18973
+ };
18890
18974
  SourceGroup.prototype._updateMarkers = function () {
18891
18975
  const self = this;
18892
18976
  if (this._markersGroup) {
@@ -18902,6 +18986,27 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18902
18986
  });
18903
18987
  }
18904
18988
  };
18989
+ SourceGroup.prototype._updateButtons = function () {
18990
+ if (this._buttonsGroup) {
18991
+ this._buttonsGroup.x(this._width);
18992
+ }
18993
+ };
18994
+ SourceGroup.prototype._getButtons = function () {
18995
+ if (!this._buttonsGroup) {
18996
+ this._buttonsGroup = this._createButtons();
18997
+ }
18998
+ return this._buttonsGroup;
18999
+ };
19000
+ SourceGroup.prototype._showButtons = function () {
19001
+ if (this._buttonsGroup) {
19002
+ this._buttonsGroup.visible(true);
19003
+ }
19004
+ };
19005
+ SourceGroup.prototype._hideButtons = function () {
19006
+ if (this._buttonsGroup) {
19007
+ this._buttonsGroup.visible(false);
19008
+ }
19009
+ };
18905
19010
  SourceGroup.prototype._getYFromVolume = function (volume) {
18906
19011
  return this._borderWidth + (this._height - 2 * this._borderWidth) * (this._source.volumeRange[1] - volume) / (this._source.volumeRange[1] - this._source.volumeRange[0]);
18907
19012
  };
@@ -19220,6 +19325,11 @@ module.exports = function (Utils) {
19220
19325
  if (Utils.isNullOrUndefined(options.markers)) {
19221
19326
  options.markers = [];
19222
19327
  }
19328
+ if (Utils.isNullOrUndefined(options.buttons)) {
19329
+ options.buttons = [];
19330
+ } else if (!Array.isArray(options.buttons)) {
19331
+ throw new TypeError('peaks.sources.' + context + ': buttons must be an array');
19332
+ }
19223
19333
  if (Utils.isNullOrUndefined(options.markerColor) || !Utils.isValidColor(options.markerColor)) {
19224
19334
  options.markerColor = options.color;
19225
19335
  }
@@ -19241,7 +19351,7 @@ module.exports = function (Utils) {
19241
19351
  }
19242
19352
  }
19243
19353
  }
19244
- function Source(peaks, id, originId, elementId, title, titleAlignments, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, warningColor, warningWidth, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition, textAutoScroll, borderWidth, borderRadius, wrapped, position, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, markerColor, markerWidth, volume, volumeRange) {
19354
+ function Source(peaks, id, originId, elementId, title, titleAlignments, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, warningColor, warningWidth, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition, textAutoScroll, borderWidth, borderRadius, wrapped, position, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, buttons, markerColor, markerWidth, volume, volumeRange) {
19245
19355
  var opts = {
19246
19356
  title: title,
19247
19357
  titleAlignments: titleAlignments,
@@ -19284,6 +19394,7 @@ module.exports = function (Utils) {
19284
19394
  binaryHeight: binaryHeight,
19285
19395
  indicators: indicators,
19286
19396
  markers: markers,
19397
+ buttons: buttons,
19287
19398
  markerColor: markerColor,
19288
19399
  markerWidth: markerWidth,
19289
19400
  volume: volume,
@@ -19335,6 +19446,7 @@ module.exports = function (Utils) {
19335
19446
  this._binaryHeight = opts.binaryHeight;
19336
19447
  this._indicators = opts.indicators;
19337
19448
  this._markers = opts.markers;
19449
+ this._buttons = opts.buttons;
19338
19450
  this._markerColor = opts.markerColor;
19339
19451
  this._markerWidth = opts.markerWidth;
19340
19452
  this._volume = opts.volume;
@@ -19685,6 +19797,12 @@ module.exports = function (Utils) {
19685
19797
  return this._markers;
19686
19798
  }
19687
19799
  },
19800
+ buttons: {
19801
+ enumerable: true,
19802
+ get: function () {
19803
+ return this._buttons;
19804
+ }
19805
+ },
19688
19806
  markerColor: {
19689
19807
  enumerable: true,
19690
19808
  get: function () {
@@ -19855,6 +19973,7 @@ module.exports = function (Utils) {
19855
19973
  binaryHeight: this.binaryHeight,
19856
19974
  indicators: this.indicators,
19857
19975
  markers: this.markers,
19976
+ buttons: this.buttons,
19858
19977
  markerColor: this.markerColor,
19859
19978
  markerWidth: this.markerWidth,
19860
19979
  volume: this.volume,
@@ -19903,6 +20022,7 @@ module.exports = function (Utils) {
19903
20022
  this._binaryHeight = opts.binaryHeight;
19904
20023
  this._indicators = opts.indicators;
19905
20024
  this._markers = opts.markers;
20025
+ this._buttons = opts.buttons;
19906
20026
  this._markerColor = opts.markerColor;
19907
20027
  this._markerWidth = opts.markerWidth;
19908
20028
  this._volume = opts.volume;
@@ -20717,7 +20837,7 @@ module.exports = function (Source, Utils) {
20717
20837
  });
20718
20838
  var newSource = this._add([{
20719
20839
  id: Utils.createUuidv4(),
20720
- originId: sourceToCut.originId,
20840
+ originId: sourceToCut.id,
20721
20841
  elementId: sourceToCut.elementId,
20722
20842
  title: sourceToCut.title,
20723
20843
  titleAlignments: sourceToCut.titleAlignments,
@@ -20759,6 +20879,7 @@ module.exports = function (Source, Utils) {
20759
20879
  previewHeight: sourceToCut.previewHeight,
20760
20880
  binaryHeight: sourceToCut.binaryHeight,
20761
20881
  markers: sourceToCut.markers,
20882
+ buttons: sourceToCut.buttons,
20762
20883
  markerColor: sourceToCut.markerColor,
20763
20884
  markerWidth: sourceToCut.markerWidth,
20764
20885
  volume: sourceToCut.volume,
@@ -20780,7 +20901,7 @@ module.exports = function (Source, Utils) {
20780
20901
  if (!Utils.isObject(options)) {
20781
20902
  throw new TypeError('peaks.sources.add(): expected a Source object parameter');
20782
20903
  }
20783
- var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.titleAlignments, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.borderColor, options.selectedColor, options.warningColor, options.warningWidth, options.volumeSliderColor, options.volumeSliderWidth, options.volumeSliderDraggingWidth, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.textAutoScroll, options.borderWidth, options.borderRadius, options.wrapped, options.position, options.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators, options.markers, options.markerColor, options.markerWidth, options.volume, options.volumeRange);
20904
+ var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.titleAlignments, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.borderColor, options.selectedColor, options.warningColor, options.warningWidth, options.volumeSliderColor, options.volumeSliderWidth, options.volumeSliderDraggingWidth, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.textAutoScroll, options.borderWidth, options.borderRadius, options.wrapped, options.position, options.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators, options.markers, options.buttons, options.markerColor, options.markerWidth, options.volume, options.volumeRange);
20784
20905
  return source;
20785
20906
  };
20786
20907
  TimelineSources.prototype.getSources = function () {
package/src/main.js CHANGED
@@ -369,6 +369,16 @@ define([
369
369
  */
370
370
  sourceIndicatorsYOffset: 12,
371
371
 
372
+ /**
373
+ * Spacing between the source buttons, in pixels
374
+ */
375
+ sourceButtonsGap: 2,
376
+
377
+ /**
378
+ * Padding around the source buttons, in pixels
379
+ */
380
+ sourceButtonsPadding: 4,
381
+
372
382
  /**
373
383
  * Threshold size on the left and right border of the view,
374
384
  * where auto scrolling is activated, between 0 and 1.
@@ -53,6 +53,7 @@ define([
53
53
  this._borderWidth = this._source.borderWidth || 0;
54
54
  this._height = this._unwrappedHeight;
55
55
  this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
56
+ this._selected = this._source.selected;
56
57
 
57
58
  this._previewList = [];
58
59
 
@@ -80,6 +81,9 @@ define([
80
81
  self.toggleDragging(false);
81
82
  self.toggleResizing(false);
82
83
  }
84
+ if (!self._selected) {
85
+ self._showButtons();
86
+ }
83
87
  });
84
88
  this._group.on('mouseout', function() {
85
89
  self._view.setHoveredElement(null);
@@ -88,6 +92,9 @@ define([
88
92
  self.toggleDragging(true);
89
93
  self.toggleResizing(true);
90
94
  }
95
+ if (!self._selected) {
96
+ self._hideButtons();
97
+ }
91
98
  });
92
99
 
93
100
  this._group.add(new Konva.Group());
@@ -198,6 +205,7 @@ define([
198
205
  }
199
206
 
200
207
  this._updateVolumeSlider();
208
+ this._updateButtons();
201
209
 
202
210
  // update unwrap
203
211
  this.updatePreviews();
@@ -428,6 +436,9 @@ define([
428
436
  if (this._source.volumeRange && this._source.volume !== undefined) {
429
437
  unwrap.add(this._getVolumeSlider());
430
438
  }
439
+ if (this._source.buttons.length > 0) {
440
+ unwrap.add(this._getButtons());
441
+ }
431
442
  unwrap.add(this._createTitle(false));
432
443
 
433
444
  return unwrap;
@@ -480,6 +491,9 @@ define([
480
491
  if (this._source.volumeRange && this._source.volume !== undefined) {
481
492
  wrap.add(this._getVolumeSlider());
482
493
  }
494
+ if (this._source.buttons.length > 0) {
495
+ wrap.add(this._getButtons());
496
+ }
483
497
  wrap.add(this._createTitle(true));
484
498
 
485
499
  return wrap;
@@ -814,14 +828,17 @@ define([
814
828
  };
815
829
 
816
830
  SourceGroup.prototype.setSelected = function() {
831
+ this._selected = this._source.selected;
817
832
  if (this._border) {
818
- if (this._source.selected) {
833
+ if (this._selected) {
819
834
  this._border.fill(this._source.selectedColor);
820
835
  this._borderWidth = this._peaks.options.sourceSelectedBorderWidth;
836
+ this._showButtons();
821
837
  }
822
838
  else {
823
839
  this._border.fill(this._source.borderColor);
824
840
  this._borderWidth = this._source.borderWidth;
841
+ this._hideButtons();
825
842
  }
826
843
  }
827
844
  else {
@@ -832,7 +849,7 @@ define([
832
849
  })[0];
833
850
 
834
851
  if (unwrap_background) {
835
- if (this._source.selected) {
852
+ if (this._selected) {
836
853
  unwrap_background.stroke(this._source.selectedColor);
837
854
  unwrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
838
855
  }
@@ -849,7 +866,7 @@ define([
849
866
  })[0];
850
867
 
851
868
  if (wrap_background) {
852
- if (this._source.selected) {
869
+ if (this._selected) {
853
870
  wrap_background.stroke(this._source.selectedColor);
854
871
  wrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
855
872
  }
@@ -1092,6 +1109,98 @@ define([
1092
1109
  return markersGroup;
1093
1110
  };
1094
1111
 
1112
+ SourceGroup.prototype._createButtons = function() {
1113
+ var buttonsGroup = new Konva.Group({
1114
+ listening: true,
1115
+ x: this._width,
1116
+ visible: false
1117
+ });
1118
+ var buttonsGroupWidth = 0;
1119
+ var buttonsGap = this._peaks.options.sourceButtonsGap;
1120
+ var self = this;
1121
+
1122
+ this._source.buttons.forEach(function(button) {
1123
+ const {
1124
+ id,
1125
+ width,
1126
+ height,
1127
+ cornerRadius,
1128
+ color,
1129
+ borderColor,
1130
+ borderWidth,
1131
+ svg,
1132
+ image
1133
+ } = button;
1134
+
1135
+ if (buttonsGroupWidth > 0) {
1136
+ buttonsGroupWidth += buttonsGap;
1137
+ }
1138
+
1139
+ var buttonGroup = new Konva.Group({
1140
+ x: buttonsGroupWidth,
1141
+ y: 0,
1142
+ listening: true
1143
+ });
1144
+
1145
+ var buttonRect = new Konva.Rect({
1146
+ width: width,
1147
+ height: height,
1148
+ fill: color,
1149
+ stroke: borderColor,
1150
+ strokeWidth: borderWidth,
1151
+ cornerRadius: cornerRadius
1152
+ });
1153
+
1154
+ buttonsGroupWidth += width;
1155
+
1156
+ buttonGroup.add(buttonRect);
1157
+
1158
+ if (svg) {
1159
+ var svgIcon = new Konva.Path({
1160
+ x: width / 2,
1161
+ y: height / 2,
1162
+ data: svg.path,
1163
+ fill: svg.color,
1164
+ offsetX: svg.width / 2,
1165
+ offsetY: svg.height / 2,
1166
+ listening: false
1167
+ });
1168
+
1169
+ buttonGroup.add(svgIcon);
1170
+ }
1171
+ else if (image) {
1172
+ var imageObj = new Image();
1173
+
1174
+ imageObj.onload = function() {
1175
+ var imageIcon = new Konva.Image({
1176
+ x: width / 2,
1177
+ y: height / 2,
1178
+ image: imageObj,
1179
+ offsetX: image.width / 2,
1180
+ offsetY: image.height / 2,
1181
+ listening: false
1182
+ });
1183
+
1184
+ buttonGroup.add(imageIcon);
1185
+ buttonGroup.draw();
1186
+ };
1187
+
1188
+ imageObj.src = image.data;
1189
+ }
1190
+
1191
+ buttonGroup.on('click', function() {
1192
+ self._peaks.emit('source.buttonClicked', self._source, id);
1193
+ });
1194
+
1195
+ buttonsGroup.add(buttonGroup);
1196
+ });
1197
+
1198
+ buttonsGroup.offsetX(buttonsGroupWidth + this._borderWidth + this._peaks.options.sourceButtonsPadding);
1199
+ buttonsGroup.offsetY(-this._borderWidth - this._peaks.options.sourceButtonsPadding);
1200
+
1201
+ return buttonsGroup;
1202
+ };
1203
+
1095
1204
  SourceGroup.prototype._updateMarkers = function() {
1096
1205
  const self = this;
1097
1206
 
@@ -1105,6 +1214,32 @@ define([
1105
1214
  }
1106
1215
  };
1107
1216
 
1217
+ SourceGroup.prototype._updateButtons = function() {
1218
+ if (this._buttonsGroup) {
1219
+ this._buttonsGroup.x(this._width);
1220
+ }
1221
+ };
1222
+
1223
+ SourceGroup.prototype._getButtons = function() {
1224
+ if (!this._buttonsGroup) {
1225
+ this._buttonsGroup = this._createButtons();
1226
+ }
1227
+
1228
+ return this._buttonsGroup;
1229
+ };
1230
+
1231
+ SourceGroup.prototype._showButtons = function() {
1232
+ if (this._buttonsGroup) {
1233
+ this._buttonsGroup.visible(true);
1234
+ }
1235
+ };
1236
+
1237
+ SourceGroup.prototype._hideButtons = function() {
1238
+ if (this._buttonsGroup) {
1239
+ this._buttonsGroup.visible(false);
1240
+ }
1241
+ };
1242
+
1108
1243
  SourceGroup.prototype._getYFromVolume = function(volume) {
1109
1244
  return this._borderWidth + (this._height - 2 * this._borderWidth) * (
1110
1245
  this._source.volumeRange[1] - volume
package/src/source.js CHANGED
@@ -307,6 +307,13 @@ define([
307
307
  options.markers = [];
308
308
  }
309
309
 
310
+ if (Utils.isNullOrUndefined(options.buttons)) {
311
+ options.buttons = [];
312
+ }
313
+ else if (!Array.isArray(options.buttons)) {
314
+ throw new TypeError('peaks.sources.' + context + ': buttons must be an array');
315
+ }
316
+
310
317
  if (Utils.isNullOrUndefined(options.markerColor)
311
318
  || !Utils.isValidColor(options.markerColor)) {
312
319
  options.markerColor = options.color;
@@ -388,6 +395,7 @@ define([
388
395
  * @param {Number} binaryHeight Height of the binary data visualization.
389
396
  * @param {Array} indicators Array containing indicator data for the source.
390
397
  * @param {Array} markers Array containing marker data for the source.
398
+ * @param {Array} buttons Array containing button data for the source.
391
399
  * @param {String} markerColor Color of the markers.
392
400
  * @param {Number} markerWidth Width of the markers.
393
401
  * @param {Number} volume Current volume level of the source.
@@ -399,7 +407,7 @@ define([
399
407
  borderColor, selectedColor, warningColor, warningWidth, volumeSliderColor, volumeSliderWidth,
400
408
  volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition,
401
409
  textAutoScroll, borderWidth, borderRadius, wrapped, position, draggable, orderable, resizable,
402
- cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, markerColor,
410
+ cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, buttons, markerColor,
403
411
  markerWidth, volume, volumeRange) {
404
412
  var opts = {
405
413
  title: title,
@@ -443,6 +451,7 @@ define([
443
451
  binaryHeight: binaryHeight,
444
452
  indicators: indicators,
445
453
  markers: markers,
454
+ buttons: buttons,
446
455
  markerColor: markerColor,
447
456
  markerWidth: markerWidth,
448
457
  volume: volume,
@@ -496,6 +505,7 @@ define([
496
505
  this._binaryHeight = opts.binaryHeight;
497
506
  this._indicators = opts.indicators;
498
507
  this._markers = opts.markers;
508
+ this._buttons = opts.buttons;
499
509
  this._markerColor = opts.markerColor;
500
510
  this._markerWidth = opts.markerWidth;
501
511
  this._volume = opts.volume;
@@ -871,6 +881,12 @@ define([
871
881
  return this._markers;
872
882
  }
873
883
  },
884
+ buttons: {
885
+ enumerable: true,
886
+ get: function() {
887
+ return this._buttons;
888
+ }
889
+ },
874
890
  markerColor: {
875
891
  enumerable: true,
876
892
  get: function() {
@@ -1075,6 +1091,7 @@ define([
1075
1091
  binaryHeight: this.binaryHeight,
1076
1092
  indicators: this.indicators,
1077
1093
  markers: this.markers,
1094
+ buttons: this.buttons,
1078
1095
  markerColor: this.markerColor,
1079
1096
  markerWidth: this.markerWidth,
1080
1097
  volume: this.volume,
@@ -1126,6 +1143,7 @@ define([
1126
1143
  this._binaryHeight = opts.binaryHeight;
1127
1144
  this._indicators = opts.indicators;
1128
1145
  this._markers = opts.markers;
1146
+ this._buttons = opts.buttons;
1129
1147
  this._markerColor = opts.markerColor;
1130
1148
  this._markerWidth = opts.markerWidth;
1131
1149
  this._volume = opts.volume;
@@ -64,7 +64,7 @@ define([
64
64
  // Create the copy (cut)
65
65
  var newSource = this._add([{
66
66
  id: Utils.createUuidv4(),
67
- originId: sourceToCut.originId,
67
+ originId: sourceToCut.id,
68
68
  elementId: sourceToCut.elementId,
69
69
  title: sourceToCut.title,
70
70
  titleAlignments: sourceToCut.titleAlignments,
@@ -106,6 +106,7 @@ define([
106
106
  previewHeight: sourceToCut.previewHeight,
107
107
  binaryHeight: sourceToCut.binaryHeight,
108
108
  markers: sourceToCut.markers,
109
+ buttons: sourceToCut.buttons,
109
110
  markerColor: sourceToCut.markerColor,
110
111
  markerWidth: sourceToCut.markerWidth,
111
112
  volume: sourceToCut.volume,
@@ -200,6 +201,7 @@ define([
200
201
  options.binaryHeight,
201
202
  options.indicators,
202
203
  options.markers,
204
+ options.buttons,
203
205
  options.markerColor,
204
206
  options.markerWidth,
205
207
  options.volume,