diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp index 0c6d0c8c10..02e7162017 100644 --- a/src/apps/deskbar/TimeView.cpp +++ b/src/apps/deskbar/TimeView.cpp @@ -37,6 +37,8 @@ All rights reserved. #include "TimeView.h" #include +#include + // for INT16_MIN and INT16_MAX #include #include @@ -69,6 +71,7 @@ TTimeView::TTimeView(float maxWidth, float height) fMaxWidth(maxWidth), fHeight(height), fOrientation(true), + fShowLevel(0), fShowSeconds(false), fShowDayOfWeek(false), fShowTimeZone(false) @@ -116,10 +119,11 @@ status_t TTimeView::Archive(BMessage* data, bool deep) const { BView::Archive(data, deep); + data->AddBool("orientation", fOrientation); + data->AddInt16("showLevel", fShowLevel); data->AddBool("showSeconds", fShowSeconds); data->AddBool("showDayOfWeek", fShowDayOfWeek); data->AddBool("showTimeZone", fShowTimeZone); - data->AddBool("orientation", fOrientation); data->AddInt32("deskbar:private_align", B_ALIGN_RIGHT); return B_OK; @@ -183,6 +187,17 @@ TTimeView::GetPreferredSize(float* width, float* height) } +void +TTimeView::Hide() +{ + // Prevent overflow + if (fShowLevel < INT16_MAX) + ++fShowLevel; + + BView::Hide(); +} + + void TTimeView::MessageReceived(BMessage* message) { @@ -292,6 +307,17 @@ TTimeView::ResizeToPreferred() } +void +TTimeView::Show() +{ + // Prevent underflow + if (fShowLevel > INT16_MIN) + --fShowLevel; + + BView::Show(); +} + + // # pragma mark - Public methods diff --git a/src/apps/deskbar/TimeView.h b/src/apps/deskbar/TimeView.h index 129b2021fb..9f28a1ca04 100644 --- a/src/apps/deskbar/TimeView.h +++ b/src/apps/deskbar/TimeView.h @@ -88,10 +88,13 @@ public: void Draw(BRect update); void FrameMoved(BPoint); void GetPreferredSize(float* width, float* height); + void Hide(); + bool IsHidden() const { return fShowLevel > 0; }; void MessageReceived(BMessage*); void MouseDown(BPoint where); void Pulse(); void ResizeToPreferred(); + void Show(); bool Orientation() const; void SetOrientation(bool o); @@ -133,16 +136,14 @@ private: float fMaxWidth; float fHeight; - bool fOrientation; // vertical = true + bool fOrientation; + // vertical = true + int16 fShowLevel; - bool fOverrideLocale; - bool fUse24HourClock; bool fShowSeconds; bool fShowDayOfWeek; bool fShowTimeZone; - BString fTimeFormat; - BPoint fTimeLocation; BPoint fDateLocation;