From 35129226ee4946304d7e06ff05d9fcfe3403335c Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 16 May 2017 16:34:03 +0700 Subject: [PATCH] handle auto layout with scaled widget --- extensions/ccui/base-classes/UIWidget.js | 8 ++++---- extensions/ccui/layouts/UILayoutManager.js | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index b01ac526db..44939ca89b 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1364,7 +1364,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {number} */ getLeftBoundary: function () { - return this.getPositionX() - this._getAnchorX() * this._contentSize.width; + return this.getBoundingBox().x; }, /** @@ -1372,7 +1372,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {number} */ getBottomBoundary: function () { - return this.getPositionY() - this._getAnchorY() * this._contentSize.height; + return this.getBoundingBox().y; }, /** @@ -1380,7 +1380,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {number} */ getRightBoundary: function () { - return this.getLeftBoundary() + this._contentSize.width; + return this.getLeftBoundary() + this.getBoundingBox().width; }, /** @@ -1388,7 +1388,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {number} */ getTopBoundary: function () { - return this.getBottomBoundary() + this._contentSize.height; + return this.getBottomBoundary() + this.getBoundingBox().height; }, /** diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js index 9f89d13e75..6c13508b2f 100644 --- a/extensions/ccui/layouts/UILayoutManager.js +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -58,7 +58,7 @@ ccui.linearVerticalLayoutManager = /** @lends ccui.linearVerticalLayoutManager# if (layoutParameter) { var childGravity = layoutParameter.getGravity(); var ap = child.getAnchorPoint(); - var cs = child.getContentSize(); + var cs = child.getBoundingBox(); var finalPosX = ap.x * cs.width; var finalPosY = topBoundary - ((1.0 - ap.y) * cs.height); switch (childGravity) { @@ -102,7 +102,7 @@ ccui.linearHorizontalLayoutManager = /** @lends ccui.linearHorizontalLayoutManag if (layoutParameter) { var childGravity = layoutParameter.getGravity(); var ap = child.getAnchorPoint(); - var cs = child.getContentSize(); + var cs = child.getBoundingBox(); var finalPosX = leftBoundary + (ap.x * cs.width); var finalPosY = layoutSize.height - (1.0 - ap.y) * cs.height; switch (childGravity) { @@ -211,7 +211,7 @@ ccui.relativeLayoutManager = /** @lends ccui.relativeLayoutManager# */{ _calculateFinalPositionWithRelativeWidget: function (layout) { var locWidget = this._widget; var ap = locWidget.getAnchorPoint(); - var cs = locWidget.getContentSize(); + var cs = locWidget.getBoundingBox(); this._finalPositionX = 0.0; this._finalPositionY = 0.0; @@ -272,7 +272,7 @@ ccui.relativeLayoutManager = /** @lends ccui.relativeLayoutManager# */{ if (relativeWidget) { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var rbs = relativeWidget.getContentSize(); + var rbs = relativeWidget.getBoundingBox(); this._finalPositionY = relativeWidget.getTopBoundary() + ap.y * cs.height; this._finalPositionX = relativeWidget.getLeftBoundary() + rbs.width * 0.5 + ap.x * cs.width - cs.width * 0.5; } @@ -297,7 +297,7 @@ ccui.relativeLayoutManager = /** @lends ccui.relativeLayoutManager# */{ if (relativeWidget) { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var rbs = relativeWidget.getContentSize(); + var rbs = relativeWidget.getBoundingBox(); this._finalPositionX = relativeWidget.getLeftBoundary() - (1.0 - ap.x) * cs.width; this._finalPositionY = relativeWidget.getBottomBoundary() + rbs.height * 0.5 + ap.y * cs.height - cs.height * 0.5; } @@ -322,7 +322,7 @@ ccui.relativeLayoutManager = /** @lends ccui.relativeLayoutManager# */{ if (relativeWidget) { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var rbs = relativeWidget.getContentSize(); + var rbs = relativeWidget.getBoundingBox(); var locationRight = relativeWidget.getRightBoundary(); this._finalPositionX = locationRight + ap.x * cs.width; this._finalPositionY = relativeWidget.getBottomBoundary() + rbs.height * 0.5 + ap.y * cs.height - cs.height * 0.5; @@ -348,7 +348,7 @@ ccui.relativeLayoutManager = /** @lends ccui.relativeLayoutManager# */{ if (relativeWidget) { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var rbs = relativeWidget.getContentSize(); + var rbs = relativeWidget.getBoundingBox(); this._finalPositionY = relativeWidget.getBottomBoundary() - (1.0 - ap.y) * cs.height; this._finalPositionX = relativeWidget.getLeftBoundary() + rbs.width * 0.5 + ap.x * cs.width - cs.width * 0.5; }