ScreenSaver: Style fixes

Update Copyright year and fix authors adding myself.
Mostly spacing and indentation fixes.
This commit is contained in:
John Scipione
2013-09-02 13:18:36 -04:00
parent 15a557e69c
commit 23ca081a2f
10 changed files with 158 additions and 128 deletions
+6 -5
View File
@@ -5,10 +5,11 @@
#include <GraphicsDefs.h> #include <GraphicsDefs.h>
const rgb_color kBlack = {0,0,0,0}; const rgb_color kBlack = { 0, 0, 0, 0};
const rgb_color kDarkGrey = {150,150,150,0}; const rgb_color kDarkGrey = { 150, 150, 150, 0};
const rgb_color kGrey = {200,200,200,0}; const rgb_color kGrey = { 200, 200, 200, 0};
const rgb_color kLightBlue = {200,200,255,0}; const rgb_color kLightBlue = { 200, 200, 255, 0};
const rgb_color kLightGreen = {255,200,200,0}; const rgb_color kLightGreen = { 255, 200, 200, 0};
#endif // CONSTANTS_H #endif // CONSTANTS_H
+28 -27
View File
@@ -1,15 +1,16 @@
/* /*
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved. * Copyright 2003-2013 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Michael Phipps
* Jérôme Duval, [email protected] * Jérôme Duval, [email protected]
* Julun <[email protected]> * Julun, [email protected]
* Michael Phipps
* John Scipione, [email protected]
*/ */
#include "PasswordWindow.h"
#include "PasswordWindow.h"
#include <Alert.h> #include <Alert.h>
#include <Box.h> #include <Box.h>
@@ -138,12 +139,12 @@ PasswordWindow::Update()
} }
char * char*
PasswordWindow::_SanitizeSalt(const char *password) PasswordWindow::_SanitizeSalt(const char* password)
{ {
char *salt; char* salt;
uint8 length = strlen(password); uint8 length = strlen(password);
if (length < 2) if (length < 2)
salt = new char[3]; salt = new char[3];
@@ -174,45 +175,45 @@ PasswordWindow::_SanitizeSalt(const char *password)
void void
PasswordWindow::MessageReceived(BMessage *message) PasswordWindow::MessageReceived(BMessage* message)
{ {
switch (message->what) { switch (message->what) {
case kMsgDone: case kMsgDone:
fSettings.SetLockMethod(fUseCustom->Value() ? "custom" : "network"); fSettings.SetLockMethod(fUseCustom->Value() ? "custom" : "network");
if (fUseCustom->Value()) { if (fUseCustom->Value()) {
if (strcmp(fPasswordControl->Text(), fConfirmControl->Text())) { if (strcmp(fPasswordControl->Text(), fConfirmControl->Text())
BAlert *alert = new BAlert("noMatch", != 0) {
BAlert* alert = new BAlert("noMatch",
B_TRANSLATE("Passwords don't match. Please try again."), B_TRANSLATE("Passwords don't match. Please try again."),
B_TRANSLATE("OK")); B_TRANSLATE("OK"));
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go(); alert->Go();
break; break;
} }
const char *salt = _SanitizeSalt(fPasswordControl->Text()); const char* salt = _SanitizeSalt(fPasswordControl->Text());
fSettings.SetPassword(crypt(fPasswordControl->Text(), salt)); fSettings.SetPassword(crypt(fPasswordControl->Text(), salt));
delete[] salt; delete[] salt;
} else { } else
fSettings.SetPassword(""); fSettings.SetPassword("");
}
fPasswordControl->SetText(""); fPasswordControl->SetText("");
fConfirmControl->SetText(""); fConfirmControl->SetText("");
fSettings.Save(); fSettings.Save();
Hide(); Hide();
break; break;
case B_CANCEL: case B_CANCEL:
fPasswordControl->SetText(""); fPasswordControl->SetText("");
fConfirmControl->SetText(""); fConfirmControl->SetText("");
Hide(); Hide();
break; break;
case kMsgPasswordTypeChanged: case kMsgPasswordTypeChanged:
fSettings.SetLockMethod(fUseCustom->Value() > 0 ? "custom" : "network"); fSettings.SetLockMethod(fUseCustom->Value() > 0 ? "custom" : "network");
Update(); Update();
break; break;
default: default:
BWindow::MessageReceived(message); BWindow::MessageReceived(message);
break;
} }
} }
+17 -17
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved. * Copyright 2003-2013 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -10,34 +10,34 @@
#define PASSWORD_WINDOW_H #define PASSWORD_WINDOW_H
#include "ScreenSaverSettings.h"
#include <Window.h> #include <Window.h>
class BRadioButton; class BRadioButton;
class BTextControl; class BTextControl;
class ScreenSaverSettings;
class PasswordWindow : public BWindow { class PasswordWindow : public BWindow {
public: public:
PasswordWindow(ScreenSaverSettings &settings); PasswordWindow(ScreenSaverSettings& settings);
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage* message);
void Update(); void Update();
private: private:
void _Setup(); void _Setup();
char * _SanitizeSalt(const char *password); char* _SanitizeSalt(const char* password);
BRadioButton *fUseCustom; BRadioButton* fUseCustom;
BRadioButton *fUseNetwork; BRadioButton* fUseNetwork;
BTextControl *fConfirmControl; BTextControl* fConfirmControl;
BTextControl *fPasswordControl; BTextControl* fPasswordControl;
ScreenSaverSettings &fSettings; ScreenSaverSettings& fSettings;
}; };
#endif // PASSWORD_WINDOW_H #endif // PASSWORD_WINDOW_H
+30 -21
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2006, Haiku. * Copyright 2003-20013 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -22,26 +22,29 @@
#include <iostream> #include <iostream>
static float sampleX[]= {0,.05,.15,.7,.725,.8,.825,.85,.950,1.0}; static float sampleX[]
static float sampleY[]= {0,.05,.90,.95,.966,.975,1.0}; = { 0, 0.05, 0.15, 0.7, 0.725, 0.8, 0.825, 0.85, 0.950, 1.0 };
static float sampleY[] = { 0, 0.05, 0.90, 0.95, 0.966, 0.975, 1.0 };
inline BPoint inline BPoint
scale2(int x, int y,BRect area) scale2(int x, int y, BRect area)
{ {
return scale_direct(sampleX[x],sampleY[y],area); return scale_direct(sampleX[x], sampleY[y], area);
} }
inline BRect inline BRect
scale2(int x1, int x2, int y1, int y2,BRect area) scale2(int x1, int x2, int y1, int y2, BRect area)
{ {
return scale_direct(sampleX[x1],sampleX[x2],sampleY[y1],sampleY[y2],area); return scale_direct(sampleX[x1], sampleX[x2], sampleY[y1], sampleY[y2],
area);
} }
PreviewView::PreviewView(BRect frame, const char *name) PreviewView::PreviewView(const char* name)
: BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW), :
BView(name, B_WILL_DRAW),
fSaverView(NULL) fSaverView(NULL)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -56,7 +59,7 @@ PreviewView::~PreviewView()
BView* BView*
PreviewView::AddPreview() PreviewView::AddPreview()
{ {
BRect rect = scale2(1,8,1,2,Bounds()); BRect rect = scale2(1, 8, 1, 2, Bounds());
rect.InsetBy(1, 1); rect.InsetBy(1, 1);
fSaverView = new BView(rect, "preview", B_FOLLOW_NONE, B_WILL_DRAW); fSaverView = new BView(rect, "preview", B_FOLLOW_NONE, B_WILL_DRAW);
fSaverView->SetViewColor(0, 0, 0); fSaverView->SetViewColor(0, 0, 0);
@@ -82,22 +85,28 @@ void
PreviewView::Draw(BRect update) PreviewView::Draw(BRect update)
{ {
SetHighColor(184, 184, 184); SetHighColor(184, 184, 184);
FillRoundRect(scale2(0,9,0,3,Bounds()),4,4);// Outer shape FillRoundRect(scale2(0, 9, 0, 3, Bounds()), 4, 4);
FillRoundRect(scale2(2,7,3,6,Bounds()),2,2);// control console outline // Outer shape
FillRoundRect(scale2(2, 7, 3, 6, Bounds()), 2, 2);
// control console outline
SetHighColor(96, 96, 96); SetHighColor(96, 96, 96);
StrokeRoundRect(scale2(2,7,3,6,Bounds()),2,2);// control console outline StrokeRoundRect(scale2(2, 7, 3, 6, Bounds()), 2, 2);
StrokeRoundRect(scale2(0,9,0,3,Bounds()),4,4); // Outline outer shape // control console outline
StrokeRoundRect(scale2(0, 9, 0, 3, Bounds()), 4, 4);
// Outline outer shape
SetHighColor(kBlack); SetHighColor(kBlack);
FillRect(scale2(1,8,1,2,Bounds())); 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());
outerShape.InsetBy(1,1); outerShape.InsetBy(1, 1);
FillRoundRect(outerShape,4,4);// Outer shape FillRoundRect(outerShape, 4, 4);
// Outer shape
SetHighColor(0, 255, 0); SetHighColor(0, 255, 0);
FillRect(scale2(3,4,4,5,Bounds())); FillRect(scale2(3, 4, 4, 5, Bounds()));
SetHighColor(96,96,96); SetHighColor(96, 96, 96);
FillRect(scale2(5,6,4,5,Bounds())); FillRect(scale2(5, 6, 4, 5, Bounds()));
} }
+10 -11
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2006, Haiku. * Copyright 2003-20013 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -14,21 +14,20 @@
#include <Box.h> #include <Box.h>
#include <ScreenSaverRunner.h> #include <ScreenSaverRunner.h>
class BScreenSaver;
class PreviewView : public BView { class PreviewView : public BView {
public: public:
PreviewView(BRect frame, const char *name); PreviewView(const char* name);
virtual ~PreviewView(); virtual ~PreviewView();
virtual void Draw(BRect update); virtual void Draw(BRect update);
BView* AddPreview(); BView* AddPreview();
BView* RemovePreview(); BView* RemovePreview();
private: private:
BView* fSaverView; BView* fSaverView;
}; };
#endif // PREVIEW_VIEW_H #endif // PREVIEW_VIEW_H
@@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2009, Haiku. * Copyright 2003-2013 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -8,8 +8,8 @@
*/ */
#include "ScreenCornerSelector.h" #include "ScreenCornerSelector.h"
#include "Constants.h"
#include "Utility.h" #include <stdio.h>
#include <Rect.h> #include <Rect.h>
#include <Point.h> #include <Point.h>
@@ -17,7 +17,8 @@
#include <Screen.h> #include <Screen.h>
#include <Window.h> #include <Window.h>
#include <stdio.h> #include "Constants.h"
#include "Utility.h"
static const float kAspectRatio = 4.0f / 3.0f; static const float kAspectRatio = 4.0f / 3.0f;
@@ -26,10 +27,11 @@ static const float kArrowSize = 11.0f;
static const float kStopSize = 15.0f; static const float kStopSize = 15.0f;
ScreenCornerSelector::ScreenCornerSelector(BRect frame, const char *name, ScreenCornerSelector::ScreenCornerSelector(BRect frame, const char* name,
BMessage* message, uint32 resizingMode) BMessage* message, uint32 resizingMode)
: BControl(frame, name, NULL, message, resizingMode, :
B_WILL_DRAW | B_NAVIGABLE), BControl(frame, name, NULL, message, resizingMode,
B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE),
fCurrentCorner(NO_CORNER), fCurrentCorner(NO_CORNER),
fPreviousCorner(-1) fPreviousCorner(-1)
{ {
@@ -70,7 +72,7 @@ ScreenCornerSelector::_CenterFrame(BRect innerFrame) const
void void
ScreenCornerSelector::Draw(BRect update) ScreenCornerSelector::Draw(BRect updateRect)
{ {
rgb_color darkColor = {160, 160, 160, 255}; rgb_color darkColor = {160, 160, 160, 255};
rgb_color blackColor = {0, 0, 0, 255}; rgb_color blackColor = {0, 0, 0, 255};
@@ -82,7 +84,7 @@ ScreenCornerSelector::Draw(BRect update)
SetDrawingMode(B_OP_OVER); SetDrawingMode(B_OP_OVER);
if (!_InnerFrame(outerRect).Contains(update)) { if (!_InnerFrame(outerRect).Contains(updateRect)) {
// frame & background // frame & background
// if the focus is changing, we don't redraw the whole view, but only // if the focus is changing, we don't redraw the whole view, but only
@@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2006, Haiku. * Copyright 2003-2013 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -10,38 +10,43 @@
#define SCREEN_CORNER_SELECTOR_H #define SCREEN_CORNER_SELECTOR_H
#include "ScreenSaverSettings.h"
#include <Control.h> #include <Control.h>
#include "ScreenSaverSettings.h"
class ScreenCornerSelector : public BControl { class ScreenCornerSelector : public BControl {
public: public:
ScreenCornerSelector(BRect frame, const char *name, BMessage* message, ScreenCornerSelector(BRect frame,
uint32 resizingMode); const char *name, BMessage* message,
uint32 resizingMode);
virtual void Draw(BRect update); virtual void Draw(BRect updateRect);
virtual void MouseDown(BPoint point); virtual void MouseDown(BPoint point);
virtual void MouseUp(BPoint point); virtual void MouseUp(BPoint point);
virtual void MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage); virtual void MouseMoved(BPoint where, uint32 transit,
virtual void KeyDown(const char* bytes, int32 numBytes); const BMessage* dragMessage);
virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void SetValue(int32 value); virtual void SetValue(int32 value);
virtual int32 Value(); virtual int32 Value();
void SetCorner(screen_corner corner); void SetCorner(screen_corner corner);
screen_corner Corner() const; screen_corner Corner() const;
private: private:
BRect _MonitorFrame() const; BRect _MonitorFrame() const;
BRect _InnerFrame(BRect monitorFrame) const; BRect _InnerFrame(BRect monitorFrame) const;
BRect _CenterFrame(BRect innerFrame) const; BRect _CenterFrame(BRect innerFrame) const;
void _DrawStop(BRect innerFrame); void _DrawStop(BRect innerFrame);
void _DrawArrow(BRect innerFrame); void _DrawArrow(BRect innerFrame);
screen_corner _ScreenCorner(BPoint point, screen_corner previous) const; screen_corner _ScreenCorner(BPoint point,
screen_corner previous) const;
screen_corner fCurrentCorner; screen_corner fCurrentCorner;
int32 fPreviousCorner; int32 fPreviousCorner;
}; };
#endif // SCREEN_CORNER_SELECTOR_H #endif // SCREEN_CORNER_SELECTOR_H
@@ -1,11 +1,12 @@
/* /*
* Copyright 2003-2010, Haiku. * Copyright 2003-2013 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Michael Phipps
* Jérôme Duval, [email protected]
* Axel Dörfler, [email protected] * Axel Dörfler, [email protected]
* Jérôme Duval, [email protected]
* Michael Phipps
* John Scipione, [email protected]
*/ */
@@ -40,9 +41,11 @@
#include "ScreenCornerSelector.h" #include "ScreenCornerSelector.h"
#include "ScreenSaverItem.h" #include "ScreenSaverItem.h"
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ScreenSaver" #define B_TRANSLATION_CONTEXT "ScreenSaver"
const uint32 kPreviewMonitorGap = 16; const uint32 kPreviewMonitorGap = 16;
const uint32 kMinSettingsWidth = 230; const uint32 kMinSettingsWidth = 230;
const uint32 kMinSettingsHeight = 120; const uint32 kMinSettingsHeight = 120;
@@ -135,6 +138,9 @@ private:
}; };
// #pragma mark - TimeSlider
static const int32 kTimeInUnits[] = { static const int32 kTimeInUnits[] = {
30, 60, 90, 30, 60, 90,
120, 150, 180, 120, 150, 180,
@@ -146,6 +152,7 @@ static const int32 kTimeInUnits[] = {
7200, 9000, 10800, 7200, 9000, 10800,
14400, 18000 14400, 18000
}; };
static const int32 kTimeUnitCount static const int32 kTimeUnitCount
= sizeof(kTimeInUnits) / sizeof(kTimeInUnits[0]); = sizeof(kTimeInUnits) / sizeof(kTimeInUnits[0]);
@@ -217,7 +224,7 @@ TimeSlider::_TimeToString(bigtime_t useconds, BString& string)
} }
// #pragma mark - // #pragma mark - FadeView
FadeView::FadeView(BRect rect, const char* name, ScreenSaverSettings& settings) FadeView::FadeView(BRect rect, const char* name, ScreenSaverSettings& settings)
@@ -382,8 +389,9 @@ ModulesView::MessageReceived(BMessage* message)
// database for example... // database for example...
BPath path; BPath path;
if (find_directory(B_SYSTEM_BIN_DIRECTORY, &path) != B_OK if (find_directory(B_SYSTEM_BIN_DIRECTORY, &path) != B_OK
|| path.Append("screen_blanker") != B_OK) || path.Append("screen_blanker") != B_OK) {
path.SetTo("/bin/screen_blanker"); path.SetTo("/bin/screen_blanker");
}
BEntry entry(path.Path()); BEntry entry(path.Path());
entry_ref ref; entry_ref ref;
@@ -393,6 +401,7 @@ ModulesView::MessageReceived(BMessage* message)
} }
break; break;
} }
case kMsgAddSaver: case kMsgAddSaver:
fFilePanel->Show(); fFilePanel->Show();
break; break;
@@ -513,6 +522,7 @@ ModulesView::_CloseSaver()
if (fSaverRunner != NULL) if (fSaverRunner != NULL)
fSaverRunner->Quit(); fSaverRunner->Quit();
if (saver != NULL) if (saver != NULL)
saver->StopConfig(); saver->StopConfig();
@@ -544,6 +554,7 @@ ModulesView::_OpenSaver()
rect.top += 14; rect.top += 14;
#endif #endif
fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW); 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);
@@ -611,7 +622,7 @@ ModulesView::_OpenSaver()
} }
// #pragma mark - // #pragma mark - ScreenSaverWindow
ScreenSaverWindow::ScreenSaverWindow() ScreenSaverWindow::ScreenSaverWindow()
@@ -1004,4 +1015,3 @@ ScreenSaverWindow::QuitRequested()
be_app->PostMessage(B_QUIT_REQUESTED); be_app->PostMessage(B_QUIT_REQUESTED);
return true; return true;
} }
@@ -1,18 +1,18 @@
/* /*
* Copyright 2003-2010, Haiku. * Copyright 2003-2013 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Michael Phipps
* Jérôme Duval, [email protected]
* Axel Dörfler, [email protected] * Axel Dörfler, [email protected]
* Jérôme Duval, [email protected]
* Michael Phipps
* John Scipione, [email protected]
*/ */
#ifndef SCREEN_SAVER_WINDOW_H #ifndef SCREEN_SAVER_WINDOW_H
#define SCREEN_SAVER_WINDOW_H #define SCREEN_SAVER_WINDOW_H
#include "PasswordWindow.h" #include "PasswordWindow.h"
#include "ScreenSaverSettings.h"
#include <Box.h> #include <Box.h>
#include <CheckBox.h> #include <CheckBox.h>
@@ -20,6 +20,8 @@
#include <Slider.h> #include <Slider.h>
#include <ListView.h> #include <ListView.h>
#include "ScreenSaverSettings.h"
class BButton; class BButton;
class BTabView; class BTabView;
+3 -2
View File
@@ -19,8 +19,8 @@ scale_direct(float x1, float x2, float y1, float y2, BRect area)
area.Width()* x2 + area.left, area.Height() * y2 + area.top); area.Width()* x2 + area.left, area.Height() * y2 + area.top);
} }
static const float kPositionalX[] = { 0, .1, .25, .3, .7, .75, .9, 1.0 }; static const float kPositionalX[] = { 0, 0.1, 0.25, 0.3, 0.7, 0.75, 0.9, 1.0 };
static const float kPositionalY[] = { 0, .1, .7, .8, .9, 1.0 }; static const float kPositionalY[] = { 0, 0.1, 0.7, 0.8, 0.9, 1.0 };
inline BPoint inline BPoint
scale(int x, int y,BRect area) scale(int x, int y,BRect area)
@@ -36,4 +36,5 @@ scale(int x1, int x2, int y1, int y2,BRect area)
kPositionalY[y1], kPositionalY[y2], area); kPositionalY[y1], kPositionalY[y2], area);
} }
#endif // UTILITY_H #endif // UTILITY_H