From 585d44f283e2d07d855f18b2f0573a4243b33844 Mon Sep 17 00:00:00 2001 From: Ryan Leavengood Date: Sun, 10 Jun 2012 00:14:21 -0400 Subject: [PATCH] Improve the workspace view tab rendering. Before this the height and width of the tab would jump around as the window was moved. In addition there was an off-by-one error which caused right-aligned tabs to not be drawn right (as reported in ticket #4615, which this fixes.) --- src/servers/app/WorkspacesView.cpp | 34 +++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/servers/app/WorkspacesView.cpp b/src/servers/app/WorkspacesView.cpp index a475aad31a..60df6d8cb1 100644 --- a/src/servers/app/WorkspacesView.cpp +++ b/src/servers/app/WorkspacesView.cpp @@ -214,18 +214,32 @@ WorkspacesView::_DrawWindow(DrawingEngine* drawingEngine, _DarkenColor(white); } - if (tabFrame.left < frame.left) - tabFrame.left = frame.left; - if (tabFrame.right >= frame.right) - tabFrame.right = frame.right - 1; + if (tabFrame.Height() > 0 && tabFrame.Width() > 0) { + float width = tabFrame.Width(); + if (tabFrame.left < frame.left) { + // Shift the tab right + tabFrame.left = frame.left; + tabFrame.right = tabFrame.left + width; + } + if (tabFrame.right > frame.right) { + // Shift the tab left + tabFrame.right = frame.right; + tabFrame.left = tabFrame.right - width; + } - tabFrame.bottom = frame.top - 1; - tabFrame.top = min_c(tabFrame.top, tabFrame.bottom); - tabFrame = tabFrame & workspaceFrame; + if (tabFrame.Height() > 0 && tabFrame.bottom >= tabFrame.top) { + // Shift the tab up + float tabHeight = tabFrame.Height(); + tabFrame.bottom = frame.top - 1; + tabFrame.top = tabFrame.bottom - tabHeight; + } - if (decorator != NULL && tabFrame.IsValid()) { - drawingEngine->FillRect(tabFrame, tabColor); - backgroundRegion.Exclude(tabFrame); + tabFrame = tabFrame & workspaceFrame; + + if (decorator != NULL && tabFrame.IsValid()) { + drawingEngine->FillRect(tabFrame, tabColor); + backgroundRegion.Exclude(tabFrame); + } } drawingEngine->StrokeRect(frame, frameColor);