1 /**************************************************************************** 2 Copyright (c) 2011-2012 cocos2d-x.org 3 Copyright (c) 2013-2014 Chukong Technologies Inc. 4 5 http://www.cocos2d-x.org 6 7 Permission is hereby granted, free of charge, to any person obtaining a copy 8 of this software and associated documentation files (the "Software"), to deal 9 in the Software without restriction, including without limitation the rights 10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 copies of the Software, and to permit persons to whom the Software is 12 furnished to do so, subject to the following conditions: 13 14 The above copyright notice and this permission notice shall be included in 15 all copies or substantial portions of the Software. 16 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 THE SOFTWARE. 24 ****************************************************************************/ 25 26 //LinearGravity 27 /** 28 * @ignore 29 */ 30 ccui.LINEAR_GRAVITY_NONE = 0; 31 ccui.LINEAR_GRAVITY_LEFT = 1; 32 ccui.LINEAR_GRAVITY_TOP = 2; 33 ccui.LINEAR_GRAVITY_RIGHT = 3; 34 ccui.LINEAR_GRAVITY_BOTTOM = 4; 35 ccui.LINEAR_GRAVITY_CENTER_VERTICAL = 5; 36 ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL = 6; 37 38 //RelativeAlign 39 ccui.RELATIVE_ALIGN_NONE = 0; 40 ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT = 1; 41 ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL = 2; 42 ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT = 3; 43 ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL = 4; 44 ccui.RELATIVE_ALIGN_PARENT_CENTER = 5; 45 ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL = 6; 46 ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM = 7; 47 ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL = 8; 48 ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM = 9; 49 50 ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT = 10; 51 ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER = 11; 52 ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT = 12; 53 54 ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP = 13; 55 ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER = 14; 56 ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM = 15; 57 58 ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP = 16; 59 ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER = 17; 60 ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM = 18; 61 62 ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP = 19; 63 ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER = 20; 64 ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM = 21; 65 66 /** 67 * Base class for ccui.Margin 68 * @class 69 * @extends ccui.Class 70 */ 71 ccui.Margin = ccui.Class.extend(/** @lends ccui.Margin# */{ 72 left: 0, 73 top: 0, 74 right: 0, 75 bottom: 0, 76 ctor: function (margin, top, right, bottom) { 77 if (margin && top === undefined) { 78 this.left = margin.left; 79 this.top = margin.top; 80 this.right = margin.right; 81 this.bottom = margin.bottom; 82 } 83 if (bottom !== undefined) { 84 this.left = margin; 85 this.top = top; 86 this.right = right; 87 this.bottom = bottom; 88 } 89 }, 90 /** 91 * set margin 92 * @param {Number} l 93 * @param {Number} t 94 * @param {Number} r 95 * @param {Number} b 96 */ 97 setMargin: function (l, t, r, b) { 98 this.left = l; 99 this.top = t; 100 this.right = r; 101 this.bottom = b; 102 }, 103 /** 104 * check is equals 105 * @param {ccui.Margin} target 106 * @returns {boolean} 107 */ 108 equals: function (target) { 109 return (this.left == target.left && this.top == target.top && this.right == target.right && this.bottom == target.bottom); 110 } 111 }); 112 113 ccui.MarginZero = function(){ 114 return new ccui.Margin(0,0,0,0); 115 };