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.)
This commit is contained in:
Ryan Leavengood 2012-06-10 00:14:21 -04:00
parent 70a5df3878
commit 585d44f283

View File

@ -214,18 +214,32 @@ WorkspacesView::_DrawWindow(DrawingEngine* drawingEngine,
_DarkenColor(white); _DarkenColor(white);
} }
if (tabFrame.left < frame.left) if (tabFrame.Height() > 0 && tabFrame.Width() > 0) {
tabFrame.left = frame.left; float width = tabFrame.Width();
if (tabFrame.right >= frame.right) if (tabFrame.left < frame.left) {
tabFrame.right = frame.right - 1; // 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; if (tabFrame.Height() > 0 && tabFrame.bottom >= tabFrame.top) {
tabFrame.top = min_c(tabFrame.top, tabFrame.bottom); // Shift the tab up
tabFrame = tabFrame & workspaceFrame; float tabHeight = tabFrame.Height();
tabFrame.bottom = frame.top - 1;
tabFrame.top = tabFrame.bottom - tabHeight;
}
if (decorator != NULL && tabFrame.IsValid()) { tabFrame = tabFrame & workspaceFrame;
drawingEngine->FillRect(tabFrame, tabColor);
backgroundRegion.Exclude(tabFrame); if (decorator != NULL && tabFrame.IsValid()) {
drawingEngine->FillRect(tabFrame, tabColor);
backgroundRegion.Exclude(tabFrame);
}
} }
drawingEngine->StrokeRect(frame, frameColor); drawingEngine->StrokeRect(frame, frameColor);