From 4ddea1f86264f27062a11f3f08473d2bceb3c23e Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 22 Aug 2014 22:34:54 +0200 Subject: [PATCH] ScreenSaver: rework some of the fixes * Use a BTextView for the "no preview" text again, as Skipp_OSX pointed this allows it to word wrap as needed with any font bigger than 10pt. * Show a black screen rather than the "no preview" text for Darkness and when a screensaver fails to load. This matches what screen_blanker will do. --- src/preferences/screensaver/PreviewView.cpp | 16 +++++++++++++--- src/preferences/screensaver/PreviewView.h | 4 ++-- .../screensaver/ScreenSaverWindow.cpp | 8 ++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/preferences/screensaver/PreviewView.cpp b/src/preferences/screensaver/PreviewView.cpp index 4289c384b2..f0ad5a1261 100644 --- a/src/preferences/screensaver/PreviewView.cpp +++ b/src/preferences/screensaver/PreviewView.cpp @@ -64,11 +64,18 @@ PreviewView::PreviewView(const char* name) BGroupLayout* layout = new BGroupLayout(B_VERTICAL); // We draw the "monitor" around the preview, hence the strange insets. - layout->SetInsets(10, 8, 11, 16); + layout->SetInsets(7, 6, 8, 12); SetLayout(layout); - fNoPreview = new BStringView("no preview", - B_TRANSLATE("No preview available")); + // A BStringView would be enough, if only it handled word wrapping. + fNoPreview = new BTextView("no preview"); + fNoPreview->SetText(B_TRANSLATE("No preview available")); + fNoPreview->SetFontAndColor(be_plain_font, B_FONT_ALL, &kWhite); + fNoPreview->MakeEditable(false); + fNoPreview->MakeResizable(false); + fNoPreview->MakeSelectable(false); + fNoPreview->SetViewColor(0, 0, 0); + fNoPreview->SetLowColor(0, 0, 0); fNoPreview->Hide(); @@ -138,6 +145,7 @@ PreviewView::AddPreview() fNoPreview->SetExplicitSize(BSize(previewWidth, previewHeight)); fNoPreview->ResizeTo(previewWidth, previewHeight); + fNoPreview->SetInsets(0, previewHeight / 3, 0 , 0); return fSaverView; } @@ -146,6 +154,8 @@ PreviewView::AddPreview() BView* PreviewView::RemovePreview() { + ShowNoPreview(); + if (fSaverView != NULL) ChildAt(0)->RemoveChild(fSaverView); diff --git a/src/preferences/screensaver/PreviewView.h b/src/preferences/screensaver/PreviewView.h index 5e1bff273d..f062f9c233 100644 --- a/src/preferences/screensaver/PreviewView.h +++ b/src/preferences/screensaver/PreviewView.h @@ -13,7 +13,7 @@ #include -class BStringView; +class BTextView; class PreviewView : public BView { public: @@ -31,7 +31,7 @@ public: private: BView* fSaverView; - BStringView* fNoPreview; + BTextView* fNoPreview; }; diff --git a/src/preferences/screensaver/ScreenSaverWindow.cpp b/src/preferences/screensaver/ScreenSaverWindow.cpp index 14fc4a56be..7c918ce65c 100644 --- a/src/preferences/screensaver/ScreenSaverWindow.cpp +++ b/src/preferences/screensaver/ScreenSaverWindow.cpp @@ -833,8 +833,12 @@ ModulesView::_OpenSaver() fSaverRunner->Run(); } else fPreviewView->ShowNoPreview(); - } else - fPreviewView->ShowNoPreview(); + } else { + // Failed to load OR this is the "Darkness" screensaver. Show a black + // preview (this is what will happen in both cases when screen_blanker + // runs). + fPreviewView->HideNoPreview(); + } if (fSettingsView->ChildAt(0) == NULL) { // There are no settings at all, we add the module name here to