@checksub_team/peaks_timeline 2.5.0-alpha.1 → 2.5.0-alpha.3
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 +117 -45
- package/peaks.js.d.ts +8 -0
- package/src/components/default-segment-marker.js +4 -0
- package/src/components/segment-marker.js +6 -0
- package/src/components/segment-shape.js +52 -46
- package/src/components/sources-layer.js +2 -4
- package/src/models/segment.js +81 -3
- package/src/segment-handler.js +4 -0
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -14753,6 +14753,9 @@ module.exports = function (Utils, Konva) {
|
|
|
14753
14753
|
DefaultSegmentMarker.prototype.timeUpdated = function (time) {
|
|
14754
14754
|
this._label.setText(Utils.formatTime(time, false));
|
|
14755
14755
|
};
|
|
14756
|
+
DefaultSegmentMarker.prototype.setTextColor = function (color) {
|
|
14757
|
+
this._label.fill(color);
|
|
14758
|
+
};
|
|
14756
14759
|
DefaultSegmentMarker.prototype._batchDraw = function () {
|
|
14757
14760
|
const group = this._options.group;
|
|
14758
14761
|
const layer = group && group.getLayer && group.getLayer();
|
|
@@ -17227,6 +17230,11 @@ module.exports = function (Konva) {
|
|
|
17227
17230
|
this._marker.timeUpdated(time);
|
|
17228
17231
|
}
|
|
17229
17232
|
};
|
|
17233
|
+
SegmentMarker.prototype.setTextColor = function (color) {
|
|
17234
|
+
if (this._marker.setTextColor) {
|
|
17235
|
+
this._marker.setTextColor(color);
|
|
17236
|
+
}
|
|
17237
|
+
};
|
|
17230
17238
|
SegmentMarker.prototype.destroy = function () {
|
|
17231
17239
|
this._group.destroyChildren();
|
|
17232
17240
|
this._group.destroy();
|
|
@@ -17253,6 +17261,8 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
17253
17261
|
this._shapeGroup = null;
|
|
17254
17262
|
this._rectangle = null;
|
|
17255
17263
|
this._indicators = {};
|
|
17264
|
+
this._selected = this._segment.selected;
|
|
17265
|
+
this._hovered = false;
|
|
17256
17266
|
var self = this;
|
|
17257
17267
|
this._segmentWidth = this._view.timeToPixels(this._segment.endTime - this._segment.startTime);
|
|
17258
17268
|
this._segmentHeight = this._peaks.options.segmentHeight;
|
|
@@ -17302,6 +17312,7 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
17302
17312
|
this._indicatorsGroup = new Konva.Group();
|
|
17303
17313
|
this._shapeGroup.add(this._indicatorsGroup);
|
|
17304
17314
|
this.createIndicators();
|
|
17315
|
+
this._applyVisualState();
|
|
17305
17316
|
}
|
|
17306
17317
|
SegmentShape.prototype._onShapeGroupDrag = function (draggedElement) {
|
|
17307
17318
|
return this._view._sourcesLayer.onSegmentDrag(draggedElement);
|
|
@@ -17321,40 +17332,54 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
17321
17332
|
fontSize: 12
|
|
17322
17333
|
});
|
|
17323
17334
|
};
|
|
17324
|
-
SegmentShape.prototype.
|
|
17325
|
-
var
|
|
17326
|
-
if (this.
|
|
17327
|
-
this.
|
|
17328
|
-
|
|
17335
|
+
SegmentShape.prototype._getFillColor = function () {
|
|
17336
|
+
var color = this._segment.color;
|
|
17337
|
+
if (this._selected) {
|
|
17338
|
+
color = this._segment.selectedColor;
|
|
17339
|
+
} else if (this._hovered) {
|
|
17340
|
+
color = this._segment.hoverColor;
|
|
17341
|
+
}
|
|
17342
|
+
return color + Math.round(this._segment.opacity * 255).toString(16);
|
|
17343
|
+
};
|
|
17344
|
+
SegmentShape.prototype._getStrokeColor = function () {
|
|
17345
|
+
if (this._selected) {
|
|
17346
|
+
return this._segment.selectedBorderColor;
|
|
17347
|
+
}
|
|
17348
|
+
return this._segment.borderColor || this._segment.textColor + 'FF';
|
|
17349
|
+
};
|
|
17350
|
+
SegmentShape.prototype._getLabelTextColor = function () {
|
|
17351
|
+
return this._selected ? this._segment.selectedTextColor : this._segment.textColor;
|
|
17352
|
+
};
|
|
17353
|
+
SegmentShape.prototype._getHandleTextColor = function () {
|
|
17354
|
+
return this._selected ? this._segment.selectedHandleTextColor : this._segment.handleTextColor;
|
|
17355
|
+
};
|
|
17356
|
+
SegmentShape.prototype._applyVisualState = function () {
|
|
17357
|
+
var fillColor = this._getFillColor();
|
|
17358
|
+
var handleTextColor = this._getHandleTextColor();
|
|
17359
|
+
this._rectangle.fill(fillColor);
|
|
17360
|
+
this._rectangle.stroke(this._getStrokeColor());
|
|
17361
|
+
this._rectangle.fillLinearGradientColorStops([
|
|
17362
|
+
0,
|
|
17363
|
+
fillColor,
|
|
17364
|
+
0.65,
|
|
17365
|
+
this._segment.warningColor
|
|
17366
|
+
]);
|
|
17367
|
+
if (this._label && this._label.fill) {
|
|
17368
|
+
this._label.fill(this._getLabelTextColor());
|
|
17329
17369
|
}
|
|
17330
17370
|
if (this._startMarker) {
|
|
17331
|
-
this._startMarker.
|
|
17332
|
-
this._startMarker = null;
|
|
17371
|
+
this._startMarker.setTextColor(handleTextColor);
|
|
17333
17372
|
}
|
|
17334
17373
|
if (this._endMarker) {
|
|
17335
|
-
this._endMarker.
|
|
17336
|
-
this._endMarker = null;
|
|
17337
|
-
}
|
|
17338
|
-
this._createLabel();
|
|
17339
|
-
this._createMarkers();
|
|
17340
|
-
if (group) {
|
|
17341
|
-
if (this._label) {
|
|
17342
|
-
this._label.moveTo(group);
|
|
17343
|
-
}
|
|
17344
|
-
if (this._startMarker) {
|
|
17345
|
-
this._startMarker.moveTo(group);
|
|
17346
|
-
}
|
|
17347
|
-
if (this._endMarker) {
|
|
17348
|
-
this._endMarker.moveTo(group);
|
|
17349
|
-
}
|
|
17374
|
+
this._endMarker.setTextColor(handleTextColor);
|
|
17350
17375
|
}
|
|
17351
17376
|
};
|
|
17352
17377
|
SegmentShape.prototype.update = function () {
|
|
17353
17378
|
this._applyDisplayTimes(this._segment.startTime, this._segment.endTime);
|
|
17354
17379
|
};
|
|
17355
17380
|
SegmentShape.prototype.setSelected = function () {
|
|
17356
|
-
this.
|
|
17357
|
-
this.
|
|
17381
|
+
this._selected = this._segment.selected;
|
|
17382
|
+
this._applyVisualState();
|
|
17358
17383
|
};
|
|
17359
17384
|
SegmentShape.prototype._applyDisplayTimes = function (startTime, endTime) {
|
|
17360
17385
|
var startPixel = this._view.timeToPixels(startTime);
|
|
@@ -17533,28 +17558,16 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
17533
17558
|
SegmentShape.prototype._onMouseEnter = function () {
|
|
17534
17559
|
this._view.setCursor('pointer');
|
|
17535
17560
|
this._view.setHoveredElement(this);
|
|
17536
|
-
|
|
17537
|
-
this.
|
|
17538
|
-
this._rectangle.fillLinearGradientColorStops([
|
|
17539
|
-
0,
|
|
17540
|
-
fillColor,
|
|
17541
|
-
0.65,
|
|
17542
|
-
this._segment.warningColor
|
|
17543
|
-
]);
|
|
17561
|
+
this._hovered = true;
|
|
17562
|
+
this._applyVisualState();
|
|
17544
17563
|
this._view.batchDrawSourcesLayer();
|
|
17545
17564
|
this._peaks.emit('segments.mouseenter', this._segment);
|
|
17546
17565
|
};
|
|
17547
17566
|
SegmentShape.prototype._onMouseLeave = function () {
|
|
17548
17567
|
this._view.setCursor('default');
|
|
17549
17568
|
this._view.setHoveredElement(null);
|
|
17550
|
-
|
|
17551
|
-
this.
|
|
17552
|
-
this._rectangle.fillLinearGradientColorStops([
|
|
17553
|
-
0,
|
|
17554
|
-
fillColor,
|
|
17555
|
-
0.65,
|
|
17556
|
-
this._segment.warningColor
|
|
17557
|
-
]);
|
|
17569
|
+
this._hovered = false;
|
|
17570
|
+
this._applyVisualState();
|
|
17558
17571
|
this._view.batchDrawSourcesLayer();
|
|
17559
17572
|
this._peaks.emit('segments.mouseleave', this._segment);
|
|
17560
17573
|
};
|
|
@@ -20109,13 +20122,12 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
20109
20122
|
}
|
|
20110
20123
|
};
|
|
20111
20124
|
SourcesLayer.prototype._onSourcesSetSelected = function (sources) {
|
|
20112
|
-
var sourcesGroups = this._lineGroups.getSourcesGroups();
|
|
20113
20125
|
sources.forEach(function (source) {
|
|
20114
|
-
const sourceGroup =
|
|
20126
|
+
const sourceGroup = this._sourcesGroup[source.id];
|
|
20115
20127
|
if (sourceGroup) {
|
|
20116
20128
|
sourceGroup.setSelected();
|
|
20117
20129
|
}
|
|
20118
|
-
});
|
|
20130
|
+
}.bind(this));
|
|
20119
20131
|
this.batchDraw();
|
|
20120
20132
|
};
|
|
20121
20133
|
SourcesLayer.prototype._onSegmentsSetSelected = function (segments) {
|
|
@@ -21904,6 +21916,26 @@ module.exports = function (Utils) {
|
|
|
21904
21916
|
} else if (!Utils.isValidColor(options.hoverColor)) {
|
|
21905
21917
|
throw new TypeError('peaks.segments.' + context + ': hoverColor must be a boolean');
|
|
21906
21918
|
}
|
|
21919
|
+
if (Utils.isNullOrUndefined(options.selectedColor)) {
|
|
21920
|
+
options.selectedColor = options.color;
|
|
21921
|
+
} else if (!Utils.isValidColor(options.selectedColor)) {
|
|
21922
|
+
throw new TypeError('peaks.segments.' + context + ': selectedColor must be a valid CSS color');
|
|
21923
|
+
}
|
|
21924
|
+
if (Utils.isNullOrUndefined(options.selectedTextColor)) {
|
|
21925
|
+
options.selectedTextColor = options.textColor;
|
|
21926
|
+
} else if (!Utils.isValidColor(options.selectedTextColor)) {
|
|
21927
|
+
throw new TypeError('peaks.segments.' + context + ': selectedTextColor must be a valid CSS color');
|
|
21928
|
+
}
|
|
21929
|
+
if (Utils.isNullOrUndefined(options.selectedHandleTextColor)) {
|
|
21930
|
+
options.selectedHandleTextColor = options.handleTextColor;
|
|
21931
|
+
} else if (!Utils.isValidColor(options.selectedHandleTextColor)) {
|
|
21932
|
+
throw new TypeError('peaks.segments.' + context + ': selectedHandleTextColor must be a valid CSS color');
|
|
21933
|
+
}
|
|
21934
|
+
if (Utils.isNullOrUndefined(options.selectedBorderColor)) {
|
|
21935
|
+
options.selectedBorderColor = Utils.shadeColor(options.borderColor || options.textColor + 'FF', 30);
|
|
21936
|
+
} else if (!Utils.isValidColor(options.selectedBorderColor)) {
|
|
21937
|
+
throw new TypeError('peaks.segments.' + context + ': selectedBorderColor must be a valid CSS color');
|
|
21938
|
+
}
|
|
21907
21939
|
if (Utils.isNullOrUndefined(options.warningColor)) {
|
|
21908
21940
|
options.warningColor = '#E48023';
|
|
21909
21941
|
} else if (!Utils.isValidColor(options.warningColor)) {
|
|
@@ -21911,7 +21943,7 @@ module.exports = function (Utils) {
|
|
|
21911
21943
|
}
|
|
21912
21944
|
return shouldNotifyUpdate;
|
|
21913
21945
|
}
|
|
21914
|
-
function Segment(peaks, id, startTime, endTime, duration, labelText, color, textColor, handleTextColor, hoverColor, warningColor, opacity, borderColor, borderWidth, borderRadius, editable, allowDeletion, line, indicators) {
|
|
21946
|
+
function Segment(peaks, id, startTime, endTime, duration, labelText, color, textColor, handleTextColor, hoverColor, selectedColor, selectedTextColor, selectedHandleTextColor, warningColor, opacity, borderColor, selectedBorderColor, borderWidth, borderRadius, editable, allowDeletion, line, indicators) {
|
|
21915
21947
|
var opts = {
|
|
21916
21948
|
startTime: startTime,
|
|
21917
21949
|
endTime: endTime,
|
|
@@ -21921,9 +21953,13 @@ module.exports = function (Utils) {
|
|
|
21921
21953
|
textColor: textColor,
|
|
21922
21954
|
handleTextColor: handleTextColor,
|
|
21923
21955
|
hoverColor: hoverColor,
|
|
21956
|
+
selectedColor: selectedColor,
|
|
21957
|
+
selectedTextColor: selectedTextColor,
|
|
21958
|
+
selectedHandleTextColor: selectedHandleTextColor,
|
|
21924
21959
|
warningColor: warningColor,
|
|
21925
21960
|
opacity: opacity,
|
|
21926
21961
|
borderColor: borderColor,
|
|
21962
|
+
selectedBorderColor: selectedBorderColor,
|
|
21927
21963
|
borderWidth: borderWidth,
|
|
21928
21964
|
borderRadius: borderRadius,
|
|
21929
21965
|
editable: editable,
|
|
@@ -21942,9 +21978,13 @@ module.exports = function (Utils) {
|
|
|
21942
21978
|
this._hoverColor = opts.hoverColor;
|
|
21943
21979
|
this._textColor = opts.textColor;
|
|
21944
21980
|
this._handleTextColor = opts.handleTextColor;
|
|
21981
|
+
this._selectedColor = opts.selectedColor;
|
|
21982
|
+
this._selectedTextColor = opts.selectedTextColor;
|
|
21983
|
+
this._selectedHandleTextColor = opts.selectedHandleTextColor;
|
|
21945
21984
|
this._warningColor = opts.warningColor;
|
|
21946
21985
|
this._opacity = opts.opacity;
|
|
21947
21986
|
this._borderColor = opts.borderColor;
|
|
21987
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
21948
21988
|
this._borderWidth = opts.borderWidth;
|
|
21949
21989
|
this._borderRadius = opts.borderRadius;
|
|
21950
21990
|
this._editable = opts.editable;
|
|
@@ -22010,18 +22050,36 @@ module.exports = function (Utils) {
|
|
|
22010
22050
|
return this._hoverColor;
|
|
22011
22051
|
}
|
|
22012
22052
|
},
|
|
22053
|
+
selectedColor: {
|
|
22054
|
+
enumerable: true,
|
|
22055
|
+
get: function () {
|
|
22056
|
+
return this._selectedColor;
|
|
22057
|
+
}
|
|
22058
|
+
},
|
|
22013
22059
|
textColor: {
|
|
22014
22060
|
enumerable: true,
|
|
22015
22061
|
get: function () {
|
|
22016
22062
|
return this._textColor;
|
|
22017
22063
|
}
|
|
22018
22064
|
},
|
|
22065
|
+
selectedTextColor: {
|
|
22066
|
+
enumerable: true,
|
|
22067
|
+
get: function () {
|
|
22068
|
+
return this._selectedTextColor;
|
|
22069
|
+
}
|
|
22070
|
+
},
|
|
22019
22071
|
handleTextColor: {
|
|
22020
22072
|
enumerable: true,
|
|
22021
22073
|
get: function () {
|
|
22022
22074
|
return this._handleTextColor;
|
|
22023
22075
|
}
|
|
22024
22076
|
},
|
|
22077
|
+
selectedHandleTextColor: {
|
|
22078
|
+
enumerable: true,
|
|
22079
|
+
get: function () {
|
|
22080
|
+
return this._selectedHandleTextColor;
|
|
22081
|
+
}
|
|
22082
|
+
},
|
|
22025
22083
|
warningColor: {
|
|
22026
22084
|
enumerable: true,
|
|
22027
22085
|
get: function () {
|
|
@@ -22040,6 +22098,12 @@ module.exports = function (Utils) {
|
|
|
22040
22098
|
return this._borderColor;
|
|
22041
22099
|
}
|
|
22042
22100
|
},
|
|
22101
|
+
selectedBorderColor: {
|
|
22102
|
+
enumerable: true,
|
|
22103
|
+
get: function () {
|
|
22104
|
+
return this._selectedBorderColor;
|
|
22105
|
+
}
|
|
22106
|
+
},
|
|
22043
22107
|
borderWidth: {
|
|
22044
22108
|
enumerable: true,
|
|
22045
22109
|
get: function () {
|
|
@@ -22111,9 +22175,13 @@ module.exports = function (Utils) {
|
|
|
22111
22175
|
textColor: this.textColor,
|
|
22112
22176
|
handleTextColor: this.handleTextColor,
|
|
22113
22177
|
hoverColor: this.hoverColor,
|
|
22178
|
+
selectedColor: this.selectedColor,
|
|
22179
|
+
selectedTextColor: this.selectedTextColor,
|
|
22180
|
+
selectedHandleTextColor: this.selectedHandleTextColor,
|
|
22114
22181
|
warningColor: this.warningColor,
|
|
22115
22182
|
opacity: this.opacity,
|
|
22116
22183
|
borderColor: this.borderColor,
|
|
22184
|
+
selectedBorderColor: this.selectedBorderColor,
|
|
22117
22185
|
borderWidth: this.borderWidth,
|
|
22118
22186
|
borderRadius: this.borderRadius,
|
|
22119
22187
|
editable: this.editable,
|
|
@@ -22131,9 +22199,13 @@ module.exports = function (Utils) {
|
|
|
22131
22199
|
this._textColor = opts.textColor;
|
|
22132
22200
|
this._handleTextColor = opts.handleTextColor;
|
|
22133
22201
|
this._hoverColor = opts.hoverColor;
|
|
22202
|
+
this._selectedColor = opts.selectedColor;
|
|
22203
|
+
this._selectedTextColor = opts.selectedTextColor;
|
|
22204
|
+
this._selectedHandleTextColor = opts.selectedHandleTextColor;
|
|
22134
22205
|
this._warningColor = opts.warningColor;
|
|
22135
22206
|
this._opacity = opts.opacity;
|
|
22136
22207
|
this._borderColor = opts.borderColor;
|
|
22208
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
22137
22209
|
this._borderWidth = opts.borderWidth;
|
|
22138
22210
|
this._borderRadius = opts.borderRadius;
|
|
22139
22211
|
this._editable = opts.editable;
|
|
@@ -23305,7 +23377,7 @@ module.exports = function (Colors, Segment, Utils) {
|
|
|
23305
23377
|
if (!Utils.isObject(options)) {
|
|
23306
23378
|
throw new TypeError('peaks.segments.add(): expected a Segment object parameter');
|
|
23307
23379
|
}
|
|
23308
|
-
var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.duration, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.hoverColor, options.warningColor, options.opacity || 1, options.borderColor, options.borderWidth, options.borderRadius, options.editable, options.allowDeletion || false, options.line, options.indicators);
|
|
23380
|
+
var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.duration, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.hoverColor, options.selectedColor, options.selectedTextColor, options.selectedHandleTextColor, options.warningColor, options.opacity || 1, options.borderColor, options.selectedBorderColor, options.borderWidth, options.borderRadius, options.editable, options.allowDeletion || false, options.line, options.indicators);
|
|
23309
23381
|
return segment;
|
|
23310
23382
|
};
|
|
23311
23383
|
SegmentHandler.prototype.getSegments = function () {
|
package/peaks.js.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ declare module 'peaks.js' {
|
|
|
9
9
|
endTime: number;
|
|
10
10
|
editable?: boolean;
|
|
11
11
|
color?: string;
|
|
12
|
+
selectedColor?: string;
|
|
13
|
+
selectedTextColor?: string;
|
|
14
|
+
selectedHandleTextColor?: string;
|
|
15
|
+
selectedBorderColor?: string;
|
|
12
16
|
labelText?: string;
|
|
13
17
|
id?: string;
|
|
14
18
|
}
|
|
@@ -18,6 +22,10 @@ declare module 'peaks.js' {
|
|
|
18
22
|
endTime?: number;
|
|
19
23
|
editable?: boolean;
|
|
20
24
|
color?: string;
|
|
25
|
+
selectedColor?: string;
|
|
26
|
+
selectedTextColor?: string;
|
|
27
|
+
selectedHandleTextColor?: string;
|
|
28
|
+
selectedBorderColor?: string;
|
|
21
29
|
labelText?: string;
|
|
22
30
|
}
|
|
23
31
|
|
|
@@ -128,6 +128,10 @@ define([
|
|
|
128
128
|
this._label.setText(Utils.formatTime(time, false));
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
+
DefaultSegmentMarker.prototype.setTextColor = function(color) {
|
|
132
|
+
this._label.fill(color);
|
|
133
|
+
};
|
|
134
|
+
|
|
131
135
|
DefaultSegmentMarker.prototype._batchDraw = function() {
|
|
132
136
|
const group = this._options.group;
|
|
133
137
|
const layer = group && group.getLayer && group.getLayer();
|
|
@@ -134,6 +134,12 @@ define([
|
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
+
SegmentMarker.prototype.setTextColor = function(color) {
|
|
138
|
+
if (this._marker.setTextColor) {
|
|
139
|
+
this._marker.setTextColor(color);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
137
143
|
SegmentMarker.prototype.destroy = function() {
|
|
138
144
|
this._group.destroyChildren();
|
|
139
145
|
this._group.destroy();
|
|
@@ -47,6 +47,8 @@ define([
|
|
|
47
47
|
this._shapeGroup = null;
|
|
48
48
|
this._rectangle = null;
|
|
49
49
|
this._indicators = {};
|
|
50
|
+
this._selected = this._segment.selected;
|
|
51
|
+
this._hovered = false;
|
|
50
52
|
|
|
51
53
|
var self = this;
|
|
52
54
|
|
|
@@ -113,6 +115,7 @@ define([
|
|
|
113
115
|
this._shapeGroup.add(this._indicatorsGroup);
|
|
114
116
|
|
|
115
117
|
this.createIndicators();
|
|
118
|
+
this._applyVisualState();
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
SegmentShape.prototype._onShapeGroupDrag = function(draggedElement) {
|
|
@@ -138,39 +141,58 @@ define([
|
|
|
138
141
|
});
|
|
139
142
|
};
|
|
140
143
|
|
|
141
|
-
SegmentShape.prototype.
|
|
142
|
-
var
|
|
144
|
+
SegmentShape.prototype._getFillColor = function() {
|
|
145
|
+
var color = this._segment.color;
|
|
143
146
|
|
|
144
|
-
if (this.
|
|
145
|
-
this.
|
|
146
|
-
this._label = null;
|
|
147
|
+
if (this._selected) {
|
|
148
|
+
color = this._segment.selectedColor;
|
|
147
149
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this._startMarker.destroy();
|
|
151
|
-
this._startMarker = null;
|
|
150
|
+
else if (this._hovered) {
|
|
151
|
+
color = this._segment.hoverColor;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
return color + Math.round(this._segment.opacity * 255).toString(16);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
SegmentShape.prototype._getStrokeColor = function() {
|
|
158
|
+
if (this._selected) {
|
|
159
|
+
return this._segment.selectedBorderColor;
|
|
157
160
|
}
|
|
158
161
|
|
|
159
|
-
this.
|
|
160
|
-
|
|
162
|
+
return this._segment.borderColor || this._segment.textColor + 'FF';
|
|
163
|
+
};
|
|
161
164
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
165
|
+
SegmentShape.prototype._getLabelTextColor = function() {
|
|
166
|
+
return this._selected ? this._segment.selectedTextColor : this._segment.textColor;
|
|
167
|
+
};
|
|
166
168
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
SegmentShape.prototype._getHandleTextColor = function() {
|
|
170
|
+
return this._selected ?
|
|
171
|
+
this._segment.selectedHandleTextColor :
|
|
172
|
+
this._segment.handleTextColor;
|
|
173
|
+
};
|
|
170
174
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
SegmentShape.prototype._applyVisualState = function() {
|
|
176
|
+
var fillColor = this._getFillColor();
|
|
177
|
+
var handleTextColor = this._getHandleTextColor();
|
|
178
|
+
|
|
179
|
+
this._rectangle.fill(fillColor);
|
|
180
|
+
this._rectangle.stroke(this._getStrokeColor());
|
|
181
|
+
this._rectangle.fillLinearGradientColorStops([
|
|
182
|
+
0, fillColor,
|
|
183
|
+
0.65, this._segment.warningColor
|
|
184
|
+
]);
|
|
185
|
+
|
|
186
|
+
if (this._label && this._label.fill) {
|
|
187
|
+
this._label.fill(this._getLabelTextColor());
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (this._startMarker) {
|
|
191
|
+
this._startMarker.setTextColor(handleTextColor);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (this._endMarker) {
|
|
195
|
+
this._endMarker.setTextColor(handleTextColor);
|
|
174
196
|
}
|
|
175
197
|
};
|
|
176
198
|
|
|
@@ -179,8 +201,8 @@ define([
|
|
|
179
201
|
};
|
|
180
202
|
|
|
181
203
|
SegmentShape.prototype.setSelected = function() {
|
|
182
|
-
this.
|
|
183
|
-
this.
|
|
204
|
+
this._selected = this._segment.selected;
|
|
205
|
+
this._applyVisualState();
|
|
184
206
|
};
|
|
185
207
|
|
|
186
208
|
SegmentShape.prototype._applyDisplayTimes = function(startTime, endTime) {
|
|
@@ -409,16 +431,8 @@ define([
|
|
|
409
431
|
this._view.setCursor('pointer');
|
|
410
432
|
|
|
411
433
|
this._view.setHoveredElement(this);
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
this._segment.opacity * 255
|
|
415
|
-
).toString(16);
|
|
416
|
-
|
|
417
|
-
this._rectangle.fill(fillColor);
|
|
418
|
-
this._rectangle.fillLinearGradientColorStops([
|
|
419
|
-
0, fillColor,
|
|
420
|
-
0.65, this._segment.warningColor
|
|
421
|
-
]);
|
|
434
|
+
this._hovered = true;
|
|
435
|
+
this._applyVisualState();
|
|
422
436
|
|
|
423
437
|
this._view.batchDrawSourcesLayer();
|
|
424
438
|
|
|
@@ -429,16 +443,8 @@ define([
|
|
|
429
443
|
this._view.setCursor('default');
|
|
430
444
|
|
|
431
445
|
this._view.setHoveredElement(null);
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
this._segment.opacity * 255
|
|
435
|
-
).toString(16);
|
|
436
|
-
|
|
437
|
-
this._rectangle.fill(fillColor);
|
|
438
|
-
this._rectangle.fillLinearGradientColorStops([
|
|
439
|
-
0, fillColor,
|
|
440
|
-
0.65, this._segment.warningColor
|
|
441
|
-
]);
|
|
446
|
+
this._hovered = false;
|
|
447
|
+
this._applyVisualState();
|
|
442
448
|
|
|
443
449
|
this._view.batchDrawSourcesLayer();
|
|
444
450
|
|
|
@@ -271,15 +271,13 @@ define([
|
|
|
271
271
|
};
|
|
272
272
|
|
|
273
273
|
SourcesLayer.prototype._onSourcesSetSelected = function(sources) {
|
|
274
|
-
var sourcesGroups = this._lineGroups.getSourcesGroups();
|
|
275
|
-
|
|
276
274
|
sources.forEach(function(source) {
|
|
277
|
-
const sourceGroup =
|
|
275
|
+
const sourceGroup = this._sourcesGroup[source.id];
|
|
278
276
|
|
|
279
277
|
if (sourceGroup) {
|
|
280
278
|
sourceGroup.setSelected();
|
|
281
279
|
}
|
|
282
|
-
});
|
|
280
|
+
}.bind(this));
|
|
283
281
|
|
|
284
282
|
this.batchDraw();
|
|
285
283
|
};
|
package/src/models/segment.js
CHANGED
|
@@ -71,6 +71,43 @@ define([
|
|
|
71
71
|
throw new TypeError('peaks.segments.' + context + ': hoverColor must be a boolean');
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
if (Utils.isNullOrUndefined(options.selectedColor)) {
|
|
75
|
+
options.selectedColor = options.color;
|
|
76
|
+
}
|
|
77
|
+
else if (!Utils.isValidColor(options.selectedColor)) {
|
|
78
|
+
throw new TypeError('peaks.segments.' + context + ': selectedColor must be a valid CSS color');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (Utils.isNullOrUndefined(options.selectedTextColor)) {
|
|
82
|
+
options.selectedTextColor = options.textColor;
|
|
83
|
+
}
|
|
84
|
+
else if (!Utils.isValidColor(options.selectedTextColor)) {
|
|
85
|
+
throw new TypeError(
|
|
86
|
+
'peaks.segments.' + context + ': selectedTextColor must be a valid CSS color'
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (Utils.isNullOrUndefined(options.selectedHandleTextColor)) {
|
|
91
|
+
options.selectedHandleTextColor = options.handleTextColor;
|
|
92
|
+
}
|
|
93
|
+
else if (!Utils.isValidColor(options.selectedHandleTextColor)) {
|
|
94
|
+
throw new TypeError(
|
|
95
|
+
'peaks.segments.' + context + ': selectedHandleTextColor must be a valid CSS color'
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (Utils.isNullOrUndefined(options.selectedBorderColor)) {
|
|
100
|
+
options.selectedBorderColor = Utils.shadeColor(
|
|
101
|
+
options.borderColor || options.textColor + 'FF',
|
|
102
|
+
30
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
else if (!Utils.isValidColor(options.selectedBorderColor)) {
|
|
106
|
+
throw new TypeError(
|
|
107
|
+
'peaks.segments.' + context + ': selectedBorderColor must be a valid CSS color'
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
74
111
|
if (Utils.isNullOrUndefined(options.warningColor)) {
|
|
75
112
|
options.warningColor = '#E48023';
|
|
76
113
|
}
|
|
@@ -104,9 +141,10 @@ define([
|
|
|
104
141
|
*/
|
|
105
142
|
|
|
106
143
|
function Segment(peaks, id, startTime, endTime, duration, labelText,
|
|
107
|
-
color, textColor, handleTextColor, hoverColor,
|
|
108
|
-
|
|
109
|
-
|
|
144
|
+
color, textColor, handleTextColor, hoverColor, selectedColor,
|
|
145
|
+
selectedTextColor, selectedHandleTextColor, warningColor, opacity,
|
|
146
|
+
borderColor, selectedBorderColor, borderWidth, borderRadius, editable,
|
|
147
|
+
allowDeletion, line, indicators) {
|
|
110
148
|
var opts = {
|
|
111
149
|
startTime: startTime,
|
|
112
150
|
endTime: endTime,
|
|
@@ -116,9 +154,13 @@ define([
|
|
|
116
154
|
textColor: textColor,
|
|
117
155
|
handleTextColor: handleTextColor,
|
|
118
156
|
hoverColor: hoverColor,
|
|
157
|
+
selectedColor: selectedColor,
|
|
158
|
+
selectedTextColor: selectedTextColor,
|
|
159
|
+
selectedHandleTextColor: selectedHandleTextColor,
|
|
119
160
|
warningColor: warningColor,
|
|
120
161
|
opacity: opacity,
|
|
121
162
|
borderColor: borderColor,
|
|
163
|
+
selectedBorderColor: selectedBorderColor,
|
|
122
164
|
borderWidth: borderWidth,
|
|
123
165
|
borderRadius: borderRadius,
|
|
124
166
|
editable: editable,
|
|
@@ -139,9 +181,13 @@ define([
|
|
|
139
181
|
this._hoverColor = opts.hoverColor;
|
|
140
182
|
this._textColor = opts.textColor;
|
|
141
183
|
this._handleTextColor = opts.handleTextColor;
|
|
184
|
+
this._selectedColor = opts.selectedColor;
|
|
185
|
+
this._selectedTextColor = opts.selectedTextColor;
|
|
186
|
+
this._selectedHandleTextColor = opts.selectedHandleTextColor;
|
|
142
187
|
this._warningColor = opts.warningColor;
|
|
143
188
|
this._opacity = opts.opacity;
|
|
144
189
|
this._borderColor = opts.borderColor;
|
|
190
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
145
191
|
this._borderWidth = opts.borderWidth;
|
|
146
192
|
this._borderRadius = opts.borderRadius;
|
|
147
193
|
this._editable = opts.editable;
|
|
@@ -213,18 +259,36 @@ define([
|
|
|
213
259
|
return this._hoverColor;
|
|
214
260
|
}
|
|
215
261
|
},
|
|
262
|
+
selectedColor: {
|
|
263
|
+
enumerable: true,
|
|
264
|
+
get: function() {
|
|
265
|
+
return this._selectedColor;
|
|
266
|
+
}
|
|
267
|
+
},
|
|
216
268
|
textColor: {
|
|
217
269
|
enumerable: true,
|
|
218
270
|
get: function() {
|
|
219
271
|
return this._textColor;
|
|
220
272
|
}
|
|
221
273
|
},
|
|
274
|
+
selectedTextColor: {
|
|
275
|
+
enumerable: true,
|
|
276
|
+
get: function() {
|
|
277
|
+
return this._selectedTextColor;
|
|
278
|
+
}
|
|
279
|
+
},
|
|
222
280
|
handleTextColor: {
|
|
223
281
|
enumerable: true,
|
|
224
282
|
get: function() {
|
|
225
283
|
return this._handleTextColor;
|
|
226
284
|
}
|
|
227
285
|
},
|
|
286
|
+
selectedHandleTextColor: {
|
|
287
|
+
enumerable: true,
|
|
288
|
+
get: function() {
|
|
289
|
+
return this._selectedHandleTextColor;
|
|
290
|
+
}
|
|
291
|
+
},
|
|
228
292
|
warningColor: {
|
|
229
293
|
enumerable: true,
|
|
230
294
|
get: function() {
|
|
@@ -243,6 +307,12 @@ define([
|
|
|
243
307
|
return this._borderColor;
|
|
244
308
|
}
|
|
245
309
|
},
|
|
310
|
+
selectedBorderColor: {
|
|
311
|
+
enumerable: true,
|
|
312
|
+
get: function() {
|
|
313
|
+
return this._selectedBorderColor;
|
|
314
|
+
}
|
|
315
|
+
},
|
|
246
316
|
borderWidth: {
|
|
247
317
|
enumerable: true,
|
|
248
318
|
get: function() {
|
|
@@ -316,9 +386,13 @@ define([
|
|
|
316
386
|
textColor: this.textColor,
|
|
317
387
|
handleTextColor: this.handleTextColor,
|
|
318
388
|
hoverColor: this.hoverColor,
|
|
389
|
+
selectedColor: this.selectedColor,
|
|
390
|
+
selectedTextColor: this.selectedTextColor,
|
|
391
|
+
selectedHandleTextColor: this.selectedHandleTextColor,
|
|
319
392
|
warningColor: this.warningColor,
|
|
320
393
|
opacity: this.opacity,
|
|
321
394
|
borderColor: this.borderColor,
|
|
395
|
+
selectedBorderColor: this.selectedBorderColor,
|
|
322
396
|
borderWidth: this.borderWidth,
|
|
323
397
|
borderRadius: this.borderRadius,
|
|
324
398
|
editable: this.editable,
|
|
@@ -339,9 +413,13 @@ define([
|
|
|
339
413
|
this._textColor = opts.textColor;
|
|
340
414
|
this._handleTextColor = opts.handleTextColor;
|
|
341
415
|
this._hoverColor = opts.hoverColor;
|
|
416
|
+
this._selectedColor = opts.selectedColor;
|
|
417
|
+
this._selectedTextColor = opts.selectedTextColor;
|
|
418
|
+
this._selectedHandleTextColor = opts.selectedHandleTextColor;
|
|
342
419
|
this._warningColor = opts.warningColor;
|
|
343
420
|
this._opacity = opts.opacity;
|
|
344
421
|
this._borderColor = opts.borderColor;
|
|
422
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
345
423
|
this._borderWidth = opts.borderWidth;
|
|
346
424
|
this._borderRadius = opts.borderRadius;
|
|
347
425
|
this._editable = opts.editable;
|
package/src/segment-handler.js
CHANGED
|
@@ -136,9 +136,13 @@ define([
|
|
|
136
136
|
options.textColor || '#000000',
|
|
137
137
|
options.handleTextColor || '#000000',
|
|
138
138
|
options.hoverColor,
|
|
139
|
+
options.selectedColor,
|
|
140
|
+
options.selectedTextColor,
|
|
141
|
+
options.selectedHandleTextColor,
|
|
139
142
|
options.warningColor,
|
|
140
143
|
options.opacity || 1,
|
|
141
144
|
options.borderColor,
|
|
145
|
+
options.selectedBorderColor,
|
|
142
146
|
options.borderWidth,
|
|
143
147
|
options.borderRadius,
|
|
144
148
|
options.editable,
|