From e9ec3d5a49274d125aaa806f3c3481842d166f5b Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Wed, 1 Sep 2010 04:09:08 +0000 Subject: [PATCH] In stack mode, draw the zoom button if the window is active otherwise use the space to draw the title. The idea to draw one zoom button at the rightmost tab does not work because in focus follow mouse mode the particular tab may loose the focus when move the mouse to the zoom button. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38487 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../decorators/SATDecorator/SATDecorator.cpp | 24 ++++++++++++++++--- .../decorators/SATDecorator/SATDecorator.h | 5 ++-- .../decorators/SATDecorator/SATWindow.cpp | 4 ++-- .../decorators/SATDecorator/SATWindow.h | 2 +- .../decorators/SATDecorator/Stacking.cpp | 20 ++-------------- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/add-ons/decorators/SATDecorator/SATDecorator.cpp b/src/add-ons/decorators/SATDecorator/SATDecorator.cpp index 1051c15ce0..4298a15c30 100644 --- a/src/add-ons/decorators/SATDecorator/SATDecorator.cpp +++ b/src/add-ons/decorators/SATDecorator/SATDecorator.cpp @@ -69,9 +69,10 @@ SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame, fBordersHighlighted(false), fStackedMode(false), - fStackedDrawZoom(false), fStackedTabLength(0) { + fStackedDrawZoom = IsFocus(); + // all colors are state based fNonHighlightFrameColors[0] = (rgb_color){ 152, 152, 152, 255 }; fNonHighlightFrameColors[1] = (rgb_color){ 240, 240, 240, 255 }; @@ -169,10 +170,9 @@ SATDecorator::SetStackedMode(bool stacked, BRegion* dirty) void -SATDecorator::SetStackedTabLength(float length, bool drawZoom, BRegion* dirty) +SATDecorator::SetStackedTabLength(float length, BRegion* dirty) { fStackedTabLength = length; - fStackedDrawZoom = drawZoom; dirty->Include(fTabRect); _DoLayout(); @@ -531,6 +531,24 @@ SATDecorator::_SetTabLocation(float location, BRegion* updateRegion) } +void +SATDecorator::_SetFocus() +{ + DefaultDecorator::_SetFocus(); + + if (!fStackedMode) + return; + + if (IsFocus()) + fStackedDrawZoom = true; + else + fStackedDrawZoom = false; + + _DoLayout(); + +} + + extern "C" DecorAddOn* (instantiate_decor_addon)(image_id id, const char* name) { return new (std::nothrow)SATDecorAddOn(id, name); diff --git a/src/add-ons/decorators/SATDecorator/SATDecorator.h b/src/add-ons/decorators/SATDecorator/SATDecorator.h index 511c231e72..5a35178254 100644 --- a/src/add-ons/decorators/SATDecorator/SATDecorator.h +++ b/src/add-ons/decorators/SATDecorator/SATDecorator.h @@ -47,8 +47,7 @@ public: /*! Set the tab length if the decorator is in stacked mode and if the tab is the last one in the tab bar. */ - void SetStackedTabLength(float length, bool drawZoom, - BRegion* dirty); + void SetStackedTabLength(float length, BRegion* dirty); float StackedTabLength() { return fStackedTabLength; } protected: @@ -58,6 +57,8 @@ protected: bool _SetTabLocation(float location, BRegion* updateRegion = NULL); + void _SetFocus(); + private: bool fTabHighlighted; bool fBordersHighlighted; diff --git a/src/add-ons/decorators/SATDecorator/SATWindow.cpp b/src/add-ons/decorators/SATDecorator/SATWindow.cpp index f870c67727..76216527c7 100644 --- a/src/add-ons/decorators/SATDecorator/SATWindow.cpp +++ b/src/add-ons/decorators/SATDecorator/SATWindow.cpp @@ -564,12 +564,12 @@ SATWindow::SetStackedMode(bool stacked) bool -SATWindow::SetStackedTabLength(float length, bool drawZoom) +SATWindow::SetStackedTabLength(float length) { if (!fDecorator) return false; BRegion dirty; - fDecorator->SetStackedTabLength(length, drawZoom, &dirty); + fDecorator->SetStackedTabLength(length, &dirty); fDesktop->RebuildAndRedrawAfterWindowChange(fWindow, dirty); return true; } diff --git a/src/add-ons/decorators/SATDecorator/SATWindow.h b/src/add-ons/decorators/SATDecorator/SATWindow.h index 38acf405a7..b637e5823d 100644 --- a/src/add-ons/decorators/SATDecorator/SATWindow.h +++ b/src/add-ons/decorators/SATDecorator/SATWindow.h @@ -114,7 +114,7 @@ public: bool IsBordersHighlighted(); bool SetStackedMode(bool stacked = true); - bool SetStackedTabLength(float length, bool drawZoom); + bool SetStackedTabLength(float length); bool SetStackedTabMoving(bool moving = true); void TabLocationMoved(float location, bool shifting); diff --git a/src/add-ons/decorators/SATDecorator/Stacking.cpp b/src/add-ons/decorators/SATDecorator/Stacking.cpp index 87e8426de3..50a562ef0f 100644 --- a/src/add-ons/decorators/SATDecorator/Stacking.cpp +++ b/src/add-ons/decorators/SATDecorator/Stacking.cpp @@ -293,7 +293,6 @@ SATStacking::TabLocationMoved(float location, bool shifting) ASSERT(windowIndex >= 0); float tabLength = stackedWindows.ItemAt(0)->GetDecorator() ->StackedTabLength(); - float tabLengthZoom = tabLength + decorator->GetZoomOffsetToRight(); float oldTabPosition = windowIndex * (tabLength + 1); if (fabs(oldTabPosition - location) < tabLength / 2) @@ -312,16 +311,6 @@ SATStacking::TabLocationMoved(float location, bool shifting) float newNeighbourPosition = windowIndex * (tabLength + 1); area->MoveWindowToPosition(fSATWindow, neighbourIndex); desktop->SetWindowTabLocation(neighbour->GetWindow(), newNeighbourPosition); - - // update zoom buttons - if (windowIndex == stackedWindows.CountItems() - 1) { - fSATWindow->SetStackedTabLength(tabLength, false); - neighbour->SetStackedTabLength(tabLengthZoom, true); - } - else if (neighbourIndex == stackedWindows.CountItems() - 1) { - neighbour->SetStackedTabLength(tabLength, false); - fSATWindow->SetStackedTabLength(tabLengthZoom, true); - } } @@ -363,8 +352,7 @@ SATStacking::_AdjustWindowTabs() const SATWindowList& stackedWindows = area->WindowList(); - float zoomOffset = decorator->GetZoomOffsetToRight(); - float tabBarLength = frame.Width() - zoomOffset; + float tabBarLength = frame.Width(); ASSERT(tabBarLength > 0); float tabLength = tabBarLength / stackedWindows.CountItems(); @@ -374,11 +362,7 @@ SATStacking::_AdjustWindowTabs() float location = 0; for (int i = 0; i < stackedWindows.CountItems(); i++) { SATWindow* window = stackedWindows.ItemAt(i); - if (i == stackedWindows.CountItems() - 1) - window->SetStackedTabLength(tabLength - 1 + zoomOffset, true); - // last tab - else - window->SetStackedTabLength(tabLength - 1, false); + window->SetStackedTabLength(tabLength - 1); desktop->SetWindowTabLocation(window->GetWindow(), location); location += tabLength;