- Use soft inequality constraints to describe the window max size. This means the max size of a window is only violated when it is really necessary. In this case the affected windows get a temporary sufficient large max size limit.
- When resizing a window the window size constraint stays soft when solving the layout. This makes sure that the layout constraints can be fulfilled. Fixes r41759. - Some other refactoring. S&T should work much better now. Sorry that I wasn't able to finish it before a3. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42280 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -78,31 +78,6 @@ WindowArea::MoveWindowToPosition(SATWindow* window, int32 index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
WindowArea::UpdateSizeLimits()
|
|
||||||
{
|
|
||||||
int32 minWidth, maxWidth, minHeight, maxHeight;
|
|
||||||
minWidth = minHeight = 1;
|
|
||||||
maxWidth = maxHeight = 1;
|
|
||||||
|
|
||||||
for (int i = 0; i < fWindowList.CountItems(); i++) {
|
|
||||||
int32 minW, maxW, minH, maxH;
|
|
||||||
fWindowList.ItemAt(i)->GetSizeLimits(&minW, &maxW, &minH, &maxH);
|
|
||||||
if (minW > minWidth)
|
|
||||||
minWidth = minW;
|
|
||||||
if (maxW > maxWidth)
|
|
||||||
maxWidth = maxW;
|
|
||||||
if (minH > minHeight)
|
|
||||||
minHeight = minH;
|
|
||||||
if (maxH > maxHeight)
|
|
||||||
maxHeight = maxH;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < fWindowList.CountItems(); i++)
|
|
||||||
fWindowList.ItemAt(i)->SetSizeLimits(minWidth, maxWidth, minHeight,
|
|
||||||
maxHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WindowArea::_AddWindow(SATWindow* window, SATWindow* after)
|
WindowArea::_AddWindow(SATWindow* window, SATWindow* after)
|
||||||
{
|
{
|
||||||
@@ -719,10 +694,13 @@ SATGroup::RemoveWindow(SATWindow* window, bool stayBelowMouse)
|
|||||||
if (area)
|
if (area)
|
||||||
area->_RemoveWindow(window);
|
area->_RemoveWindow(window);
|
||||||
|
|
||||||
for (int i = 0; i < CountItems(); i++)
|
int32 windowCount = CountItems();
|
||||||
WindowAt(i)->DoGroupLayout();
|
|
||||||
|
|
||||||
window->RemovedFromGroup(this, stayBelowMouse);
|
window->RemovedFromGroup(this, stayBelowMouse);
|
||||||
|
|
||||||
|
if (windowCount >= 2)
|
||||||
|
WindowAt(0)->DoGroupLayout();
|
||||||
|
|
||||||
// Do nothing after removing the window from the group because this
|
// Do nothing after removing the window from the group because this
|
||||||
// could have released the last reference and destroyed ourself.
|
// could have released the last reference and destroyed ourself.
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ public:
|
|||||||
float Position() const;
|
float Position() const;
|
||||||
void SetPosition(float position);
|
void SetPosition(float position);
|
||||||
orientation_t Orientation() const;
|
orientation_t Orientation() const;
|
||||||
|
Variable* Var() { return fVariable; }
|
||||||
|
|
||||||
//! Caller takes ownership of the constraint.
|
//! Caller takes ownership of the constraint.
|
||||||
Constraint* Connect(Variable* variable);
|
Constraint* Connect(Variable* variable);
|
||||||
@@ -143,7 +144,6 @@ public:
|
|||||||
const SATWindowList& LayerOrder() { return fWindowLayerOrder; }
|
const SATWindowList& LayerOrder() { return fWindowLayerOrder; }
|
||||||
bool MoveWindowToPosition(SATWindow* window,
|
bool MoveWindowToPosition(SATWindow* window,
|
||||||
int32 index);
|
int32 index);
|
||||||
void UpdateSizeLimits();
|
|
||||||
|
|
||||||
Crossing* LeftTopCrossing()
|
Crossing* LeftTopCrossing()
|
||||||
{ return fLeftTopCrossing.Get(); }
|
{ return fLeftTopCrossing.Get(); }
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ using namespace BPrivate;
|
|||||||
using namespace LinearProgramming;
|
using namespace LinearProgramming;
|
||||||
|
|
||||||
|
|
||||||
const uint32 kExtentPenalty = 10;
|
const float kExtentPenalty = 1;
|
||||||
|
const float kHighPenalty = 10;
|
||||||
|
const float kInequalityPenalty = 10000;
|
||||||
|
|
||||||
|
|
||||||
GroupCookie::GroupCookie(SATWindow* satWindow)
|
GroupCookie::GroupCookie(SATWindow* satWindow)
|
||||||
@@ -36,15 +38,10 @@ GroupCookie::GroupCookie(SATWindow* satWindow)
|
|||||||
fRightBorder(NULL),
|
fRightBorder(NULL),
|
||||||
fBottomBorder(NULL),
|
fBottomBorder(NULL),
|
||||||
|
|
||||||
fLeftBorderConstraint(NULL),
|
|
||||||
fTopBorderConstraint(NULL),
|
|
||||||
fRightBorderConstraint(NULL),
|
|
||||||
fBottomBorderConstraint(NULL),
|
|
||||||
|
|
||||||
fLeftConstraint(NULL),
|
|
||||||
fTopConstraint(NULL),
|
|
||||||
fMinWidthConstraint(NULL),
|
fMinWidthConstraint(NULL),
|
||||||
fMinHeightConstraint(NULL),
|
fMinHeightConstraint(NULL),
|
||||||
|
fMaxWidthConstraint(NULL),
|
||||||
|
fMaxHeightConstraint(NULL),
|
||||||
fWidthConstraint(NULL),
|
fWidthConstraint(NULL),
|
||||||
fHeightConstraint(NULL)
|
fHeightConstraint(NULL)
|
||||||
{
|
{
|
||||||
@@ -58,12 +55,12 @@ GroupCookie::~GroupCookie()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
|
GroupCookie::DoGroupLayout()
|
||||||
{
|
{
|
||||||
if (!fSATGroup.Get())
|
if (!fSATGroup.Get())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BRect frame = triggerWindow->CompleteWindowFrame();
|
BRect frame = fSATWindow->CompleteWindowFrame();
|
||||||
// Make it also work for solver which don't support negative variables
|
// Make it also work for solver which don't support negative variables
|
||||||
frame.OffsetBy(kMakePositiveOffset, kMakePositiveOffset);
|
frame.OffsetBy(kMakePositiveOffset, kMakePositiveOffset);
|
||||||
|
|
||||||
@@ -72,17 +69,16 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
|
|||||||
fHeightConstraint->SetRightSide(frame.Height());
|
fHeightConstraint->SetRightSide(frame.Height());
|
||||||
|
|
||||||
LinearSpec* linearSpec = fSATGroup->GetLinearSpec();
|
LinearSpec* linearSpec = fSATGroup->GetLinearSpec();
|
||||||
fLeftConstraint = linearSpec->AddConstraint(1.0, fLeftBorder, kEQ,
|
Constraint* leftConstraint = linearSpec->AddConstraint(1.0, fLeftBorder,
|
||||||
frame.left);
|
kEQ, frame.left);
|
||||||
fTopConstraint = linearSpec->AddConstraint(1.0, fTopBorder, kEQ,
|
Constraint* topConstraint = linearSpec->AddConstraint(1.0, fTopBorder, kEQ,
|
||||||
frame.top);
|
frame.top);
|
||||||
|
|
||||||
// adjust window position soft constraints
|
// give soft constraints a high penalty
|
||||||
// (a bit more penalty for them so they take precedence)
|
fWidthConstraint->SetPenaltyNeg(kHighPenalty);
|
||||||
fWidthConstraint->SetPenaltyNeg(-1);
|
fWidthConstraint->SetPenaltyPos(kHighPenalty);
|
||||||
fWidthConstraint->SetPenaltyPos(-1);
|
fHeightConstraint->SetPenaltyNeg(kHighPenalty);
|
||||||
fHeightConstraint->SetPenaltyNeg(-1);
|
fHeightConstraint->SetPenaltyPos(kHighPenalty);
|
||||||
fHeightConstraint->SetPenaltyPos(-1);
|
|
||||||
|
|
||||||
// After we set the new parameter solve and apply the new layout.
|
// After we set the new parameter solve and apply the new layout.
|
||||||
ResultType result;
|
ResultType result;
|
||||||
@@ -93,8 +89,7 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (result == kOptimal) {
|
if (result == kOptimal) {
|
||||||
fSATGroup->AdjustWindows(triggerWindow);
|
fSATGroup->AdjustWindows(fSATWindow);
|
||||||
_UpdateWindowSize(frame);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,10 +100,8 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
|
|||||||
fHeightConstraint->SetPenaltyNeg(kExtentPenalty);
|
fHeightConstraint->SetPenaltyNeg(kExtentPenalty);
|
||||||
fHeightConstraint->SetPenaltyPos(kExtentPenalty);
|
fHeightConstraint->SetPenaltyPos(kExtentPenalty);
|
||||||
|
|
||||||
linearSpec->RemoveConstraint(fLeftConstraint);
|
linearSpec->RemoveConstraint(leftConstraint);
|
||||||
fLeftConstraint = NULL;
|
linearSpec->RemoveConstraint(topConstraint);
|
||||||
linearSpec->RemoveConstraint(fTopConstraint);
|
|
||||||
fTopConstraint = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -124,6 +117,7 @@ GroupCookie::MoveWindow(int32 workspace)
|
|||||||
fRightBorder->Value() - kMakePositiveOffset,
|
fRightBorder->Value() - kMakePositiveOffset,
|
||||||
fBottomBorder->Value() - kMakePositiveOffset);
|
fBottomBorder->Value() - kMakePositiveOffset);
|
||||||
|
|
||||||
|
fSATWindow->AdjustSizeLimits(frameSAT);
|
||||||
desktop->MoveWindowBy(window, round(frameSAT.left - frame.left),
|
desktop->MoveWindowBy(window, round(frameSAT.left - frame.left),
|
||||||
round(frameSAT.top - frame.top), workspace);
|
round(frameSAT.top - frame.top), workspace);
|
||||||
|
|
||||||
@@ -133,7 +127,7 @@ GroupCookie::MoveWindow(int32 workspace)
|
|||||||
desktop->ResizeWindowBy(window, round(frameSAT.right - frame.right),
|
desktop->ResizeWindowBy(window, round(frameSAT.right - frame.right),
|
||||||
round(frameSAT.bottom - frame.bottom));
|
round(frameSAT.bottom - frame.bottom));
|
||||||
|
|
||||||
_UpdateWindowSize(frame);
|
UpdateSizeConstaints(frameSAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,6 +137,19 @@ GroupCookie::SetSizeLimits(int32 minWidth, int32 maxWidth, int32 minHeight,
|
|||||||
{
|
{
|
||||||
fMinWidthConstraint->SetRightSide(minWidth);
|
fMinWidthConstraint->SetRightSide(minWidth);
|
||||||
fMinHeightConstraint->SetRightSide(minHeight);
|
fMinHeightConstraint->SetRightSide(minHeight);
|
||||||
|
fMaxWidthConstraint->SetRightSide(maxWidth);
|
||||||
|
fMaxHeightConstraint->SetRightSide(maxHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
GroupCookie::UpdateSizeConstaints(const BRect& frame)
|
||||||
|
{
|
||||||
|
// adjust window size soft constraints
|
||||||
|
if (fSATWindow->IsHResizeable() == true)
|
||||||
|
fWidthConstraint->SetRightSide(frame.Width());
|
||||||
|
if (fSATWindow->IsVResizeable() == true)
|
||||||
|
fHeightConstraint->SetRightSide(frame.Height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -156,56 +163,44 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
|
|||||||
|
|
||||||
LinearSpec* linearSpec = group->GetLinearSpec();
|
LinearSpec* linearSpec = group->GetLinearSpec();
|
||||||
// create variables
|
// create variables
|
||||||
fLeftBorder = linearSpec->AddVariable();
|
fLeftBorder = area->LeftTab()->Var();
|
||||||
fTopBorder = linearSpec->AddVariable();
|
fTopBorder = area->TopTab()->Var();
|
||||||
fRightBorder = linearSpec->AddVariable();
|
fRightBorder = area->RightTab()->Var();
|
||||||
fBottomBorder = linearSpec->AddVariable();
|
fBottomBorder = area->BottomTab()->Var();
|
||||||
|
|
||||||
if (!fLeftBorder || !fTopBorder || !fRightBorder || !fBottomBorder) {
|
// size limit constraints
|
||||||
// clean up
|
int32 minWidth, maxWidth;
|
||||||
Uninit();
|
int32 minHeight, maxHeight;
|
||||||
return false;
|
fSATWindow->GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
||||||
}
|
fSATWindow->AddDecorator(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
||||||
|
|
||||||
// create constraints
|
|
||||||
BRect frame = fSATWindow->CompleteWindowFrame();
|
|
||||||
|
|
||||||
int32 minWidth, maxWidth, minHeight, maxHeight;
|
|
||||||
fSATWindow->GetSizeLimits(&minWidth, &maxWidth, &minHeight,
|
|
||||||
&maxHeight);
|
|
||||||
fMinWidthConstraint = linearSpec->AddConstraint(1.0, fRightBorder, -1.0,
|
fMinWidthConstraint = linearSpec->AddConstraint(1.0, fRightBorder, -1.0,
|
||||||
fLeftBorder, kGE, minWidth);
|
fLeftBorder, kGE, minWidth);
|
||||||
fMinHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0,
|
fMinHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0,
|
||||||
fTopBorder, kGE, minHeight);
|
fTopBorder, kGE, minHeight);
|
||||||
|
|
||||||
// The width and height constraints have higher penalties than the
|
fMaxWidthConstraint = linearSpec->AddConstraint(1.0, fRightBorder, -1.0,
|
||||||
// position constraints (left, top), so a window will keep its size
|
fLeftBorder, kLE, maxWidth, kInequalityPenalty, kInequalityPenalty);
|
||||||
// unless explicitly resized.
|
fMaxHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0,
|
||||||
fWidthConstraint = linearSpec->AddConstraint(-1.0, fLeftBorder, 1.0,
|
fTopBorder, kLE, maxHeight, kInequalityPenalty, kInequalityPenalty);
|
||||||
fRightBorder, kEQ, frame.Width(), kExtentPenalty,
|
|
||||||
|
// Width and height have soft constraints
|
||||||
|
BRect frame = fSATWindow->CompleteWindowFrame();
|
||||||
|
fWidthConstraint = linearSpec->AddConstraint(1.0, fRightBorder, -1.0,
|
||||||
|
fLeftBorder, kEQ, frame.Width(), kExtentPenalty,
|
||||||
kExtentPenalty);
|
kExtentPenalty);
|
||||||
fHeightConstraint = linearSpec->AddConstraint(-1.0, fTopBorder, 1.0,
|
fHeightConstraint = linearSpec->AddConstraint(-1.0, fTopBorder, 1.0,
|
||||||
fBottomBorder, kEQ, frame.Height(), kExtentPenalty,
|
fBottomBorder, kEQ, frame.Height(), kExtentPenalty,
|
||||||
kExtentPenalty);
|
kExtentPenalty);
|
||||||
|
|
||||||
if (!fMinWidthConstraint
|
if (!fMinWidthConstraint || !fMinHeightConstraint || !fWidthConstraint
|
||||||
|| !fMinHeightConstraint || !fWidthConstraint || !fHeightConstraint) {
|
|| !fHeightConstraint || !fMaxWidthConstraint
|
||||||
|
|| !fMaxHeightConstraint) {
|
||||||
// clean up
|
// clean up
|
||||||
Uninit();
|
Uninit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fLeftBorderConstraint = area->LeftTab()->Connect(fLeftBorder);
|
|
||||||
fTopBorderConstraint = area->TopTab()->Connect(fTopBorder);
|
|
||||||
fRightBorderConstraint = area->RightTab()->Connect(fRightBorder);
|
|
||||||
fBottomBorderConstraint = area->BottomTab()->Connect(fBottomBorder);
|
|
||||||
|
|
||||||
if (!fLeftBorderConstraint || !fTopBorderConstraint
|
|
||||||
|| !fRightBorderConstraint || !fBottomBorderConstraint) {
|
|
||||||
Uninit();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,34 +208,21 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
|
|||||||
void
|
void
|
||||||
GroupCookie::Uninit()
|
GroupCookie::Uninit()
|
||||||
{
|
{
|
||||||
delete fLeftBorder;
|
|
||||||
delete fTopBorder;
|
|
||||||
delete fRightBorder;
|
|
||||||
delete fBottomBorder;
|
|
||||||
fLeftBorder = NULL;
|
fLeftBorder = NULL;
|
||||||
fTopBorder = NULL;
|
fTopBorder = NULL;
|
||||||
fRightBorder = NULL;
|
fRightBorder = NULL;
|
||||||
fBottomBorder = NULL;
|
fBottomBorder = NULL;
|
||||||
|
|
||||||
delete fLeftBorderConstraint;
|
|
||||||
delete fTopBorderConstraint;
|
|
||||||
delete fRightBorderConstraint;
|
|
||||||
delete fBottomBorderConstraint;
|
|
||||||
fLeftBorderConstraint = NULL;
|
|
||||||
fTopBorderConstraint = NULL;
|
|
||||||
fRightBorderConstraint = NULL;
|
|
||||||
fBottomBorderConstraint = NULL;
|
|
||||||
|
|
||||||
delete fLeftConstraint;
|
|
||||||
delete fTopConstraint;
|
|
||||||
delete fMinWidthConstraint;
|
delete fMinWidthConstraint;
|
||||||
delete fMinHeightConstraint;
|
delete fMinHeightConstraint;
|
||||||
|
delete fMaxWidthConstraint;
|
||||||
|
delete fMaxHeightConstraint;
|
||||||
delete fWidthConstraint;
|
delete fWidthConstraint;
|
||||||
delete fHeightConstraint;
|
delete fHeightConstraint;
|
||||||
fLeftConstraint = NULL;
|
|
||||||
fTopConstraint = NULL;
|
|
||||||
fMinWidthConstraint = NULL;
|
fMinWidthConstraint = NULL;
|
||||||
fMinHeightConstraint = NULL;
|
fMinHeightConstraint = NULL;
|
||||||
|
fMaxWidthConstraint = NULL;
|
||||||
|
fMaxHeightConstraint = NULL;
|
||||||
fWidthConstraint = NULL;
|
fWidthConstraint = NULL;
|
||||||
fHeightConstraint = NULL;
|
fHeightConstraint = NULL;
|
||||||
|
|
||||||
@@ -268,15 +250,6 @@ GroupCookie::PropagateToGroup(SATGroup* group, WindowArea* area)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
GroupCookie::_UpdateWindowSize(const BRect& frame)
|
|
||||||
{
|
|
||||||
// adjust window size soft constraints
|
|
||||||
fWidthConstraint->SetRightSide(frame.Width());
|
|
||||||
fHeightConstraint->SetRightSide(frame.Height());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@@ -297,16 +270,18 @@ SATWindow::SATWindow(StackAndTile* sat, Window* window)
|
|||||||
|
|
||||||
fDesktop = fWindow->Desktop();
|
fDesktop = fWindow->Desktop();
|
||||||
|
|
||||||
|
// read initial limit values
|
||||||
|
fWindow->GetSizeLimits(&fOriginalMinWidth, &fOriginalMaxWidth,
|
||||||
|
&fOriginalMinHeight, &fOriginalMaxHeight);
|
||||||
|
BRect frame = fWindow->Frame();
|
||||||
|
fOriginalWidth = frame.Width();
|
||||||
|
fOriginalHeight = frame.Height();
|
||||||
|
|
||||||
fGroupCookie = &fOwnGroupCookie;
|
fGroupCookie = &fOwnGroupCookie;
|
||||||
_InitGroup();
|
_InitGroup();
|
||||||
|
|
||||||
fSATSnappingBehaviourList.AddItem(&fSATStacking);
|
fSATSnappingBehaviourList.AddItem(&fSATStacking);
|
||||||
fSATSnappingBehaviourList.AddItem(&fSATTiling);
|
fSATSnappingBehaviourList.AddItem(&fSATTiling);
|
||||||
|
|
||||||
// read initial limit values
|
|
||||||
fWindow->GetSizeLimits(&fOriginalMinWidth, &fOriginalMaxWidth,
|
|
||||||
&fOriginalMinHeight, &fOriginalMaxHeight);
|
|
||||||
Resized();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -392,11 +367,6 @@ SATWindow::AddedToGroup(SATGroup* group, WindowArea* area)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group->CountItems() > 1)
|
|
||||||
area->UpdateSizeLimits();
|
|
||||||
|
|
||||||
if (group->CountItems() == 2)
|
|
||||||
group->WindowAt(0)->_UpdateSizeLimits();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,8 +378,6 @@ SATWindow::RemovedFromGroup(SATGroup* group, bool stayBelowMouse)
|
|||||||
fWindow->Title());
|
fWindow->Title());
|
||||||
|
|
||||||
_RestoreOriginalSize(stayBelowMouse);
|
_RestoreOriginalSize(stayBelowMouse);
|
||||||
if (group->CountItems() == 1)
|
|
||||||
group->WindowAt(0)->_RestoreOriginalSize(false);
|
|
||||||
|
|
||||||
if (fShutdown) {
|
if (fShutdown) {
|
||||||
fGroupCookie->Uninit();
|
fGroupCookie->Uninit();
|
||||||
@@ -507,26 +475,154 @@ SATWindow::DoGroupLayout()
|
|||||||
if (!PositionManagedBySAT())
|
if (!PositionManagedBySAT())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fGroupCookie->DoGroupLayout(this);
|
fGroupCookie->DoGroupLayout();
|
||||||
|
|
||||||
DoWindowLayout();
|
DoWindowLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SATWindow::SetSizeLimits(int32 minWidth, int32 maxWidth, int32 minHeight,
|
SATWindow::AdjustSizeLimits(BRect targetFrame)
|
||||||
int32 maxHeight)
|
|
||||||
{
|
{
|
||||||
_UpdateSizeLimits();
|
SATDecorator* decorator = GetDecorator();
|
||||||
|
if (decorator == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
targetFrame.right -= 2 * (int32)decorator->BorderWidth();
|
||||||
|
targetFrame.bottom -= 2 * (int32)decorator->BorderWidth()
|
||||||
|
+ (int32)decorator->TabHeight() + 1;
|
||||||
|
|
||||||
|
int32 minWidth, maxWidth;
|
||||||
|
int32 minHeight, maxHeight;
|
||||||
|
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
||||||
|
|
||||||
|
if (maxWidth < targetFrame.Width())
|
||||||
|
maxWidth = targetFrame.IntegerWidth();
|
||||||
|
if (maxHeight < targetFrame.Height())
|
||||||
|
maxHeight = targetFrame.IntegerHeight();
|
||||||
|
|
||||||
|
fWindow->SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SATWindow::GetSizeLimits(int32* minWidth, int32* maxWidth, int32* minHeight,
|
||||||
|
int32* maxHeight) const
|
||||||
|
{
|
||||||
|
*minWidth = fOriginalMinWidth;
|
||||||
|
*minHeight = fOriginalMinHeight;
|
||||||
|
*maxWidth = fOriginalMaxWidth;
|
||||||
|
*maxHeight = fOriginalMaxHeight;
|
||||||
|
|
||||||
|
SATDecorator* decorator = GetDecorator();
|
||||||
|
if (decorator == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int32 minDecorWidth = 1, maxDecorWidth = 1;
|
||||||
|
int32 minDecorHeight = 1, maxDecorHeight = 1;
|
||||||
|
decorator->GetSizeLimits(&minDecorWidth, &minDecorHeight,
|
||||||
|
&maxDecorWidth, &maxDecorHeight);
|
||||||
|
|
||||||
|
// if no size limit is set but the window is not resizeable choose the
|
||||||
|
// current size as limit
|
||||||
|
if (IsHResizeable() == false && fOriginalMinWidth <= minDecorWidth)
|
||||||
|
*minWidth = (int32)fOriginalWidth;
|
||||||
|
if (IsVResizeable() == false && fOriginalMinHeight <= minDecorHeight)
|
||||||
|
*minHeight = (int32)fOriginalHeight;
|
||||||
|
|
||||||
|
if (*minWidth > *maxWidth)
|
||||||
|
*maxWidth = *minWidth;
|
||||||
|
if (*minHeight > *maxHeight)
|
||||||
|
*maxHeight = *minHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SATWindow::AddDecorator(int32* minWidth, int32* maxWidth, int32* minHeight,
|
||||||
|
int32* maxHeight)
|
||||||
|
{
|
||||||
|
SATDecorator* decorator = GetDecorator();
|
||||||
|
if (decorator == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*minWidth += 2 * (int32)decorator->BorderWidth();
|
||||||
|
*minHeight += 2 * (int32)decorator->BorderWidth()
|
||||||
|
+ (int32)decorator->TabHeight() + 1;
|
||||||
|
*maxWidth += 2 * (int32)decorator->BorderWidth();
|
||||||
|
*maxHeight += 2 * (int32)decorator->BorderWidth()
|
||||||
|
+ (int32)decorator->TabHeight() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SATWindow::AddDecorator(BRect& frame)
|
||||||
|
{
|
||||||
|
SATDecorator* decorator = GetDecorator();
|
||||||
|
if (!decorator)
|
||||||
|
return;
|
||||||
|
frame.left -= decorator->BorderWidth();
|
||||||
|
frame.right += decorator->BorderWidth() + 1;
|
||||||
|
frame.top -= decorator->BorderWidth() + decorator->TabHeight() + 1;
|
||||||
|
frame.bottom += decorator->BorderWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SATWindow::SetOriginalSizeLimits(int32 minWidth, int32 maxWidth,
|
||||||
|
int32 minHeight, int32 maxHeight)
|
||||||
|
{
|
||||||
|
fOriginalMinWidth = minWidth;
|
||||||
|
fOriginalMaxWidth = maxWidth;
|
||||||
|
fOriginalMinHeight = minHeight;
|
||||||
|
fOriginalMaxHeight = maxHeight;
|
||||||
|
|
||||||
|
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
||||||
|
AddDecorator(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
||||||
|
fGroupCookie->SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SATWindow::Resized()
|
SATWindow::Resized()
|
||||||
{
|
{
|
||||||
|
bool hResizeable = IsHResizeable();
|
||||||
|
bool vResizeable = IsVResizeable();
|
||||||
|
if (hResizeable == false && vResizeable == false)
|
||||||
|
return;
|
||||||
|
|
||||||
BRect frame = fWindow->Frame();
|
BRect frame = fWindow->Frame();
|
||||||
fOriginalWidth = frame.Width();
|
if (hResizeable)
|
||||||
fOriginalHeight = frame.Height();
|
fOriginalWidth = frame.Width();
|
||||||
|
if (vResizeable)
|
||||||
|
fOriginalHeight = frame.Height();
|
||||||
|
|
||||||
|
fGroupCookie->UpdateSizeConstaints(CompleteWindowFrame());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
SATWindow::IsHResizeable() const
|
||||||
|
{
|
||||||
|
if (fWindow->Look() == B_MODAL_WINDOW_LOOK
|
||||||
|
|| fWindow->Look() == B_BORDERED_WINDOW_LOOK
|
||||||
|
|| fWindow->Look() == B_NO_BORDER_WINDOW_LOOK
|
||||||
|
|| (fWindow->Flags() & B_NOT_RESIZABLE) != 0
|
||||||
|
|| (fWindow->Flags() & B_NOT_H_RESIZABLE) != 0)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
SATWindow::IsVResizeable() const
|
||||||
|
{
|
||||||
|
if (fWindow->Look() == B_MODAL_WINDOW_LOOK
|
||||||
|
|| fWindow->Look() == B_BORDERED_WINDOW_LOOK
|
||||||
|
|| fWindow->Look() == B_NO_BORDER_WINDOW_LOOK
|
||||||
|
|| (fWindow->Flags() & B_NOT_RESIZABLE) != 0
|
||||||
|
|| (fWindow->Flags() & B_NOT_V_RESIZABLE) != 0)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -541,37 +637,11 @@ SATWindow::CompleteWindowFrame()
|
|||||||
frame.OffsetTo(anchor.position);
|
frame.OffsetTo(anchor.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
SATDecorator* decorator = GetDecorator();
|
AddDecorator(frame);
|
||||||
if (!decorator)
|
|
||||||
return frame;
|
|
||||||
frame.left -= decorator->BorderWidth();
|
|
||||||
frame.right += decorator->BorderWidth() + 1;
|
|
||||||
frame.top -= decorator->BorderWidth() + decorator->TabHeight() + 1;
|
|
||||||
frame.bottom += decorator->BorderWidth();
|
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATWindow::GetSizeLimits(int32* minWidth, int32* maxWidth, int32* minHeight,
|
|
||||||
int32* maxHeight) const
|
|
||||||
{
|
|
||||||
fWindow->GetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
|
|
||||||
|
|
||||||
SATDecorator* decorator = GetDecorator();
|
|
||||||
if (decorator == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
*minWidth += 2 * (int32)decorator->BorderWidth() + 1;
|
|
||||||
*minHeight += 2 * (int32)decorator->BorderWidth()
|
|
||||||
+ (int32)decorator->TabHeight() + 1;
|
|
||||||
*maxWidth += 2 * (int32)decorator->BorderWidth() + 1;
|
|
||||||
*maxHeight += 2 * (int32)decorator->BorderWidth()
|
|
||||||
+ (int32)decorator->TabHeight() + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SATWindow::PositionManagedBySAT()
|
SATWindow::PositionManagedBySAT()
|
||||||
{
|
{
|
||||||
@@ -711,53 +781,6 @@ SATWindow::_InitGroup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATWindow::_UpdateSizeLimits()
|
|
||||||
{
|
|
||||||
int32 minWidth, minHeight;
|
|
||||||
int32 maxWidth, maxHeight;
|
|
||||||
fWindow->GetSizeLimits(&fOriginalMinWidth, &maxWidth,
|
|
||||||
&fOriginalMinHeight, &maxHeight);
|
|
||||||
minWidth = fOriginalMinWidth;
|
|
||||||
minHeight = fOriginalMinHeight;
|
|
||||||
if (maxWidth != B_SIZE_UNLIMITED)
|
|
||||||
fOriginalMaxWidth = maxWidth;
|
|
||||||
if (maxHeight != B_SIZE_UNLIMITED)
|
|
||||||
fOriginalMaxHeight = maxHeight;
|
|
||||||
SATDecorator* decorator = GetDecorator();
|
|
||||||
// if no size limit is set but the window is not resizeable choose the
|
|
||||||
// current size as limit
|
|
||||||
if (fWindow->Look() == B_MODAL_WINDOW_LOOK
|
|
||||||
|| fWindow->Look() == B_BORDERED_WINDOW_LOOK
|
|
||||||
|| fWindow->Look() == B_NO_BORDER_WINDOW_LOOK
|
|
||||||
|| (fWindow->Flags() & B_NOT_RESIZABLE) != 0
|
|
||||||
|| (fWindow->Flags() & B_NOT_H_RESIZABLE) != 0
|
|
||||||
|| (fWindow->Flags() & B_NOT_V_RESIZABLE) != 0) {
|
|
||||||
int32 minDecorWidth = 1, maxDecorWidth = 1;
|
|
||||||
int32 minDecorHeight = 1, maxDecorHeight = 1;
|
|
||||||
if (decorator)
|
|
||||||
decorator->GetSizeLimits(&minDecorWidth, &minDecorHeight,
|
|
||||||
&maxDecorWidth, &maxDecorHeight);
|
|
||||||
BRect frame = fWindow->Frame();
|
|
||||||
if (fOriginalMinWidth <= minDecorWidth)
|
|
||||||
minWidth = frame.IntegerWidth();
|
|
||||||
if (fOriginalMinHeight <= minDecorHeight)
|
|
||||||
minHeight = frame.IntegerHeight();
|
|
||||||
}
|
|
||||||
fWindow->SetSizeLimits(minWidth, B_SIZE_UNLIMITED,
|
|
||||||
minHeight, B_SIZE_UNLIMITED);
|
|
||||||
|
|
||||||
|
|
||||||
if (decorator) {
|
|
||||||
minWidth += 2 * (int32)decorator->BorderWidth();
|
|
||||||
minHeight += 2 * (int32)decorator->BorderWidth()
|
|
||||||
+ (int32)decorator->TabHeight() + 1;
|
|
||||||
}
|
|
||||||
fGroupCookie->SetSizeLimits(minWidth, B_SIZE_UNLIMITED, minHeight,
|
|
||||||
B_SIZE_UNLIMITED);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint64
|
uint64
|
||||||
SATWindow::_GenerateId()
|
SATWindow::_GenerateId()
|
||||||
{
|
{
|
||||||
@@ -767,6 +790,7 @@ SATWindow::_GenerateId()
|
|||||||
return (time & ~0xFFFF) | randNumber;
|
return (time & ~0xFFFF) | randNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SATWindow::_RestoreOriginalSize(bool stayBelowMouse)
|
SATWindow::_RestoreOriginalSize(bool stayBelowMouse)
|
||||||
{
|
{
|
||||||
@@ -775,18 +799,10 @@ SATWindow::_RestoreOriginalSize(bool stayBelowMouse)
|
|||||||
fOriginalMinHeight, fOriginalMaxHeight);
|
fOriginalMinHeight, fOriginalMaxHeight);
|
||||||
BRect frame = fWindow->Frame();
|
BRect frame = fWindow->Frame();
|
||||||
float x = 0, y = 0;
|
float x = 0, y = 0;
|
||||||
if (fWindow->Look() == B_MODAL_WINDOW_LOOK
|
if (IsHResizeable() == false)
|
||||||
|| fWindow->Look() == B_BORDERED_WINDOW_LOOK
|
|
||||||
|| fWindow->Look() == B_NO_BORDER_WINDOW_LOOK
|
|
||||||
|| (fWindow->Flags() & B_NOT_RESIZABLE) != 0) {
|
|
||||||
x = fOriginalWidth - frame.Width();
|
x = fOriginalWidth - frame.Width();
|
||||||
|
if (IsVResizeable() == false)
|
||||||
y = fOriginalHeight - frame.Height();
|
y = fOriginalHeight - frame.Height();
|
||||||
} else {
|
|
||||||
if ((fWindow->Flags() & B_NOT_H_RESIZABLE) != 0)
|
|
||||||
x = fOriginalWidth - frame.Width();
|
|
||||||
if ((fWindow->Flags() & B_NOT_V_RESIZABLE) != 0)
|
|
||||||
y = fOriginalHeight - frame.Height();
|
|
||||||
}
|
|
||||||
fDesktop->ResizeWindowBy(fWindow, x, y);
|
fDesktop->ResizeWindowBy(fWindow, x, y);
|
||||||
|
|
||||||
if (!stayBelowMouse)
|
if (!stayBelowMouse)
|
||||||
|
|||||||
@@ -30,10 +30,11 @@ public:
|
|||||||
bool Init(SATGroup* group, WindowArea* area);
|
bool Init(SATGroup* group, WindowArea* area);
|
||||||
void Uninit();
|
void Uninit();
|
||||||
|
|
||||||
void DoGroupLayout(SATWindow* triggerWindow);
|
void DoGroupLayout();
|
||||||
void MoveWindow(int32 workspace);
|
void MoveWindow(int32 workspace);
|
||||||
void SetSizeLimits(int32 minWidth, int32 maxWidth,
|
void SetSizeLimits(int32 minWidth, int32 maxWidth,
|
||||||
int32 minHeight, int32 maxHeight);
|
int32 minHeight, int32 maxHeight);
|
||||||
|
void UpdateSizeConstaints(const BRect& frame);
|
||||||
|
|
||||||
SATGroup* GetGroup() { return fSATGroup.Get(); }
|
SATGroup* GetGroup() { return fSATGroup.Get(); }
|
||||||
|
|
||||||
@@ -43,8 +44,6 @@ public:
|
|||||||
WindowArea* area);
|
WindowArea* area);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _UpdateWindowSize(const BRect& frame);
|
|
||||||
|
|
||||||
SATWindow* fSATWindow;
|
SATWindow* fSATWindow;
|
||||||
|
|
||||||
BReference<SATGroup> fSATGroup;
|
BReference<SATGroup> fSATGroup;
|
||||||
@@ -56,15 +55,12 @@ private:
|
|||||||
Variable* fRightBorder;
|
Variable* fRightBorder;
|
||||||
Variable* fBottomBorder;
|
Variable* fBottomBorder;
|
||||||
|
|
||||||
Constraint* fLeftBorderConstraint;
|
|
||||||
Constraint* fTopBorderConstraint;
|
|
||||||
Constraint* fRightBorderConstraint;
|
|
||||||
Constraint* fBottomBorderConstraint;
|
|
||||||
|
|
||||||
Constraint* fLeftConstraint;
|
|
||||||
Constraint* fTopConstraint;
|
|
||||||
Constraint* fMinWidthConstraint;
|
Constraint* fMinWidthConstraint;
|
||||||
Constraint* fMinHeightConstraint;
|
Constraint* fMinHeightConstraint;
|
||||||
|
Constraint* fMaxWidthConstraint;
|
||||||
|
Constraint* fMaxHeightConstraint;
|
||||||
|
Constraint* fKeepMaxWidthConstraint;
|
||||||
|
Constraint* fKeepMaxHeightConstraint;
|
||||||
Constraint* fWidthConstraint;
|
Constraint* fWidthConstraint;
|
||||||
Constraint* fHeightConstraint;
|
Constraint* fHeightConstraint;
|
||||||
};
|
};
|
||||||
@@ -107,15 +103,23 @@ public:
|
|||||||
void DoWindowLayout();
|
void DoWindowLayout();
|
||||||
void DoGroupLayout();
|
void DoGroupLayout();
|
||||||
|
|
||||||
void SetSizeLimits(int32 minWidth, int32 maxWidth,
|
void AdjustSizeLimits(BRect targetFrame);
|
||||||
int32 minHeight, int32 maxHeight);
|
void SetOriginalSizeLimits(int32 minWidth,
|
||||||
|
int32 maxWidth, int32 minHeight,
|
||||||
|
int32 maxHeight);
|
||||||
|
void GetSizeLimits(int32* minWidth, int32* maxWidth,
|
||||||
|
int32* minHeight, int32* maxHeight) const;
|
||||||
|
void AddDecorator(int32* minWidth, int32* maxWidth,
|
||||||
|
int32* minHeight, int32* maxHeight);
|
||||||
|
void AddDecorator(BRect& frame);
|
||||||
|
|
||||||
// hook called when window has been resized form the outside
|
// hook called when window has been resized form the outside
|
||||||
void Resized();
|
void Resized();
|
||||||
|
bool IsHResizeable() const;
|
||||||
|
bool IsVResizeable() const;
|
||||||
|
|
||||||
//! \return the complete window frame including the Decorator
|
//! \return the complete window frame including the Decorator
|
||||||
BRect CompleteWindowFrame();
|
BRect CompleteWindowFrame();
|
||||||
void GetSizeLimits(int32* minWidth, int32* maxWidth,
|
|
||||||
int32* minHeight, int32* maxHeight) const;
|
|
||||||
|
|
||||||
//! \return true if window is in a group with a least another window
|
//! \return true if window is in a group with a least another window
|
||||||
bool PositionManagedBySAT();
|
bool PositionManagedBySAT();
|
||||||
@@ -137,9 +141,9 @@ public:
|
|||||||
void GetSettings(BMessage& message);
|
void GetSettings(BMessage& message);
|
||||||
private:
|
private:
|
||||||
void _InitGroup();
|
void _InitGroup();
|
||||||
void _UpdateSizeLimits();
|
|
||||||
uint64 _GenerateId();
|
uint64 _GenerateId();
|
||||||
|
|
||||||
|
void _UpdateSizeLimits();
|
||||||
void _RestoreOriginalSize(
|
void _RestoreOriginalSize(
|
||||||
bool stayBelowMouse = true);
|
bool stayBelowMouse = true);
|
||||||
|
|
||||||
|
|||||||
@@ -397,10 +397,10 @@ StackAndTile::SizeLimitsChanged(Window* window, int32 minWidth, int32 maxWidth,
|
|||||||
SATWindow* satWindow = GetSATWindow(window);
|
SATWindow* satWindow = GetSATWindow(window);
|
||||||
if (!satWindow)
|
if (!satWindow)
|
||||||
return;
|
return;
|
||||||
WindowArea* area = satWindow->GetWindowArea();
|
satWindow->SetOriginalSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
|
||||||
if (!area)
|
|
||||||
return;
|
// trigger a relayout
|
||||||
area->UpdateSizeLimits();
|
WindowMoved(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user