- Add size limit changes to the listener interface.

- Update size limit constraints in S&T only if necessary.
- Header style fixes.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38682 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler 2010-09-17 04:04:02 +00:00
parent d2cf4da51f
commit dcbc4af5d1
7 changed files with 141 additions and 78 deletions

View File

@ -73,13 +73,6 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
fLeftConstraint->SetRightSide(frame.left); fLeftConstraint->SetRightSide(frame.left);
fTopConstraint->SetRightSide(frame.top); fTopConstraint->SetRightSide(frame.top);
int32 minWidth, maxWidth, minHeight, maxHeight;
fSATWindow->GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
fMinWidthConstraint->SetRightSide(minWidth);
fMinHeightConstraint->SetRightSide(minHeight);
fMaxWidthConstraint->SetRightSide(maxWidth);
fMaxHeightConstraint->SetRightSide(maxHeight);
fWidthConstraint->SetPenaltyNeg(110); fWidthConstraint->SetPenaltyNeg(110);
fWidthConstraint->SetPenaltyPos(110); fWidthConstraint->SetPenaltyPos(110);
fHeightConstraint->SetPenaltyNeg(110); fHeightConstraint->SetPenaltyNeg(110);
@ -136,6 +129,17 @@ GroupCookie::MoveWindow(int32 workspace)
} }
void
GroupCookie::SetSizeLimit(int32 minWidth, int32 maxWidth, int32 minHeight,
int32 maxHeight)
{
fMinWidthConstraint->SetRightSide(minWidth);
fMinHeightConstraint->SetRightSide(minHeight);
fMaxWidthConstraint->SetRightSide(maxWidth);
fMaxHeightConstraint->SetRightSide(maxHeight);
}
bool bool
GroupCookie::Init(SATGroup* group, WindowArea* area) GroupCookie::Init(SATGroup* group, WindowArea* area)
{ {
@ -170,8 +174,8 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
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, fBottomBorder, -1.0, fMaxWidthConstraint = linearSpec->AddConstraint(1.0, fRightBorder, -1.0,
fTopBorder, OperatorType(LE), maxHeight); fLeftBorder, OperatorType(LE), maxWidth);
fMaxHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0, fMaxHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0,
fTopBorder, OperatorType(LE), maxHeight); fTopBorder, OperatorType(LE), maxHeight);
@ -371,6 +375,10 @@ SATWindow::AddedToGroup(SATGroup* group, WindowArea* area)
return false; return false;
} }
int32 minWidth, maxWidth, minHeight, maxHeight;
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
fGroupCookie->SetSizeLimit(minWidth, maxWidth, minHeight, maxHeight);
return true; return true;
} }
@ -451,6 +459,7 @@ SATWindow::JoinCandidates()
return false; return false;
bool status = fOngoingSnapping->JoinCandidates(); bool status = fOngoingSnapping->JoinCandidates();
fOngoingSnapping = NULL; fOngoingSnapping = NULL;
return status; return status;
} }
@ -475,6 +484,15 @@ SATWindow::DoGroupLayout()
} }
void
SATWindow::SizeLimitChanged(int32 minWidth, int32 maxWidth, int32 minHeight,
int32 maxHeight)
{
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
fGroupCookie->SetSizeLimit(minWidth, maxWidth, minHeight, maxHeight);
}
BRect BRect
SATWindow::CompleteWindowFrame() SATWindow::CompleteWindowFrame()
{ {

View File

@ -32,6 +32,8 @@ public:
void DoGroupLayout(SATWindow* triggerWindow); void DoGroupLayout(SATWindow* triggerWindow);
void MoveWindow(int32 workspace); void MoveWindow(int32 workspace);
void SetSizeLimit(int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight);
SATGroup* GetGroup() { return fSATGroup.Get(); } SATGroup* GetGroup() { return fSATGroup.Get(); }
@ -103,6 +105,9 @@ public:
void DoWindowLayout(); void DoWindowLayout();
void DoGroupLayout(); void DoGroupLayout();
void SizeLimitChanged(int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight);
//! \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, void GetSizeLimits(int32* minWidth, int32* maxWidth,

View File

@ -290,6 +290,18 @@ StackAndTile::WindowTabLocationChanged(Window* window, float location)
} }
void
StackAndTile::SizeLimitChanged(Window* window, int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight)
{
SATWindow* satWindow = GetSATWindow(window);
if (!satWindow)
return;
satWindow->SizeLimitChanged(minWidth, maxWidth, minHeight, maxHeight);
}
bool bool
StackAndTile::SetDecoratorSettings(Window* window, const BMessage& settings) StackAndTile::SetDecoratorSettings(Window* window, const BMessage& settings)
{ {

View File

@ -37,65 +37,69 @@ typedef std::map<Window*, SATWindow*> SATWindowMap;
class StackAndTile : public DesktopListener { class StackAndTile : public DesktopListener {
public: public:
StackAndTile(); StackAndTile();
virtual ~StackAndTile(); virtual ~StackAndTile();
virtual int32 Identifier(); virtual int32 Identifier();
// DesktopListener hooks // DesktopListener hooks
virtual void ListenerRegistered(Desktop* desktop); virtual void ListenerRegistered(Desktop* desktop);
virtual void ListenerUnregistered(); virtual void ListenerUnregistered();
virtual bool HandleMessage(Window* sender, virtual bool HandleMessage(Window* sender,
BPrivate::ServerLink& link); BPrivate::ServerLink& link);
virtual void WindowAdded(Window* window); virtual void WindowAdded(Window* window);
virtual void WindowRemoved(Window* window); virtual void WindowRemoved(Window* window);
virtual void KeyPressed(uint32 what, int32 key, virtual void KeyPressed(uint32 what, int32 key,
int32 modifiers); int32 modifiers);
virtual void MouseEvent(BMessage* message) {} virtual void MouseEvent(BMessage* message) {}
virtual void MouseDown(Window* window, BMessage* message, virtual void MouseDown(Window* window, BMessage* message,
const BPoint& where); const BPoint& where);
virtual void MouseUp(Window* window, BMessage* message, virtual void MouseUp(Window* window, BMessage* message,
const BPoint& where); const BPoint& where);
virtual void MouseMoved(Window* window, BMessage* message, virtual void MouseMoved(Window* window, BMessage* message,
const BPoint& where) {} const BPoint& where) {}
virtual void WindowMoved(Window* window); virtual void WindowMoved(Window* window);
virtual void WindowResized(Window* window); virtual void WindowResized(Window* window);
virtual void WindowActitvated(Window* window); virtual void WindowActitvated(Window* window);
virtual void WindowSentBehind(Window* window, Window* behindOf); virtual void WindowSentBehind(Window* window,
virtual void WindowWorkspacesChanged(Window* window, Window* behindOf);
virtual void WindowWorkspacesChanged(Window* window,
uint32 workspaces); uint32 workspaces);
virtual void WindowMinimized(Window* window, bool minimize); virtual void WindowMinimized(Window* window, bool minimize);
virtual void WindowTabLocationChanged(Window* window, virtual void WindowTabLocationChanged(Window* window,
float location); float location);
virtual void SizeLimitChanged(Window* window, int32 minWidth,
int32 maxWidth, int32 minHeight,
int32 maxHeight);
virtual bool SetDecoratorSettings(Window* window, virtual bool SetDecoratorSettings(Window* window,
const BMessage& settings); const BMessage& settings);
virtual void GetDecoratorSettings(Window* window, virtual void GetDecoratorSettings(Window* window,
BMessage& settings); BMessage& settings);
bool SATKeyPressed() bool SATKeyPressed()
{ return fSATKeyPressed; } { return fSATKeyPressed; }
SATWindow* GetSATWindow(Window* window); SATWindow* GetSATWindow(Window* window);
private: private:
void _StartSAT(); void _StartSAT();
void _StopSAT(); void _StopSAT();
void _ActivateWindow(SATWindow* window); void _ActivateWindow(SATWindow* window);
bool fSATKeyPressed; bool fSATKeyPressed;
SATWindowMap fSATWindowMap; SATWindowMap fSATWindowMap;
SATWindowList fGrouplessWindows; SATWindowList fGrouplessWindows;
SATWindow* fCurrentSATWindow; SATWindow* fCurrentSATWindow;
bool fTabIsShifting; bool fTabIsShifting;
}; };

View File

@ -252,6 +252,21 @@ DesktopObservable::NotifyWindowTabLocationChanged(Window* window,
} }
void
DesktopObservable::NotifySizeLimitChanged(Window* window, int32 minWidth,
int32 maxWidth, int32 minHeight, int32 maxHeight)
{
if (fWeAreInvoking)
return;
InvokeGuard invokeGuard(fWeAreInvoking);
for (DesktopListener* listener = fDesktopListenerList.First();
listener != NULL; listener = fDesktopListenerList.GetNext(listener))
listener->SizeLimitChanged(window, minWidth, maxWidth, minHeight,
maxHeight);
}
bool bool
DesktopObservable::SetDecoratorSettings(Window* window, DesktopObservable::SetDecoratorSettings(Window* window,
const BMessage& settings) const BMessage& settings)

View File

@ -58,6 +58,9 @@ public:
virtual void WindowTabLocationChanged(Window* window, virtual void WindowTabLocationChanged(Window* window,
float location) = 0; float location) = 0;
virtual void SizeLimitChanged(Window* window, int32 minWidth,
int32 maxWidth, int32 minHeight,
int32 maxHeight) = 0;
virtual bool SetDecoratorSettings(Window* window, virtual bool SetDecoratorSettings(Window* window,
const BMessage& settings) = 0; const BMessage& settings) = 0;
@ -71,46 +74,49 @@ typedef DoublyLinkedList<DesktopListener> DesktopListenerDLList;
class DesktopObservable { class DesktopObservable {
public: public:
DesktopObservable(); DesktopObservable();
void RegisterListener(DesktopListener* listener, void RegisterListener(DesktopListener* listener,
Desktop* desktop); Desktop* desktop);
void UnregisterListener(DesktopListener* listener); void UnregisterListener(DesktopListener* listener);
const DesktopListenerDLList& GetDesktopListenerList(); const DesktopListenerDLList& GetDesktopListenerList();
bool MessageForListener(Window* sender, bool MessageForListener(Window* sender,
BPrivate::ServerLink& link); BPrivate::ServerLink& link);
void NotifyWindowAdded(Window* window); void NotifyWindowAdded(Window* window);
void NotifyWindowRemoved(Window* window); void NotifyWindowRemoved(Window* window);
void NotifyKeyPressed(uint32 what, int32 key, void NotifyKeyPressed(uint32 what, int32 key,
int32 modifiers); int32 modifiers);
void NotifyMouseEvent(BMessage* message); void NotifyMouseEvent(BMessage* message);
void NotifyMouseDown(Window* window, BMessage* message, void NotifyMouseDown(Window* window,
const BPoint& where); BMessage* message, const BPoint& where);
void NotifyMouseUp(Window* window, BMessage* message, void NotifyMouseUp(Window* window, BMessage* message,
const BPoint& where); const BPoint& where);
void NotifyMouseMoved(Window* window, BMessage* message, void NotifyMouseMoved(Window* window,
const BPoint& where); BMessage* message, const BPoint& where);
void NotifyWindowMoved(Window* window); void NotifyWindowMoved(Window* window);
void NotifyWindowResized(Window* window); void NotifyWindowResized(Window* window);
void NotifyWindowActitvated(Window* window); void NotifyWindowActitvated(Window* window);
void NotifyWindowSentBehind(Window* window, void NotifyWindowSentBehind(Window* window,
Window* behindOf); Window* behindOf);
void NotifyWindowWorkspacesChanged(Window* window, void NotifyWindowWorkspacesChanged(Window* window,
uint32 workspaces); uint32 workspaces);
void NotifyWindowMinimized(Window* window, void NotifyWindowMinimized(Window* window,
bool minimize); bool minimize);
void NotifyWindowTabLocationChanged(Window* window, void NotifyWindowTabLocationChanged(Window* window,
float location); float location);
void NotifySizeLimitChanged(Window* window,
int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight);
bool SetDecoratorSettings(Window* window, bool SetDecoratorSettings(Window* window,
const BMessage& settings); const BMessage& settings);
void GetDecoratorSettings(Window* window, void GetDecoratorSettings(Window* window,
BMessage& settings); BMessage& settings);
private: private:
class InvokeGuard { class InvokeGuard {

View File

@ -961,6 +961,9 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
fLink.Attach<float>((float)maxHeight); fLink.Attach<float>((float)maxHeight);
fLink.Flush(); fLink.Flush();
fDesktop->NotifySizeLimitChanged(fWindow, minWidth, maxWidth,
minHeight, maxHeight);
break; break;
} }