فهرست منبع

Extracting statics from the control class

Raanan Weber 7 سال پیش
والد
کامیت
a19070207c
3فایلهای تغییر یافته به همراه52 افزوده شده و 36 حذف شده
  1. 3 35
      gui/src/2D/controls/control.ts
  2. 8 1
      gui/src/2D/controls/index.ts
  3. 41 0
      gui/src/2D/controls/statics.ts

+ 3 - 35
gui/src/2D/controls/control.ts

@@ -5,8 +5,6 @@ import { Nullable, Observer, Vector2, AbstractMesh, Observable, Vector3, Scene,
 import { Measure } from "../measure";
 import { Measure } from "../measure";
 import { Style } from "../style";
 import { Style } from "../style";
 import { Matrix2D, Vector2WithInfo } from "../math2D";
 import { Matrix2D, Vector2WithInfo } from "../math2D";
-import { StackPanel } from "./stackPanel";
-import { TextBlock } from "./textBlock";
 
 
 /**
 /**
  * Root class used for all 2D controls
  * Root class used for all 2D controls
@@ -1398,6 +1396,8 @@ export class Control {
         return result;
         return result;
     };
     };
 
 
+
+
     /**
     /**
      * Creates a stack panel that can be used to render headers
      * Creates a stack panel that can be used to render headers
      * @param control defines the control to associate with the header
      * @param control defines the control to associate with the header
@@ -1406,39 +1406,7 @@ export class Control {
      * @param options defines options used to configure the header
      * @param options defines options used to configure the header
      * @returns a new StackPanel
      * @returns a new StackPanel
      */
      */
-    public static AddHeader(control: Control, text: string, size: string | number, options: { isHorizontal: boolean, controlFirst: boolean }): StackPanel {
-        let panel = new StackPanel("panel");
-        let isHorizontal = options ? options.isHorizontal : true;
-        let controlFirst = options ? options.controlFirst : true;
-
-        panel.isVertical = !isHorizontal;
-
-        let header = new TextBlock("header");
-        header.text = text;
-        header.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
-        if (isHorizontal) {
-            header.width = size;
-        } else {
-            header.height = size;
-        }
-
-        if (controlFirst) {
-            panel.addControl(control);
-            panel.addControl(header);
-            header.paddingLeft = "5px";
-        } else {
-            panel.addControl(header);
-            panel.addControl(control);
-            header.paddingRight = "5px";
-        }
-
-        header.shadowBlur = control.shadowBlur;
-        header.shadowColor = control.shadowColor;
-        header.shadowOffsetX = control.shadowOffsetX;
-        header.shadowOffsetY = control.shadowOffsetY;
-
-        return panel;
-    }
+    public static AddHeader: (control: Control, text: string, size: string | number, options: { isHorizontal: boolean, controlFirst: boolean }) => any;
 
 
     /** @hidden */
     /** @hidden */
     protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void {
     protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void {

+ 8 - 1
gui/src/2D/controls/index.ts

@@ -9,4 +9,11 @@ export * from "./image";
 export * from "./inputText";
 export * from "./inputText";
 export * from "./line";
 export * from "./line";
 export * from "./multiLine";
 export * from "./multiLine";
-export * from "./radioButton";
+export * from "./radioButton";
+export * from "./stackPanel";
+export * from "./textBlock";
+export * from "./virtualKeyboard";
+export * from "./slider";
+export * from "./rectangle";
+
+export * from "./statics";

+ 41 - 0
gui/src/2D/controls/statics.ts

@@ -0,0 +1,41 @@
+import { Control } from "./control";
+import { StackPanel } from "./stackPanel";
+import { TextBlock } from "./textBlock";
+
+let name = "Statics";
+
+export { name };
+
+Control.AddHeader = function (control: Control, text: string, size: string | number, options: { isHorizontal: boolean, controlFirst: boolean }): StackPanel {
+    let panel = new StackPanel("panel");
+    let isHorizontal = options ? options.isHorizontal : true;
+    let controlFirst = options ? options.controlFirst : true;
+
+    panel.isVertical = !isHorizontal;
+
+    let header = new TextBlock("header");
+    header.text = text;
+    header.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
+    if (isHorizontal) {
+        header.width = size;
+    } else {
+        header.height = size;
+    }
+
+    if (controlFirst) {
+        panel.addControl(control);
+        panel.addControl(header);
+        header.paddingLeft = "5px";
+    } else {
+        panel.addControl(header);
+        panel.addControl(control);
+        header.paddingRight = "5px";
+    }
+
+    header.shadowBlur = control.shadowBlur;
+    header.shadowColor = control.shadowColor;
+    header.shadowOffsetX = control.shadowOffsetX;
+    header.shadowOffsetY = control.shadowOffsetY;
+
+    return panel;
+}