LayoutUtils: Style fix, remove leading space

This commit is contained in:
John Scipione 2014-04-04 15:02:29 -04:00
parent 4e8acd3232
commit 04b48a29bd

View File

@ -174,34 +174,29 @@ BLayoutUtils::AlignInFrame(BRect frame, BSize maxSize, BAlignment alignment)
void
BLayoutUtils::AlignInFrame(BView* view, BRect frame)
{
BSize maxSize = view->MaxSize();
BAlignment alignment = view->LayoutAlignment();
if (view->HasHeightForWidth()) {
// The view has height for width, so we do the horizontal alignment
// ourselves and restrict the height max constraint respectively.
if (maxSize.width < frame.Width()
&& alignment.horizontal != B_ALIGN_USE_FULL_WIDTH) {
frame.OffsetBy(floor((frame.Width() - maxSize.width)
* alignment.RelativeHorizontal()), 0);
frame.right = frame.left + maxSize.width;
}
alignment.horizontal = B_ALIGN_USE_FULL_WIDTH;
float minHeight;
float maxHeight;
float preferredHeight;
view->GetHeightForWidth(frame.Width(), &minHeight, &maxHeight,
&preferredHeight);
frame.bottom = frame.top + max_c(frame.Height(), minHeight);
maxSize.height = minHeight;
}
frame = AlignInFrame(frame, maxSize, alignment);
view->MoveTo(frame.LeftTop());
view->ResizeTo(frame.Size());
BSize maxSize = view->MaxSize();
BAlignment alignment = view->LayoutAlignment();
if (view->HasHeightForWidth()) {
// The view has height for width, so we do the horizontal alignment
// ourselves and restrict the height max constraint respectively.
if (maxSize.width < frame.Width()
&& alignment.horizontal != B_ALIGN_USE_FULL_WIDTH) {
frame.OffsetBy(floor((frame.Width() - maxSize.width)
* alignment.RelativeHorizontal()), 0);
frame.right = frame.left + maxSize.width;
}
alignment.horizontal = B_ALIGN_USE_FULL_WIDTH;
float minHeight;
float maxHeight;
float preferredHeight;
view->GetHeightForWidth(frame.Width(), &minHeight, &maxHeight,
&preferredHeight);
frame.bottom = frame.top + max_c(frame.Height(), minHeight);
maxSize.height = minHeight;
}
frame = AlignInFrame(frame, maxSize, alignment);
view->MoveTo(frame.LeftTop());
view->ResizeTo(frame.Size());
}