- Fix a TODO: get the border width and tab height directly from the decorator and don't use hard coded values. For example, you can tile tab less windows probably together now.
- Only use min size constraints now. If there is a clash between a window with a max size and another window with a min size the max size is ignored and the size is enlarged if needed. When removing this window from a S&T group the old size limit is restored. Same is done for none resizeable windows. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39432 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -39,8 +39,6 @@ GroupCookie::GroupCookie(SATWindow* satWindow)
|
|||||||
fTopConstraint(NULL),
|
fTopConstraint(NULL),
|
||||||
fMinWidthConstraint(NULL),
|
fMinWidthConstraint(NULL),
|
||||||
fMinHeightConstraint(NULL),
|
fMinHeightConstraint(NULL),
|
||||||
fMaxWidthConstraint(NULL),
|
|
||||||
fMaxHeightConstraint(NULL),
|
|
||||||
fWidthConstraint(NULL),
|
fWidthConstraint(NULL),
|
||||||
fHeightConstraint(NULL)
|
fHeightConstraint(NULL)
|
||||||
{
|
{
|
||||||
@@ -94,10 +92,10 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
|
|||||||
}
|
}
|
||||||
if (result == OPTIMAL) {
|
if (result == OPTIMAL) {
|
||||||
fSATGroup->AdjustWindows(triggerWindow);
|
fSATGroup->AdjustWindows(triggerWindow);
|
||||||
|
_UpdateWindowSize(frame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_UpdateWindowSize(frame);
|
|
||||||
|
|
||||||
// set penalties back to normal
|
// set penalties back to normal
|
||||||
fWidthConstraint->SetPenaltyNeg(kExtentPenalty);
|
fWidthConstraint->SetPenaltyNeg(kExtentPenalty);
|
||||||
@@ -138,8 +136,6 @@ 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -172,15 +168,12 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
|
|||||||
OperatorType(EQ), frame.top, 1, 1);
|
OperatorType(EQ), frame.top, 1, 1);
|
||||||
|
|
||||||
int32 minWidth, maxWidth, minHeight, maxHeight;
|
int32 minWidth, maxWidth, minHeight, maxHeight;
|
||||||
fSATWindow->GetSizeLimits(&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, OperatorType(GE), minWidth);
|
fLeftBorder, OperatorType(GE), minWidth);
|
||||||
fMinHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0,
|
fMinHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0,
|
||||||
fTopBorder, OperatorType(GE), minHeight);
|
fTopBorder, OperatorType(GE), minHeight);
|
||||||
fMaxWidthConstraint = linearSpec->AddConstraint(1.0, fRightBorder, -1.0,
|
|
||||||
fLeftBorder, OperatorType(LE), maxWidth);
|
|
||||||
fMaxHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0,
|
|
||||||
fTopBorder, OperatorType(LE), maxHeight);
|
|
||||||
|
|
||||||
// The width and height constraints have higher penalties than the
|
// The width and height constraints have higher penalties than the
|
||||||
// position constraints (left, top), so a window will keep its size
|
// position constraints (left, top), so a window will keep its size
|
||||||
@@ -239,16 +232,12 @@ GroupCookie::Uninit()
|
|||||||
delete fTopConstraint;
|
delete fTopConstraint;
|
||||||
delete fMinWidthConstraint;
|
delete fMinWidthConstraint;
|
||||||
delete fMinHeightConstraint;
|
delete fMinHeightConstraint;
|
||||||
delete fMaxWidthConstraint;
|
|
||||||
delete fMaxHeightConstraint;
|
|
||||||
delete fWidthConstraint;
|
delete fWidthConstraint;
|
||||||
delete fHeightConstraint;
|
delete fHeightConstraint;
|
||||||
fLeftConstraint = NULL;
|
fLeftConstraint = NULL;
|
||||||
fTopConstraint = NULL;
|
fTopConstraint = NULL;
|
||||||
fMinWidthConstraint = NULL;
|
fMinWidthConstraint = NULL;
|
||||||
fMinHeightConstraint = NULL;
|
fMinHeightConstraint = NULL;
|
||||||
fMaxWidthConstraint = NULL;
|
|
||||||
fMaxHeightConstraint = NULL;
|
|
||||||
fWidthConstraint = NULL;
|
fWidthConstraint = NULL;
|
||||||
fHeightConstraint = NULL;
|
fHeightConstraint = NULL;
|
||||||
|
|
||||||
@@ -305,6 +294,11 @@ SATWindow::SATWindow(StackAndTile* sat, Window* window)
|
|||||||
|
|
||||||
fSATSnappingBehaviourList.AddItem(&fSATStacking);
|
fSATSnappingBehaviourList.AddItem(&fSATStacking);
|
||||||
fSATSnappingBehaviourList.AddItem(&fSATTiling);
|
fSATSnappingBehaviourList.AddItem(&fSATTiling);
|
||||||
|
|
||||||
|
// read initial limit values
|
||||||
|
fWindow->GetSizeLimits(&fOriginalMinWidth, &fOriginalMaxWidth,
|
||||||
|
&fOriginalMinHeight, &fOriginalMaxHeight);
|
||||||
|
Resized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -320,7 +314,7 @@ SATWindow::~SATWindow()
|
|||||||
|
|
||||||
|
|
||||||
SATDecorator*
|
SATDecorator*
|
||||||
SATWindow::GetDecorator()
|
SATWindow::GetDecorator() const
|
||||||
{
|
{
|
||||||
return static_cast<SATDecorator*>(fWindow->Decorator());
|
return static_cast<SATDecorator*>(fWindow->Decorator());
|
||||||
}
|
}
|
||||||
@@ -386,6 +380,8 @@ SATWindow::AddedToGroup(SATGroup* group, WindowArea* area)
|
|||||||
|
|
||||||
area->UpdateSizeLimits();
|
area->UpdateSizeLimits();
|
||||||
|
|
||||||
|
if (group->CountItems() == 2)
|
||||||
|
group->WindowAt(0)->_UpdateSizeLimits();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,6 +392,24 @@ SATWindow::RemovedFromGroup(SATGroup* group)
|
|||||||
STRACE_SAT("SATWindow::RemovedFromGroup group: %p window %s\n", group,
|
STRACE_SAT("SATWindow::RemovedFromGroup group: %p window %s\n", group,
|
||||||
fWindow->Title());
|
fWindow->Title());
|
||||||
|
|
||||||
|
fWindow->SetSizeLimits(fOriginalMinWidth, fOriginalMaxWidth,
|
||||||
|
fOriginalMinHeight, fOriginalMaxHeight);
|
||||||
|
BRect frame = fWindow->Frame();
|
||||||
|
float x = 0, y = 0;
|
||||||
|
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) {
|
||||||
|
x = fOriginalWidth - frame.Width();
|
||||||
|
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);
|
||||||
|
|
||||||
if (fShutdown) {
|
if (fShutdown) {
|
||||||
fGroupCookie->Uninit();
|
fGroupCookie->Uninit();
|
||||||
return true;
|
return true;
|
||||||
@@ -495,7 +509,16 @@ void
|
|||||||
SATWindow::SetSizeLimits(int32 minWidth, int32 maxWidth, int32 minHeight,
|
SATWindow::SetSizeLimits(int32 minWidth, int32 maxWidth, int32 minHeight,
|
||||||
int32 maxHeight)
|
int32 maxHeight)
|
||||||
{
|
{
|
||||||
fGroupCookie->SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
|
_UpdateSizeLimits();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SATWindow::Resized()
|
||||||
|
{
|
||||||
|
BRect frame = fWindow->Frame();
|
||||||
|
fOriginalWidth = frame.Width();
|
||||||
|
fOriginalHeight = frame.Height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -510,11 +533,13 @@ SATWindow::CompleteWindowFrame()
|
|||||||
frame.OffsetTo(anchor.position);
|
frame.OffsetTo(anchor.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO get this values from the decorator
|
SATDecorator* decorator = GetDecorator();
|
||||||
frame.left -= 5.;
|
if (!decorator)
|
||||||
frame.right += 6.;
|
return frame;
|
||||||
frame.top -= 27;
|
frame.left -= decorator->BorderWidth();
|
||||||
frame.bottom += 5;
|
frame.right += decorator->BorderWidth() + 1;
|
||||||
|
frame.top -= decorator->BorderWidth() + decorator->TabHeight() + 1;
|
||||||
|
frame.bottom += decorator->BorderWidth();
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
@@ -526,11 +551,13 @@ SATWindow::GetSizeLimits(int32* minWidth, int32* maxWidth, int32* minHeight,
|
|||||||
{
|
{
|
||||||
fWindow->GetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
|
fWindow->GetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
|
||||||
|
|
||||||
// TODO get this values from the decorator
|
SATDecorator* decorator = GetDecorator();
|
||||||
*minWidth += 11;
|
if (!decorator)
|
||||||
*minHeight += 32;
|
return;
|
||||||
*maxWidth += 11;
|
*minWidth += 2 * decorator->BorderWidth() + 1;
|
||||||
*maxHeight += 32;
|
*minHeight += 2 * decorator->BorderWidth() + decorator->TabHeight() + 1;
|
||||||
|
*maxWidth += 2 * decorator->BorderWidth() + 1;
|
||||||
|
*maxHeight += 2 * decorator->BorderWidth() + decorator->TabHeight() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -665,3 +692,49 @@ SATWindow::_InitGroup()
|
|||||||
if (!groupRef->AddWindow(this, NULL, NULL, NULL, NULL))
|
if (!groupRef->AddWindow(this, NULL, NULL, NULL, NULL))
|
||||||
STRACE_SAT("SATWindow::_InitGroup(): adding window to group failed\n");
|
STRACE_SAT("SATWindow::_InitGroup(): adding window to group failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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.Width();
|
||||||
|
if (fOriginalMinHeight <= minDecorHeight)
|
||||||
|
minHeight = frame.Height();
|
||||||
|
}
|
||||||
|
fWindow->SetSizeLimits(minWidth, B_SIZE_UNLIMITED,
|
||||||
|
minHeight, B_SIZE_UNLIMITED);
|
||||||
|
|
||||||
|
|
||||||
|
if (decorator) {
|
||||||
|
minWidth += 2 * decorator->BorderWidth();
|
||||||
|
minHeight += 2 * decorator->BorderWidth() + decorator->TabHeight() + 1;
|
||||||
|
}
|
||||||
|
fGroupCookie->SetSizeLimits(minWidth, B_SIZE_UNLIMITED, minHeight,
|
||||||
|
B_SIZE_UNLIMITED);
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,8 +65,6 @@ private:
|
|||||||
Constraint* fTopConstraint;
|
Constraint* fTopConstraint;
|
||||||
Constraint* fMinWidthConstraint;
|
Constraint* fMinWidthConstraint;
|
||||||
Constraint* fMinHeightConstraint;
|
Constraint* fMinHeightConstraint;
|
||||||
Constraint* fMaxWidthConstraint;
|
|
||||||
Constraint* fMaxHeightConstraint;
|
|
||||||
Constraint* fWidthConstraint;
|
Constraint* fWidthConstraint;
|
||||||
Constraint* fHeightConstraint;
|
Constraint* fHeightConstraint;
|
||||||
};
|
};
|
||||||
@@ -78,7 +76,7 @@ public:
|
|||||||
~SATWindow();
|
~SATWindow();
|
||||||
|
|
||||||
Window* GetWindow() { return fWindow; }
|
Window* GetWindow() { return fWindow; }
|
||||||
SATDecorator* GetDecorator();
|
SATDecorator* GetDecorator() const;
|
||||||
StackAndTile* GetStackAndTile() { return fStackAndTile; }
|
StackAndTile* GetStackAndTile() { return fStackAndTile; }
|
||||||
Desktop* GetDesktop() { return fDesktop; }
|
Desktop* GetDesktop() { return fDesktop; }
|
||||||
//! Can be NULL if memory allocation failed!
|
//! Can be NULL if memory allocation failed!
|
||||||
@@ -109,6 +107,8 @@ public:
|
|||||||
|
|
||||||
void SetSizeLimits(int32 minWidth, int32 maxWidth,
|
void SetSizeLimits(int32 minWidth, int32 maxWidth,
|
||||||
int32 minHeight, int32 maxHeight);
|
int32 minHeight, int32 maxHeight);
|
||||||
|
// hook called when window has been resized form the outside
|
||||||
|
void Resized();
|
||||||
|
|
||||||
//! \return the complete window frame including the Decorator
|
//! \return the complete window frame including the Decorator
|
||||||
BRect CompleteWindowFrame();
|
BRect CompleteWindowFrame();
|
||||||
@@ -130,6 +130,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void _InitGroup();
|
void _InitGroup();
|
||||||
|
void _UpdateSizeLimits();
|
||||||
|
|
||||||
Window* fWindow;
|
Window* fWindow;
|
||||||
StackAndTile* fStackAndTile;
|
StackAndTile* fStackAndTile;
|
||||||
@@ -149,6 +150,14 @@ private:
|
|||||||
SATSnappingBehaviourList fSATSnappingBehaviourList;
|
SATSnappingBehaviourList fSATSnappingBehaviourList;
|
||||||
|
|
||||||
bool fShutdown;
|
bool fShutdown;
|
||||||
|
|
||||||
|
int32 fOriginalMinWidth;
|
||||||
|
int32 fOriginalMaxWidth;
|
||||||
|
int32 fOriginalMinHeight;
|
||||||
|
int32 fOriginalMaxHeight;
|
||||||
|
|
||||||
|
float fOriginalWidth;
|
||||||
|
float fOriginalHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -189,13 +189,14 @@ StackAndTile::WindowResized(Window* window)
|
|||||||
SATWindow* satWindow = GetSATWindow(window);
|
SATWindow* satWindow = GetSATWindow(window);
|
||||||
if (!satWindow)
|
if (!satWindow)
|
||||||
return;
|
return;
|
||||||
|
satWindow->Resized();
|
||||||
|
|
||||||
if (SATKeyPressed() && fCurrentSATWindow)
|
if (SATKeyPressed() && fCurrentSATWindow)
|
||||||
satWindow->FindSnappingCandidates();
|
satWindow->FindSnappingCandidates();
|
||||||
else {
|
else {
|
||||||
satWindow->DoGroupLayout();
|
satWindow->DoGroupLayout();
|
||||||
|
|
||||||
// Do a window layout for all windows. TODO: mybe do it a bit more
|
// Do a window layout for all windows. TODO: maybe do it a bit more
|
||||||
// efficient
|
// efficient
|
||||||
SATGroup* group = satWindow->GetGroup();
|
SATGroup* group = satWindow->GetGroup();
|
||||||
if (!group)
|
if (!group)
|
||||||
|
|||||||
@@ -247,6 +247,22 @@ DefaultDecorator::MouseAction(const BMessage* message, BPoint point,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
DefaultDecorator::BorderWidth()
|
||||||
|
{
|
||||||
|
return fBorderWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
DefaultDecorator::TabHeight()
|
||||||
|
{
|
||||||
|
if (fTabRect.IsValid())
|
||||||
|
return fTabRect.Height();
|
||||||
|
return BorderWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DefaultDecorator::_DoLayout()
|
DefaultDecorator::_DoLayout()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ public:
|
|||||||
BPoint point, int32 buttons,
|
BPoint point, int32 buttons,
|
||||||
int32 modifiers);
|
int32 modifiers);
|
||||||
|
|
||||||
|
float BorderWidth();
|
||||||
|
float TabHeight();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void _DoLayout();
|
virtual void _DoLayout();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user