UNPKG

dragonbones-runtime

Version:

the tools to build dragonbones file for diffrent framework

1,260 lines 1.03 MB
var __reflect = (this && this.__reflect) || function (p, c, t) { p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; }; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); ////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2014-present, Egret Technology. // All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of the Egret nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////////////// var eui; (function (eui) { var sys; (function (sys) { /** * @private * 失效验证管理器 */ var Validator = (function (_super) { __extends(Validator, _super); /** * @private * 创建一个Validator对象 */ function Validator() { var _this = _super.call(this) || this; /** * @private */ _this.targetLevel = Number.POSITIVE_INFINITY; /** * @private */ _this.invalidatePropertiesFlag = false; /** * @private */ _this.invalidateClientPropertiesFlag = false; /** * @private */ _this.invalidatePropertiesQueue = new DepthQueue(); /** * @private */ _this.invalidateSizeFlag = false; /** * @private */ _this.invalidateClientSizeFlag = false; /** * @private */ _this.invalidateSizeQueue = new DepthQueue(); /** * @private */ _this.invalidateDisplayListFlag = false; /** * @private */ _this.invalidateDisplayListQueue = new DepthQueue(); /** * @private * 是否已经添加了事件监听 */ _this.listenersAttached = false; return _this; } /** * @private * 标记组件属性失效 */ Validator.prototype.invalidateProperties = function (client) { if (!this.invalidatePropertiesFlag) { this.invalidatePropertiesFlag = true; if (!this.listenersAttached) this.attachListeners(); } if (this.targetLevel <= client.$nestLevel) this.invalidateClientPropertiesFlag = true; this.invalidatePropertiesQueue.insert(client); }; /** * @private * 验证失效的属性 */ Validator.prototype.validateProperties = function () { var queue = this.invalidatePropertiesQueue; var client = queue.shift(); while (client) { if (client.$stage) { client.validateProperties(); } client = queue.shift(); } if (queue.isEmpty()) this.invalidatePropertiesFlag = false; }; /** * @private * 标记需要重新测量尺寸 */ Validator.prototype.invalidateSize = function (client) { if (!this.invalidateSizeFlag) { this.invalidateSizeFlag = true; if (!this.listenersAttached) this.attachListeners(); } if (this.targetLevel <= client.$nestLevel) this.invalidateClientSizeFlag = true; this.invalidateSizeQueue.insert(client); }; /** * @private * 测量尺寸 */ Validator.prototype.validateSize = function () { var queue = this.invalidateSizeQueue; var client = queue.pop(); while (client) { if (client.$stage) { client.validateSize(); } client = queue.pop(); } if (queue.isEmpty()) this.invalidateSizeFlag = false; }; /** * @private * 标记需要重新布局 */ Validator.prototype.invalidateDisplayList = function (client) { if (!this.invalidateDisplayListFlag) { this.invalidateDisplayListFlag = true; if (!this.listenersAttached) this.attachListeners(); } this.invalidateDisplayListQueue.insert(client); }; /** * @private * 重新布局 */ Validator.prototype.validateDisplayList = function () { var queue = this.invalidateDisplayListQueue; var client = queue.shift(); while (client) { if (client.$stage) { client.validateDisplayList(); } client = queue.shift(); } if (queue.isEmpty()) this.invalidateDisplayListFlag = false; }; /** * @private * 添加事件监听 */ Validator.prototype.attachListeners = function () { if (!this.eventDisplay) { this.eventDisplay = new egret.Bitmap(); } this.eventDisplay.addEventListener(egret.Event.ENTER_FRAME, this.doPhasedInstantiationCallBack, this); this.eventDisplay.addEventListener(egret.Event.RENDER, this.doPhasedInstantiationCallBack, this); egret.sys.$invalidateRenderFlag = true; this.listenersAttached = true; }; /** * @private * 执行属性应用 */ Validator.prototype.doPhasedInstantiationCallBack = function (event) { if (!this.eventDisplay) { this.eventDisplay = new egret.Bitmap(); } this.eventDisplay.removeEventListener(egret.Event.ENTER_FRAME, this.doPhasedInstantiationCallBack, this); this.eventDisplay.removeEventListener(egret.Event.RENDER, this.doPhasedInstantiationCallBack, this); this.doPhasedInstantiation(); }; /** * @private * */ Validator.prototype.doPhasedInstantiation = function () { if (this.invalidatePropertiesFlag) { this.validateProperties(); } if (this.invalidateSizeFlag) { this.validateSize(); } if (this.invalidateDisplayListFlag) { this.validateDisplayList(); } if (this.invalidatePropertiesFlag || this.invalidateSizeFlag || this.invalidateDisplayListFlag) { this.attachListeners(); } else { this.listenersAttached = false; } }; /** * @private * 使大于等于指定组件层级的元素立即应用属性 * @param target 要立即应用属性的组件 */ Validator.prototype.validateClient = function (target) { var obj; var done = false; var oldTargetLevel = this.targetLevel; if (this.targetLevel === Number.POSITIVE_INFINITY) this.targetLevel = target.$nestLevel; var propertiesQueue = this.invalidatePropertiesQueue; var sizeQueue = this.invalidateSizeQueue; var displayListQueue = this.invalidateDisplayListQueue; while (!done) { done = true; obj = propertiesQueue.removeSmallestChild(target); while (obj) { if (obj.$stage) { obj.validateProperties(); } obj = propertiesQueue.removeSmallestChild(target); } if (propertiesQueue.isEmpty()) { this.invalidatePropertiesFlag = false; } this.invalidateClientPropertiesFlag = false; obj = sizeQueue.removeLargestChild(target); while (obj) { if (obj.$stage) { obj.validateSize(); } if (this.invalidateClientPropertiesFlag) { obj = (propertiesQueue.removeSmallestChild(target)); if (obj) { propertiesQueue.insert(obj); done = false; break; } } obj = sizeQueue.removeLargestChild(target); } if (sizeQueue.isEmpty()) { this.invalidateSizeFlag = false; } this.invalidateClientPropertiesFlag = false; this.invalidateClientSizeFlag = false; obj = displayListQueue.removeSmallestChild(target); while (obj) { if (obj.$stage) { obj.validateDisplayList(); } if (this.invalidateClientPropertiesFlag) { obj = propertiesQueue.removeSmallestChild(target); if (obj) { propertiesQueue.insert(obj); done = false; break; } } if (this.invalidateClientSizeFlag) { obj = sizeQueue.removeLargestChild(target); if (obj) { sizeQueue.insert(obj); done = false; break; } } obj = displayListQueue.removeSmallestChild(target); } if (displayListQueue.isEmpty()) { this.invalidateDisplayListFlag = false; } } if (oldTargetLevel === Number.POSITIVE_INFINITY) { this.targetLevel = Number.POSITIVE_INFINITY; } }; return Validator; }(egret.EventDispatcher)); sys.Validator = Validator; __reflect(Validator.prototype, "eui.sys.Validator"); /** * @private * 显示列表嵌套深度排序队列 */ var DepthQueue = (function () { function DepthQueue() { /** * 深度队列 */ this.depthBins = {}; /** * 最小深度 */ this.minDepth = 0; /** * 最大深度 */ this.maxDepth = -1; } /** * 插入一个元素 */ DepthQueue.prototype.insert = function (client) { var depth = client.$nestLevel; if (this.maxDepth < this.minDepth) { this.minDepth = this.maxDepth = depth; } else { if (depth < this.minDepth) this.minDepth = depth; if (depth > this.maxDepth) this.maxDepth = depth; } var bin = this.depthBins[depth]; if (!bin) { bin = this.depthBins[depth] = new DepthBin(); } bin.insert(client); }; /** * 从队列尾弹出深度最大的一个对象 */ DepthQueue.prototype.pop = function () { var client; var minDepth = this.minDepth; if (minDepth <= this.maxDepth) { var bin = this.depthBins[this.maxDepth]; while (!bin || bin.length === 0) { this.maxDepth--; if (this.maxDepth < minDepth) return null; bin = this.depthBins[this.maxDepth]; } client = bin.pop(); while (!bin || bin.length == 0) { this.maxDepth--; if (this.maxDepth < minDepth) break; bin = this.depthBins[this.maxDepth]; } } return client; }; /** * 从队列首弹出深度最小的一个对象 */ DepthQueue.prototype.shift = function () { var client; var maxDepth = this.maxDepth; if (this.minDepth <= maxDepth) { var bin = this.depthBins[this.minDepth]; while (!bin || bin.length === 0) { this.minDepth++; if (this.minDepth > maxDepth) return null; bin = this.depthBins[this.minDepth]; } client = bin.pop(); while (!bin || bin.length == 0) { this.minDepth++; if (this.minDepth > maxDepth) break; bin = this.depthBins[this.minDepth]; } } return client; }; /** * 移除大于等于指定组件层级的元素中最大的元素 */ DepthQueue.prototype.removeLargestChild = function (client) { var hashCode = client.$hashCode; var nestLevel = client.$nestLevel; var max = this.maxDepth; var min = nestLevel; while (min <= max) { var bin = this.depthBins[max]; if (bin && bin.length > 0) { if (max === nestLevel) { if (bin.map[hashCode]) { bin.remove(client); return client; } } else if (egret.is(client, "egret.DisplayObjectContainer")) { var items = bin.items; var length_1 = bin.length; for (var i = 0; i < length_1; i++) { var value = items[i]; if (client.contains(value)) { bin.remove(value); return value; } } } else { break; } max--; } else { if (max == this.maxDepth) { this.maxDepth--; } max--; if (max < min) break; } } return null; }; /** * 移除大于等于指定组件层级的元素中最小的元素 */ DepthQueue.prototype.removeSmallestChild = function (client) { var nestLevel = client.$nestLevel; var min = nestLevel; var max = this.maxDepth; var hashCode = client.$hashCode; while (min <= max) { var bin = this.depthBins[min]; if (bin && bin.length > 0) { if (min === nestLevel) { if (bin.map[hashCode]) { bin.remove(client); return client; } } else if (egret.is(client, "egret.DisplayObjectContainer")) { var items = bin.items; var length_2 = bin.length; for (var i = 0; i < length_2; i++) { var value = items[i]; if (client.contains(value)) { bin.remove(value); return value; } } } else { break; } min++; } else { if (min == this.minDepth) this.minDepth++; min++; if (min > max) break; } } return null; }; /** * 队列是否为空 */ DepthQueue.prototype.isEmpty = function () { return this.minDepth > this.maxDepth; }; return DepthQueue; }()); __reflect(DepthQueue.prototype, "DepthQueue"); /** * @private * 列表项 */ var DepthBin = (function () { function DepthBin() { this.map = {}; this.items = []; this.length = 0; } DepthBin.prototype.insert = function (client) { var hashCode = client.$hashCode; if (this.map[hashCode]) { return; } this.map[hashCode] = true; this.length++; this.items.push(client); }; DepthBin.prototype.pop = function () { var client = this.items.pop(); //使用pop会比shift有更高的性能,避免索引整体重置。 if (client) { this.length--; if (this.length === 0) { this.map = {}; //清空所有key防止内存泄露 } else { this.map[client.$hashCode] = false; } } return client; }; DepthBin.prototype.remove = function (client) { var index = this.items.indexOf(client); if (index >= 0) { this.items.splice(index, 1); this.length--; if (this.length === 0) { this.map = {}; //清空所有key防止内存泄露 } else { this.map[client.$hashCode] = false; } } }; return DepthBin; }()); __reflect(DepthBin.prototype, "DepthBin"); })(sys = eui.sys || (eui.sys = {})); })(eui || (eui = {})); ////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2014-present, Egret Technology. // All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of the Egret nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////////////// var eui; (function (eui) { /** * Register a property for a class definition in running, * so that the EUI can get type of property accurate when parsing a EXML. * This need not be called directly in most of time. Only when you have a custom UI * component need to be described in EXML, you may invoke this method explicitly. * * Contains no following: * When the property is the basic data type(boolean, number, string or Array), you only need set a correct initial value * for he custom property then the EXML parser can get the correct property type in running. * * If you can not set the correct initial value (such as <code>null</code>), the EXML parser will treat this property as * <code>string</code>. If there is no inital value, EUI will throw an error. But you can invoked this method to register * a property in this case. * * * @param classDefinition The class definition need to be registered. * @param property The property need to be registered. Note that the property * name cannot start with "_" or "$". * @param type The type need to be registered, * such as “boolean","number","string","Array","egret.Rectangle" and so on. * @param asDefault Whether register this property as a default property of component. * One component can register only on default property. And the default property can be spare in an EXML. * * @example: * <pre> * <s:Scroller> * <s:viewport> * <s:Group/> * </e:viewport> * </e:Scroller> * </pre> * Cuz <code>viewport</code> is the default property of Scroller. So you can write as follow: * <pre> * <s:Scroller> * <s:Group/> * </e:Scroller> * </pre> * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native * @language en_US */ /** * 为一个类定义注册运行时属性类型,以便运行时的EXML文件解析过程能获取准确的属性类型。大多数情况下,您都不需要手动调用此方法显式注册属性类型。 * 仅当您有一个自定义的 UI 组件,需要在EXML中用标签描述时可能需要显式注册,但以下情况除外: * 当属性类型为基本数据类型:boolean,number,string,Array这四种其中之一时,您只需要为自定义的属性赋值上正确的初始值, * 运行时EXML解析器就能通过初始值自动分析出正确的属性类型。 * 若您无法为属性赋值上正确的初始值时(有初始值,比如null),运行时EXML解析器会把此属性当做string来处理,若完全没有初始值,将会报错找不到节点属性, * 这种情况下可以手动调用此方法显式注册属性类型。 * * @param classDefinition 要注册的类定义。 * @param property 要注册的属性,注意属性名不能以 _ 或 $ 符开头。 * @param type 要注册的类型,例如:“boolean","number","string","Array","egret.Rectangle" * @param asDefault 是否将此属性注册为组件的默认属性,一个组件只可以设置一个默认属性。注册了组件默认属性后,在EXML中可以使用省略属性节点的写法, * @example: * <pre> * <s:Scroller> * <s:viewport> * <s:Group/> * </e:viewport> * </e:Scroller> * </pre> * 因为 viewport 已经注册为 Scroller 的默认属性,上面的例子可以等效为: * <pre> * <s:Scroller> * <s:Group/> * </e:Scroller> * </pre> * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native * @language zh_CN */ function registerProperty(classDefinition, property, type, asDefault) { if (true) { if (!classDefinition) { egret.$error(1003, "classDefinition"); } if (!classDefinition.prototype) { egret.$error(1012, "classDefinition"); } if (!property) { egret.$error(1003, "property"); } if (!type) { egret.$error(1003, "type"); } } var prototype = classDefinition.prototype; prototype.__meta__ = prototype.__meta__ || {}; prototype.__meta__[property] = type; if (asDefault) { prototype.__defaultProperty__ = property; } } eui.registerProperty = registerProperty; })(eui || (eui = {})); ////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2014-present, Egret Technology. // All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of the Egret nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////////////// /// <reference path="Validator.ts" /> var eui; (function (eui) { var sys; (function (sys) { var UIComponentClass = "eui.UIComponent"; function isDeltaIdentity(m) { return (m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1); } var validator = new sys.Validator(); /** * @private * EUI 显示对象基类模板。仅作为 UIComponent 的默认实现,为egret.sys.implemenetUIComponenet()方法提供代码模板。 * 注意:在此类里不允许直接使用super关键字访问父类方法。一律使用this.$super属性访问。 */ var UIComponentImpl = (function (_super) { __extends(UIComponentImpl, _super); /** * @private * 构造函数 */ function UIComponentImpl() { var _this = _super.call(this) || this; _this.initializeUIValues(); return _this; } /** * @private * UIComponentImpl 定义的所有变量请不要添加任何初始值,必须统一在此处初始化。 */ UIComponentImpl.prototype.initializeUIValues = function () { this.$UIComponent = { 0: NaN, 1: NaN, 2: NaN, 3: NaN, 4: NaN, 5: NaN, 6: NaN, 7: NaN, 8: NaN, 9: NaN, 10: 0, 11: 0, 12: 0, 13: 100000, 14: 0, 15: 100000, 16: 0, 17: 0, 18: NaN, 19: NaN, 20: 0, 21: 0, 22: 0, 23: 0, 24: true, 25: true, 26: true, 27: false, 28: false, 29: false, }; this.$includeInLayout = true; //if egret this.$touchEnabled = true; //endif*/ }; /** * @private * 子类覆盖此方法可以执行一些初始化子项操作。此方法仅在组件第一次添加到舞台时回调一次。 * 请务必调用super.createChildren()以完成父类组件的初始化 */ UIComponentImpl.prototype.createChildren = function () { }; /** * @private * 子项创建完成,此方法在createChildren()之后执行。 */ UIComponentImpl.prototype.childrenCreated = function () { }; /** * @private * 提交属性,子类在调用完invalidateProperties()方法后,应覆盖此方法以应用属性 */ UIComponentImpl.prototype.commitProperties = function () { var values = this.$UIComponent; if (values[22 /* oldWidth */] != values[10 /* width */] || values[23 /* oldHeight */] != values[11 /* height */]) { this.dispatchEventWith(egret.Event.RESIZE); values[22 /* oldWidth */] = values[10 /* width */]; values[23 /* oldHeight */] = values[11 /* height */]; } if (values[20 /* oldX */] != this.$getX() || values[21 /* oldY */] != this.$getY()) { eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.MOVE); values[20 /* oldX */] = this.$getX(); values[21 /* oldY */] = this.$getY(); } }; /** * @private * 测量组件尺寸 */ UIComponentImpl.prototype.measure = function () { }; /** * @private * 更新显示列表 */ UIComponentImpl.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { }; Object.defineProperty(UIComponentImpl.prototype, "includeInLayout", { /** * @private * 指定此组件是否包含在父容器的布局中。若为false,则父级容器在测量和布局阶段都忽略此组件。默认值为true。 * 注意,visible属性与此属性不同,设置visible为false,父级容器仍会对其布局。 */ get: function () { return this.$includeInLayout; }, set: function (value) { value = !!value; if (this.$includeInLayout === value) return; this.$includeInLayout = true; this.invalidateParentLayout(); this.$includeInLayout = value; }, enumerable: true, configurable: true }); /** * @private * * @param stage * @param nestLevel */ UIComponentImpl.prototype.$onAddToStage = function (stage, nestLevel) { this.$super.$onAddToStage.call(this, stage, nestLevel); this.checkInvalidateFlag(); var values = this.$UIComponent; if (!values[29 /* initialized */]) { values[29 /* initialized */] = true; this.createChildren(); this.childrenCreated(); eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CREATION_COMPLETE); } }; /** * @private * 检查属性失效标记并应用 */ UIComponentImpl.prototype.checkInvalidateFlag = function (event) { var values = this.$UIComponent; if (values[24 /* invalidatePropertiesFlag */]) { validator.invalidateProperties(this); } if (values[25 /* invalidateSizeFlag */]) { validator.invalidateSize(this); } if (values[26 /* invalidateDisplayListFlag */]) { validator.invalidateDisplayList(this); } }; Object.defineProperty(UIComponentImpl.prototype, "left", { /** * @private * 距父级容器离左边距离 */ get: function () { return this.$UIComponent[0 /* left */]; }, set: function (value) { if (!value || typeof value == "number") { value = +value; } else { value = value.toString().trim(); } var values = this.$UIComponent; if (values[0 /* left */] === value) return; values[0 /* left */] = value; this.invalidateParentLayout(); }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "right", { /** * @private * 距父级容器右边距离 */ get: function () { return this.$UIComponent[1 /* right */]; }, set: function (value) { if (!value || typeof value == "number") { value = +value; } else { value = value.toString().trim(); } var values = this.$UIComponent; if (values[1 /* right */] === value) return; values[1 /* right */] = value; this.invalidateParentLayout(); }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "top", { /** * @private * 距父级容器顶部距离 */ get: function () { return this.$UIComponent[2 /* top */]; }, set: function (value) { if (!value || typeof value == "number") { value = +value; } else { value = value.toString().trim(); } var values = this.$UIComponent; if (values[2 /* top */] === value) return; values[2 /* top */] = value; this.invalidateParentLayout(); }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "bottom", { /** * @private * 距父级容器底部距离 */ get: function () { return this.$UIComponent[3 /* bottom */]; }, set: function (value) { if (!value || typeof value == "number") { value = +value; } else { value = value.toString().trim(); } var values = this.$UIComponent; if (values[3 /* bottom */] == value) return; values[3 /* bottom */] = value; this.invalidateParentLayout(); }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "horizontalCenter", { /** * @private * 在父级容器中距水平中心位置的距离 */ get: function () { return this.$UIComponent[4 /* horizontalCenter */]; }, set: function (value) { if (!value || typeof value == "number") { value = +value; } else { value = value.toString().trim(); } var values = this.$UIComponent; if (values[4 /* horizontalCenter */] === value) return; values[4 /* horizontalCenter */] = value; this.invalidateParentLayout(); }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "verticalCenter", { /** * @private * 在父级容器中距竖直中心位置的距离 */ get: function () { return this.$UIComponent[5 /* verticalCenter */]; }, set: function (value) { if (!value || typeof value == "number") { value = +value; } else { value = value.toString().trim(); } var values = this.$UIComponent; if (values[5 /* verticalCenter */] === value) return; values[5 /* verticalCenter */] = value; this.invalidateParentLayout(); }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "percentWidth", { /** * @private * 相对父级容器宽度的百分比 */ get: function () { return this.$UIComponent[6 /* percentWidth */]; }, set: function (value) { value = +value; var values = this.$UIComponent; if (values[6 /* percentWidth */] === value) return; values[6 /* percentWidth */] = value; this.invalidateParentLayout(); }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "percentHeight", { /** * @private * 相对父级容器高度的百分比 */ get: function () { return this.$UIComponent[7 /* percentHeight */]; }, set: function (value) { value = +value; var values = this.$UIComponent; if (values[7 /* percentHeight */] === value) return; values[7 /* percentHeight */] = value; this.invalidateParentLayout(); }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "explicitWidth", { /** * @private * 外部显式指定的宽度 */ get: function () { return this.$UIComponent[8 /* explicitWidth */]; }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "explicitHeight", { /** * @private * 外部显式指定的高度 */ get: function () { return this.$UIComponent[9 /* explicitHeight */]; }, enumerable: true, configurable: true }); /** * @private * 组件宽度,默认值为egret.NaN,设置为NaN将使用组件的measure()方法自动计算尺寸 */ UIComponentImpl.prototype.$getWidth = function () { this.validateSizeNow(); return this.$UIComponent[10 /* width */]; }; /** * @private * * @param value */ UIComponentImpl.prototype.$setWidth = function (value) { value = +value; var values = this.$UIComponent; if (value < 0 || values[10 /* width */] === value && values[8 /* explicitWidth */] === value) return false; values[8 /* explicitWidth */] = value; if (isNaN(value)) this.invalidateSize(); this.invalidateProperties(); this.invalidateDisplayList(); this.invalidateParentLayout(); return true; }; /** * @private * 立即验证自身的尺寸。 */ UIComponentImpl.prototype.validateSizeNow = function () { this.validateSize(true); this.updateFinalSize(); }; /** * @private * 组件高度,默认值为NaN,设置为NaN将使用组件的measure()方法自动计算尺寸 */ UIComponentImpl.prototype.$getHeight = function () { this.validateSizeNow(); return this.$UIComponent[11 /* height */]; }; /** * @private * * @param value */ UIComponentImpl.prototype.$setHeight = function (value) { value = +value; var values = this.$UIComponent; if (value < 0 || values[11 /* height */] === value && values[9 /* explicitHeight */] === value) return false; values[9 /* explicitHeight */] = value; if (isNaN(value)) this.invalidateSize(); this.invalidateProperties(); this.invalidateDisplayList(); this.invalidateParentLayout(); return true; }; Object.defineProperty(UIComponentImpl.prototype, "minWidth", { /** * @private * 组件的最小宽度,此属性设置为大于maxWidth的值时无效。同时影响测量和自动布局的尺寸。 */ get: function () { return this.$UIComponent[12 /* minWidth */]; }, set: function (value) { value = +value || 0; var values = this.$UIComponent; if (value < 0 || values[12 /* minWidth */] === value) { return; } values[12 /* minWidth */] = value; this.invalidateSize(); this.invalidateParentLayout(); }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "maxWidth", { /** * @private * 组件的最大高度。同时影响测量和自动布局的尺寸。 */ get: function () { return this.$UIComponent[13 /* maxWidth */]; }, set: function (value) { value = +value || 0; var values = this.$UIComponent; if (value < 0 || values[13 /* maxWidth */] === value) { return; } values[13 /* maxWidth */] = value; this.invalidateSize(); this.invalidateParentLayout(); }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "minHeight", { /** * @private * 组件的最小高度,此属性设置为大于maxHeight的值时无效。同时影响测量和自动布局的尺寸。 */ get: function () { return this.$UIComponent[14 /* minHeight */]; }, set: function (value) { value = +value || 0; var values = this.$UIComponent; if (value < 0 || values[14 /* minHeight */] === value) { return; } values[14 /* minHeight */] = value; this.invalidateSize(); this.invalidateParentLayout(); }, enumerable: true, configurable: true }); Object.defineProperty(UIComponentImpl.prototype, "maxHeight", { /** * @private * 组件的最大高度,同时影响测量和自动布局的尺寸。 */ get: function () { return this.$UIComponent[15 /* maxHeight */]; }, set: function (value) { value = +value || 0; var values = this.$UIComponent; if (value < 0 || values[15 /* maxHeight */] === value) { return; } values[15 /* maxHeight */] = value; this.invalidateSize(); this.invalidateParentLayout(); }, enumerable: true, configurable: true }); /** * @private * 设置测量结果。 * @param width 测量宽度 * @param height 测量高度 */ UIComponentImpl.prototype.setMeasuredSize = function (width, height) { var values = this.$UIComponent; values[16 /* measuredWidth */] = Math.ceil(+width || 0); values[17 /* measuredHeight */] = Math.ceil(+height || 0); }; /** * @private * 设置组件的宽高。此方法不同于直接设置width,height属性, * 不会影响显式标记尺寸属性 */ UIComponentImpl.prototype.setActualSize = function (w, h) { var change = false; var values = this.$UIComponent; if (values[10 /* width */] !== w) { values[10 /* width */] = w; change = true; } if (values[11 /* height */] !== h) { values[11 /* height */] = h; change = true; } if (change) { this.invalidateDisplayList(); this.dispatchEventWith(egret.Event.RESIZE); } }; /** * @private */ UIComponentImpl.prototype.$invalidateMatrix = function () { this.$super.$invalidateMatrix.call(this); this.invalidateParentLayout(); }; /** * @private */ UIComponentImpl.prototype.$setMatrix = function (matrix, n