Added method SetExplicitSize() for convenience.

This commit is contained in:
Axel Dörfler 2012-11-04 10:45:51 +01:00
parent d2c8db267d
commit 4656e550b0
4 changed files with 27 additions and 4 deletions

View File

@ -32,6 +32,7 @@ public:
virtual void SetExplicitMinSize(BSize size) = 0;
virtual void SetExplicitMaxSize(BSize size) = 0;
virtual void SetExplicitPreferredSize(BSize size) = 0;
void SetExplicitSize(BSize size);
virtual void SetExplicitAlignment(BAlignment alignment) = 0;
virtual bool IsVisible() = 0;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2009, Haiku, Inc. All rights reserved.
* Copyright 2001-2012, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _VIEW_H
@ -537,6 +537,7 @@ public:
void SetExplicitMinSize(BSize size);
void SetExplicitMaxSize(BSize size);
void SetExplicitPreferredSize(BSize size);
void SetExplicitSize(BSize size);
void SetExplicitAlignment(BAlignment alignment);
BSize ExplicitMinSize() const;
@ -753,4 +754,5 @@ BView::SetLowColor(uchar r, uchar g, uchar b, uchar a)
SetLowColor(color);
}
#endif // _VIEW_H

View File

@ -1,9 +1,10 @@
/*
* Copyright 2010, Haiku, Inc.
* Copyright 2010-2012, Haiku, Inc.
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <LayoutItem.h>
#include <Layout.h>
@ -46,6 +47,15 @@ BLayoutItem::Layout() const
}
void
BLayoutItem::SetExplicitSize(BSize size)
{
SetExplicitMinSize(size);
SetExplicitMaxSize(size);
SetExplicitPreferredSize(size);
}
bool
BLayoutItem::HasHeightForWidth()
{
@ -122,7 +132,7 @@ BLayoutItem::AlignInFrame(BRect frame)
float minHeight;
GetHeightForWidth(frame.Width(), &minHeight, NULL, NULL);
frame.bottom = frame.top + max_c(frame.Height(), minHeight);
maxSize.height = minHeight;
}
@ -178,7 +188,7 @@ BLayoutItem::SetLayout(BLayout* layout)
BView::Private(view).RegisterLayoutItem(this);
}
}
if (fLayout)
AttachedToLayout();
}

View File

@ -4586,6 +4586,16 @@ BView::SetExplicitPreferredSize(BSize size)
}
void
BView::SetExplicitSize(BSize size)
{
fLayoutData->fMinSize = size;
fLayoutData->fMaxSize = size;
fLayoutData->fPreferredSize = size;
InvalidateLayout();
}
void
BView::SetExplicitAlignment(BAlignment alignment)
{