Browse Source

Merge pull request #8828 from Patbox/master

Allow changing color of thumb in sliders
David Catuhe 5 năm trước cách đây
mục cha
commit
53aaeae8d3
1 tập tin đã thay đổi với 16 bổ sung0 xóa
  1. 16 0
      gui/src/2D/controls/sliders/slider.ts

+ 16 - 0
gui/src/2D/controls/sliders/slider.ts

@@ -9,6 +9,7 @@ import { Measure } from '../../measure';
 export class Slider extends BaseSlider {
     private _background = "black";
     private _borderColor = "white";
+    private _thumbColor = "";
     private _isThumbCircle = false;
     protected _displayValueBar = true;
 
@@ -54,6 +55,20 @@ export class Slider extends BaseSlider {
         this._markAsDirty();
     }
 
+    /** Gets or sets thumb's color */
+    public get thumbColor(): string {
+        return this._thumbColor;
+    }
+
+    public set thumbColor(value: string) {
+        if (this._thumbColor === value) {
+            return;
+        }
+
+        this._thumbColor = value;
+        this._markAsDirty();
+    }
+
     /** Gets or sets a boolean indicating if the thumb should be round or square */
     public get isThumbCircle(): boolean {
         return this._isThumbCircle;
@@ -193,6 +208,7 @@ export class Slider extends BaseSlider {
         }
 
         // Thumb
+        context.fillStyle = this._thumbColor || this.color;
         if (this.displayThumb) {
             if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
                 context.shadowColor = this.shadowColor;