DebugNow: Style fixes, export class def to header
Update copyright header, make colors static const, * goes with type
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007-2009, Haiku, Inc. All Rights Reserved.
|
* Copyright 2007-2014 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,48 +7,38 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "DebugNow.h"
|
||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
#include <ScreenSaver.h>
|
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
#include <BuildScreenSaverDefaultSettingsView.h>
|
#include <BuildScreenSaverDefaultSettingsView.h>
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "Screensaver DebugNow"
|
#define B_TRANSLATION_CONTEXT "Screensaver DebugNow"
|
||||||
|
|
||||||
|
|
||||||
const rgb_color kMediumBlue = {0, 0, 100};
|
static const rgb_color kMediumBlue = { 0, 0, 100 };
|
||||||
const rgb_color kWhite = {255, 255, 255};
|
static const rgb_color kWhite = { 255, 255, 255 };
|
||||||
|
|
||||||
|
|
||||||
// Inspired by the classic BeOS BuyNow screensaver, of course
|
// #pragma mark - Instantiation function
|
||||||
class DebugNow : public BScreenSaver
|
|
||||||
|
|
||||||
|
BScreenSaver* instantiate_screen_saver(BMessage* message, image_id image)
|
||||||
{
|
{
|
||||||
public:
|
return new DebugNow(message, image);
|
||||||
DebugNow(BMessage *archive, image_id);
|
}
|
||||||
void Draw(BView *view, int32 frame);
|
|
||||||
void StartConfig(BView *view);
|
|
||||||
status_t StartSaver(BView *view, bool preview);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char* fLine1;
|
|
||||||
const char* fLine2;
|
|
||||||
BPoint fLine1Start;
|
|
||||||
BPoint fLine2Start;
|
|
||||||
escapement_delta fDelta;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
BScreenSaver* instantiate_screen_saver(BMessage *msg, image_id image)
|
// #pragma mark - DebugNow
|
||||||
{
|
|
||||||
return new DebugNow(msg, image);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DebugNow::DebugNow(BMessage *archive, image_id id)
|
DebugNow::DebugNow(BMessage* archive, image_id id)
|
||||||
:
|
:
|
||||||
BScreenSaver(archive, id),
|
BScreenSaver(archive, id),
|
||||||
fLine1("DEBUG"),
|
fLine1("DEBUG"),
|
||||||
fLine2("NOW")
|
fLine2("NOW")
|
||||||
@@ -56,25 +46,25 @@ DebugNow::DebugNow(BMessage *archive, image_id id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DebugNow::StartConfig(BView *view)
|
DebugNow::StartConfig(BView* view)
|
||||||
{
|
{
|
||||||
BPrivate::BuildScreenSaverDefaultSettingsView(view, "DEBUG NOW",
|
BPrivate::BuildScreenSaverDefaultSettingsView(view, "DEBUG NOW",
|
||||||
B_TRANSLATE("by Ryan Leavengood"));
|
B_TRANSLATE("by Ryan Leavengood"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DebugNow::StartSaver(BView *view, bool preview)
|
DebugNow::StartSaver(BView* view, bool preview)
|
||||||
{
|
{
|
||||||
float viewWidth = view->Bounds().Width();
|
float viewWidth = view->Bounds().Width();
|
||||||
float viewHeight = view->Bounds().Height();
|
float viewHeight = view->Bounds().Height();
|
||||||
|
|
||||||
BFont font;
|
BFont font;
|
||||||
view->GetFont(&font);
|
view->GetFont(&font);
|
||||||
font.SetSize(viewHeight / 2.5);
|
font.SetSize(viewHeight / 2.5);
|
||||||
view->SetFont(&font);
|
view->SetFont(&font);
|
||||||
|
|
||||||
fDelta.nonspace = 0;
|
fDelta.nonspace = 0;
|
||||||
fDelta.space = 0;
|
fDelta.space = 0;
|
||||||
BRect stringRect;
|
BRect stringRect;
|
||||||
@@ -87,30 +77,29 @@ DebugNow::StartSaver(BView *view, bool preview)
|
|||||||
&stringRect);
|
&stringRect);
|
||||||
fLine2Start.Set(((viewWidth - stringRect.Width()) / 2) - stringRect.left,
|
fLine2Start.Set(((viewWidth - stringRect.Width()) / 2) - stringRect.left,
|
||||||
y + stringRect.Height() + viewHeight / 10);
|
y + stringRect.Height() + viewHeight / 10);
|
||||||
|
|
||||||
// Set tick size to 500,000 microseconds = 0.5 second
|
// set tick size to 500,000 microseconds (0.5 seconds)
|
||||||
SetTickSize(500000);
|
SetTickSize(500000);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DebugNow::Draw(BView *view, int32 frame)
|
DebugNow::Draw(BView* view, int32 frame)
|
||||||
{
|
{
|
||||||
// On first frame set the low color to make the text rendering correct
|
// on first frame set the low color to make the text rendering correct
|
||||||
if (frame == 0)
|
if (frame == 0)
|
||||||
view->SetLowColor(kMediumBlue);
|
view->SetLowColor(kMediumBlue);
|
||||||
|
|
||||||
// Draw the background color every frame
|
// draw the background color every frame
|
||||||
view->SetHighColor(kMediumBlue);
|
view->SetHighColor(kMediumBlue);
|
||||||
view->FillRect(view->Bounds());
|
view->FillRect(view->Bounds());
|
||||||
|
|
||||||
// Draw the text every other frame to make the it blink
|
// draw the text every other frame to make the it blink
|
||||||
if (frame % 2 == 1) {
|
if (frame % 2 == 1) {
|
||||||
view->SetHighColor(kWhite);
|
view->SetHighColor(kWhite);
|
||||||
view->DrawString(fLine1, fLine1Start, &fDelta);
|
view->DrawString(fLine1, fLine1Start, &fDelta);
|
||||||
view->DrawString(fLine2, fLine2Start, &fDelta);
|
view->DrawString(fLine2, fLine2Start, &fDelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2007-2014 Haiku, Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef DEBUG_NOW_H
|
||||||
|
#define DEBUG_NOW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Point.h>
|
||||||
|
#include <ScreenSaver.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Inspired by the classic BeOS BuyNow screensaver, of course
|
||||||
|
|
||||||
|
class BMessage;
|
||||||
|
class BView;
|
||||||
|
|
||||||
|
class DebugNow : public BScreenSaver {
|
||||||
|
public:
|
||||||
|
DebugNow(BMessage* archive, image_id);
|
||||||
|
|
||||||
|
void Draw(BView* view, int32 frame);
|
||||||
|
void StartConfig(BView *view);
|
||||||
|
status_t StartSaver(BView *view, bool preview);
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char* fLine1;
|
||||||
|
const char* fLine2;
|
||||||
|
BPoint fLine1Start;
|
||||||
|
BPoint fLine2Start;
|
||||||
|
escapement_delta fDelta;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // DEBUG_NOW_H
|
||||||
@@ -15,5 +15,5 @@ ScreenSaver DebugNow :
|
|||||||
DoCatalogs DebugNow :
|
DoCatalogs DebugNow :
|
||||||
x-vnd.Haiku-DebugNowScreensaver
|
x-vnd.Haiku-DebugNowScreensaver
|
||||||
:
|
:
|
||||||
DebugNow.cpp
|
DebugNow.cpp
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user