Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle auto layout with scaled widget #3488

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions extensions/ccui/base-classes/UIWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -1364,31 +1364,31 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{
* @returns {number}
*/
getLeftBoundary: function () {
return this.getPositionX() - this._getAnchorX() * this._contentSize.width;
return this.getBoundingBox().x;
},

/**
* Gets the bottom boundary position of this widget.
* @returns {number}
*/
getBottomBoundary: function () {
return this.getPositionY() - this._getAnchorY() * this._contentSize.height;
return this.getBoundingBox().y;
},

/**
* Gets the right boundary position of this widget.
* @returns {number}
*/
getRightBoundary: function () {
return this.getLeftBoundary() + this._contentSize.width;
return this.getLeftBoundary() + this.getBoundingBox().width;
},

/**
* Gets the top boundary position of this widget.
* @returns {number}
*/
getTopBoundary: function () {
return this.getBottomBoundary() + this._contentSize.height;
return this.getBottomBoundary() + this.getBoundingBox().height;
},

/**
Expand Down
14 changes: 7 additions & 7 deletions extensions/ccui/layouts/UILayoutManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down