Added BWindow::ResizeToPreferred().
* B_AUTO_UPDATE_SIZE_LIMITS only really makes sense for resizable windows, and it only sets the minimum/maximum window size. * ResizeToPreferred() resizes the window to its preferred size, and also supports height-for-width layouts.
This commit is contained in:
@@ -165,6 +165,7 @@ public:
|
|||||||
void MoveTo(float x, float y);
|
void MoveTo(float x, float y);
|
||||||
void ResizeBy(float dx, float dy);
|
void ResizeBy(float dx, float dy);
|
||||||
void ResizeTo(float width, float height);
|
void ResizeTo(float width, float height);
|
||||||
|
void ResizeToPreferred();
|
||||||
|
|
||||||
void CenterIn(const BRect& rect);
|
void CenterIn(const BRect& rect);
|
||||||
void CenterOnScreen();
|
void CenterOnScreen();
|
||||||
|
|||||||
@@ -2521,7 +2521,26 @@ BWindow::ResizeTo(float width, float height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Center the window in the passed in rect.
|
void
|
||||||
|
BWindow::ResizeToPreferred()
|
||||||
|
{
|
||||||
|
Layout(false);
|
||||||
|
|
||||||
|
float width = fTopView->PreferredSize().width;
|
||||||
|
width = std::min(width, fTopView->MaxSize().width);
|
||||||
|
width = std::max(width, fTopView->MinSize().width);
|
||||||
|
|
||||||
|
float height = fTopView->PreferredSize().height;
|
||||||
|
height = std::min(width, fTopView->MaxSize().height);
|
||||||
|
height = std::max(width, fTopView->MinSize().height);
|
||||||
|
|
||||||
|
if (GetLayout()->HasHeightForWidth())
|
||||||
|
GetLayout()->GetHeightForWidth(width, NULL, NULL, &height);
|
||||||
|
|
||||||
|
ResizeTo(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindow::CenterIn(const BRect& rect)
|
BWindow::CenterIn(const BRect& rect)
|
||||||
{
|
{
|
||||||
@@ -2534,7 +2553,6 @@ BWindow::CenterIn(const BRect& rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Centers the window on the screen the window is currently on.
|
|
||||||
void
|
void
|
||||||
BWindow::CenterOnScreen()
|
BWindow::CenterOnScreen()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user