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
1 changed files with 23 additions and 28 deletions

View File

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