Fix Deskbar clock show/hide when Deskbar is hidden.
Bug #9469 happens because I set the showClock checkbox or not based on whether or not the clock is currently hidden. This works most of the time, but if Deskbar is hidden the clock is also considered to be hidden and that isn't what I want in this case. The solution is to override BView's Show(), Hide(), and IsHidden() methods in TimeView to ignore whether or not the window is hidden when considering if the clock is hidden. The commit also deletes some no-longer-used private member variables of TimeView. Fixes #9469
This commit is contained in:
@@ -37,6 +37,8 @@ All rights reserved.
|
||||
#include "TimeView.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
// for INT16_MIN and INT16_MAX
|
||||
|
||||
#include <Application.h>
|
||||
#include <Catalog.h>
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user