Merge pull request #124 from zilongshanren/improve-ui-components

improve ui components
This commit is contained in:
Jare Guo
2015-12-25 10:53:47 +08:00
6 changed files with 52 additions and 20 deletions
+1 -3
View File
@@ -123,9 +123,9 @@ var EVENT_HOVER_OUT = 'hover-out';
var Button = cc.Class({
name: 'cc.Button',
extends: require('./CCComponent'),
mixins: [EventTarget],
ctor: function () {
EventTarget.call(this);
this._touchListener = null;
this._mouseListener = null;
@@ -511,6 +511,4 @@ var Button = cc.Class({
});
cc.js.addon(Button.prototype, EventTarget.prototype);
cc.Button = module.exports = Button;
+23 -3
View File
@@ -59,7 +59,7 @@ var Label = cc.Class({
/**
* Horizontal Alignment of label
* @property {TextAlignment} horizontalAlign
* @property {Label.HorizontalAlign} horizontalAlign
*/
horizontalAlign: {
default: HorizontalAlign.LEFT,
@@ -75,7 +75,7 @@ var Label = cc.Class({
/**
* Vertical Alignment of label
* @property {VerticalTextAlignment} verticalAlign
* @property {Label.VerticalAlign} verticalAlign
*/
verticalAlign: {
default: VerticalAlign.TOP,
@@ -135,7 +135,7 @@ var Label = cc.Class({
},
/**
* Overflow of label
* @property {Overflow} overFlow
* @property {Label.Overflow} overFlow
*/
overflow: {
default: Overflow.CLAMP,
@@ -230,6 +230,26 @@ var Label = cc.Class({
},
statics: {
/**
* The horizontal alignment of label.
* @property {cc.TextAlignment} HorizontalAlign
*/
HorizontalAlign: HorizontalAlign,
/**
* The vertical alignment of label.
* @property {cc.VerticalTextAlignment} VerticalAlign
*/
VerticalAlign: VerticalAlign,
/**
* Label overflow type, currently three types are supported: Clamp, Shrink and ResizeHeight.
* @property {Overflow} Overflow
*/
Overflow: Overflow,
},
onLoad: function () {
this._super();
this.node.on('size-changed', this._resized, this);
+16 -10
View File
@@ -25,9 +25,9 @@
/**
* Enum for Layout type
* @enum Layout.LayoutType
* @enum Layout.Type
*/
var LayoutType = cc.Enum({
var Type = cc.Enum({
/**
*@property {Number} BASIC
*/
@@ -98,12 +98,12 @@ var Layout = cc.Class({
/**
* The layout type.
* @property {LayoutType} layoutType
* @default Layout.LayoutType.BASIC
* @property {Layout.Type} layoutType
* @default Layout.Type.BASIC
*/
layoutType: {
default: LayoutType.BASIC,
type: LayoutType,
default: Type.BASIC,
type: Type,
notify: function() {
this._doLayoutDirty();
}
@@ -134,7 +134,7 @@ var Layout = cc.Class({
/**
* Only take effect in Vertical layout mode.
* This option changes the start element's positioning.
* @property {VerticalDirection} verticalDirection
* @property {Layout.VerticalDirection} verticalDirection
*/
verticalDirection: {
default: VerticalDirection.TOP_TO_BOTTOM,
@@ -147,7 +147,7 @@ var Layout = cc.Class({
/**
* Only take effect in Horizontal layout mode.
* This option changes the start element's positioning.
* @property {HorizontalDirection} horizontalDirection
* @property {Layout.HorizontalDirection} horizontalDirection
*/
horizontalDirection: {
default: HorizontalDirection.LEFT_TO_RIGHT,
@@ -158,6 +158,12 @@ var Layout = cc.Class({
},
},
statics: {
Type: Type,
VerticalDirection: VerticalDirection,
HorizontalDirection: HorizontalDirection
},
onLoad: function() {
this.node.setContentSize(this._layoutSize);
@@ -259,9 +265,9 @@ var Layout = cc.Class({
var layoutAnchor = this.node.getAnchorPoint();
var layoutSize = this.node.getContentSize();
if (this.layoutType === LayoutType.HORIZONTAL) {
if (this.layoutType === Type.HORIZONTAL) {
this._doLayoutHorizontally(layoutAnchor, layoutSize, children);
} else if (this.layoutType === LayoutType.VERTICAL) {
} else if (this.layoutType === Type.VERTICAL) {
this._doLayoutVertically(layoutAnchor, layoutSize, children);
}
},
+3 -3
View File
@@ -52,7 +52,7 @@ var Mask = cc.Class({
this._clippingStencil.ignoreAnchorPointForPosition(false);
this._clippingNode = new cc.ClippingNode(this._clippingStencil);
},
onEnable: function () {
var oldNode = this.node._sgNode;
this._clippingStencil.setContentSize(this.node._contentSize);
@@ -69,11 +69,11 @@ var Mask = cc.Class({
this.node.off('size-changed', this._onContentSizeChanged, this);
this.node.off('anchor-changed',this._onAnchorChanged,this);
},
onDestroy: function () {
},
_onContentSizeChanged: function() {
if(this._clippingStencil) {
this._clippingStencil.setContentSize(this.node._contentSize);
+5 -1
View File
@@ -141,7 +141,7 @@ var ProgressBar = cc.Class({
/**
* The progress mode, there are two modes supported now: horizontal and vertical.
*@property {Mode} mode
*@property {ProgressBar.Mode} mode
*/
mode: {
default: Mode.HORIZONTAL,
@@ -198,6 +198,10 @@ var ProgressBar = cc.Class({
this._updateBarStatus();
}
}
},
statics: {
Mode: Mode
}
});
+4
View File
@@ -109,6 +109,10 @@ var Scrollbar = cc.Class({
}
},
statics: {
Direction: Direction
},
setTargetScrollView: function(scrollView) {
this._scrollView = scrollView;
},