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

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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;