UNPKG

olympus-r-17plugins

Version:

A plugin of Olympus for 17zuoye.

1,245 lines (1,244 loc) 1.05 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.eventDisplay = new egret.Bitmap(); /** * @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 () { 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) { 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. // ////////////////////////////////////////////////////////////////////////////////////// var eui; (function (eui) { /** * The State class defines a view state, a particular view of a component. * * For example, a product thumbnail could have two view states; * a base view state with minimal information, and a rich view state with * additional information. * * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native * @language en_US */ /** * State 类定义视图状态,即组件的特定视图。 * * 例如,产品缩略图可以有两个视图状态,包含最少信息的基本视图状态和包含附加信息的丰富视图状态。 * * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native * @language zh_CN */ var State = (function (_super) { __extends(State, _super); /** * Constructor. * * @param name The name of the view state. * State names must be unique for a given component. * This property must be set. * @param overrides The overrides for this view state, as an Array of objects that implement * the IOverride interface. These overrides are applied in order when the * state is entered, and removed in reverse order when the state is exited. * * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native * @language en_US */ /** * 创建一个State实例。 * * @param name 视图状态的名称。给定组件的状态名称必须唯一。必须设置此属性。 * @param overrides 该视图状态的覆盖,表现为实现 IOverride 接口的对象的数组。 * 这些覆盖在进入状态时按顺序应用,在退出状态时按相反的顺序删除。 * * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native * @language zh_CN */ function State(name, overrides) { if (overrides === void 0) { overrides = []; } var _this = _super.call(this) || this; _this.name = name; _this.overrides = overrides; return _this; } /** * Initialize this state and all of its overrides. * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native * @language en_US */ /** * 初始化视图状态 * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native * @language zh_CN */ State.prototype.initialize = function (host, stage) { var overrides = this.overrides; var length = overrides.length; for (var i = 0; i < length; i++) { var addItems = overrides[i]; if (addItems instanceof eui.AddItems) { var target = host[addItems.target]; if (target && target instanceof eui.Image && !target.$parent) { stage.addChild(target); stage.removeChild(target); } } } }; return State; }(egret.HashObject)); eui.State = State; __reflect(State.prototype, "eui.State"); })(eui || (eui = {})); (function (eui) { var sys; (function (sys) { /** * @private */ var StateClient = (function () { function StateClient() { } Object.defineProperty(StateClient.prototype, "states", { /** * @private * 为此组件定义的视图状态。 */ get: function () { return this.$stateValues.states; }, set: function (value) { if (!value) value = []; var values = this.$stateValues; values.states = value; var statesMap = {}; var length = value.length; for (var i = 0; i < length; i++) { var state = value[i]; statesMap[state.name] = state; } values.statesMap = statesMap; if (values.parent) { this.commitCurrentState(); } }, enumerable: true, configurable: true }); Object.defineProperty(StateClient.prototype, "currentState", { /** * @private * 组件的当前视图状态。将其设置为 "" 或 null 可将组件重置回其基本状态。 */ get: function () { return this.$stateValues.currentState; }, set: function (value) { var values = this.$stateValues; values.explicitState = value; values.currentState = value; this.commitCurrentState(); }, enumerable: true, configurable: true }); /** * @private * 应用当前的视图状态。子类覆盖此方法在视图状态发生改变时执行相应更新操作。 */ StateClient.prototype.commitCurrentState = function () { var values = this.$stateValues; if (!values.parent) { return; } var destination = values.statesMap[values.currentState]; if (!destination) { if (values.states.length > 0) { values.currentState = values.states[0].name; } else { return; } } if (values.oldState == values.currentState) { return; } var parent = values.parent; var state = values.statesMap[values.oldState]; if (state) { var overrides = state.overrides; var length_3 = overrides.length; for (var i = 0; i < length_3; i++) { overrides[i].remove(this, parent); } } values.oldState = values.currentState; state = values.statesMap[values.currentState]; if (state) { var overrides = state.overrides; var length_4 = overrides.length; for (var i = 0; i < length_4; i++) { overrides[i].apply(this, parent); } } }; /** * @private * 返回是否含有指定名称的视图状态 * @param stateName 要检查的视图状态名称 */ StateClient.prototype.hasState = function (stateName) { return !!this.$stateValues.statesMap[stateName]; }; /** * @private * 初始化所有视图状态 */ StateClient.prototype.initializeStates = function (stage) { this.$stateValues.intialized = true; var states = this.states; var length = states.length; for (var i = 0; i < length; i++) { states[i].initialize(this, stage); } }; return StateClient; }()); sys.StateClient = StateClient; __reflect(StateClient.prototype, "eui.sys.StateClient"); /** * @private */ var StateValues = (function () { function StateValues() { /** * @private */ this.intialized = false; /** * @private */ this.statesMap = {}; /** * @private */ this.states = []; /** * @private */ this.oldState = null; /** * @private */ this.explicitState = null; /** * @private */ this.currentState = null; /** * @private */ this.parent = null; /** * @private */ this.stateIsDirty = false; } return StateValues; }()); sys.StateValues = StateValues; __reflect(StateValues.prototype, "eui.sys.StateValues"); })(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. // ////////////////////////////////////////////////////////////////////////////////////// /// <reference path="Validator.ts" /> var eui; (function (eui) { function getAssets(source, callback) { var adapter = egret.getImplementation("eui.IAssetAdapter"); if (!adapter) { adapter = new eui.DefaultAssetAdapter(); } adapter.getAsset(source, function (content) { callback(content); }, this); } eui.getAssets = getAssets; function getTheme(source, callback) { var adapter = egret.getImplementation("eui.IThemeAdapter"); if (!adapter) { adapter = new eui.DefaultThemeAdapter(); } adapter.getTheme(source, function (data) { callback(data); }, function (e) { console.log(e); }, this); } eui.getTheme = getTheme; })(eui || (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", {