Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions extensions/ccui/base-classes/UIWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
_name: "default",
_widgetType: null,
_actionTag: 0,
_size: null,
_size: cc.size(0, 0),
_customSize: null,
_layoutParameterDictionary: null,
_ignoreSize: false,
Expand All @@ -85,38 +85,22 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
_flippedY: false,
ctor: function () {
cc.Node.prototype.ctor.call(this);
this._enabled = true;
this._bright = true;
this._touchEnabled = false;
this._touchPassedEnabled = false;
this._focus = false;
this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE;
this._updateEnabled = false;
this._touchStartPos = cc.p(0, 0);
this._touchMovePos = cc.p(0, 0);
this._touchEndPos = cc.p(0, 0);
this._touchEventListener = null;
this._touchEventSelector = null;
this._name = "default";
this._widgetType = ccui.Widget.TYPE_WIDGET;
this._actionTag = 0;
this._size = cc.size(0, 0);
this._customSize = cc.size(0, 0);
this._layoutParameterDictionary = {};
this._ignoreSize = false;
this._widgetChildren = [];
this._affectByClipping = false;
this._sizeType = ccui.Widget.SIZE_ABSOLUTE;
this._sizePercent = cc.p(0, 0);
this.positionType = ccui.Widget.POSITION_ABSOLUTE;
this._positionPercent = cc.p(0, 0);
this._reorderWidgetChildDirty = false;
this._hitted = false;
this._nodes = [];
this._color = cc.color(255, 255, 255, 255);
this._touchListener = null;
this._flippedX = false;
this._flippedY = false;
this.init();
},

/**
Expand Down Expand Up @@ -1491,11 +1475,7 @@ _p = null;
* var uiWidget = ccui.Widget.create();
*/
ccui.Widget.create = function () {
var widget = new ccui.Widget();
if (widget && widget.init()) {
return widget;
}
return null;
return new ccui.Widget();
};


Expand Down
36 changes: 13 additions & 23 deletions extensions/ccui/layouts/UILayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
_backGroundImageFileName: null,
_backGroundImageCapInsets: null,
_colorType: null,
_bgImageTexType: null,
_bgImageTexType: ccui.Widget.LOCAL_TEXTURE,
_colorRender: null,
_gradientRender: null,
_color: null,
_startColor: null,
_endColor: null,
_alongVector: null,
_opacity: null,
_opacity: 255,
_backGroundImageTextureSize: null,
_layoutType: null,
_doLayoutDirty: false,
_clippingRectDirty: false,
_doLayoutDirty: true,
_clippingRectDirty: true,
_clippingType: null,
_clippingStencil: null,
_handleScissor: false,
Expand All @@ -60,33 +60,27 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
_clippingParent: null,
_className: "Layout",
_backGroundImageColor: null,

/**
* allocates and initializes a UILayout.
* @constructor
* @example
* // example
* var uiLayout = new ccui.Layout();
*/
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._clippingEnabled = false;
this._backGroundScale9Enabled = false;
this._backGroundImage = null;
this._backGroundImageFileName = "";
this._backGroundImageCapInsets = cc.rect(0, 0, 0, 0);
this._colorType = ccui.Layout.BG_COLOR_NONE;
this._bgImageTexType = ccui.Widget.LOCAL_TEXTURE;
this._colorRender = null;
this._gradientRender = null;
this._color = cc.color(255, 255, 255, 255);
this._startColor = cc.color(255, 255, 255, 255);
this._endColor = cc.color(255, 255, 255, 255);
this._alongVector = cc.p(0, -1);
this._opacity = 255;
this._backGroundImageTextureSize = cc.size(0, 0);
this._layoutType = ccui.Layout.ABSOLUTE;
this._widgetType = ccui.Widget.TYPE_CONTAINER;
this._doLayoutDirty = true;
this._clippingRectDirty = true;
this._clippingType = ccui.Layout.CLIPPING_STENCIL;
this._clippingStencil = null;
this._handleScissor = false;
this._scissorRectDirty = false;
this._clippingRect = cc.rect(0, 0, 0, 0);
this._clippingParent = null;
this._backGroundImageColor = cc.color(255, 255, 255, 255);
},
init: function () {
Expand Down Expand Up @@ -1532,11 +1526,7 @@ _p = null;
* var uiLayout = ccui.Layout.create();
*/
ccui.Layout.create = function () {
var layout = new ccui.Layout();
if (layout && layout.init()) {
return layout;
}
return null;
return new ccui.Layout();
};

// Constants
Expand Down
46 changes: 15 additions & 31 deletions extensions/ccui/uiwidgets/UIButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
_capInsetsNormal: null,
_capInsetsPressed: null,
_capInsetsDisabled: null,
_normalTexType: null,
_pressedTexType: null,
_disabledTexType: null,
_normalTexType: ccui.Widget.LOCAL_TEXTURE,
_pressedTexType: ccui.Widget.LOCAL_TEXTURE,
_disabledTexType: ccui.Widget.LOCAL_TEXTURE,
_normalTextureSize: null,
_pressedTextureSize: null,
_disabledTextureSize: null,
pressedActionEnabled: false,
_titleColor: null,
_titleColor: cc.color.WHITE,
_normalTextureScaleXInSize: 1,
_normalTextureScaleYInSize: 1,
_pressedTextureScaleXInSize: 1,
Expand All @@ -65,36 +65,24 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
_pressedTextureLoaded: false,
_disabledTextureLoaded: false,
_className: "Button",

/**
* allocates and initializes a UIButton.
* @constructor
* @example
* // example
* var uiButton = new ccui.Button();
*/
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._buttonNormalRenderer = null;
this._buttonClickedRenderer = null;
this._buttonDisableRenderer = null;
this._titleRenderer = null;
this._normalFileName = "";
this._clickedFileName = "";
this._disabledFileName = "";
this._prevIgnoreSize = true;
this._scale9Enabled = false;
this._capInsetsNormal = cc.rect(0, 0, 0, 0);
this._capInsetsPressed = cc.rect(0, 0, 0, 0);
this._capInsetsDisabled = cc.rect(0, 0, 0, 0);
this._normalTexType = ccui.Widget.LOCAL_TEXTURE;
this._pressedTexType = ccui.Widget.LOCAL_TEXTURE;
this._disabledTexType = ccui.Widget.LOCAL_TEXTURE;
var locSize = this._size;
this._normalTextureSize = cc.size(locSize.width, locSize.height);
this._pressedTextureSize = cc.size(locSize.width, locSize.height);
this._disabledTextureSize = cc.size(locSize.width, locSize.height);
this.pressedActionEnabled = false;
this._titleColor = cc.color.WHITE;
this._normalTextureScaleXInSize = 1;
this._normalTextureScaleYInSize = 1;
this._pressedTextureScaleXInSize = 1;
this._pressedTextureScaleYInSize = 1;
this._normalTextureLoaded = false;
this._pressedTextureLoaded = false;
this._disabledTextureLoaded = false;

ccui.Widget.prototype.ctor.call(this);
},

init: function () {
Expand Down Expand Up @@ -821,11 +809,7 @@ _p = null;
* var uiButton = ccui.Button.create();
*/
ccui.Button.create = function () {
var uiButton = new ccui.Button();
if (uiButton && uiButton.init()) {
return uiButton;
}
return null;
return new ccui.Button;
};

// Constants
Expand Down
42 changes: 14 additions & 28 deletions extensions/ccui/uiwidgets/UICheckBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,27 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{
_isSelected: true,
_checkBoxEventListener: null,
_checkBoxEventSelector: null,
_backGroundTexType: null,
_backGroundSelectedTexType: null,
_frontCrossTexType: null,
_backGroundDisabledTexType: null,
_frontCrossDisabledTexType: null,
_backGroundTexType: ccui.Widget.LOCAL_TEXTURE,
_backGroundSelectedTexType: ccui.Widget.LOCAL_TEXTURE,
_frontCrossTexType: ccui.Widget.LOCAL_TEXTURE,
_backGroundDisabledTexType: ccui.Widget.LOCAL_TEXTURE,
_frontCrossDisabledTexType: ccui.Widget.LOCAL_TEXTURE,
_backGroundFileName: "",
_backGroundSelectedFileName: "",
_frontCrossFileName: "",
_backGroundDisabledFileName: "",
_frontCrossDisabledFileName: "",
_className: "CheckBox",

/**
* allocates and initializes a UICheckBox.
* @constructor
* @example
* // example
* var uiCheckBox = new ccui.CheckBox();
*/
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._backGroundBoxRenderer = null;
this._backGroundSelectedBoxRenderer = null;
this._frontCrossRenderer = null;
this._backGroundBoxDisabledRenderer = null;
this._frontCrossDisabledRenderer = null;
this._isSelected = true;
this._checkBoxEventListener = null;
this._checkBoxEventSelector = null;
this._backGroundTexType = ccui.Widget.LOCAL_TEXTURE;
this._backGroundSelectedTexType = ccui.Widget.LOCAL_TEXTURE;
this._frontCrossTexType = ccui.Widget.LOCAL_TEXTURE;
this._backGroundDisabledTexType = ccui.Widget.LOCAL_TEXTURE;
this._frontCrossDisabledTexType = ccui.Widget.LOCAL_TEXTURE;
this._backGroundFileName = "";
this._backGroundSelectedFileName = "";
this._frontCrossFileName = "";
this._backGroundDisabledFileName = "";
this._frontCrossDisabledFileName = "";
},
init: function () {
if (ccui.Widget.prototype.init.call(this)) {
Expand Down Expand Up @@ -572,11 +562,7 @@ _p = null;
* var uiCheckBox = ccui.CheckBox.create();
*/
ccui.CheckBox.create = function () {
var uiCheckBox = new ccui.CheckBox();
if (uiCheckBox && uiCheckBox.init()) {
return uiCheckBox;
}
return null;
return new ccui.CheckBox();
};

// Constants
Expand Down
23 changes: 11 additions & 12 deletions extensions/ccui/uiwidgets/UIImageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{
_capInsets: null,
_imageRenderer: null,
_textureFile: "",
_imageTexType: null,
_imageTexType: ccui.Widget.LOCAL_TEXTURE,
_imageTextureSize: null,
_className:"ImageView",

/**
* allocates and initializes a UIImageView.
* @constructor
* @example
* // example
* var uiImageView = new ccui.ImageView;
*/
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._scale9Enabled = false;
this._prevIgnoreSize = true;
this._capInsets = cc.rect(0,0,0,0);
this._imageRenderer = null;
this._textureFile = "";
this._imageTexType = ccui.Widget.LOCAL_TEXTURE;
this._imageTextureSize = cc.size(this._size.width, this._size.height);
ccui.Widget.prototype.ctor.call(this);
},

initRenderer: function () {
Expand Down Expand Up @@ -320,11 +323,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{
* var uiImageView = ccui.ImageView.create();
*/
ccui.ImageView.create = function () {
var uiImageView = new ccui.ImageView();
if (uiImageView && uiImageView.init()) {
return uiImageView;
}
return null;
return new ccui.ImageView();
};

// Constants
Expand Down
25 changes: 11 additions & 14 deletions extensions/ccui/uiwidgets/UILoadingBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,27 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{
_percent: 100,
_totalLength: 0,
_barRenderer: null,
_renderBarTexType: null,
_renderBarTexType: ccui.Widget.LOCAL_TEXTURE,
_barRendererTextureSize: null,
_scale9Enabled: false,
_prevIgnoreSize: true,
_capInsets: null,
_textureFile: "",
_isTextureLoaded: false,
_className: "LoadingBar",

/**
* allocates and initializes a UILoadingBar.
* @constructor
* @example
* // example
* var uiLoadingBar = new ccui.LoadingBar;
*/
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._barType = ccui.LoadingBar.TYPE_LEFT;
this._percent = 100;
this._totalLength = 0;
this._barRenderer = null;
this._renderBarTexType = ccui.Widget.LOCAL_TEXTURE;
this._barRendererTextureSize = cc.size(0, 0);
this._scale9Enabled = false;
this._prevIgnoreSize = true;
this._capInsets = cc.rect(0, 0, 0, 0);
this._textureFile = "";
ccui.Widget.prototype.ctor.call(this);
},

initRenderer: function () {
Expand Down Expand Up @@ -404,11 +405,7 @@ _p = null;
* var uiLoadingBar = ccui.LoadingBar.create();
*/
ccui.LoadingBar.create = function () {
var uiLoadingBar = new ccui.LoadingBar();
if (uiLoadingBar && uiLoadingBar.init()) {
return uiLoadingBar;
}
return null;
return new ccui.LoadingBar();
};

// Constants
Expand Down
Loading