From 743d974099bf346e8e444064c810745b01564136 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Thu, 2 Sep 2010 03:51:29 +0000 Subject: [PATCH] Floor the tabLength to avoid drawing bugs. Add the leftover of this cutting to the last tab. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38511 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../decorators/SATDecorator/Stacking.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/add-ons/decorators/SATDecorator/Stacking.cpp b/src/add-ons/decorators/SATDecorator/Stacking.cpp index ca2d3fce98..6bec1981ee 100644 --- a/src/add-ons/decorators/SATDecorator/Stacking.cpp +++ b/src/add-ons/decorators/SATDecorator/Stacking.cpp @@ -352,17 +352,25 @@ SATStacking::_AdjustWindowTabs() const SATWindowList& stackedWindows = area->WindowList(); - float tabBarLength = frame.Width(); - - ASSERT(tabBarLength > 0); - float tabLength = tabBarLength / stackedWindows.CountItems(); + int stackCount = stackedWindows.CountItems(); + float titleBarLength = frame.Width(); + ASSERT(titleBarLength > 0); + // floor to avoid drawing issues + float tabLength = floorf(titleBarLength / stackCount); + // the part that we lost due to the floor + float roundingError = 0; if (tabLength > kMaxTabWidth) tabLength = kMaxTabWidth; + else + roundingError = titleBarLength - stackCount * tabLength; float location = 0; - for (int i = 0; i < stackedWindows.CountItems(); i++) { + for (int i = 0; i < stackCount; i++) { SATWindow* window = stackedWindows.ItemAt(i); - window->SetStackedTabLength(tabLength - 1); + if (i == stackCount - 1) + window->SetStackedTabLength(tabLength - 1 + roundingError); + else + window->SetStackedTabLength(tabLength - 1); desktop->SetWindowTabLocation(window->GetWindow(), location); location += tabLength;