Skip to content

Commit

Permalink
Merge pull request #3636 from vishalduggal/timob-11998-30X
Browse files Browse the repository at this point in the history
[TIMOB-11998] (3_0_X) Horizontal Layout Fixes for percent values
  • Loading branch information
srahim committed Dec 27, 2012
2 parents 9edcb4c + b9e2034 commit 7c42640
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions iphone/Classes/TiViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -2449,10 +2449,12 @@ -(CGRect)computeChildSandbox:(TiViewProxy*)child withBounds:(CGRect)bounds

CGFloat desiredWidth;
BOOL recalculateWidth = NO;
BOOL isPercent = NO;

if (TiDimensionIsDip(constraint) || TiDimensionIsPercent(constraint))
{
desiredWidth = TiDimensionCalculateValue(constraint, bounds.size.width) + offsetH;
isPercent = TiDimensionIsPercent(constraint);
}
else if (TiDimensionIsUndefined(constraint))
{
Expand Down Expand Up @@ -2499,7 +2501,14 @@ -(CGRect)computeChildSandbox:(TiViewProxy*)child withBounds:(CGRect)bounds
bounds.origin.y = verticalLayoutBoundary;
if (!childIsFixedHeight)
{
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(desiredWidth,boundingHeight)];
//TIMOB-11998. minimumParentHeightForSize:CGSize will limit width anyways. Pass bounding width here
//desiredHeight = [child minimumParentHeightForSize:CGSizeMake(desiredWidth,boundingHeight)];
if (isPercent) {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(bounds.size.width,boundingHeight)];
}
else {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(boundingWidth,boundingHeight)];
}
bounds.size.height = desiredHeight;
}
verticalLayoutBoundary += bounds.size.height;
Expand All @@ -2520,7 +2529,14 @@ -(CGRect)computeChildSandbox:(TiViewProxy*)child withBounds:(CGRect)bounds
if (desiredWidth < boundingWidth) {
if (!childIsFixedHeight)
{
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(desiredWidth,boundingHeight)];
//TIMOB-11998. minimumParentHeightForSize:CGSize will limit width anyways. Pass bounding width here
//desiredHeight = [child minimumParentHeightForSize:CGSizeMake(desiredWidth,boundingHeight)];
if (isPercent) {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(bounds.size.width,boundingHeight)];
}
else {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(boundingWidth,boundingHeight)];
}
bounds.size.height = desiredHeight;
}
horizontalLayoutBoundary += desiredWidth;
Expand All @@ -2531,7 +2547,12 @@ -(CGRect)computeChildSandbox:(TiViewProxy*)child withBounds:(CGRect)bounds
//Will take up whole row
if (!childIsFixedHeight)
{
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(boundingWidth,boundingHeight)];
if (isPercent) {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(bounds.size.width,boundingHeight)];
}
else {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(boundingWidth,boundingHeight)];
}
bounds.size.height = desiredHeight;
}
verticalLayoutBoundary += bounds.size.height;
Expand All @@ -2551,7 +2572,14 @@ -(CGRect)computeChildSandbox:(TiViewProxy*)child withBounds:(CGRect)bounds
if (desiredWidth < boundingWidth) {
if (!childIsFixedHeight)
{
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(desiredWidth,boundingHeight)];
//TIMOB-11998. minimumParentHeightForSize:CGSize will limit width anyways. Pass bounding width here
//desiredHeight = [child minimumParentHeightForSize:CGSizeMake(desiredWidth,boundingHeight)];
if (isPercent) {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(bounds.size.width,boundingHeight)];
}
else {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(boundingWidth,boundingHeight)];
}
bounds.size.height = desiredHeight;
}
bounds.size.width = desiredWidth;
Expand All @@ -2562,7 +2590,12 @@ -(CGRect)computeChildSandbox:(TiViewProxy*)child withBounds:(CGRect)bounds
//Will take up whole row
if (!childIsFixedHeight)
{
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(boundingWidth,boundingHeight)];
if (isPercent) {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(bounds.size.width,boundingHeight)];
}
else {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(boundingWidth,boundingHeight)];
}
bounds.size.height = desiredHeight;
}
verticalLayoutBoundary += bounds.size.height;
Expand All @@ -2575,7 +2608,14 @@ -(CGRect)computeChildSandbox:(TiViewProxy*)child withBounds:(CGRect)bounds
//If it fits update the horizontal layout row height
if (!childIsFixedHeight)
{
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(desiredWidth,boundingHeight)];
//TIMOB-11998. minimumParentHeightForSize:CGSize will limit width anyways. Pass bounding width here
//desiredHeight = [child minimumParentHeightForSize:CGSizeMake(desiredWidth,boundingHeight)];
if (isPercent) {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(bounds.size.width,boundingHeight)];
}
else {
desiredHeight = [child minimumParentHeightForSize:CGSizeMake(boundingWidth,boundingHeight)];
}
bounds.size.height = desiredHeight;
}
bounds.origin.x = horizontalLayoutBoundary;
Expand Down

0 comments on commit 7c42640

Please sign in to comment.