浏览代码

Add thumbColor in sliders

Patbox 5 年之前
父节点
当前提交
3651391179
共有 1 个文件被更改,包括 16 次插入0 次删除
  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;
 
@@ -53,6 +54,20 @@ export class Slider extends BaseSlider {
         this._background = value;
         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 {
@@ -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;