Suggestion from Rene:

- Make the BuildScreenSaverDefaultSettingsView function be built into
libscreensaver.so and under the BPrivate namespace. This avoids the repetition
of the compiled code in each screen saver that uses it.
- Updated the ScreenSaver preferences to use this.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33403 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood 2009-10-01 20:48:14 +00:00
parent db9feb346e
commit 1c5a1e55c1
4 changed files with 41 additions and 17 deletions

View File

@ -9,25 +9,12 @@
#define BUILD_SCREEN_SAVER_DEFAULT_SETTINGS_VIEW
#include <StringView.h>
#include <View.h>
class BView;
namespace BPrivate {
// This is used to provide a consistent look for the settings view for screen
// savers without any configuration.
void
BuildScreenSaverDefaultSettingsView(BView* view, const char* moduleName, const char* info)
{
BRect rect(15, 15, 20, 20);
BStringView* stringView = new BStringView(rect, "module", moduleName);
stringView->SetFont(be_bold_font);
stringView->ResizeToPreferred();
view->AddChild(stringView);
void BuildScreenSaverDefaultSettingsView(BView* view, const char* moduleName, const char* info);
rect.OffsetBy(0, stringView->Bounds().Height() + 4);
stringView = new BStringView(rect, "info", info);
stringView->ResizeToPreferred();
view->AddChild(stringView);
}

View File

@ -0,0 +1,36 @@
/*
* Copyright 2009, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ryan Leavengood, leavengood@gmail.com
*/
#include <BuildScreenSaverDefaultSettingsView.h>
#include <StringView.h>
#include <View.h>
namespace BPrivate {
// This is used to provide a consistent look for the settings view for screen
// savers without any configuration.
void
BuildScreenSaverDefaultSettingsView(BView* view, const char* moduleName, const char* info)
{
BRect rect(15, 15, 20, 20);
BStringView* stringView = new BStringView(rect, "module", moduleName);
stringView->SetFont(be_bold_font);
stringView->ResizeToPreferred();
view->AddChild(stringView);
rect.OffsetBy(0, stringView->Bounds().Height() + 4);
stringView = new BStringView(rect, "info", info);
stringView->ResizeToPreferred();
view->AddChild(stringView);
}
}

View File

@ -8,6 +8,7 @@ UseHeaders [ FDirName $(HAIKU_TOP) headers os add-ons screen_saver ] ;
UsePrivateHeaders screen_saver ;
SharedLibrary libscreensaver.so :
BuildScreenSaverDefaultSettingsView.cpp
ScreenSaver.cpp
ScreenSaverSettings.cpp
ScreenSaverRunner.cpp

View File

@ -532,7 +532,7 @@ ModulesView::_OpenSaver()
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.
BuildScreenSaverDefaultSettingsView(fSettingsView,
BPrivate::BuildScreenSaverDefaultSettingsView(fSettingsView,
fSettings.ModuleName()[0] ? fSettings.ModuleName() : "Blackness",
saver || !fSettings.ModuleName()[0]
? "No options available" : "Could not load screen saver");