* Made MonitorView better utilize the space it has.
* Less flickering. * Reduced spacing in the left box. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32034 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2006, Haiku.
|
||||
* Copyright 2001-2009, Haiku.
|
||||
* Copyright 2002, Thomas Kurschel.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
@@ -27,8 +27,9 @@ operator!=(const rgb_color& x, const rgb_color& y)
|
||||
|
||||
|
||||
MonitorView::MonitorView(BRect rect, char *name, int32 width, int32 height)
|
||||
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW),
|
||||
fMaxSize(1600),
|
||||
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
||||
fMaxWidth(1920),
|
||||
fMaxHeight(1200),
|
||||
fWidth(width),
|
||||
fHeight(height)
|
||||
{
|
||||
@@ -45,10 +46,11 @@ MonitorView::~MonitorView()
|
||||
void
|
||||
MonitorView::AttachedToWindow()
|
||||
{
|
||||
SetViewColor(B_TRANSPARENT_COLOR);
|
||||
if (Parent())
|
||||
SetViewColor(Parent()->ViewColor());
|
||||
fBackgroundColor = Parent()->ViewColor();
|
||||
else
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
fBackgroundColor = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,26 +64,30 @@ MonitorView::MouseDown(BPoint point)
|
||||
BRect
|
||||
MonitorView::MonitorBounds()
|
||||
{
|
||||
float picWidth, picHeight;
|
||||
float maxWidth = Bounds().Width();
|
||||
float maxHeight = Bounds().Height();
|
||||
if (maxWidth / maxHeight > (float)fMaxWidth / fMaxHeight)
|
||||
maxWidth = maxHeight / fMaxHeight * fMaxWidth;
|
||||
else
|
||||
maxHeight = maxWidth / fMaxWidth * fMaxHeight;
|
||||
|
||||
float maxSize = min_c(Bounds().Width(), Bounds().Height());
|
||||
float factorX = (float)fWidth / fMaxWidth;
|
||||
float factorY = (float)fHeight / fMaxHeight;
|
||||
|
||||
picWidth = maxSize * fWidth / fMaxSize;
|
||||
picHeight = maxSize * fHeight / fMaxSize;
|
||||
|
||||
if (picWidth > maxSize) {
|
||||
picHeight = picHeight * maxSize / picWidth;
|
||||
picWidth = maxSize;
|
||||
if (factorX > factorY && factorX > 1) {
|
||||
factorY /= factorX;
|
||||
factorX = 1;
|
||||
} else if (factorY > factorX && factorY > 1) {
|
||||
factorX /= factorY;
|
||||
factorY = 1;
|
||||
}
|
||||
|
||||
if (picHeight > maxSize) {
|
||||
picWidth = picWidth * maxSize / picHeight;
|
||||
picHeight = maxSize;
|
||||
}
|
||||
float width = maxWidth * factorX;
|
||||
float height = maxHeight * factorY;
|
||||
|
||||
BPoint size = BPoint(Bounds().Width(), Bounds().Height());
|
||||
return BRect((size.x - picWidth) / 2, (size.y - picHeight) / 2,
|
||||
(size.x + picWidth) / 2, (size.y + picHeight) / 2);
|
||||
BSize size = Bounds().Size();
|
||||
return BRect((size.width - width) / 2, (size.height - height) / 2,
|
||||
(size.width + width) / 2, (size.height + height) / 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +99,9 @@ MonitorView::Draw(BRect updateRect)
|
||||
rgb_color redColor = {228, 0, 0, 255};
|
||||
BRect outerRect = MonitorBounds();
|
||||
|
||||
SetHighColor(fBackgroundColor);
|
||||
FillRect(updateRect);
|
||||
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
|
||||
// frame & background
|
||||
@@ -137,11 +146,11 @@ MonitorView::SetResolution(int32 width, int32 height)
|
||||
void
|
||||
MonitorView::SetMaxResolution(int32 width, int32 height)
|
||||
{
|
||||
int32 maxSize = max_c(width, height);
|
||||
if (fMaxSize == maxSize)
|
||||
if (fMaxWidth == width && fMaxHeight == height)
|
||||
return;
|
||||
|
||||
fMaxSize = maxSize;
|
||||
fMaxWidth = width;
|
||||
fMaxHeight = height;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
@@ -32,8 +32,10 @@ class MonitorView : public BView {
|
||||
private:
|
||||
BRect MonitorBounds();
|
||||
|
||||
rgb_color fBackgroundColor;
|
||||
rgb_color fDesktopColor;
|
||||
int32 fMaxSize;
|
||||
int32 fMaxWidth;
|
||||
int32 fMaxHeight;
|
||||
int32 fWidth;
|
||||
int32 fHeight;
|
||||
};
|
||||
|
||||
@@ -131,7 +131,8 @@ static void
|
||||
refresh_rate_to_string(float refresh, BString &string,
|
||||
bool appendUnit = true, bool alwaysWithFraction = false)
|
||||
{
|
||||
snprintf(string.LockBuffer(32), 32, "%.*g", refresh >= 100.0 ? 4 : 3, refresh);
|
||||
snprintf(string.LockBuffer(32), 32, "%.*g", refresh >= 100.0 ? 4 : 3,
|
||||
refresh);
|
||||
string.UnlockBuffer();
|
||||
|
||||
if (appendUnit)
|
||||
@@ -197,7 +198,7 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
|
||||
// box on the left with workspace count and monitor view
|
||||
|
||||
BBox* screenBox = new BBox("screen box");
|
||||
BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 10.0);
|
||||
BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 5.0);
|
||||
layout->SetInsets(10, 10, 10, 10);
|
||||
screenBox->SetLayout(layout);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user