diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 9f46a53e61..b9ba42a4f3 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -733,15 +733,18 @@ TBarView::_ChangeState(BMessage* message) // Send a message to the preferences window to let it know to // enable or disable preference items. - if (vertSwap && fExpandoMenuBar != NULL) { - if (fVertical) { - fInlineScrollView->SetOrientation(B_VERTICAL); - fExpandoMenuBar->SetMenuLayout(B_ITEMS_IN_COLUMN); - fExpandoMenuBar->StartMonitoringWindows(); - } else { - fInlineScrollView->SetOrientation(B_HORIZONTAL); - fExpandoMenuBar->SetMenuLayout(B_ITEMS_IN_ROW); - fExpandoMenuBar->StopMonitoringWindows(); + if (vertSwap) { + fReplicantTray->fTime->SetOrientation(fVertical); + if (fExpandoMenuBar != NULL) { + if (fVertical) { + fInlineScrollView->SetOrientation(B_VERTICAL); + fExpandoMenuBar->SetMenuLayout(B_ITEMS_IN_COLUMN); + fExpandoMenuBar->StartMonitoringWindows(); + } else { + fInlineScrollView->SetOrientation(B_HORIZONTAL); + fExpandoMenuBar->SetMenuLayout(B_ITEMS_IN_ROW); + fExpandoMenuBar->StopMonitoringWindows(); + } } } } diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index 5a9d2fc093..cc3ed6e632 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -175,6 +175,7 @@ TReplicantTray::AttachedToWindow() AddChild(fTime); fTime->MoveTo(Bounds().right - fTime->Bounds().Width() - kTrayPadding, 2); + fTime->SetOrientation(fMultiRowMode); if (!((TBarApp*)be_app)->Settings()->showClock) fTime->Hide(); diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h index 14f06e5665..ccaf881929 100644 --- a/src/apps/deskbar/StatusView.h +++ b/src/apps/deskbar/StatusView.h @@ -167,6 +167,7 @@ private: status_t _SaveSettings(); friend class TReplicantShelf; + friend class TBarView; TTimeView* fTime; TBarView* fBarView; diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp index 4fb05facac..5ea67ea13b 100644 --- a/src/apps/deskbar/TimeView.cpp +++ b/src/apps/deskbar/TimeView.cpp @@ -51,6 +51,8 @@ All rights reserved. #include #include +#include "BarApp.h" +#include "StatusView.h" #include "CalendarMenuWindow.h" @@ -149,8 +151,8 @@ TTimeView::AttachedToWindow() } else SetViewUIColor(B_PANEL_BACKGROUND_COLOR); - CalculateTextPlacement(); ResizeToPreferred(); + CalculateTextPlacement(); } @@ -182,15 +184,14 @@ TTimeView::GetPreferredSize(float* width, float* height) { *height = fHeight; - GetCurrentTime(); - float timeWidth = StringWidth(fCurrentTimeStr); - // TODO: SetOrientation never gets called, fix that when in vertical mode, - // we want to limit the width so that it can't overlap the bevels in the - // parent view. - *width = fOrientation ? std::min(fMaxWidth - kHMargin, timeWidth) - : timeWidth; + if (fOrientation) { + float appWidth = static_cast(be_app)->Settings()->width; + *width = fMaxWidth + = std::min(appWidth - (kDragRegionWidth + kHMargin) * 2, timeWidth); + } else + *width = fMaxWidth = timeWidth; } @@ -312,6 +313,7 @@ void TTimeView::SetOrientation(bool orientation) { fOrientation = orientation; + ResizeToPreferred(); CalculateTextPlacement(); Invalidate(); } @@ -459,6 +461,17 @@ TTimeView::CalculateTextPlacement() fTimeLocation.y = fDateLocation.y = ceilf((bounds.Height() - rectArray[0].Height() + 1.0) / 2.0 - rectArray[0].top); + + if (fOrientation) { + float timeWidth = StringWidth(fCurrentTimeStr); + if (timeWidth > fMaxWidth) { + // time does not fit, push it over to truncate the left side + // to see the entire time string you must make the window wider + float difference = timeWidth - fMaxWidth; + fDateLocation.x -= difference; + fTimeLocation.x -= difference; + } + } } @@ -496,8 +509,8 @@ TTimeView::Update() GetCurrentDate(); SetToolTip(fCurrentDateStr); - CalculateTextPlacement(); ResizeToPreferred(); + CalculateTextPlacement(); if (fParent != NULL) fParent->Invalidate();