123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- /// <reference path="../../../../dist/preview release/babylon.d.ts"/>
- module BABYLON.GUI {
- /**
- * Class used to create containers for controls
- */
- export class Container3D extends Control3D {
- private _blockLayout = false;
- /**
- * Gets the list of child controls
- */
- protected _children = new Array<Control3D>();
- /**
- * Gets the list of child controls
- */
- public get children(): Array<Control3D> {
- return this._children;
- }
- /**
- * Gets or sets a boolean indicating if the layout must be blocked (default is false).
- * This is helpful to optimize layout operation when adding multiple children in a row
- */
- public get blockLayout(): boolean {
- return this._blockLayout;
- }
- public set blockLayout(value: boolean) {
- if (this._blockLayout === value) {
- return;
- }
- this._blockLayout = value;
- if (!this._blockLayout) {
- this._arrangeChildren();
- }
- }
- /**
- * Creates a new container
- * @param name defines the container name
- */
- constructor(name?: string) {
- super(name);
- }
- /**
- * Gets a boolean indicating if the given control is in the children of this control
- * @param control defines the control to check
- * @returns true if the control is in the child list
- */
- public containsControl(control: Control3D): boolean {
- return this._children.indexOf(control) !== -1;
- }
- /**
- * Adds a control to the children of this control
- * @param control defines the control to add
- * @returns the current container
- */
- public addControl(control: Control3D): Container3D {
- var index = this._children.indexOf(control);
- if (index !== -1) {
- return this;
- }
- control.parent = this;
- control._host = this._host;
- this._children.push(control);
- if (this._host.utilityLayer) {
- control._prepareNode(this._host.utilityLayer.utilityLayerScene);
- if (control.node) {
- control.node.parent = this.node;
- }
- if (!this.blockLayout) {
- this._arrangeChildren();
- }
- }
- return this;
- }
- /**
- * This function will be called everytime a new control is added
- */
- protected _arrangeChildren() {
- }
- protected _createNode(scene: Scene): Nullable<TransformNode> {
- return new TransformNode("ContainerNode", scene);
- }
- /**
- * Removes a control from the children of this control
- * @param control defines the control to remove
- * @returns the current container
- */
- public removeControl(control: Control3D): Container3D {
- var index = this._children.indexOf(control);
- if (index !== -1) {
- this._children.splice(index, 1);
- control.parent = null;
- control._disposeNode();
- }
- return this;
- }
- protected _getTypeName(): string {
- return "Container3D";
- }
-
- /**
- * Releases all associated resources
- */
- public dispose() {
- for (var control of this._children) {
- control.dispose();
- }
- this._children = [];
- super.dispose();
- }
- /** Control rotation will remain unchanged */
- public static readonly UNSET_ORIENTATION = 0;
- /** Control will rotate to make it look at sphere central axis */
- public static readonly FACEORIGIN_ORIENTATION = 1;
- /** Control will rotate to make it look back at sphere central axis */
- public static readonly FACEORIGINREVERSED_ORIENTATION = 2;
- /** Control will rotate to look at z axis (0, 0, 1) */
- public static readonly FACEFORWARD_ORIENTATION = 3;
- /** Control will rotate to look at negative z axis (0, 0, -1) */
- public static readonly FACEFORWARDREVERSED_ORIENTATION = 4;
- }
- }
|