* 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.
|
* Copyright 2002, Thomas Kurschel.
|
||||||
* Distributed under the terms of the MIT License.
|
* 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)
|
MonitorView::MonitorView(BRect rect, char *name, int32 width, int32 height)
|
||||||
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW),
|
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
||||||
fMaxSize(1600),
|
fMaxWidth(1920),
|
||||||
|
fMaxHeight(1200),
|
||||||
fWidth(width),
|
fWidth(width),
|
||||||
fHeight(height)
|
fHeight(height)
|
||||||
{
|
{
|
||||||
@@ -45,10 +46,11 @@ MonitorView::~MonitorView()
|
|||||||
void
|
void
|
||||||
MonitorView::AttachedToWindow()
|
MonitorView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
|
SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
if (Parent())
|
if (Parent())
|
||||||
SetViewColor(Parent()->ViewColor());
|
fBackgroundColor = Parent()->ViewColor();
|
||||||
else
|
else
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
fBackgroundColor = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -62,26 +64,30 @@ MonitorView::MouseDown(BPoint point)
|
|||||||
BRect
|
BRect
|
||||||
MonitorView::MonitorBounds()
|
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;
|
if (factorX > factorY && factorX > 1) {
|
||||||
picHeight = maxSize * fHeight / fMaxSize;
|
factorY /= factorX;
|
||||||
|
factorX = 1;
|
||||||
if (picWidth > maxSize) {
|
} else if (factorY > factorX && factorY > 1) {
|
||||||
picHeight = picHeight * maxSize / picWidth;
|
factorX /= factorY;
|
||||||
picWidth = maxSize;
|
factorY = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (picHeight > maxSize) {
|
float width = maxWidth * factorX;
|
||||||
picWidth = picWidth * maxSize / picHeight;
|
float height = maxHeight * factorY;
|
||||||
picHeight = maxSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
BPoint size = BPoint(Bounds().Width(), Bounds().Height());
|
BSize size = Bounds().Size();
|
||||||
return BRect((size.x - picWidth) / 2, (size.y - picHeight) / 2,
|
return BRect((size.width - width) / 2, (size.height - height) / 2,
|
||||||
(size.x + picWidth) / 2, (size.y + picHeight) / 2);
|
(size.width + width) / 2, (size.height + height) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -93,6 +99,9 @@ MonitorView::Draw(BRect updateRect)
|
|||||||
rgb_color redColor = {228, 0, 0, 255};
|
rgb_color redColor = {228, 0, 0, 255};
|
||||||
BRect outerRect = MonitorBounds();
|
BRect outerRect = MonitorBounds();
|
||||||
|
|
||||||
|
SetHighColor(fBackgroundColor);
|
||||||
|
FillRect(updateRect);
|
||||||
|
|
||||||
SetDrawingMode(B_OP_OVER);
|
SetDrawingMode(B_OP_OVER);
|
||||||
|
|
||||||
// frame & background
|
// frame & background
|
||||||
@@ -137,11 +146,11 @@ MonitorView::SetResolution(int32 width, int32 height)
|
|||||||
void
|
void
|
||||||
MonitorView::SetMaxResolution(int32 width, int32 height)
|
MonitorView::SetMaxResolution(int32 width, int32 height)
|
||||||
{
|
{
|
||||||
int32 maxSize = max_c(width, height);
|
if (fMaxWidth == width && fMaxHeight == height)
|
||||||
if (fMaxSize == maxSize)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fMaxSize = maxSize;
|
fMaxWidth = width;
|
||||||
|
fMaxHeight = height;
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,10 @@ class MonitorView : public BView {
|
|||||||
private:
|
private:
|
||||||
BRect MonitorBounds();
|
BRect MonitorBounds();
|
||||||
|
|
||||||
|
rgb_color fBackgroundColor;
|
||||||
rgb_color fDesktopColor;
|
rgb_color fDesktopColor;
|
||||||
int32 fMaxSize;
|
int32 fMaxWidth;
|
||||||
|
int32 fMaxHeight;
|
||||||
int32 fWidth;
|
int32 fWidth;
|
||||||
int32 fHeight;
|
int32 fHeight;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ static void
|
|||||||
refresh_rate_to_string(float refresh, BString &string,
|
refresh_rate_to_string(float refresh, BString &string,
|
||||||
bool appendUnit = true, bool alwaysWithFraction = false)
|
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();
|
string.UnlockBuffer();
|
||||||
|
|
||||||
if (appendUnit)
|
if (appendUnit)
|
||||||
@@ -197,7 +198,7 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
|
|||||||
// box on the left with workspace count and monitor view
|
// box on the left with workspace count and monitor view
|
||||||
|
|
||||||
BBox* screenBox = new BBox("screen box");
|
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);
|
layout->SetInsets(10, 10, 10, 10);
|
||||||
screenBox->SetLayout(layout);
|
screenBox->SetLayout(layout);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user