Skip to content

Commit 17e33ea

Browse files
committed
HorizontalLayout, VerticalLayout: Fixed issue where scaleX and scaleY were not accounted for when using pivotX and pivotY (closes #1696)
1 parent 748aa61 commit 17e33ea

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

source/feathers/layout/HorizontalLayout.as

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,12 @@ package feathers.layout
473473
{
474474
continue;
475475
}
476-
item.x = item.pivotX + positionX;
476+
var pivotX:Number = item.pivotX;
477+
if(pivotX !== 0)
478+
{
479+
pivotX *= item.scaleX;
480+
}
481+
item.x = pivotX + positionX;
477482
var itemWidth:Number;
478483
if(hasDistributedWidth)
479484
{
@@ -668,12 +673,18 @@ package feathers.layout
668673
continue;
669674
}
670675

676+
var pivotY:Number = item.pivotY;
677+
if(pivotY !== 0)
678+
{
679+
pivotY *= item.scaleY;
680+
}
681+
671682
//in this section, we handle vertical alignment and percent
672683
//height from HorizontalLayoutData
673684
if(this._verticalAlign == VerticalAlign.JUSTIFY)
674685
{
675686
//if we justify items vertically, we can skip percent height
676-
item.y = item.pivotY + boundsY + this._paddingTop;
687+
item.y = pivotY + boundsY + this._paddingTop;
677688
item.height = availableHeightMinusPadding;
678689
}
679690
else
@@ -735,17 +746,17 @@ package feathers.layout
735746
{
736747
case VerticalAlign.BOTTOM:
737748
{
738-
item.y = item.pivotY + boundsY + verticalAlignHeight - this._paddingBottom - item.height;
749+
item.y = pivotY + boundsY + verticalAlignHeight - this._paddingBottom - item.height;
739750
break;
740751
}
741752
case VerticalAlign.MIDDLE:
742753
{
743-
item.y = item.pivotY + boundsY + this._paddingTop + Math.round((verticalAlignHeight - this._paddingTop - this._paddingBottom - item.height) / 2);
754+
item.y = pivotY + boundsY + this._paddingTop + Math.round((verticalAlignHeight - this._paddingTop - this._paddingBottom - item.height) / 2);
744755
break;
745756
}
746757
default: //top
747758
{
748-
item.y = item.pivotY + boundsY + this._paddingTop;
759+
item.y = pivotY + boundsY + this._paddingTop;
749760
}
750761
}
751762
}

source/feathers/layout/VerticalLayout.as

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,12 @@ package feathers.layout
619619
{
620620
continue;
621621
}
622-
item.y = item.pivotY + positionY;
622+
var pivotY:Number = item.pivotY;
623+
if(pivotY !== 0)
624+
{
625+
pivotY *= item.scaleY;
626+
}
627+
item.y = pivotY + positionY;
623628
var itemWidth:Number = item.width;
624629
var itemHeight:Number;
625630
if(hasDistributedHeight)
@@ -822,12 +827,18 @@ package feathers.layout
822827
continue;
823828
}
824829

830+
var pivotX:Number = item.pivotX;
831+
if(pivotX !== 0)
832+
{
833+
pivotX *= item.scaleX;
834+
}
835+
825836
//in this section, we handle horizontal alignment and percent
826837
//width from VerticalLayoutData
827838
if(this._horizontalAlign == HorizontalAlign.JUSTIFY)
828839
{
829840
//if we justify items horizontally, we can skip percent width
830-
item.x = item.pivotX + boundsX + this._paddingLeft;
841+
item.x = pivotX + boundsX + this._paddingLeft;
831842
item.width = availableWidthMinusPadding;
832843
}
833844
else
@@ -889,19 +900,19 @@ package feathers.layout
889900
{
890901
case HorizontalAlign.RIGHT:
891902
{
892-
item.x = item.pivotX + boundsX + horizontalAlignWidth - this._paddingRight - item.width;
903+
item.x = pivotX + boundsX + horizontalAlignWidth - this._paddingRight - item.width;
893904
break;
894905
}
895906
case HorizontalAlign.CENTER:
896907
{
897908
//round to the nearest pixel when dividing by 2 to
898909
//align in the center
899-
item.x = item.pivotX + boundsX + this._paddingLeft + Math.round((horizontalAlignWidth - this._paddingLeft - this._paddingRight - item.width) / 2);
910+
item.x = pivotX + boundsX + this._paddingLeft + Math.round((horizontalAlignWidth - this._paddingLeft - this._paddingRight - item.width) / 2);
900911
break;
901912
}
902913
default: //left
903914
{
904-
item.x = item.pivotX + boundsX + this._paddingLeft;
915+
item.x = pivotX + boundsX + this._paddingLeft;
905916
}
906917
}
907918
}

0 commit comments

Comments
 (0)