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
This commit is contained in:
Clemens Zeidler
2010-09-01 04:09:08 +00:00
parent cd4692196c
commit e9ec3d5a49
5 changed files with 29 additions and 26 deletions
@@ -69,9 +69,10 @@ SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame,
fBordersHighlighted(false), fBordersHighlighted(false),
fStackedMode(false), fStackedMode(false),
fStackedDrawZoom(false),
fStackedTabLength(0) fStackedTabLength(0)
{ {
fStackedDrawZoom = IsFocus();
// all colors are state based // all colors are state based
fNonHighlightFrameColors[0] = (rgb_color){ 152, 152, 152, 255 }; fNonHighlightFrameColors[0] = (rgb_color){ 152, 152, 152, 255 };
fNonHighlightFrameColors[1] = (rgb_color){ 240, 240, 240, 255 }; fNonHighlightFrameColors[1] = (rgb_color){ 240, 240, 240, 255 };
@@ -169,10 +170,9 @@ SATDecorator::SetStackedMode(bool stacked, BRegion* dirty)
void void
SATDecorator::SetStackedTabLength(float length, bool drawZoom, BRegion* dirty) SATDecorator::SetStackedTabLength(float length, BRegion* dirty)
{ {
fStackedTabLength = length; fStackedTabLength = length;
fStackedDrawZoom = drawZoom;
dirty->Include(fTabRect); dirty->Include(fTabRect);
_DoLayout(); _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) extern "C" DecorAddOn* (instantiate_decor_addon)(image_id id, const char* name)
{ {
return new (std::nothrow)SATDecorAddOn(id, name); return new (std::nothrow)SATDecorAddOn(id, name);
@@ -47,8 +47,7 @@ public:
/*! Set the tab length if the decorator is in stacked mode and if the /*! Set the tab length if the decorator is in stacked mode and if the
tab is the last one in the tab bar. */ tab is the last one in the tab bar. */
void SetStackedTabLength(float length, bool drawZoom, void SetStackedTabLength(float length, BRegion* dirty);
BRegion* dirty);
float StackedTabLength() { return fStackedTabLength; } float StackedTabLength() { return fStackedTabLength; }
protected: protected:
@@ -58,6 +57,8 @@ protected:
bool _SetTabLocation(float location, bool _SetTabLocation(float location,
BRegion* updateRegion = NULL); BRegion* updateRegion = NULL);
void _SetFocus();
private: private:
bool fTabHighlighted; bool fTabHighlighted;
bool fBordersHighlighted; bool fBordersHighlighted;
@@ -564,12 +564,12 @@ SATWindow::SetStackedMode(bool stacked)
bool bool
SATWindow::SetStackedTabLength(float length, bool drawZoom) SATWindow::SetStackedTabLength(float length)
{ {
if (!fDecorator) if (!fDecorator)
return false; return false;
BRegion dirty; BRegion dirty;
fDecorator->SetStackedTabLength(length, drawZoom, &dirty); fDecorator->SetStackedTabLength(length, &dirty);
fDesktop->RebuildAndRedrawAfterWindowChange(fWindow, dirty); fDesktop->RebuildAndRedrawAfterWindowChange(fWindow, dirty);
return true; return true;
} }
@@ -114,7 +114,7 @@ public:
bool IsBordersHighlighted(); bool IsBordersHighlighted();
bool SetStackedMode(bool stacked = true); bool SetStackedMode(bool stacked = true);
bool SetStackedTabLength(float length, bool drawZoom); bool SetStackedTabLength(float length);
bool SetStackedTabMoving(bool moving = true); bool SetStackedTabMoving(bool moving = true);
void TabLocationMoved(float location, bool shifting); void TabLocationMoved(float location, bool shifting);
@@ -293,7 +293,6 @@ SATStacking::TabLocationMoved(float location, bool shifting)
ASSERT(windowIndex >= 0); ASSERT(windowIndex >= 0);
float tabLength = stackedWindows.ItemAt(0)->GetDecorator() float tabLength = stackedWindows.ItemAt(0)->GetDecorator()
->StackedTabLength(); ->StackedTabLength();
float tabLengthZoom = tabLength + decorator->GetZoomOffsetToRight();
float oldTabPosition = windowIndex * (tabLength + 1); float oldTabPosition = windowIndex * (tabLength + 1);
if (fabs(oldTabPosition - location) < tabLength / 2) if (fabs(oldTabPosition - location) < tabLength / 2)
@@ -312,16 +311,6 @@ SATStacking::TabLocationMoved(float location, bool shifting)
float newNeighbourPosition = windowIndex * (tabLength + 1); float newNeighbourPosition = windowIndex * (tabLength + 1);
area->MoveWindowToPosition(fSATWindow, neighbourIndex); area->MoveWindowToPosition(fSATWindow, neighbourIndex);
desktop->SetWindowTabLocation(neighbour->GetWindow(), newNeighbourPosition); 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(); const SATWindowList& stackedWindows = area->WindowList();
float zoomOffset = decorator->GetZoomOffsetToRight(); float tabBarLength = frame.Width();
float tabBarLength = frame.Width() - zoomOffset;
ASSERT(tabBarLength > 0); ASSERT(tabBarLength > 0);
float tabLength = tabBarLength / stackedWindows.CountItems(); float tabLength = tabBarLength / stackedWindows.CountItems();
@@ -374,11 +362,7 @@ SATStacking::_AdjustWindowTabs()
float location = 0; float location = 0;
for (int i = 0; i < stackedWindows.CountItems(); i++) { for (int i = 0; i < stackedWindows.CountItems(); i++) {
SATWindow* window = stackedWindows.ItemAt(i); SATWindow* window = stackedWindows.ItemAt(i);
if (i == stackedWindows.CountItems() - 1) window->SetStackedTabLength(tabLength - 1);
window->SetStackedTabLength(tabLength - 1 + zoomOffset, true);
// last tab
else
window->SetStackedTabLength(tabLength - 1, false);
desktop->SetWindowTabLocation(window->GetWindow(), location); desktop->SetWindowTabLocation(window->GetWindow(), location);
location += tabLength; location += tabLength;