@babylonjs/gui 7.20.1 → 7.21.1
Sign up to get free protection for your applications and to get access to all the features.
- package/2D/advancedDynamicTexture.d.ts +4 -0
- package/2D/advancedDynamicTexture.js +6 -1
- package/2D/advancedDynamicTexture.js.map +1 -1
- package/2D/controls/control.d.ts +1 -0
- package/2D/controls/control.js +30 -5
- package/2D/controls/control.js.map +1 -1
- package/2D/xmlLoader.js +4 -1
- package/2D/xmlLoader.js.map +1 -1
- package/package.json +2 -2
package/2D/xmlLoader.js
CHANGED
@@ -70,7 +70,10 @@ export class XmlLoader {
|
|
70
70
|
}
|
71
71
|
else if (node.attributes[i].value.match(/{{.*}}/)) {
|
72
72
|
const matches = node.attributes[i].value.match(/{{(.*)}}/);
|
73
|
-
|
73
|
+
let element = this._getChainElement(matches[1]);
|
74
|
+
if (!(node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}"))) {
|
75
|
+
element = node.attributes[i].value.replace(/{{.*}}/, `${element}`);
|
76
|
+
}
|
74
77
|
guiNode[node.attributes[i].name] = element;
|
75
78
|
}
|
76
79
|
else if (!this._objectAttributes[node.attributes[i].name]) {
|
package/2D/xmlLoader.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"xmlLoader.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/xmlLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,0CAA4B;AAG/C,MAAM,cAAc,GAAG,2DAA2D,CAAC;AAEnF;;GAEG;AACH,MAAM,OAAO,SAAS;IAuBlB;;;OAGG;IACH,YAAY,cAAmB,IAAI;QA1B3B,WAAM,GAAQ,EAAE,CAAC;QAEjB,eAAU,GAAQ;YACtB,OAAO,EAAE,CAAC;YACV,SAAS,EAAE,CAAC;YACZ,IAAI,EAAE,CAAC;SACV,CAAC;QAEM,cAAS,GAAY,KAAK,CAAC;QAE3B,sBAAiB,GAAQ;YAC7B,uBAAuB,EAAE,CAAC;YAC1B,qBAAqB,EAAE,CAAC;YAC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ACX,SAAS,EAAE,CAAC;iBACf;aACJ;QACL,CAAC,CAAC;QAEF,KAAK,CAAC,OAAO,GAAG;YACZ,IAAI,OAAO,EAAE;gBACT,OAAO,CAAC,6CAA6C,CAAC,CAAC;aAC1D;QACL,CAAC,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACjC,KAAK,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,eAAe,CAAC,OAAY,EAAE,QAAa;QACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAY,EAAE,MAAW,EAAE,EAAE;YAC7C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { GetClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst XmlLoaderError = \"XmlLoader Exception : XML file is malformed or corrupted.\";\r\n\r\n/**\r\n * Class used to load GUI via XML.\r\n */\r\nexport class XmlLoader {\r\n private _nodes: any = {};\r\n\r\n private _nodeTypes: any = {\r\n element: 1,\r\n attribute: 2,\r\n text: 3,\r\n };\r\n\r\n private _isLoaded: boolean = false;\r\n\r\n private _objectAttributes: any = {\r\n textHorizontalAlignment: 1,\r\n textVerticalAlignment: 2,\r\n horizontalAlignment: 3,\r\n verticalAlignment: 4,\r\n stretch: 5,\r\n };\r\n\r\n private _rootNode: any;\r\n\r\n private _parentClass: any;\r\n\r\n /**\r\n * Create a new xml loader\r\n * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context\r\n */\r\n constructor(parentClass: any = null) {\r\n if (parentClass) {\r\n this._parentClass = parentClass;\r\n }\r\n }\r\n\r\n private _getChainElement(attributeValue: any): any {\r\n let element: any = window;\r\n\r\n if (this._parentClass) {\r\n element = this._parentClass;\r\n }\r\n let value = attributeValue;\r\n value = value.split(\".\");\r\n\r\n for (let i = 0; i < value.length; i++) {\r\n element = element[value[i]];\r\n }\r\n return element;\r\n }\r\n\r\n private _getClassAttribute(attributeName: string): any {\r\n const attribute = attributeName.split(\".\");\r\n const className = GetClass(\"BABYLON.GUI.\" + attribute[0]);\r\n return className[attribute[1]];\r\n }\r\n\r\n private _createGuiElement(node: any, parent: any, linkParent: boolean = true): void {\r\n try {\r\n const className = GetClass(\"BABYLON.GUI.\" + node.nodeName);\r\n const guiNode = new className();\r\n\r\n if (parent && linkParent) {\r\n parent.addControl(guiNode);\r\n }\r\n\r\n for (let i = 0; i < node.attributes.length; i++) {\r\n if (node.attributes[i].name.toLowerCase().includes(\"datasource\")) {\r\n continue;\r\n }\r\n\r\n if (node.attributes[i].name.toLowerCase().includes(\"observable\")) {\r\n const element = this._getChainElement(node.attributes[i].value);\r\n guiNode[node.attributes[i].name].add(element);\r\n\r\n continue;\r\n } else if (node.attributes[i].name == \"linkWithMesh\") {\r\n if (this._parentClass) {\r\n guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);\r\n } else {\r\n guiNode.linkWithMesh(window[node.attributes[i].value]);\r\n }\r\n } else if (node.attributes[i].value.match(/{{.*}}/)) {\r\n const matches = node.attributes[i].value.match(/{{(.*)}}/);\r\n const element = (node.attributes[i].value as string).replace(/{{.*}}/, `${this._getChainElement(matches[1])}`);\r\n guiNode[node.attributes[i].name] = element;\r\n } else if (!this._objectAttributes[node.attributes[i].name]) {\r\n if (node.attributes[i].value == \"true\" || node.attributes[i].value == \"false\") {\r\n guiNode[node.attributes[i].name] = node.attributes[i].value == \"true\";\r\n } else {\r\n guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;\r\n }\r\n } else {\r\n guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);\r\n }\r\n }\r\n\r\n if (!node.attributes.getNamedItem(\"id\")) {\r\n this._nodes[node.nodeName + Object.keys(this._nodes).length + \"_gen\"] = guiNode;\r\n return guiNode;\r\n }\r\n\r\n let id = node.attributes.getNamedItem(\"id\").value;\r\n if (id.startsWith(\"{{\") && id.endsWith(\"}}\")) {\r\n id = this._getChainElement(id.substring(2, id.length - 2));\r\n }\r\n\r\n if (!this._nodes[id]) {\r\n this._nodes[id] = guiNode;\r\n } else {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute\";\r\n }\r\n return guiNode;\r\n } catch (exception) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Error parsing Control \" + node.nodeName + \",\" + exception + \".\";\r\n }\r\n }\r\n\r\n private _parseGrid(node: any, guiNode: any, parent: any): void {\r\n let width;\r\n let height;\r\n let columns;\r\n const rows = node.children;\r\n let cells;\r\n let isPixel = false;\r\n let cellNode;\r\n let rowNumber = -1;\r\n let columnNumber = -1;\r\n let totalColumnsNumber = 0;\r\n\r\n for (let i = 0; i < rows.length; i++) {\r\n if (rows[i].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (rows[i].nodeName != \"Row\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Row node, received \" + rows[i].nodeName;\r\n }\r\n rowNumber += 1;\r\n columns = rows[i].children;\r\n\r\n if (!rows[i].attributes.getNamedItem(\"height\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Height must be defined for grid rows\";\r\n }\r\n height = Number(rows[i].attributes.getNamedItem(\"height\").nodeValue);\r\n isPixel = rows[i].attributes.getNamedItem(\"isPixel\") ? JSON.parse(rows[i].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addRowDefinition(height, isPixel);\r\n\r\n for (let j = 0; j < columns.length; j++) {\r\n if (columns[j].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (columns[j].nodeName != \"Column\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Column node, received \" + columns[j].nodeName;\r\n }\r\n columnNumber += 1;\r\n if (rowNumber > 0 && columnNumber > totalColumnsNumber) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.\";\r\n }\r\n\r\n if (rowNumber == 0) {\r\n if (!columns[j].attributes.getNamedItem(\"width\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Width must be defined for all the grid columns in the first row\";\r\n }\r\n width = Number(columns[j].attributes.getNamedItem(\"width\").nodeValue);\r\n isPixel = columns[j].attributes.getNamedItem(\"isPixel\") ? JSON.parse(columns[j].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addColumnDefinition(width, isPixel);\r\n }\r\n\r\n cells = columns[j].children;\r\n\r\n for (let k = 0; k < cells.length; k++) {\r\n if (cells[k].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n cellNode = this._createGuiElement(cells[k], guiNode, false);\r\n guiNode.addControl(cellNode, rowNumber, columnNumber);\r\n if (cells[k].firstChild) {\r\n this._parseXml(cells[k].firstChild, cellNode);\r\n }\r\n }\r\n }\r\n if (rowNumber == 0) {\r\n totalColumnsNumber = columnNumber;\r\n }\r\n columnNumber = -1;\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _parseElement(node: any, guiNode: any, parent: any): void {\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode);\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _prepareSourceElement(node: any, guiNode: any, variable: any, source: any, iterator: any): void {\r\n if (this._parentClass) {\r\n this._parentClass[variable] = source[iterator];\r\n } else {\r\n window[variable] = source[iterator];\r\n }\r\n\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode, true);\r\n }\r\n }\r\n\r\n private _parseElementsFromSource(node: any, guiNode: any, parent: any): void {\r\n const dataSource = node.attributes.getNamedItem(\"dataSource\").value;\r\n\r\n if (!dataSource.includes(\" in \")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must include an in\";\r\n } else {\r\n let isArray = true;\r\n const splittedSource = dataSource.split(\" in \");\r\n if (splittedSource.length < 2) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must have an iterator and a source\";\r\n }\r\n let source = splittedSource[1];\r\n if (source.startsWith(\"{\") && source.endsWith(\"}\")) {\r\n isArray = false;\r\n }\r\n\r\n if (!isArray || (source.startsWith(\"[\") && source.endsWith(\"]\"))) {\r\n source = source.substring(1, source.length - 1);\r\n }\r\n\r\n if (this._parentClass) {\r\n source = this._parentClass[source];\r\n } else {\r\n source = window[source];\r\n }\r\n\r\n if (isArray) {\r\n for (let i = 0; i < source.length; i++) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n } else {\r\n for (const i in source) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n }\r\n\r\n private _parseXml(node: any, parent: any, generated: boolean = false): void {\r\n if (node.nodeType != this._nodeTypes.element) {\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent, generated);\r\n }\r\n return;\r\n }\r\n\r\n if (generated) {\r\n node.setAttribute(\"id\", parent.id + (parent._children.length + 1));\r\n }\r\n\r\n const guiNode = this._createGuiElement(node, parent);\r\n\r\n if (!this._rootNode) {\r\n this._rootNode = guiNode;\r\n }\r\n\r\n if (node.nodeName == \"Grid\") {\r\n this._parseGrid(node, guiNode, parent);\r\n } else if (!node.attributes.getNamedItem(\"dataSource\")) {\r\n this._parseElement(node, guiNode, parent);\r\n } else {\r\n this._parseElementsFromSource(node, guiNode, parent);\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the loading has finished.\r\n * @returns whether the loading has finished or not\r\n */\r\n public isLoaded(): boolean {\r\n return this._isLoaded;\r\n }\r\n\r\n /**\r\n * Gets a loaded node / control by id.\r\n * @param id the Controls id set in the xml\r\n * @returns element of type Control\r\n */\r\n public getNodeById(id: string): any {\r\n return this._nodes[id];\r\n }\r\n\r\n /**\r\n * Gets all loaded nodes / controls\r\n * @returns Array of controls\r\n */\r\n public getNodes(): any {\r\n return this._nodes;\r\n }\r\n /**\r\n * Disposes the loaded layout\r\n */\r\n public dispose(): void {\r\n if (this._rootNode) {\r\n this._rootNode.dispose();\r\n this._rootNode = null;\r\n this._nodes = {};\r\n }\r\n }\r\n\r\n /**\r\n * Initiates the xml layout loading\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @param onSuccess defines the callback called on layout load successfully.\r\n * @param onError defines the callback called on layout load failure.\r\n */\r\n public loadLayout(xmlFile: any, rootNode: any, onSuccess: Nullable<() => void> = null, onError: Nullable<(error: string) => void> = null): void {\r\n const xhttp = new XMLHttpRequest();\r\n xhttp.onload = () => {\r\n if (xhttp.readyState === 4 && xhttp.status === 200) {\r\n if (!xhttp.responseXML) {\r\n if (onError) {\r\n onError(XmlLoaderError);\r\n return;\r\n } else {\r\n throw XmlLoaderError;\r\n }\r\n }\r\n\r\n const xmlDoc = xhttp.responseXML.documentElement;\r\n this._parseXml(xmlDoc.firstChild, rootNode);\r\n this._isLoaded = true;\r\n\r\n if (onSuccess) {\r\n onSuccess();\r\n }\r\n }\r\n };\r\n\r\n xhttp.onerror = function () {\r\n if (onError) {\r\n onError(\"an error occurred during loading the layout\");\r\n }\r\n };\r\n\r\n xhttp.open(\"GET\", xmlFile, true);\r\n xhttp.send();\r\n }\r\n /**\r\n * Initiates the xml layout loading asynchronously\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @returns Promise\r\n */\r\n public async loadLayoutAsync(xmlFile: any, rootNode: any): Promise<any> {\r\n return new Promise((resolve: any, reject: any) => {\r\n this.loadLayout(xmlFile, rootNode, resolve, reject);\r\n });\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"xmlLoader.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/xmlLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,0CAA4B;AAG/C,MAAM,cAAc,GAAG,2DAA2D,CAAC;AAEnF;;GAEG;AACH,MAAM,OAAO,SAAS;IAuBlB;;;OAGG;IACH,YAAY,cAAmB,IAAI;QA1B3B,WAAM,GAAQ,EAAE,CAAC;QAEjB,eAAU,GAAQ;YACtB,OAAO,EAAE,CAAC;YACV,SAAS,EAAE,CAAC;YACZ,IAAI,EAAE,CAAC;SACV,CAAC;QAEM,cAAS,GAAY,KAAK,CAAC;QAE3B,sBAAiB,GAAQ;YAC7B,uBAAuB,EAAE,CAAC;YAC1B,qBAAqB,EAAE,CAAC;YACxB,mBAAmB,EAAE,CAAC;YACtB,iBAAiB,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;SACb,CAAC;QAWE,IAAI,WAAW,EAAE;YACb,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;SACnC;IACL,CAAC;IAEO,gBAAgB,CAAC,cAAmB;QACxC,IAAI,OAAO,GAAQ,MAAM,CAAC;QAE1B,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC;SAC/B;QACD,IAAI,KAAK,GAAG,cAAc,CAAC;QAC3B,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,C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,EAAE,QAAa;QACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAY,EAAE,MAAW,EAAE,EAAE;YAC7C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { GetClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst XmlLoaderError = \"XmlLoader Exception : XML file is malformed or corrupted.\";\r\n\r\n/**\r\n * Class used to load GUI via XML.\r\n */\r\nexport class XmlLoader {\r\n private _nodes: any = {};\r\n\r\n private _nodeTypes: any = {\r\n element: 1,\r\n attribute: 2,\r\n text: 3,\r\n };\r\n\r\n private _isLoaded: boolean = false;\r\n\r\n private _objectAttributes: any = {\r\n textHorizontalAlignment: 1,\r\n textVerticalAlignment: 2,\r\n horizontalAlignment: 3,\r\n verticalAlignment: 4,\r\n stretch: 5,\r\n };\r\n\r\n private _rootNode: any;\r\n\r\n private _parentClass: any;\r\n\r\n /**\r\n * Create a new xml loader\r\n * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context\r\n */\r\n constructor(parentClass: any = null) {\r\n if (parentClass) {\r\n this._parentClass = parentClass;\r\n }\r\n }\r\n\r\n private _getChainElement(attributeValue: any): any {\r\n let element: any = window;\r\n\r\n if (this._parentClass) {\r\n element = this._parentClass;\r\n }\r\n let value = attributeValue;\r\n value = value.split(\".\");\r\n\r\n for (let i = 0; i < value.length; i++) {\r\n element = element[value[i]];\r\n }\r\n return element;\r\n }\r\n\r\n private _getClassAttribute(attributeName: string): any {\r\n const attribute = attributeName.split(\".\");\r\n const className = GetClass(\"BABYLON.GUI.\" + attribute[0]);\r\n return className[attribute[1]];\r\n }\r\n\r\n private _createGuiElement(node: any, parent: any, linkParent: boolean = true): void {\r\n try {\r\n const className = GetClass(\"BABYLON.GUI.\" + node.nodeName);\r\n const guiNode = new className();\r\n\r\n if (parent && linkParent) {\r\n parent.addControl(guiNode);\r\n }\r\n\r\n for (let i = 0; i < node.attributes.length; i++) {\r\n if (node.attributes[i].name.toLowerCase().includes(\"datasource\")) {\r\n continue;\r\n }\r\n\r\n if (node.attributes[i].name.toLowerCase().includes(\"observable\")) {\r\n const element = this._getChainElement(node.attributes[i].value);\r\n guiNode[node.attributes[i].name].add(element);\r\n\r\n continue;\r\n } else if (node.attributes[i].name == \"linkWithMesh\") {\r\n if (this._parentClass) {\r\n guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);\r\n } else {\r\n guiNode.linkWithMesh(window[node.attributes[i].value]);\r\n }\r\n } else if (node.attributes[i].value.match(/{{.*}}/)) {\r\n const matches = node.attributes[i].value.match(/{{(.*)}}/);\r\n let element = this._getChainElement(matches[1]);\r\n if (!(node.attributes[i].value.startsWith(\"{{\") && node.attributes[i].value.endsWith(\"}}\"))) {\r\n element = (node.attributes[i].value as string).replace(/{{.*}}/, `${element}`);\r\n }\r\n guiNode[node.attributes[i].name] = element;\r\n } else if (!this._objectAttributes[node.attributes[i].name]) {\r\n if (node.attributes[i].value == \"true\" || node.attributes[i].value == \"false\") {\r\n guiNode[node.attributes[i].name] = node.attributes[i].value == \"true\";\r\n } else {\r\n guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;\r\n }\r\n } else {\r\n guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);\r\n }\r\n }\r\n\r\n if (!node.attributes.getNamedItem(\"id\")) {\r\n this._nodes[node.nodeName + Object.keys(this._nodes).length + \"_gen\"] = guiNode;\r\n return guiNode;\r\n }\r\n\r\n let id = node.attributes.getNamedItem(\"id\").value;\r\n if (id.startsWith(\"{{\") && id.endsWith(\"}}\")) {\r\n id = this._getChainElement(id.substring(2, id.length - 2));\r\n }\r\n\r\n if (!this._nodes[id]) {\r\n this._nodes[id] = guiNode;\r\n } else {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute\";\r\n }\r\n return guiNode;\r\n } catch (exception) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Error parsing Control \" + node.nodeName + \",\" + exception + \".\";\r\n }\r\n }\r\n\r\n private _parseGrid(node: any, guiNode: any, parent: any): void {\r\n let width;\r\n let height;\r\n let columns;\r\n const rows = node.children;\r\n let cells;\r\n let isPixel = false;\r\n let cellNode;\r\n let rowNumber = -1;\r\n let columnNumber = -1;\r\n let totalColumnsNumber = 0;\r\n\r\n for (let i = 0; i < rows.length; i++) {\r\n if (rows[i].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (rows[i].nodeName != \"Row\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Row node, received \" + rows[i].nodeName;\r\n }\r\n rowNumber += 1;\r\n columns = rows[i].children;\r\n\r\n if (!rows[i].attributes.getNamedItem(\"height\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Height must be defined for grid rows\";\r\n }\r\n height = Number(rows[i].attributes.getNamedItem(\"height\").nodeValue);\r\n isPixel = rows[i].attributes.getNamedItem(\"isPixel\") ? JSON.parse(rows[i].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addRowDefinition(height, isPixel);\r\n\r\n for (let j = 0; j < columns.length; j++) {\r\n if (columns[j].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (columns[j].nodeName != \"Column\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Column node, received \" + columns[j].nodeName;\r\n }\r\n columnNumber += 1;\r\n if (rowNumber > 0 && columnNumber > totalColumnsNumber) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.\";\r\n }\r\n\r\n if (rowNumber == 0) {\r\n if (!columns[j].attributes.getNamedItem(\"width\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Width must be defined for all the grid columns in the first row\";\r\n }\r\n width = Number(columns[j].attributes.getNamedItem(\"width\").nodeValue);\r\n isPixel = columns[j].attributes.getNamedItem(\"isPixel\") ? JSON.parse(columns[j].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addColumnDefinition(width, isPixel);\r\n }\r\n\r\n cells = columns[j].children;\r\n\r\n for (let k = 0; k < cells.length; k++) {\r\n if (cells[k].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n cellNode = this._createGuiElement(cells[k], guiNode, false);\r\n guiNode.addControl(cellNode, rowNumber, columnNumber);\r\n if (cells[k].firstChild) {\r\n this._parseXml(cells[k].firstChild, cellNode);\r\n }\r\n }\r\n }\r\n if (rowNumber == 0) {\r\n totalColumnsNumber = columnNumber;\r\n }\r\n columnNumber = -1;\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _parseElement(node: any, guiNode: any, parent: any): void {\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode);\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _prepareSourceElement(node: any, guiNode: any, variable: any, source: any, iterator: any): void {\r\n if (this._parentClass) {\r\n this._parentClass[variable] = source[iterator];\r\n } else {\r\n window[variable] = source[iterator];\r\n }\r\n\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode, true);\r\n }\r\n }\r\n\r\n private _parseElementsFromSource(node: any, guiNode: any, parent: any): void {\r\n const dataSource = node.attributes.getNamedItem(\"dataSource\").value;\r\n\r\n if (!dataSource.includes(\" in \")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must include an in\";\r\n } else {\r\n let isArray = true;\r\n const splittedSource = dataSource.split(\" in \");\r\n if (splittedSource.length < 2) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must have an iterator and a source\";\r\n }\r\n let source = splittedSource[1];\r\n if (source.startsWith(\"{\") && source.endsWith(\"}\")) {\r\n isArray = false;\r\n }\r\n\r\n if (!isArray || (source.startsWith(\"[\") && source.endsWith(\"]\"))) {\r\n source = source.substring(1, source.length - 1);\r\n }\r\n\r\n if (this._parentClass) {\r\n source = this._parentClass[source];\r\n } else {\r\n source = window[source];\r\n }\r\n\r\n if (isArray) {\r\n for (let i = 0; i < source.length; i++) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n } else {\r\n for (const i in source) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n }\r\n\r\n private _parseXml(node: any, parent: any, generated: boolean = false): void {\r\n if (node.nodeType != this._nodeTypes.element) {\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent, generated);\r\n }\r\n return;\r\n }\r\n\r\n if (generated) {\r\n node.setAttribute(\"id\", parent.id + (parent._children.length + 1));\r\n }\r\n\r\n const guiNode = this._createGuiElement(node, parent);\r\n\r\n if (!this._rootNode) {\r\n this._rootNode = guiNode;\r\n }\r\n\r\n if (node.nodeName == \"Grid\") {\r\n this._parseGrid(node, guiNode, parent);\r\n } else if (!node.attributes.getNamedItem(\"dataSource\")) {\r\n this._parseElement(node, guiNode, parent);\r\n } else {\r\n this._parseElementsFromSource(node, guiNode, parent);\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the loading has finished.\r\n * @returns whether the loading has finished or not\r\n */\r\n public isLoaded(): boolean {\r\n return this._isLoaded;\r\n }\r\n\r\n /**\r\n * Gets a loaded node / control by id.\r\n * @param id the Controls id set in the xml\r\n * @returns element of type Control\r\n */\r\n public getNodeById(id: string): any {\r\n return this._nodes[id];\r\n }\r\n\r\n /**\r\n * Gets all loaded nodes / controls\r\n * @returns Array of controls\r\n */\r\n public getNodes(): any {\r\n return this._nodes;\r\n }\r\n /**\r\n * Disposes the loaded layout\r\n */\r\n public dispose(): void {\r\n if (this._rootNode) {\r\n this._rootNode.dispose();\r\n this._rootNode = null;\r\n this._nodes = {};\r\n }\r\n }\r\n\r\n /**\r\n * Initiates the xml layout loading\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @param onSuccess defines the callback called on layout load successfully.\r\n * @param onError defines the callback called on layout load failure.\r\n */\r\n public loadLayout(xmlFile: any, rootNode: any, onSuccess: Nullable<() => void> = null, onError: Nullable<(error: string) => void> = null): void {\r\n const xhttp = new XMLHttpRequest();\r\n xhttp.onload = () => {\r\n if (xhttp.readyState === 4 && xhttp.status === 200) {\r\n if (!xhttp.responseXML) {\r\n if (onError) {\r\n onError(XmlLoaderError);\r\n return;\r\n } else {\r\n throw XmlLoaderError;\r\n }\r\n }\r\n\r\n const xmlDoc = xhttp.responseXML.documentElement;\r\n this._parseXml(xmlDoc.firstChild, rootNode);\r\n this._isLoaded = true;\r\n\r\n if (onSuccess) {\r\n onSuccess();\r\n }\r\n }\r\n };\r\n\r\n xhttp.onerror = function () {\r\n if (onError) {\r\n onError(\"an error occurred during loading the layout\");\r\n }\r\n };\r\n\r\n xhttp.open(\"GET\", xmlFile, true);\r\n xhttp.send();\r\n }\r\n /**\r\n * Initiates the xml layout loading asynchronously\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @returns Promise\r\n */\r\n public async loadLayoutAsync(xmlFile: any, rootNode: any): Promise<any> {\r\n return new Promise((resolve: any, reject: any) => {\r\n this.loadLayout(xmlFile, rootNode, resolve, reject);\r\n });\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/gui",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.21.1",
|
4
4
|
"main": "index.js",
|
5
5
|
"module": "index.js",
|
6
6
|
"types": "index.d.ts",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
|
-
"@babylonjs/core": "^7.
|
21
|
+
"@babylonjs/core": "^7.21.1",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/gui": "1.0.0"
|
24
24
|
},
|