@checksub_team/peaks_timeline 2.5.0-alpha.1 → 2.5.0-alpha.2
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 +115 -42
- 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/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
|
};
|
|
@@ -21904,6 +21917,26 @@ module.exports = function (Utils) {
|
|
|
21904
21917
|
} else if (!Utils.isValidColor(options.hoverColor)) {
|
|
21905
21918
|
throw new TypeError('peaks.segments.' + context + ': hoverColor must be a boolean');
|
|
21906
21919
|
}
|
|
21920
|
+
if (Utils.isNullOrUndefined(options.selectedColor)) {
|
|
21921
|
+
options.selectedColor = options.color;
|
|
21922
|
+
} else if (!Utils.isValidColor(options.selectedColor)) {
|
|
21923
|
+
throw new TypeError('peaks.segments.' + context + ': selectedColor must be a valid CSS color');
|
|
21924
|
+
}
|
|
21925
|
+
if (Utils.isNullOrUndefined(options.selectedTextColor)) {
|
|
21926
|
+
options.selectedTextColor = options.textColor;
|
|
21927
|
+
} else if (!Utils.isValidColor(options.selectedTextColor)) {
|
|
21928
|
+
throw new TypeError('peaks.segments.' + context + ': selectedTextColor must be a valid CSS color');
|
|
21929
|
+
}
|
|
21930
|
+
if (Utils.isNullOrUndefined(options.selectedHandleTextColor)) {
|
|
21931
|
+
options.selectedHandleTextColor = options.handleTextColor;
|
|
21932
|
+
} else if (!Utils.isValidColor(options.selectedHandleTextColor)) {
|
|
21933
|
+
throw new TypeError('peaks.segments.' + context + ': selectedHandleTextColor must be a valid CSS color');
|
|
21934
|
+
}
|
|
21935
|
+
if (Utils.isNullOrUndefined(options.selectedBorderColor)) {
|
|
21936
|
+
options.selectedBorderColor = Utils.shadeColor(options.borderColor || options.textColor + 'FF', 30);
|
|
21937
|
+
} else if (!Utils.isValidColor(options.selectedBorderColor)) {
|
|
21938
|
+
throw new TypeError('peaks.segments.' + context + ': selectedBorderColor must be a valid CSS color');
|
|
21939
|
+
}
|
|
21907
21940
|
if (Utils.isNullOrUndefined(options.warningColor)) {
|
|
21908
21941
|
options.warningColor = '#E48023';
|
|
21909
21942
|
} else if (!Utils.isValidColor(options.warningColor)) {
|
|
@@ -21911,7 +21944,7 @@ module.exports = function (Utils) {
|
|
|
21911
21944
|
}
|
|
21912
21945
|
return shouldNotifyUpdate;
|
|
21913
21946
|
}
|
|
21914
|
-
function Segment(peaks, id, startTime, endTime, duration, labelText, color, textColor, handleTextColor, hoverColor, warningColor, opacity, borderColor, borderWidth, borderRadius, editable, allowDeletion, line, indicators) {
|
|
21947
|
+
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
21948
|
var opts = {
|
|
21916
21949
|
startTime: startTime,
|
|
21917
21950
|
endTime: endTime,
|
|
@@ -21921,9 +21954,13 @@ module.exports = function (Utils) {
|
|
|
21921
21954
|
textColor: textColor,
|
|
21922
21955
|
handleTextColor: handleTextColor,
|
|
21923
21956
|
hoverColor: hoverColor,
|
|
21957
|
+
selectedColor: selectedColor,
|
|
21958
|
+
selectedTextColor: selectedTextColor,
|
|
21959
|
+
selectedHandleTextColor: selectedHandleTextColor,
|
|
21924
21960
|
warningColor: warningColor,
|
|
21925
21961
|
opacity: opacity,
|
|
21926
21962
|
borderColor: borderColor,
|
|
21963
|
+
selectedBorderColor: selectedBorderColor,
|
|
21927
21964
|
borderWidth: borderWidth,
|
|
21928
21965
|
borderRadius: borderRadius,
|
|
21929
21966
|
editable: editable,
|
|
@@ -21942,9 +21979,13 @@ module.exports = function (Utils) {
|
|
|
21942
21979
|
this._hoverColor = opts.hoverColor;
|
|
21943
21980
|
this._textColor = opts.textColor;
|
|
21944
21981
|
this._handleTextColor = opts.handleTextColor;
|
|
21982
|
+
this._selectedColor = opts.selectedColor;
|
|
21983
|
+
this._selectedTextColor = opts.selectedTextColor;
|
|
21984
|
+
this._selectedHandleTextColor = opts.selectedHandleTextColor;
|
|
21945
21985
|
this._warningColor = opts.warningColor;
|
|
21946
21986
|
this._opacity = opts.opacity;
|
|
21947
21987
|
this._borderColor = opts.borderColor;
|
|
21988
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
21948
21989
|
this._borderWidth = opts.borderWidth;
|
|
21949
21990
|
this._borderRadius = opts.borderRadius;
|
|
21950
21991
|
this._editable = opts.editable;
|
|
@@ -22010,18 +22051,36 @@ module.exports = function (Utils) {
|
|
|
22010
22051
|
return this._hoverColor;
|
|
22011
22052
|
}
|
|
22012
22053
|
},
|
|
22054
|
+
selectedColor: {
|
|
22055
|
+
enumerable: true,
|
|
22056
|
+
get: function () {
|
|
22057
|
+
return this._selectedColor;
|
|
22058
|
+
}
|
|
22059
|
+
},
|
|
22013
22060
|
textColor: {
|
|
22014
22061
|
enumerable: true,
|
|
22015
22062
|
get: function () {
|
|
22016
22063
|
return this._textColor;
|
|
22017
22064
|
}
|
|
22018
22065
|
},
|
|
22066
|
+
selectedTextColor: {
|
|
22067
|
+
enumerable: true,
|
|
22068
|
+
get: function () {
|
|
22069
|
+
return this._selectedTextColor;
|
|
22070
|
+
}
|
|
22071
|
+
},
|
|
22019
22072
|
handleTextColor: {
|
|
22020
22073
|
enumerable: true,
|
|
22021
22074
|
get: function () {
|
|
22022
22075
|
return this._handleTextColor;
|
|
22023
22076
|
}
|
|
22024
22077
|
},
|
|
22078
|
+
selectedHandleTextColor: {
|
|
22079
|
+
enumerable: true,
|
|
22080
|
+
get: function () {
|
|
22081
|
+
return this._selectedHandleTextColor;
|
|
22082
|
+
}
|
|
22083
|
+
},
|
|
22025
22084
|
warningColor: {
|
|
22026
22085
|
enumerable: true,
|
|
22027
22086
|
get: function () {
|
|
@@ -22040,6 +22099,12 @@ module.exports = function (Utils) {
|
|
|
22040
22099
|
return this._borderColor;
|
|
22041
22100
|
}
|
|
22042
22101
|
},
|
|
22102
|
+
selectedBorderColor: {
|
|
22103
|
+
enumerable: true,
|
|
22104
|
+
get: function () {
|
|
22105
|
+
return this._selectedBorderColor;
|
|
22106
|
+
}
|
|
22107
|
+
},
|
|
22043
22108
|
borderWidth: {
|
|
22044
22109
|
enumerable: true,
|
|
22045
22110
|
get: function () {
|
|
@@ -22111,9 +22176,13 @@ module.exports = function (Utils) {
|
|
|
22111
22176
|
textColor: this.textColor,
|
|
22112
22177
|
handleTextColor: this.handleTextColor,
|
|
22113
22178
|
hoverColor: this.hoverColor,
|
|
22179
|
+
selectedColor: this.selectedColor,
|
|
22180
|
+
selectedTextColor: this.selectedTextColor,
|
|
22181
|
+
selectedHandleTextColor: this.selectedHandleTextColor,
|
|
22114
22182
|
warningColor: this.warningColor,
|
|
22115
22183
|
opacity: this.opacity,
|
|
22116
22184
|
borderColor: this.borderColor,
|
|
22185
|
+
selectedBorderColor: this.selectedBorderColor,
|
|
22117
22186
|
borderWidth: this.borderWidth,
|
|
22118
22187
|
borderRadius: this.borderRadius,
|
|
22119
22188
|
editable: this.editable,
|
|
@@ -22131,9 +22200,13 @@ module.exports = function (Utils) {
|
|
|
22131
22200
|
this._textColor = opts.textColor;
|
|
22132
22201
|
this._handleTextColor = opts.handleTextColor;
|
|
22133
22202
|
this._hoverColor = opts.hoverColor;
|
|
22203
|
+
this._selectedColor = opts.selectedColor;
|
|
22204
|
+
this._selectedTextColor = opts.selectedTextColor;
|
|
22205
|
+
this._selectedHandleTextColor = opts.selectedHandleTextColor;
|
|
22134
22206
|
this._warningColor = opts.warningColor;
|
|
22135
22207
|
this._opacity = opts.opacity;
|
|
22136
22208
|
this._borderColor = opts.borderColor;
|
|
22209
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
22137
22210
|
this._borderWidth = opts.borderWidth;
|
|
22138
22211
|
this._borderRadius = opts.borderRadius;
|
|
22139
22212
|
this._editable = opts.editable;
|
|
@@ -23305,7 +23378,7 @@ module.exports = function (Colors, Segment, Utils) {
|
|
|
23305
23378
|
if (!Utils.isObject(options)) {
|
|
23306
23379
|
throw new TypeError('peaks.segments.add(): expected a Segment object parameter');
|
|
23307
23380
|
}
|
|
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);
|
|
23381
|
+
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
23382
|
return segment;
|
|
23310
23383
|
};
|
|
23311
23384
|
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
|
|
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,
|