Made some coding style changes, no code changes.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10969 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -17,41 +17,45 @@
|
|||||||
class ScreenSaver : public BScreenSaver
|
class ScreenSaver : public BScreenSaver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScreenSaver(BMessage *archive, image_id);
|
ScreenSaver(BMessage *archive, image_id);
|
||||||
void Draw(BView *view, int32 frame);
|
void Draw(BView *view, int32 frame);
|
||||||
void StartConfig(BView *view);
|
void StartConfig(BView *view);
|
||||||
status_t StartSaver(BView *view, bool preview);
|
status_t StartSaver(BView *view, bool preview);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char *fText;
|
const char *fText;
|
||||||
float fX;
|
float fX;
|
||||||
float fY;
|
float fY;
|
||||||
float fSizeX;
|
float fSizeX;
|
||||||
float fSizeY;
|
float fSizeY;
|
||||||
float fTextHeight;
|
float fTextHeight;
|
||||||
float fTextWith;
|
float fTextWith;
|
||||||
bool fIsPreview;
|
bool fIsPreview;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
BScreenSaver *instantiate_screen_saver(BMessage *msg, image_id image)
|
BScreenSaver *instantiate_screen_saver(BMessage *msg, image_id image)
|
||||||
{
|
{
|
||||||
return new ScreenSaver(msg, image);
|
return new ScreenSaver(msg, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenSaver::ScreenSaver(BMessage *archive, image_id id) :
|
|
||||||
BScreenSaver(archive, id),
|
ScreenSaver::ScreenSaver(BMessage *archive, image_id id)
|
||||||
fText("Haiku"),
|
: BScreenSaver(archive, id)
|
||||||
fX(0),
|
, fText("Haiku")
|
||||||
fY(0)
|
, fX(0)
|
||||||
|
, fY(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenSaver::StartConfig(BView *view)
|
ScreenSaver::StartConfig(BView *view)
|
||||||
{
|
{
|
||||||
view->AddChild(new BStringView(BRect(20,10,200,35), "", "Haiku, by Marcus Overhagen"));
|
view->AddChild(new BStringView(BRect(20, 10, 200, 35), "", "Haiku, by Marcus Overhagen"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ScreenSaver::StartSaver(BView *view, bool preview)
|
ScreenSaver::StartSaver(BView *view, bool preview)
|
||||||
{
|
{
|
||||||
@@ -72,7 +76,7 @@ ScreenSaver::StartSaver(BView *view, bool preview)
|
|||||||
escapement_delta delta;
|
escapement_delta delta;
|
||||||
delta.nonspace = 0;
|
delta.nonspace = 0;
|
||||||
delta.space = 0;
|
delta.space = 0;
|
||||||
font.GetBoundingBoxesForStrings(&fText,1,B_SCREEN_METRIC,&delta,&rect);
|
font.GetBoundingBoxesForStrings(&fText, 1, B_SCREEN_METRIC, &delta, &rect);
|
||||||
fTextHeight = rect.Height();
|
fTextHeight = rect.Height();
|
||||||
fTextWith = rect.Width();
|
fTextWith = rect.Width();
|
||||||
|
|
||||||
@@ -82,6 +86,7 @@ ScreenSaver::StartSaver(BView *view, bool preview)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenSaver::Draw(BView *view, int32 frame)
|
ScreenSaver::Draw(BView *view, int32 frame)
|
||||||
{
|
{
|
||||||
@@ -91,8 +96,8 @@ ScreenSaver::Draw(BView *view, int32 frame)
|
|||||||
view->FillRect(view->Bounds(), B_SOLID_LOW);
|
view->FillRect(view->Bounds(), B_SOLID_LOW);
|
||||||
} else {
|
} else {
|
||||||
// erase old text on all other frames
|
// erase old text on all other frames
|
||||||
view->SetHighColor(0,0,0);
|
view->SetHighColor(0, 0, 0);
|
||||||
view->DrawString(fText,BPoint(fX,fY));
|
view->DrawString(fText, BPoint(fX, fY));
|
||||||
}
|
}
|
||||||
|
|
||||||
// find some new text coordinates
|
// find some new text coordinates
|
||||||
@@ -100,10 +105,9 @@ ScreenSaver::Draw(BView *view, int32 frame)
|
|||||||
fY = rand() % int(fSizeY - fTextHeight - (fIsPreview ? 2 : 20)) + fTextHeight;
|
fY = rand() % int(fSizeY - fTextHeight - (fIsPreview ? 2 : 20)) + fTextHeight;
|
||||||
|
|
||||||
// draw new text
|
// draw new text
|
||||||
view->SetHighColor(0,255,0);
|
view->SetHighColor(0, 255, 0);
|
||||||
view->DrawString(fText,BPoint(fX,fY));
|
view->DrawString(fText, BPoint(fX, fY));
|
||||||
|
|
||||||
// randomize time until next update (preview mode is faster)
|
// randomize time until next update (preview mode is faster)
|
||||||
SetTickSize(((rand() % 4) + 1) * (fIsPreview ? 300000 : 1000000));
|
SetTickSize(((rand() % 4) + 1) * (fIsPreview ? 300000 : 1000000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user