Polished the rendering of the miniature windows in Workspaces.
* The window names are now drawn. * The window scaling is improved to avoid wobbly placement when windows move slightly. * The tab rect is scaled to size, not a single line. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27976 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -150,15 +150,22 @@ WorkspacesView::_WindowFrame(const BRect& workspaceFrame,
|
|||||||
BRect frame = windowFrame;
|
BRect frame = windowFrame;
|
||||||
frame.OffsetTo(windowPosition);
|
frame.OffsetTo(windowPosition);
|
||||||
|
|
||||||
|
// scale down the rect
|
||||||
float factor = workspaceFrame.Width() / screenFrame.Width();
|
float factor = workspaceFrame.Width() / screenFrame.Width();
|
||||||
frame.left = rintf(frame.left * factor);
|
frame.left = frame.left * factor;
|
||||||
frame.right = rintf(frame.right * factor);
|
frame.right = frame.right * factor;
|
||||||
|
|
||||||
factor = workspaceFrame.Height() / screenFrame.Height();
|
factor = workspaceFrame.Height() / screenFrame.Height();
|
||||||
frame.top = rintf(frame.top * factor);
|
frame.top = frame.top * factor;
|
||||||
frame.bottom = rintf(frame.bottom * factor);
|
frame.bottom = frame.bottom * factor;
|
||||||
|
|
||||||
|
// offset by the workspace fame position
|
||||||
|
// and snap to integer coordinates without distorting the size too much
|
||||||
|
frame.OffsetTo(rintf(frame.left + workspaceFrame.left),
|
||||||
|
rintf(frame.top + workspaceFrame.top));
|
||||||
|
frame.right = rintf(frame.right);
|
||||||
|
frame.bottom = rintf(frame.bottom);
|
||||||
|
|
||||||
frame.OffsetBy(workspaceFrame.LeftTop());
|
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +188,8 @@ WorkspacesView::_DrawWindow(DrawingEngine* drawingEngine,
|
|||||||
|
|
||||||
tabFrame = _WindowFrame(workspaceFrame, screenFrame,
|
tabFrame = _WindowFrame(workspaceFrame, screenFrame,
|
||||||
tabFrame, tabFrame.LeftTop() - offset);
|
tabFrame, tabFrame.LeftTop() - offset);
|
||||||
if (!workspaceFrame.Intersects(frame) && !workspaceFrame.Intersects(tabFrame))
|
if (!workspaceFrame.Intersects(frame)
|
||||||
|
&& !workspaceFrame.Intersects(tabFrame))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// ToDo: let decorator do this!
|
// ToDo: let decorator do this!
|
||||||
@@ -206,48 +214,55 @@ WorkspacesView::_DrawWindow(DrawingEngine* drawingEngine,
|
|||||||
if (tabFrame.right >= frame.right)
|
if (tabFrame.right >= frame.right)
|
||||||
tabFrame.right = frame.right - 1;
|
tabFrame.right = frame.right - 1;
|
||||||
|
|
||||||
tabFrame.top = frame.top - 1;
|
|
||||||
tabFrame.bottom = frame.top - 1;
|
tabFrame.bottom = frame.top - 1;
|
||||||
|
tabFrame.top = min_c(tabFrame.top, tabFrame.bottom);
|
||||||
tabFrame = tabFrame & workspaceFrame;
|
tabFrame = tabFrame & workspaceFrame;
|
||||||
|
|
||||||
if (decorator != NULL && tabFrame.IsValid()) {
|
if (decorator != NULL && tabFrame.IsValid()) {
|
||||||
drawingEngine->StrokeLine(tabFrame.LeftTop(), tabFrame.RightBottom(), yellow);
|
drawingEngine->FillRect(tabFrame, yellow);
|
||||||
backgroundRegion.Exclude(tabFrame);
|
backgroundRegion.Exclude(tabFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawingEngine->StrokeRect(frame, frameColor);
|
drawingEngine->StrokeRect(frame, frameColor);
|
||||||
|
|
||||||
|
BRect fillFrame = frame.InsetByCopy(1, 1) & workspaceFrame;
|
||||||
frame = frame & workspaceFrame;
|
frame = frame & workspaceFrame;
|
||||||
if (frame.IsValid()) {
|
if (!frame.IsValid())
|
||||||
drawingEngine->FillRect(frame.InsetByCopy(1, 1), white);
|
return;
|
||||||
backgroundRegion.Exclude(frame);
|
|
||||||
}
|
// fill the window itself
|
||||||
|
drawingEngine->FillRect(fillFrame, white);
|
||||||
|
|
||||||
// draw title
|
// draw title
|
||||||
|
|
||||||
// TODO: disabled because it's much too slow this way - the mini-window
|
// TODO: the mini-window functionality should probably be moved into the
|
||||||
// functionality should probably be moved into the Window class,
|
// Window class, so that it has only to be recalculated on demand. With
|
||||||
// so that it has only to be recalculated on demand. With double buffered
|
// double buffered windows, this would also open up the door to have a
|
||||||
// windows, this would also open up the door to have a more detailed
|
// more detailed preview.
|
||||||
// preview.
|
|
||||||
#if 0
|
|
||||||
BString title(window->Title());
|
BString title(window->Title());
|
||||||
|
|
||||||
ServerFont font = fDrawState->Font();
|
const ServerFont& font = fDrawState->Font();
|
||||||
font.SetSize(7);
|
|
||||||
fDrawState->SetFont(font);
|
|
||||||
|
|
||||||
fDrawState->Font().TruncateString(&title, B_TRUNCATE_END, frame.Width() - 4);
|
font.TruncateString(&title, B_TRUNCATE_END, fillFrame.Width() - 4);
|
||||||
float width = drawingEngine->StringWidth(title.String(), title.Length(),
|
font_height fontHeight;
|
||||||
fDrawState, NULL);
|
font.GetHeight(fontHeight);
|
||||||
float height = drawingEngine->StringHeight(title.String(), title.Length(),
|
float height = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent);
|
||||||
fDrawState);
|
if (title.Length() > 0 && height < frame.Height() - 2) {
|
||||||
|
rgb_color textColor = tint_color(white, B_DARKEN_4_TINT);
|
||||||
|
drawingEngine->SetHighColor(textColor);
|
||||||
|
drawingEngine->SetLowColor(white);
|
||||||
|
|
||||||
drawingEngine->DrawString(title.String(), title.Length(),
|
float width = font.StringWidth(title.String(), title.Length());
|
||||||
BPoint(frame.left + (frame.Width() - width) / 2,
|
|
||||||
frame.top + (frame.Height() + height) / 2),
|
BPoint textOffset;
|
||||||
fDrawState, NULL);
|
textOffset.x = rintf(frame.left + (frame.Width() - width) / 2);
|
||||||
#endif
|
textOffset.y = rintf(frame.top + (frame.Height() - height) / 2
|
||||||
|
+ fontHeight.ascent);
|
||||||
|
drawingEngine->DrawString(title.String(), title.Length(), textOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
// prevent the next window down from drawing over this window
|
||||||
|
backgroundRegion.Exclude(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -286,6 +301,12 @@ WorkspacesView::_DrawWorkspace(DrawingEngine* drawingEngine,
|
|||||||
backgroundRegion.IntersectWith(&workspaceRegion);
|
backgroundRegion.IntersectWith(&workspaceRegion);
|
||||||
drawingEngine->ConstrainClippingRegion(&backgroundRegion);
|
drawingEngine->ConstrainClippingRegion(&backgroundRegion);
|
||||||
|
|
||||||
|
ServerFont font = fDrawState->Font();
|
||||||
|
font.SetSize(ceilf(max_c(9.0,
|
||||||
|
min_c(Frame().Height(), Frame().Width()) / 15)));
|
||||||
|
fDrawState->SetFont(font);
|
||||||
|
drawingEngine->SetFont(font);
|
||||||
|
|
||||||
// We draw from top down and cut the window out of the clipping region
|
// We draw from top down and cut the window out of the clipping region
|
||||||
// which reduces the flickering
|
// which reduces the flickering
|
||||||
::Window* window;
|
::Window* window;
|
||||||
|
|||||||
Reference in New Issue
Block a user