Pulse: automatic whitespace cleanup.

This commit is contained in:
Augustin Cavalier
2015-02-14 18:49:22 -05:00
parent 99515c66b8
commit 9c353c978c
16 changed files with 72 additions and 72 deletions
+1 -1
View File
@@ -313,7 +313,7 @@ CPUButton::AttachedToWindow()
SetTarget(this);
SetFont(be_plain_font);
SetFontSize(10);
fReplicantInDeskbar = false;
if (fReplicant) {
+2 -2
View File
@@ -28,11 +28,11 @@ class CPUButton : public BControl {
virtual void MessageReceived(BMessage *message);
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
status_t Invoke(BMessage *message = NULL);
static CPUButton *Instantiate(BMessage *data);
status_t Archive(BMessage *data, bool deep = true) const;
void UpdateColors(int32 color);
private:
+13 -13
View File
@@ -82,7 +82,7 @@ ConfigView::ConfigView(BRect rect, const char *name, uint32 mode, BMessenger& ta
if (mode == PRV_NORMAL_CHANGE_COLOR) {
// normal mode
fFadeCheckBox = new BCheckBox(rect, "FadeColors",
fFadeCheckBox = new BCheckBox(rect, "FadeColors",
B_TRANSLATE("Fade colors"), new BMessage(PRV_NORMAL_FADE_COLORS));
fFadeCheckBox->ResizeToPreferred();
AddChild(fFadeCheckBox);
@@ -92,20 +92,20 @@ ConfigView::ConfigView(BRect rect, const char *name, uint32 mode, BMessenger& ta
} else if (mode == PRV_MINI_CHANGE_COLOR) {
// mini mode
fActiveButton = new BRadioButton(rect, "ActiveColor",
fActiveButton = new BRadioButton(rect, "ActiveColor",
B_TRANSLATE("Active color"), new BMessage(PRV_MINI_ACTIVE));
fActiveButton->ResizeToPreferred();
fActiveButton->SetValue(B_CONTROL_ON);
AddChild(fActiveButton);
rect.left = fActiveButton->Frame().right + 5.0f;
fIdleButton = new BRadioButton(rect, "IdleColor",
fIdleButton = new BRadioButton(rect, "IdleColor",
B_TRANSLATE("Idle color"), new BMessage(PRV_MINI_IDLE));
fIdleButton->ResizeToPreferred();
AddChild(fIdleButton);
rect.left = fIdleButton->Frame().right + 5.0f;
fFrameButton = new BRadioButton(rect, "FrameColor",
fFrameButton = new BRadioButton(rect, "FrameColor",
B_TRANSLATE("Frame color"), new BMessage(PRV_MINI_FRAME));
fFrameButton->ResizeToPreferred();
AddChild(fFrameButton);
@@ -113,20 +113,20 @@ ConfigView::ConfigView(BRect rect, const char *name, uint32 mode, BMessenger& ta
fColorControl->SetValue(fPrefs->mini_active_color);
} else {
// deskbar mode
fActiveButton = new BRadioButton(rect, "ActiveColor",
fActiveButton = new BRadioButton(rect, "ActiveColor",
B_TRANSLATE("Active color"), new BMessage(PRV_DESKBAR_ACTIVE));
fActiveButton->ResizeToPreferred();
fActiveButton->SetValue(B_CONTROL_ON);
AddChild(fActiveButton);
rect.left = fActiveButton->Frame().right + 5.0f;
fIdleButton = new BRadioButton(rect, "IdleColor",
fIdleButton = new BRadioButton(rect, "IdleColor",
B_TRANSLATE("Idle color"), new BMessage(PRV_DESKBAR_IDLE));
fIdleButton->ResizeToPreferred();
AddChild(fIdleButton);
rect.left = fIdleButton->Frame().right + 5.0f;
fFrameButton = new BRadioButton(rect, "FrameColor",
fFrameButton = new BRadioButton(rect, "FrameColor",
B_TRANSLATE("Frame color"), new BMessage(PRV_DESKBAR_FRAME));
fFrameButton->ResizeToPreferred();
AddChild(fFrameButton);
@@ -136,8 +136,8 @@ ConfigView::ConfigView(BRect rect, const char *name, uint32 mode, BMessenger& ta
char temp[10];
snprintf(temp, sizeof(temp), "%d", fPrefs->deskbar_icon_width);
fIconWidthControl = new BTextControl(rect, "Width",
B_TRANSLATE("Width of icon:"), temp,
fIconWidthControl = new BTextControl(rect, "Width",
B_TRANSLATE("Width of icon:"), temp,
new BMessage(PRV_DESKBAR_ICON_WIDTH));
AddChild(fIconWidthControl);
fIconWidthControl->SetDivider(be_plain_font->StringWidth(
@@ -148,7 +148,7 @@ ConfigView::ConfigView(BRect rect, const char *name, uint32 mode, BMessenger& ta
fIconWidthControl->TextView()->DisallowChar(c);
}
fIconWidthControl->TextView()->SetMaxBytes(2);
float width, height;
fIconWidthControl->GetPreferredSize(&width, &height);
fIconWidthControl->ResizeTo(fIconWidthControl->Divider() + 32.0f
@@ -194,7 +194,7 @@ void
ConfigView::AttachedToWindow()
{
BView::AttachedToWindow();
// AttachedToWindow() gets called every time this tab is brought
// to the front, but we only want this initialization to happen once
if (fFirstTimeAttached) {
@@ -211,7 +211,7 @@ ConfigView::AttachedToWindow()
fActiveButton->SetTarget(messenger);
if (fIdleButton != NULL)
fIdleButton->SetTarget(messenger);
if (fFrameButton != NULL)
if (fFrameButton != NULL)
fFrameButton->SetTarget(messenger);
if (fIconWidthControl != NULL)
fIconWidthControl->SetTarget(messenger);
@@ -350,7 +350,7 @@ ConfigView::_ResetDefaults()
message->AddInt32("idle_color", DEFAULT_MINI_IDLE_COLOR);
message->AddInt32("frame_color", DEFAULT_MINI_FRAME_COLOR);
fTarget.SendMessage(message);
} else {
} else {
fPrefs->deskbar_active_color = DEFAULT_DESKBAR_ACTIVE_COLOR;
fPrefs->deskbar_idle_color = DEFAULT_DESKBAR_IDLE_COLOR;
fPrefs->deskbar_frame_color = DEFAULT_DESKBAR_FRAME_COLOR;
+3 -3
View File
@@ -23,15 +23,15 @@ class DeskbarPulseView : public MiniPulseView {
void MouseDown(BPoint point);
void AttachedToWindow();
void Pulse();
void MessageReceived(BMessage *message);
static DeskbarPulseView *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
private:
void Remove();
void SetMode(bool normal);
PrefsWindow *prefswindow;
Prefs *prefs;
BMessageRunner *messagerunner;
+1 -1
View File
@@ -28,4 +28,4 @@ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+14 -14
View File
@@ -17,7 +17,7 @@
#define B_TRANSLATION_CONTEXT "MiniPulseView"
MiniPulseView::MiniPulseView(BRect rect, const char *name, Prefs *prefs) :
MiniPulseView::MiniPulseView(BRect rect, const char *name, Prefs *prefs) :
PulseView(rect, name) {
mode1->SetLabel(B_TRANSLATE("Normal mode"));
@@ -27,19 +27,19 @@ MiniPulseView::MiniPulseView(BRect rect, const char *name, Prefs *prefs) :
quit = new BMenuItem(B_TRANSLATE("Quit"), new BMessage(PV_QUIT), 0, 0);
popupmenu->AddSeparatorItem();
popupmenu->AddItem(quit);
// Our drawing covers every pixel in the view, so no reason to
// take the time (and to flicker) by resetting the view color
SetViewColor(B_TRANSPARENT_COLOR);
active_color.red = (prefs->mini_active_color & 0xff000000) >> 24;
active_color.green = (prefs->mini_active_color & 0x00ff0000) >> 16;
active_color.blue = (prefs->mini_active_color & 0x0000ff00) >> 8;
idle_color.red = (prefs->mini_idle_color & 0xff000000) >> 24;
idle_color.green = (prefs->mini_idle_color & 0x00ff0000) >> 16;
idle_color.blue = (prefs->mini_idle_color & 0x0000ff00) >> 8;
frame_color.red = (prefs->mini_frame_color & 0xff000000) >> 24;
frame_color.green = (prefs->mini_frame_color & 0x00ff0000) >> 16;
frame_color.blue = (prefs->mini_frame_color & 0x0000ff00) >> 8;
@@ -53,7 +53,7 @@ MiniPulseView::MiniPulseView(BRect rect, const char *name)
}
MiniPulseView::MiniPulseView(BMessage *message)
MiniPulseView::MiniPulseView(BMessage *message)
:
PulseView(message)
{
@@ -66,7 +66,7 @@ void MiniPulseView::Draw(BRect rect) {
get_system_info(&sys_info);
if (sys_info.cpu_count <= 0)
return;
BRect bounds(Bounds());
SetDrawingMode(B_OP_COPY);
@@ -75,18 +75,18 @@ void MiniPulseView::Draw(BRect rect) {
float bottom = top + h;
float bar_width = (bounds.Width()) / sys_info.cpu_count - 2;
float right = bar_width + left;
for (unsigned int x = 0; x < sys_info.cpu_count; x++) {
int bar_height = (int)(cpu_times[x] * (h + 1));
if (bar_height > h) bar_height = h;
double rem = cpu_times[x] * (h + 1) - bar_height;
rgb_color fraction_color;
fraction_color.red = (uint8)(idle_color.red + rem
fraction_color.red = (uint8)(idle_color.red + rem
* (active_color.red - idle_color.red));
fraction_color.green = (uint8)(idle_color.green + rem
fraction_color.green = (uint8)(idle_color.green + rem
* (active_color.green - idle_color.green));
fraction_color.blue = (uint8)(idle_color.blue + rem
fraction_color.blue = (uint8)(idle_color.blue + rem
* (active_color.blue - idle_color.blue));
fraction_color.alpha = 0xff;
@@ -127,7 +127,7 @@ void MiniPulseView::AttachedToWindow() {
preferences->SetTarget(messenger);
about->SetTarget(messenger);
quit->SetTarget(messenger);
system_info sys_info;
get_system_info(&sys_info);
if (sys_info.cpu_count >= 2) {
@@ -142,7 +142,7 @@ void MiniPulseView::UpdateColors(BMessage *message) {
int32 ac = message->FindInt32("active_color");
int32 ic = message->FindInt32("idle_color");
int32 fc = message->FindInt32("frame_color");
active_color.red = (ac & 0xff000000) >> 24;
active_color.green = (ac & 0x00ff0000) >> 16;
active_color.blue = (ac & 0x0000ff00) >> 8;
@@ -154,7 +154,7 @@ void MiniPulseView::UpdateColors(BMessage *message) {
frame_color.red = (fc & 0xff000000) >> 24;
frame_color.green = (fc & 0x00ff0000) >> 16;
frame_color.blue = (fc & 0x0000ff00) >> 8;
Draw(Bounds());
}
+1 -1
View File
@@ -25,7 +25,7 @@ class MiniPulseView : public PulseView {
void Pulse();
void FrameResized(float width, float height);
void UpdateColors(BMessage *message);
protected:
BMenuItem *quit;
rgb_color frame_color, active_color, idle_color;
+5 -5
View File
@@ -42,7 +42,7 @@ max_font_size(BFont font, const char* text, float maxSize, float maxWidth)
return 4;
}
// #pragma mark -
@@ -58,7 +58,7 @@ NormalPulseView::NormalPulseView(BRect rect)
mode1->SetMessage(new BMessage(PV_MINI_MODE));
mode2->SetLabel(B_TRANSLATE("Deskbar mode"));
mode2->SetMessage(new BMessage(PV_DESKBAR_MODE));
DetermineVendorAndProcessor();
// Allocate progress bars and button pointers
@@ -190,7 +190,7 @@ NormalPulseView::Draw(BRect rect)
StrokeLine(BPoint(1, frame.bottom + 1), BPoint(frame.right, frame.bottom + 1));
SetHighColor(255, 255, 255);
StrokeLine(BPoint(1, frame.bottom + 2), BPoint(frame.right, frame.bottom + 2));
// Processor picture
DrawBitmap(fCpuLogo, BPoint(10, 10));
@@ -210,7 +210,7 @@ NormalPulseView::Draw(BRect rect)
// Draw processor type and speed
SetDrawingMode(B_OP_OVER);
SetHighColor(240, 240, 240);
SetFontSize(fProcessorFontSize);
float width = StringWidth(fProcessor);
MovePenTo(10 + (32 - width / 2), 48);
@@ -222,7 +222,7 @@ NormalPulseView::Draw(BRect rect)
snprintf(buffer, sizeof(buffer), B_TRANSLATE("%.2f GHz"), cpuSpeed / 1000.0f);
else
snprintf(buffer, sizeof(buffer), B_TRANSLATE("%ld MHz"), cpuSpeed);
// We can't assume anymore that a CPU clock speed is always static.
// Let's compute the best font size for the CPU speed string each time...
BFont font;
+2 -2
View File
@@ -51,10 +51,10 @@ Prefs::Prefs()
return;
}
// While normal window position is under user control, size is not.
// Width is fixed and height must be dynamically computed each time,
// Width is fixed and height must be dynamically computed each time,
// as number of CPUs could change since boot.
ComputeNormalWindowSize();
r = GetMiniWindowRect();
if (!GetRect("mini_window_rect", &mini_window_rect, &r)) {
fFatalError = true;
+2 -2
View File
@@ -19,7 +19,7 @@ class Prefs {
Prefs();
bool Save();
~Prefs();
int window_mode, deskbar_icon_width;
BRect normal_window_rect, mini_window_rect, prefs_window_rect;
int normal_bar_color, mini_active_color, mini_idle_color, mini_frame_color,
@@ -35,7 +35,7 @@ class Prefs {
bool PutInt(const char *name, int *value);
bool PutBool(const char *name, bool *value);
bool PutRect(const char *name, BRect *value);
float GetNormalWindowHeight();
void ComputeNormalWindowSize();
BRect GetNormalWindowRect();
+7 -7
View File
@@ -26,7 +26,7 @@
#define B_TRANSLATION_CONTEXT "PrefsWindow"
PrefsWindow::PrefsWindow(BRect frame, const char *name,
PrefsWindow::PrefsWindow(BRect frame, const char *name,
BMessenger *messenger, Prefs *prefs)
: BWindow(frame, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
| B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS),
@@ -52,7 +52,7 @@ PrefsWindow::PrefsWindow(BRect frame, const char *name,
PRV_NORMAL_CHANGE_COLOR, fTarget, prefs);
fTabView->AddTab(normalView);
ConfigView *miniView = new ConfigView(rect, B_TRANSLATE("Mini mode"),
ConfigView *miniView = new ConfigView(rect, B_TRANSLATE("Mini mode"),
PRV_MINI_CHANGE_COLOR, fTarget, prefs);
fTabView->AddTab(miniView);
@@ -67,19 +67,19 @@ PrefsWindow::PrefsWindow(BRect frame, const char *name,
deskbarView->ResizeTo(width, height);
fTabView->Select(0L);
fTabView->ResizeTo(deskbarView->Bounds().Width() + 16.0f,
deskbarView->Bounds().Height() +
fTabView->ResizeTo(deskbarView->Bounds().Width() + 16.0f,
deskbarView->Bounds().Height() +
fTabView->ContainerView()->Frame().top + 16.0f);
BButton *okButton = new BButton(rect, "ok", B_TRANSLATE("OK"),
BButton *okButton = new BButton(rect, "ok", B_TRANSLATE("OK"),
new BMessage(PRV_BOTTOM_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
okButton->ResizeToPreferred();
okButton->MoveTo(Bounds().Width() - 8.0f - okButton->Bounds().Width(),
Bounds().Height() - 8.0f - okButton->Bounds().Height());
topView->AddChild(okButton);
BButton *defaultsButton = new BButton(okButton->Frame(), "defaults",
B_TRANSLATE("Defaults"), new BMessage(PRV_BOTTOM_DEFAULTS),
BButton *defaultsButton = new BButton(okButton->Frame(), "defaults",
B_TRANSLATE("Defaults"), new BMessage(PRV_BOTTOM_DEFAULTS),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
defaultsButton->ResizeToPreferred();
defaultsButton->MoveBy(-defaultsButton->Bounds().Width() - 10.0f, 0.0f);
+12 -12
View File
@@ -13,9 +13,9 @@
#include "PulseApp.h"
ProgressBar::ProgressBar(BRect r, char *name) : BView(r, name, B_FOLLOW_NONE,
ProgressBar::ProgressBar(BRect r, char *name) : BView(r, name, B_FOLLOW_NONE,
B_WILL_DRAW)
{
{
previous_value = current_value = 0;
// Create 20 segments
@@ -44,11 +44,11 @@ ProgressBar::UpdateColors(int32 color, bool fade)
unsigned char blue_base = blue / 3;
for (int x = 0; x < 20; x++) {
segments[x].color.red = (uint8)(red_base + ((red - red_base)
segments[x].color.red = (uint8)(red_base + ((red - red_base)
* ((float)x / 19.0)));
segments[x].color.green = (uint8)(green_base
segments[x].color.green = (uint8)(green_base
+ ((green - green_base) * ((float)x / 19.0)));
segments[x].color.blue = (uint8)(blue_base + ((blue - blue_base)
segments[x].color.blue = (uint8)(blue_base + ((blue - blue_base)
* ((float)x / 19.0)));
segments[x].color.alpha = 0xff;
}
@@ -155,21 +155,21 @@ ProgressBar::Draw(BRect rect)
SetHighColor(dkgray, dkgray, dkgray);
BRect frame = Bounds();
StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top));
StrokeLine(BPoint(frame.left, frame.top + 1), BPoint(frame.right,
StrokeLine(BPoint(frame.left, frame.top + 1), BPoint(frame.right,
frame.top + 1));
StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.left,
StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.left,
frame.bottom));
StrokeLine(BPoint(frame.left + 1, frame.top),
StrokeLine(BPoint(frame.left + 1, frame.top),
BPoint(frame.left + 1, frame.bottom));
SetHighColor(ltgray, ltgray, ltgray);
StrokeLine(BPoint(frame.right-1, frame.top + 2),
StrokeLine(BPoint(frame.right-1, frame.top + 2),
BPoint(frame.right - 1, frame.bottom));
StrokeLine(BPoint(frame.right, frame.top + 1),
StrokeLine(BPoint(frame.right, frame.top + 1),
BPoint(frame.right, frame.bottom));
StrokeLine(BPoint(frame.left+1, frame.bottom - 1),
StrokeLine(BPoint(frame.left+1, frame.bottom - 1),
BPoint(frame.right - 1, frame.bottom - 1));
StrokeLine(BPoint(frame.left, frame.bottom),
StrokeLine(BPoint(frame.left, frame.bottom),
BPoint(frame.right, frame.bottom));
Render(true);
+1 -1
View File
@@ -37,7 +37,7 @@ class ProgressBar : public BView {
private:
void Render(bool all = false);
segment segments[20];
int32 current_value, previous_value;
};
+3 -3
View File
@@ -186,10 +186,10 @@ PulseApp::ShowAbout(bool asApplication)
BTextView* view = alert->TextView();
BFont font;
view->SetStylable(true);
view->SetStylable(true);
view->GetFont(&font);
font.SetSize(18);
font.SetFace(B_BOLD_FACE);
view->SetFontAndColor(0, name.Length(), &font);
+2 -2
View File
@@ -69,9 +69,9 @@ void PulseView::Init() {
popupmenu->SetFont(be_plain_font);
mode1 = new BMenuItem("", NULL, 0, 0);
mode2 = new BMenuItem("", NULL, 0, 0);
preferences = new BMenuItem(B_TRANSLATE("Settings" B_UTF8_ELLIPSIS),
preferences = new BMenuItem(B_TRANSLATE("Settings" B_UTF8_ELLIPSIS),
new BMessage(PV_PREFERENCES), 0, 0);
about = new BMenuItem(B_TRANSLATE("About Pulse" B_UTF8_ELLIPSIS),
about = new BMenuItem(B_TRANSLATE("About Pulse" B_UTF8_ELLIPSIS),
new BMessage(PV_ABOUT), 0, 0);
popupmenu->AddItem(mode1);
+3 -3
View File
@@ -33,13 +33,13 @@ PulseWindow::PulseWindow(BRect rect)
B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
SetPulseRate(200000);
PulseApp *pulseapp = (PulseApp *)be_app;
BRect bounds = Bounds();
fNormalPulseView = new NormalPulseView(bounds);
AddChild(fNormalPulseView);
fMiniPulseView = new MiniPulseView(bounds, "MiniPulseView",
fMiniPulseView = new MiniPulseView(bounds, "MiniPulseView",
pulseapp->prefs);
AddChild(fMiniPulseView);
@@ -97,7 +97,7 @@ PulseWindow::MessageReceived(BMessage *message)
// Otherwise launch a new preferences window
PulseApp *pulseapp = (PulseApp *)be_app;
fPrefsWindow = new PrefsWindow(pulseapp->prefs->prefs_window_rect,
B_TRANSLATE("Pulse settings"), new BMessenger(this),
B_TRANSLATE("Pulse settings"), new BMessenger(this),
pulseapp->prefs);
fPrefsWindow->Show();
break;