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

TIMOB-11966-3_1_X: When horizontal wrap is enabled, make FILL behavior take up... #4206

Merged
merged 2 commits into from
May 16, 2013
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,25 @@ private void computeHorizontalLayoutPosition(TiCompositeLayout.LayoutParams para
}
horiztonalLayoutPreviousRight = (optionRight == null) ? 0 : optionRight.getAsPixels(this);

int right = left + measuredWidth;
if (enableHorizontalWrap && ((right + horiztonalLayoutPreviousRight) > layoutRight)) {
int right;
// If it's fill width with horizontal wrap, just take up remaining space.
if(enableHorizontalWrap && params.autoFillsWidth && params.sizeOrFillWidthEnabled) {
right = measuredWidth;
} else {
right = left + measuredWidth;
}

if (enableHorizontalWrap && ((right + horiztonalLayoutPreviousRight) > layoutRight || left >= layoutRight)) {
// Too long for the current "line" that it's on. Need to move it down.
left = optionLeftValue;
right = measuredWidth + left;
horizontalLayoutTopBuffer = horizontalLayoutTopBuffer + horizontalLayoutLineHeight;
horizontalLayoutLineHeight = 0;
} else if (!enableHorizontalWrap && params.autoFillsWidth && params.sizeOrFillWidthEnabled) {
// If there is no wrap, and width is fill behavior, cap it off at the width of the screen
right = Math.min(right, layoutRight);
}

hpos[0] = left;
hpos[1] = right;
horizontalLayoutCurrentLeft = right;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ module.exports = new function() {
{name: "horizontalNoWrapTopPaddingSIZEHeight"},
{name: "horizontalWrapTopPaddingSIZEHeight"},
{name: "verticalWithTopBottomPadding"},
{name: "horizontalWrapWithSIZEWidth"}
{name: "horizontalWrapWithSIZEWidth"},
{name: "horizontalWrapWithFILLWidth"}
];

this.horizontalTopBottomUndefinedHeight = function(testRun) {
Expand Down Expand Up @@ -347,4 +348,76 @@ module.exports = new function() {
win.add(topView);
win.open();
};

this.horizontalWrapWithFILLWidth = function(testRun) {
var win2 = Titanium.UI.createWindow({
title:'Tab 2',
backgroundColor:'#fff'
});

var fieldWrapper = Ti.UI.createView({
top: 0,
left: 0,
backgroundColor: '#ff0',
layout:'horizontal'
});
var Label = Ti.UI.createLabel({
text: 'Test text field',
height: 20,
width: 20
});
var Spacer = Ti.UI.createView({
width: 10,
height: 10,
backgroundColor: '#0f0',
});

var textfield = Titanium.UI.createTextField({
width: Ti.UI.FILL,
hintText: 'hint text',
height: '35'
});

var view3 = Ti.UI.createView({
width: Ti.UI.FILL,
height: 10,
backgroundColor: 'purple'
});

var view4= Ti.UI.createView({
width: 30,
height: 10,
backgroundColor: 'red'
});

var view5= Ti.UI.createView({
width: 30,
height: 10,
backgroundColor: 'white'
});

win2.addEventListener("postlayout", function(e){
// purple view should be in 2nd row
valueOf(testRun, view3.rect.x).shouldBe(30);
valueOf(testRun, view3.rect.y).shouldBe(35);

// red view should be first view in 2nd row
valueOf(testRun, view4.rect.x).shouldBe(0);
valueOf(testRun, view4.rect.y).shouldBe(35);

// white view should be on the third row
valueOf(testRun, view5.rect.x).shouldBe(0);
valueOf(testRun, view5.rect.y).shouldBe(45); // 35 (TextField) + 10 (view4)
finish(testRun);
});

fieldWrapper.add(Label);
fieldWrapper.add(Spacer);
fieldWrapper.add(textfield);
fieldWrapper.add(view4);
fieldWrapper.add(view3);
fieldWrapper.add(view5);
win2.add(fieldWrapper);
win2.open();
};
};