* First baby steps to a font sensitive GUI. The window now adapts its size
to the demands of the screen saver settings. * At least temporarily, the window is also resizable; we'll see how well that turns out. * The PreviewView did not have a black border around the preview. * You can now switch again from Blackness to another saver directly... * The turn off screen timeout is stored relative to the blanking time. * The list now scrolls to the selection whenever the tab is shown. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17743 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -56,7 +56,9 @@ PreviewView::~PreviewView()
|
|||||||
BView*
|
BView*
|
||||||
PreviewView::AddPreview()
|
PreviewView::AddPreview()
|
||||||
{
|
{
|
||||||
fSaverView = new BView(scale2(1,8,1,2,Bounds()),"previewArea",B_FOLLOW_NONE,B_WILL_DRAW);
|
BRect rect = scale2(1,8,1,2,Bounds());
|
||||||
|
rect.InsetBy(1, 1);
|
||||||
|
fSaverView = new BView(rect, "preview", B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
fSaverView->SetViewColor(0, 0, 0);
|
fSaverView->SetViewColor(0, 0, 0);
|
||||||
AddChild(fSaverView);
|
AddChild(fSaverView);
|
||||||
|
|
||||||
@@ -85,6 +87,7 @@ PreviewView::Draw(BRect update)
|
|||||||
StrokeRoundRect(scale2(2,7,3,6,Bounds()),2,2);// control console outline
|
StrokeRoundRect(scale2(2,7,3,6,Bounds()),2,2);// control console outline
|
||||||
StrokeRoundRect(scale2(0,9,0,3,Bounds()),4,4); // Outline outer shape
|
StrokeRoundRect(scale2(0,9,0,3,Bounds()),4,4); // Outline outer shape
|
||||||
SetHighColor(kBlack);
|
SetHighColor(kBlack);
|
||||||
|
FillRect(scale2(1,8,1,2,Bounds()));
|
||||||
|
|
||||||
SetHighColor(184, 184, 184);
|
SetHighColor(184, 184, 184);
|
||||||
BRect outerShape = scale2(2,7,2,6,Bounds());
|
BRect outerShape = scale2(2,7,2,6,Bounds());
|
||||||
|
|||||||
@@ -38,6 +38,10 @@
|
|||||||
#define CALLED() PRINT(("%s\n", __PRETTY_FUNCTION__))
|
#define CALLED() PRINT(("%s\n", __PRETTY_FUNCTION__))
|
||||||
|
|
||||||
|
|
||||||
|
const uint32 kPreviewMonitorGap = 16;
|
||||||
|
const uint32 kMinSettingsWidth = 230;
|
||||||
|
const uint32 kMinSettingsHeight = 120;
|
||||||
|
|
||||||
const int32 kMsgSaverSelected = 'SSEL';
|
const int32 kMsgSaverSelected = 'SSEL';
|
||||||
const int32 kMsgTestSaver = 'TEST';
|
const int32 kMsgTestSaver = 'TEST';
|
||||||
const int32 kMsgAddSaver = 'ADD ';
|
const int32 kMsgAddSaver = 'ADD ';
|
||||||
@@ -70,6 +74,13 @@ class TimeSlider : public BSlider {
|
|||||||
uint32 fModificationMessage;
|
uint32 fModificationMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FadeView : public BView {
|
||||||
|
public:
|
||||||
|
FadeView(BRect frame, const char* name, ScreenSaverPrefs& prefs);
|
||||||
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
};
|
||||||
|
|
||||||
class ModulesView : public BView {
|
class ModulesView : public BView {
|
||||||
public:
|
public:
|
||||||
ModulesView(BRect frame, const char* name, ScreenSaverPrefs& prefs);
|
ModulesView(BRect frame, const char* name, ScreenSaverPrefs& prefs);
|
||||||
@@ -77,6 +88,7 @@ class ModulesView : public BView {
|
|||||||
|
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
|
virtual void AllAttached();
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
void PopulateScreenSaverList();
|
void PopulateScreenSaverList();
|
||||||
@@ -100,7 +112,7 @@ class ModulesView : public BView {
|
|||||||
BBox* fSettingsBox;
|
BBox* fSettingsBox;
|
||||||
BView* fSettingsView;
|
BView* fSettingsView;
|
||||||
|
|
||||||
PreviewView* fPreviewDisplay;
|
PreviewView* fPreviewView;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int32 kTimeInUnits[] = {
|
static const int32 kTimeInUnits[] = {
|
||||||
@@ -119,7 +131,7 @@ static const int32 kTimeUnitCount = sizeof(kTimeInUnits) / sizeof(kTimeInUnits[0
|
|||||||
|
|
||||||
TimeSlider::TimeSlider(BRect frame, const char* name, uint32 modificationMessage)
|
TimeSlider::TimeSlider(BRect frame, const char* name, uint32 modificationMessage)
|
||||||
: BSlider(frame, name, "0 minutes", new BMessage(kTimeSliderChanged),
|
: BSlider(frame, name, "0 minutes", new BMessage(kTimeSliderChanged),
|
||||||
0, kTimeUnitCount - 1, B_TRIANGLE_THUMB),
|
0, kTimeUnitCount - 1, B_TRIANGLE_THUMB, B_FOLLOW_LEFT_RIGHT),
|
||||||
fModificationMessage(modificationMessage)
|
fModificationMessage(modificationMessage)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
@@ -223,6 +235,27 @@ TimeSlider::_TimeToString(bigtime_t useconds, BString& string)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
FadeView::FadeView(BRect rect, const char* name, ScreenSaverPrefs& prefs)
|
||||||
|
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
|
||||||
|
{
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
FadeView::AttachedToWindow()
|
||||||
|
{
|
||||||
|
if (Parent() != NULL) {
|
||||||
|
// We adopt the size of our parent view (in case the window
|
||||||
|
// was resized during our absence (BTabView...)
|
||||||
|
ResizeTo(Parent()->Bounds().Width(), Parent()->Bounds().Height());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
ModulesView::ModulesView(BRect rect, const char* name, ScreenSaverPrefs& prefs)
|
ModulesView::ModulesView(BRect rect, const char* name, ScreenSaverPrefs& prefs)
|
||||||
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW),
|
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW),
|
||||||
fPrefs(prefs),
|
fPrefs(prefs),
|
||||||
@@ -231,27 +264,45 @@ ModulesView::ModulesView(BRect rect, const char* name, ScreenSaverPrefs& prefs)
|
|||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
AddChild(fSettingsBox = new BBox(BRect(183,11,434,285),
|
fTestButton = new BButton(rect, "TestButton", "Test", new BMessage(kMsgTestSaver),
|
||||||
"ModuleSettingsBox", B_FOLLOW_NONE, B_WILL_DRAW));
|
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||||
fSettingsBox->SetLabel("Module settings");
|
float width, height;
|
||||||
|
fTestButton->GetPreferredSize(&width, &height);
|
||||||
fListView = new BListView(BRect(8,136,156,255), "SaversListView",
|
fTestButton->ResizeTo(width + 16, height);
|
||||||
B_SINGLE_SELECTION_LIST);
|
fTestButton->MoveTo(8, rect.bottom - 8 - height);
|
||||||
fListView->SetSelectionMessage(new BMessage(kMsgSaverSelected));
|
|
||||||
AddChild(new BScrollView("scroll_list", fListView,
|
|
||||||
B_FOLLOW_ALL, 0, false, true));
|
|
||||||
|
|
||||||
fTestButton = new BButton(BRect(8,260,88,277), "TestButton", "Test",
|
|
||||||
new BMessage(kMsgTestSaver));
|
|
||||||
AddChild(fTestButton);
|
AddChild(fTestButton);
|
||||||
|
|
||||||
fAddButton = new BButton(BRect(98,260,173,277), "AddButton", "Add" B_UTF8_ELLIPSIS,
|
rect = fTestButton->Frame();
|
||||||
new BMessage(kMsgAddSaver));
|
rect.OffsetBy(fTestButton->Bounds().Width() + 8, 0);
|
||||||
|
fAddButton = new BButton(rect, "AddButton", "Add" B_UTF8_ELLIPSIS,
|
||||||
|
new BMessage(kMsgAddSaver), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||||
AddChild(fAddButton);
|
AddChild(fAddButton);
|
||||||
|
|
||||||
AddChild(fPreviewDisplay = new PreviewView(BRect(20, 15, 150, 120), "preview"));
|
rect = Bounds().InsetByCopy(8 + kPreviewMonitorGap, 12);
|
||||||
|
rect.right = fAddButton->Frame().right - kPreviewMonitorGap;
|
||||||
|
rect.bottom = rect.top + 3 * rect.Width() / 4;
|
||||||
|
// 4:3 monitor
|
||||||
|
|
||||||
PopulateScreenSaverList();
|
fPreviewView = new PreviewView(rect, "preview");
|
||||||
|
AddChild(fPreviewView);
|
||||||
|
|
||||||
|
rect.left = 8;
|
||||||
|
rect.right -= B_V_SCROLL_BAR_WIDTH + 2 - kPreviewMonitorGap;
|
||||||
|
// scroll view border
|
||||||
|
rect.top = rect.bottom + 14;
|
||||||
|
rect.bottom = fTestButton->Frame().top - 10;
|
||||||
|
fListView = new BListView(rect, "SaversListView", B_SINGLE_SELECTION_LIST,
|
||||||
|
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM);
|
||||||
|
fListView->SetSelectionMessage(new BMessage(kMsgSaverSelected));
|
||||||
|
AddChild(new BScrollView("scroll_list", fListView,
|
||||||
|
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, 0, false, true));
|
||||||
|
|
||||||
|
rect = Bounds().InsetByCopy(8, 8);
|
||||||
|
rect.left = fAddButton->Frame().right + 8;
|
||||||
|
AddChild(fSettingsBox = new BBox(rect, "SettingsBox", B_FOLLOW_ALL, B_WILL_DRAW));
|
||||||
|
fSettingsBox->SetLabel("Module settings");
|
||||||
|
|
||||||
|
PopulateScreenSaverList();
|
||||||
fFilePanel = new BFilePanel();
|
fFilePanel = new BFilePanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,6 +323,12 @@ ModulesView::DetachedFromWindow()
|
|||||||
void
|
void
|
||||||
ModulesView::AttachedToWindow()
|
ModulesView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
|
if (Parent() != NULL) {
|
||||||
|
// We adopt the size of our parent view (in case the window
|
||||||
|
// was resized during our absence (BTabView...)
|
||||||
|
ResizeTo(Parent()->Bounds().Width(), Parent()->Bounds().Height());
|
||||||
|
}
|
||||||
|
|
||||||
_OpenSaver();
|
_OpenSaver();
|
||||||
|
|
||||||
fListView->SetTarget(this);
|
fListView->SetTarget(this);
|
||||||
@@ -280,6 +337,14 @@ ModulesView::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ModulesView::AllAttached()
|
||||||
|
{
|
||||||
|
// This only works after the view has been attached
|
||||||
|
fListView->ScrollToSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ModulesView::MessageReceived(BMessage* message)
|
ModulesView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
@@ -294,7 +359,7 @@ ModulesView::MessageReceived(BMessage* message)
|
|||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!strcmp(fPrefs.ModuleName(), "Blackness"))
|
if (!strcmp(item->Text(), "Blackness"))
|
||||||
fPrefs.SetModuleName("");
|
fPrefs.SetModuleName("");
|
||||||
else
|
else
|
||||||
fPrefs.SetModuleName(item->Text());
|
fPrefs.SetModuleName(item->Text());
|
||||||
@@ -409,7 +474,7 @@ ModulesView::_CloseSaver()
|
|||||||
// remove old screen saver preview & config
|
// remove old screen saver preview & config
|
||||||
|
|
||||||
BScreenSaver* saver = _ScreenSaver();
|
BScreenSaver* saver = _ScreenSaver();
|
||||||
BView* view = fPreviewDisplay->RemovePreview();
|
BView* view = fPreviewView->RemovePreview();
|
||||||
if (fSettingsView != NULL)
|
if (fSettingsView != NULL)
|
||||||
fSettingsBox->RemoveChild(fSettingsView);
|
fSettingsBox->RemoveChild(fSettingsView);
|
||||||
|
|
||||||
@@ -432,17 +497,18 @@ ModulesView::_OpenSaver()
|
|||||||
{
|
{
|
||||||
// create new screen saver preview & config
|
// create new screen saver preview & config
|
||||||
|
|
||||||
BView* view = fPreviewDisplay->AddPreview();
|
BView* view = fPreviewView->AddPreview();
|
||||||
fCurrentName = fPrefs.ModuleName();
|
fCurrentName = fPrefs.ModuleName();
|
||||||
fSaverRunner = new ScreenSaverRunner(Window(), view, true, fPrefs);
|
fSaverRunner = new ScreenSaverRunner(Window(), view, true, fPrefs);
|
||||||
BScreenSaver* saver = _ScreenSaver();
|
BScreenSaver* saver = _ScreenSaver();
|
||||||
|
|
||||||
BRect bnds = fSettingsBox->Bounds();
|
BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4);
|
||||||
bnds.left = 3;
|
#ifdef __HAIKU__
|
||||||
bnds.right -= 7;
|
rect.top += fSettingsBox->TopBorderOffset();
|
||||||
bnds.top = 21;
|
#else
|
||||||
bnds.bottom -= 2;
|
rect.top += 14;
|
||||||
fSettingsView = new BView(bnds,"settingsArea",B_FOLLOW_NONE,B_WILL_DRAW);
|
#endif
|
||||||
|
fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
fSettingsView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
fSettingsView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
fSettingsBox->AddChild(fSettingsView);
|
fSettingsBox->AddChild(fSettingsView);
|
||||||
|
|
||||||
@@ -450,6 +516,66 @@ ModulesView::_OpenSaver()
|
|||||||
fSaverRunner->Run();
|
fSaverRunner->Run();
|
||||||
saver->StartConfig(fSettingsView);
|
saver->StartConfig(fSettingsView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fSettingsView->ChildAt(0) == NULL) {
|
||||||
|
// There are no settings at all, we add the module name here to
|
||||||
|
// let it look a bit better at least.
|
||||||
|
rect = BRect(15, 15, 20, 20);
|
||||||
|
BStringView* stringView = new BStringView(rect, "module", fPrefs.ModuleName()[0]
|
||||||
|
? fPrefs.ModuleName() : "Blackness");
|
||||||
|
stringView->SetFont(be_bold_font);
|
||||||
|
stringView->ResizeToPreferred();
|
||||||
|
fSettingsView->AddChild(stringView);
|
||||||
|
|
||||||
|
rect.OffsetBy(0, stringView->Bounds().Height() + 4);
|
||||||
|
stringView = new BStringView(rect, "info", saver || !fPrefs.ModuleName()[0]
|
||||||
|
? "No options available" : "Could not load screen saver");
|
||||||
|
stringView->ResizeToPreferred();
|
||||||
|
fSettingsView->AddChild(stringView);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScreenSaverWindow* window = dynamic_cast<ScreenSaverWindow*>(Window());
|
||||||
|
if (window == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// find the minimal size of the settings view
|
||||||
|
|
||||||
|
float right = 0, bottom = 0;
|
||||||
|
int32 i = 0;
|
||||||
|
while ((view = fSettingsView->ChildAt(i++)) != NULL) {
|
||||||
|
// very simple heuristic...
|
||||||
|
float viewRight = view->Frame().right;
|
||||||
|
if ((view->ResizingMode() & _rule_(0, 0xf, 0, 0xf)) == B_FOLLOW_LEFT_RIGHT) {
|
||||||
|
float width, height;
|
||||||
|
view->GetPreferredSize(&width, &height);
|
||||||
|
viewRight = view->Frame().left + width / 2;
|
||||||
|
} else if ((view->ResizingMode() & _rule_(0, 0xf, 0, 0xf)) == B_FOLLOW_RIGHT)
|
||||||
|
viewRight = 8 + view->Frame().Width();
|
||||||
|
|
||||||
|
float viewBottom = view->Frame().bottom;
|
||||||
|
if ((view->ResizingMode() & _rule_(0xf, 0, 0xf, 0)) == B_FOLLOW_TOP_BOTTOM) {
|
||||||
|
float width, height;
|
||||||
|
view->GetPreferredSize(&width, &height);
|
||||||
|
viewBottom = view->Frame().top + height;
|
||||||
|
} else if ((view->ResizingMode() & _rule_(0xf, 0, 0xf, 0)) == B_FOLLOW_BOTTOM)
|
||||||
|
viewBottom = 8 + view->Frame().Height();
|
||||||
|
|
||||||
|
if (viewRight > right)
|
||||||
|
right = viewRight;
|
||||||
|
if (viewBottom > bottom)
|
||||||
|
bottom = viewBottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (right < kMinSettingsWidth)
|
||||||
|
right = kMinSettingsWidth;
|
||||||
|
if (bottom < kMinSettingsHeight)
|
||||||
|
bottom = kMinSettingsHeight;
|
||||||
|
|
||||||
|
BPoint leftTop = fSettingsView->LeftTop();
|
||||||
|
fSettingsView->ConvertToScreen(&leftTop);
|
||||||
|
window->ConvertFromScreen(&leftTop);
|
||||||
|
window->SetMinimalSizeLimit(leftTop.x + right + 16,
|
||||||
|
leftTop.y + bottom + 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -458,7 +584,7 @@ ModulesView::_OpenSaver()
|
|||||||
|
|
||||||
ScreenSaverWindow::ScreenSaverWindow()
|
ScreenSaverWindow::ScreenSaverWindow()
|
||||||
: BWindow(BRect(50, 50, 496, 375), "Screen Saver",
|
: BWindow(BRect(50, 50, 496, 375), "Screen Saver",
|
||||||
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS /*| B_NOT_ZOOMABLE | B_NOT_RESIZABLE*/),
|
||||||
fFadeNowString(NULL),
|
fFadeNowString(NULL),
|
||||||
fFadeNowString2(NULL),
|
fFadeNowString2(NULL),
|
||||||
fDontFadeString(NULL),
|
fDontFadeString(NULL),
|
||||||
@@ -492,11 +618,16 @@ ScreenSaverWindow::ScreenSaverWindow()
|
|||||||
fPasswordWindow = new PasswordWindow(fPrefs);
|
fPasswordWindow = new PasswordWindow(fPrefs);
|
||||||
fPasswordWindow->Run();
|
fPasswordWindow->Run();
|
||||||
|
|
||||||
|
// TODO: better limits!
|
||||||
|
fMinWidth = 430;
|
||||||
|
fMinHeight = 325;
|
||||||
|
SetMinimalSizeLimit(fMinWidth, fMinHeight);
|
||||||
MoveTo(fPrefs.WindowFrame().left, fPrefs.WindowFrame().top);
|
MoveTo(fPrefs.WindowFrame().left, fPrefs.WindowFrame().top);
|
||||||
|
ResizeTo(fPrefs.WindowFrame().Width(), fPrefs.WindowFrame().Height());
|
||||||
|
|
||||||
fEnableCheckBox->SetValue(fPrefs.TimeFlags() & ENABLE_SAVER ? B_CONTROL_ON : B_CONTROL_OFF);
|
fEnableCheckBox->SetValue(fPrefs.TimeFlags() & ENABLE_SAVER ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
fRunSlider->SetTime(fPrefs.BlankTime());
|
fRunSlider->SetTime(fPrefs.BlankTime());
|
||||||
fTurnOffSlider->SetTime(fPrefs.OffTime());
|
fTurnOffSlider->SetTime(fPrefs.OffTime() + fPrefs.BlankTime());
|
||||||
fFadeNow->SetCorner(fPrefs.GetBlankCorner());
|
fFadeNow->SetCorner(fPrefs.GetBlankCorner());
|
||||||
fFadeNever->SetCorner(fPrefs.GetNeverBlankCorner());
|
fFadeNever->SetCorner(fPrefs.GetNeverBlankCorner());
|
||||||
fPasswordCheckBox->SetValue(fPrefs.LockEnable());
|
fPasswordCheckBox->SetValue(fPrefs.LockEnable());
|
||||||
@@ -518,10 +649,8 @@ ScreenSaverWindow::~ScreenSaverWindow()
|
|||||||
void
|
void
|
||||||
ScreenSaverWindow::_SetupFadeTab(BRect rect)
|
ScreenSaverWindow::_SetupFadeTab(BRect rect)
|
||||||
{
|
{
|
||||||
fFadeView = new BView(rect, "Fade", B_FOLLOW_ALL, 0);
|
fFadeView = new FadeView(rect, "Fade", fPrefs);
|
||||||
fFadeView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
|
|
||||||
rect.InsetBy(8, 8);
|
|
||||||
/*
|
/*
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
be_plain_font->GetHeight(&fontHeight);
|
be_plain_font->GetHeight(&fontHeight);
|
||||||
@@ -531,6 +660,7 @@ ScreenSaverWindow::_SetupFadeTab(BRect rect)
|
|||||||
"Enable Screen Saver", new BMessage(kMsgEnableScreenSaverBox));
|
"Enable Screen Saver", new BMessage(kMsgEnableScreenSaverBox));
|
||||||
fEnableCheckBox->ResizeToPreferred();
|
fEnableCheckBox->ResizeToPreferred();
|
||||||
|
|
||||||
|
rect.InsetBy(8, 8);
|
||||||
BBox* box = new BBox(rect, "EnableScreenSaverBox", B_FOLLOW_ALL);
|
BBox* box = new BBox(rect, "EnableScreenSaverBox", B_FOLLOW_ALL);
|
||||||
box->SetLabel(fEnableCheckBox);
|
box->SetLabel(fEnableCheckBox);
|
||||||
fFadeView->AddChild(box);
|
fFadeView->AddChild(box);
|
||||||
@@ -625,7 +755,53 @@ ScreenSaverWindow::_UpdateTurnOffScreen()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenSaverWindow::MessageReceived(BMessage *msg)
|
ScreenSaverWindow::_UpdateStatus()
|
||||||
|
{
|
||||||
|
DisableUpdates();
|
||||||
|
|
||||||
|
bool enabled = fEnableCheckBox->Value() == B_CONTROL_ON;
|
||||||
|
fPasswordCheckBox->SetEnabled(enabled);
|
||||||
|
fTurnOffCheckBox->SetEnabled(enabled && fTurnOffScreenFlags != 0);
|
||||||
|
fRunSlider->SetEnabled(enabled);
|
||||||
|
fTurnOffSlider->SetEnabled(enabled && fTurnOffCheckBox->Value());
|
||||||
|
fPasswordSlider->SetEnabled(enabled && fPasswordCheckBox->Value());
|
||||||
|
fPasswordButton->SetEnabled(enabled && fPasswordCheckBox->Value());
|
||||||
|
|
||||||
|
EnableUpdates();
|
||||||
|
|
||||||
|
// Update the saved preferences
|
||||||
|
fPrefs.SetWindowFrame(Frame());
|
||||||
|
fPrefs.SetWindowTab(fTabView->Selection());
|
||||||
|
fPrefs.SetTimeFlags((enabled ? ENABLE_SAVER : 0)
|
||||||
|
| (fTurnOffCheckBox->Value() ? fTurnOffScreenFlags : 0));
|
||||||
|
fPrefs.SetBlankTime(fRunSlider->Time());
|
||||||
|
bigtime_t offTime = fTurnOffSlider->Time() - fPrefs.BlankTime();
|
||||||
|
fPrefs.SetOffTime(offTime);
|
||||||
|
fPrefs.SetSuspendTime(offTime);
|
||||||
|
fPrefs.SetStandbyTime(offTime);
|
||||||
|
fPrefs.SetBlankCorner(fFadeNow->Corner());
|
||||||
|
fPrefs.SetNeverBlankCorner(fFadeNever->Corner());
|
||||||
|
fPrefs.SetLockEnable(fPasswordCheckBox->Value());
|
||||||
|
fPrefs.SetPasswordTime(fPasswordSlider->Time());
|
||||||
|
|
||||||
|
// TODO - Tell the password window to update its stuff
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScreenSaverWindow::SetMinimalSizeLimit(float width, float height)
|
||||||
|
{
|
||||||
|
if (width < fMinWidth)
|
||||||
|
width = fMinWidth;
|
||||||
|
if (height < fMinHeight)
|
||||||
|
height = fMinHeight;
|
||||||
|
|
||||||
|
SetSizeLimits(width, 32767, height, 32767);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScreenSaverWindow::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
// "Fade" tab
|
// "Fade" tab
|
||||||
@@ -679,7 +855,7 @@ ScreenSaverWindow::ScreenChanged(BRect frame, color_space colorSpace)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ScreenSaverWindow::QuitRequested()
|
ScreenSaverWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
_UpdateStatus();
|
_UpdateStatus();
|
||||||
fModulesView->SaveState();
|
fModulesView->SaveState();
|
||||||
@@ -689,36 +865,3 @@ ScreenSaverWindow::QuitRequested()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ScreenSaverWindow::_UpdateStatus()
|
|
||||||
{
|
|
||||||
DisableUpdates();
|
|
||||||
|
|
||||||
bool enabled = fEnableCheckBox->Value() == B_CONTROL_ON;
|
|
||||||
fPasswordCheckBox->SetEnabled(enabled);
|
|
||||||
fTurnOffCheckBox->SetEnabled(enabled && fTurnOffScreenFlags != 0);
|
|
||||||
fRunSlider->SetEnabled(enabled);
|
|
||||||
fTurnOffSlider->SetEnabled(enabled && fTurnOffCheckBox->Value());
|
|
||||||
fPasswordSlider->SetEnabled(enabled && fPasswordCheckBox->Value());
|
|
||||||
fPasswordButton->SetEnabled(enabled && fPasswordCheckBox->Value());
|
|
||||||
|
|
||||||
EnableUpdates();
|
|
||||||
|
|
||||||
// Update the saved preferences
|
|
||||||
fPrefs.SetWindowFrame(Frame());
|
|
||||||
fPrefs.SetWindowTab(fTabView->Selection());
|
|
||||||
fPrefs.SetTimeFlags((enabled ? ENABLE_SAVER : 0)
|
|
||||||
| (fTurnOffCheckBox->Value() ? fTurnOffScreenFlags : 0));
|
|
||||||
fPrefs.SetBlankTime(fRunSlider->Time());
|
|
||||||
fPrefs.SetOffTime(fTurnOffSlider->Time());
|
|
||||||
fPrefs.SetSuspendTime(fTurnOffSlider->Time());
|
|
||||||
fPrefs.SetStandbyTime(fTurnOffSlider->Time());
|
|
||||||
fPrefs.SetBlankCorner(fFadeNow->Corner());
|
|
||||||
fPrefs.SetNeverBlankCorner(fFadeNever->Corner());
|
|
||||||
fPrefs.SetLockEnable(fPasswordCheckBox->Value());
|
|
||||||
fPrefs.SetPasswordTime(fPasswordSlider->Time());
|
|
||||||
|
|
||||||
// TODO - Tell the password window to update its stuff
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,12 +38,14 @@ class ScreenSaverWindow : public BWindow {
|
|||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
|
void SetMinimalSizeLimit(float width, float height);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _SetupFadeTab(BRect frame);
|
void _SetupFadeTab(BRect frame);
|
||||||
void _UpdateTurnOffScreen();
|
void _UpdateTurnOffScreen();
|
||||||
void _UpdateStatus();
|
void _UpdateStatus();
|
||||||
|
|
||||||
|
float fMinWidth, fMinHeight;
|
||||||
ScreenSaverPrefs fPrefs;
|
ScreenSaverPrefs fPrefs;
|
||||||
uint32 fTurnOffScreenFlags;
|
uint32 fTurnOffScreenFlags;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user