[haiku-commits] haiku: hrev43976 - src/apps/deskbar

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 8 Apr 2012 05:46:03 +0200 (CEST)

hrev43976 adds 1 changeset to branch 'master'
old head: 8ff49ae3169d6ccceb17ade6f1dc8037ab9e5e78
new head: d0a49328634b3702d647e27b8704a3ce706074b8

----------------------------------------------------------------------------

d0a4932: Fix a few more bugs in Deskbar, find a new one too.
  
  Hiding in horizontal mode was leaving behind a white bar because the
  window was getting hidden but the view not resized. Now fixed.
  
  Moved simple state and member access function implementations from
  BarView.cpp to BarView.h. Always use the local variable in BarView.cpp
  to avoid a function call.
  
  Rename Expando() to ExpandoState() and add FullState() and MiniState()
  methods to BarView.h.
  
  Call just PlaceApplicationBar() in vertical expando mode when resizing
  icons. Call the full UpdatePlacement() in horizontal mode because I need
  to update the height of the status tray when icons resize. Do not call
  any method in MiniState because the icons will get resized when the
  menu gets opened later.
  
  The new bug I found is a little subtle. If you hide the clock by right
  clicking on the clock and selecting Hide clock then quit deskbar with
  'hey Deskbar QUIT' and restart Deskbar with 'Deskbar' the Show seconds
  checkbox in the preference is disabled correctly, however, right clicking
  Show Clock doesn't undisable the checkbox so you can no longer hide
  seconds anymore. I'll fix this in a bit.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev43976
Commit:      d0a49328634b3702d647e27b8704a3ce706074b8
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d0a4932
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Sun Apr  8 03:37:33 2012 UTC

----------------------------------------------------------------------------

7 files changed, 59 insertions(+), 123 deletions(-)
src/apps/deskbar/BarApp.cpp            |    9 ++-
src/apps/deskbar/BarView.cpp           |  129 ++++++----------------------
src/apps/deskbar/BarView.h             |   30 ++++---
src/apps/deskbar/BarWindow.cpp         |    6 +-
src/apps/deskbar/PreferencesWindow.cpp |    2 +-
src/apps/deskbar/TeamMenuItem.cpp      |    2 +-
src/apps/deskbar/WindowMenu.cpp        |    4 +-

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index 8795c05..e63afc3 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -570,8 +570,15 @@ TBarApp::MessageReceived(BMessage* message)
 
                        ResizeTeamIcons();
 
+                       if (BarView()->MiniState())
+                               break;
+
                        fBarWindow->Lock();
-                       BarView()->PlaceApplicationBar();
+                       if (BarView()->Vertical())
+                               BarView()->PlaceApplicationBar();
+                       else
+                               BarView()->UpdatePlacement();
+
                        fBarWindow->Unlock();
                        break;
                }
diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index b15e384..adb7d01 100644
--- a/src/apps/deskbar/BarView.cpp
+++ b/src/apps/deskbar/BarView.cpp
@@ -70,13 +70,13 @@ const int32 kMenuTrackMargin = 20;
 
 
 TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
-               bool showInterval, uint32 state, float, bool showTime)
+               bool showInterval, uint32 state, float, bool showClock)
        : BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW),
        fBarMenuBar(NULL),
        fExpando(NULL),
        fTrayLocation(1),
        fShowInterval(showInterval),
-       fShowClock(showTime),
+       fShowClock(showClock),
        fVertical(vertical),
        fTop(top),
        fLeft(left),
@@ -143,7 +143,7 @@ TBarView::Draw(BRect)
        else if (AcrossBottom())
                StrokeLine(bounds.LeftTop(), bounds.RightTop());
 
-       if (Vertical() && Expando()) {
+       if (fVertical && fState == kExpandoState) {
                SetHighColor(hilite);
                BRect frame(fExpando->Frame());
                StrokeLine(BPoint(frame.left, frame.top - 1),
@@ -200,8 +200,7 @@ TBarView::MouseMoved(BPoint where, uint32 transit, const 
BMessage* dragMessage)
 
        // Auto-Raise
        where = ConvertToScreen(where);
-       BScreen screen(Window());
-       BRect screenFrame = screen.Frame();
+       BRect screenFrame = (BScreen(Window())).Frame();
        if ((where.x == screenFrame.left || where.x == screenFrame.right
                        || where.y == screenFrame.top || where.y == 
screenFrame.bottom)
                && Window()->Frame().Contains(where)) {
@@ -276,7 +275,7 @@ TBarView::PlaceDeskbarMenu()
        // only for vertical mini or expanded
        // mini mode will have team menu added as part of BarMenuBar
        if (fVertical && !fBarMenuBar) {
-               //      create the Be menu
+               // create the Be menu
                BRect mbarFrame(Bounds());
                mbarFrame.bottom = mbarFrame.top + kMenuBarHeight;
                fBarMenuBar = new TBarMenuBar(this, mbarFrame, "BarMenuBar");
@@ -341,7 +340,7 @@ TBarView::PlaceTray(bool vertSwap, bool leftSwap)
                if (fVertical) {
                        statusLoc.y = fBarMenuBar->Frame().bottom + 1;
                        statusLoc.x = 0;
-                       if (Left() && Vertical())
+                       if (fLeft && fVertical)
                                fReplicantTray->MoveTo(5, 2);
                        else
                                fReplicantTray->MoveTo(2, 2);
@@ -420,11 +419,20 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, 
float* width, float* height)
 {
        float windowHeight = 0;
        float windowWidth = sMinimumWindowWidth;
-       bool calcHiddenSize = ((TBarApp*)be_app)->Settings()->autoHide
+       bool setToHiddenSize = ((TBarApp*)be_app)->Settings()->autoHide
                && IsHidden() && !DragRegion()->IsDragging();
        int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
 
-       if (!calcHiddenSize) {
+       if (setToHiddenSize) {
+               windowHeight = kHiddenDimension;
+
+               if (fState == kExpandoState && !fVertical) {
+                       // top or bottom, full
+                       fExpando->CheckItemSizes(0);
+                       windowWidth = screenFrame.Width();
+               } else
+                       windowWidth = kHiddenDimension;
+       } else {
                if (fState == kFullState) {
                        windowHeight = screenFrame.bottom;
                        windowWidth = fBarMenuBar->Frame().Width();
@@ -445,16 +453,6 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* 
width, float* height)
                        else
                                windowHeight = fBarMenuBar->Frame().bottom;
                }
-       } else {
-               windowHeight = kHModeHiddenHeight;
-
-               if (fState == kExpandoState && !fVertical) {
-                       // top or bottom, full
-                       fExpando->CheckItemSizes(0);
-                       windowHeight = iconSize + 4;
-                       windowWidth = screenFrame.Width();
-               } else
-                       windowWidth = kHModeHiddenHeight;
        }
 
        *width = windowWidth;
@@ -501,13 +499,13 @@ TBarView::SaveSettings()
 {
        desk_settings* settings = ((TBarApp*)be_app)->Settings();
 
-       settings->vertical = Vertical();
-       settings->left = Left();
-       settings->top = Top();
-       settings->ampmMode = MilTime();
-       settings->state = (uint32)State();
+       settings->vertical = fVertical;
+       settings->left = fLeft;
+       settings->top = fTop;
+       settings->ampmMode = fShowInterval;
+       settings->state = (uint32)fState;
        settings->width = 0;
-       settings->showTime = ShowingClock();
+       settings->showTime = fShowClock;
 
        fReplicantTray->RememberClockSettings();
 }
@@ -584,7 +582,7 @@ TBarView::RemoveExpandedItems()
 void
 TBarView::ExpandItems()
 {
-       if (fExpando == NULL || !fVertical || !Expando()
+       if (fExpando == NULL || !fVertical || fState != kExpandoState
                || !static_cast<TBarApp*>(be_app)->Settings()->superExpando
                || fExpandedItems.CountItems() <= 0)
                return;
@@ -653,8 +651,7 @@ TBarView::RaiseDeskbar(bool raise)
 void
 TBarView::HideDeskbar(bool hide)
 {
-       BScreen screen(Window());
-       BRect screenFrame = screen.Frame();
+       BRect screenFrame = (BScreen(Window())).Frame();
 
        if (hide) {
                Hide();
@@ -668,80 +665,6 @@ TBarView::HideDeskbar(bool hide)
 }
 
 
-// window placement functions
-
-bool
-TBarView::Vertical() const
-{
-       return fVertical;
-}
-
-
-bool
-TBarView::Left() const
-{
-       return fLeft;
-}
-
-
-bool
-TBarView::AcrossTop() const
-{
-       return fTop && !fVertical;
-}
-
-
-bool
-TBarView::AcrossBottom() const
-{
-       return !fTop && !fVertical;
-}
-
-
-bool
-TBarView::Expando() const
-{
-       return fState == kExpandoState;
-}
-
-
-bool
-TBarView::Top() const
-{
-       return fTop;
-}
-
-
-int32
-TBarView::State() const
-{
-       return fState;
-}
-
-
-// optional functionality functions
-
-bool
-TBarView::MilTime() const
-{
-       return fShowInterval;
-}
-
-
-void
-TBarView::ShowClock(bool on)
-{
-       fShowClock = on;
-}
-
-
-bool
-TBarView::ShowingClock() const
-{
-       return fShowClock;
-}
-
-
 //     #pragma mark - Drag and Drop
 
 
@@ -1002,7 +925,7 @@ TBarView::HandleDeskbarMenu(BMessage* 
messagewithdestination)
                return;
 
        // in mini-mode
-       if (Vertical() && !Expando()) {
+       if (fVertical && fState != kExpandoState) {
                // if drop is in the team menu, bail
                if (fBarMenuBar->CountItems() >= 2) {
                        uint32 buttons;
diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h
index d81d1aa..065ff6b 100644
--- a/src/apps/deskbar/BarView.h
+++ b/src/apps/deskbar/BarView.h
@@ -57,7 +57,7 @@ const float kMiniHeight = 46.0f;
 const float kHModeHeight = 21.0f;
 const float kMenuBarHeight = 21.0f;
 const float kStatusHeight = 22.0f;
-const float kHModeHiddenHeight = 1.0f;
+const float kHiddenDimension = 1.0f;
 const float kMaxPreventHidingDist = 80.0f;
 
 class BShelf;
@@ -89,17 +89,23 @@ class TBarView : public BView {
                void RaiseDeskbar(bool raise);
                void HideDeskbar(bool hide);
 
-               bool Vertical() const;
-               bool Left() const;
-               bool Top() const;
-               bool AcrossTop() const;
-               bool AcrossBottom() const;
-               bool Expando() const;
-               int32 State() const;
-
-               bool MilTime() const;
-               void ShowClock(bool);
-               bool ShowingClock() const;
+               // window placement methods
+               bool Vertical() const { return fVertical; };
+               bool Left() const { return fLeft; };
+               bool Top() const { return fTop; };
+               bool AcrossTop() const { return fTop && !fVertical; };
+               bool AcrossBottom() const { return !fTop && !fVertical; };
+
+               // window state methods
+               bool ExpandoState() const { return fState == kExpandoState; };
+               bool FullState() const { return fState == kFullState; };
+               bool MiniState() const { return fState == kMiniState; };
+               int32 State() const { return fState; };
+
+               // optional functionality methods
+               bool MilTime() const { return fShowInterval; };
+               void ShowClock(bool show) { fShowClock = show; };
+               bool ShowingClock() const { return fShowClock; };
 
                void CacheDragData(const BMessage* incoming);
                status_t DragStart();
diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp
index af65feb..fe5cec6 100644
--- a/src/apps/deskbar/BarWindow.cpp
+++ b/src/apps/deskbar/BarWindow.cpp
@@ -252,7 +252,7 @@ TBarWindow::WorkspaceActivated(int32 workspace, bool active)
 {
        BWindow::WorkspaceActivated(workspace, active);
 
-       if (active && !(fBarView->Expando() && fBarView->Vertical()))
+       if (active && !(fBarView->ExpandoState() && fBarView->Vertical()))
                fBarView->UpdatePlacement();
        else {
                BRect screenFrame = (BScreen(fBarView->Window())).Frame();
@@ -346,7 +346,7 @@ TBarWindow::GetLocation(BMessage* message)
 {
        BMessage reply('rply');
        reply.AddInt32("location", (int32)DeskbarLocation());
-       reply.AddBool("expanded", fBarView->Expando());
+       reply.AddBool("expanded", fBarView->ExpandoState());
 
        message->SendReply(&reply);
 }
@@ -430,7 +430,7 @@ void
 TBarWindow::IsExpanded(BMessage* message)
 {
        BMessage reply('rply');
-       reply.AddBool("expanded", fBarView->Expando());
+       reply.AddBool("expanded", fBarView->ExpandoState());
        message->SendReply(&reply);
 }
 
diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index 8140a87..38947ac 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -302,7 +302,7 @@ PreferencesWindow::_EnableDisableDependentItems()
 {
        TBarApp* barApp = static_cast<TBarApp*>(be_app);
        if (barApp->BarView()->Vertical()
-               && barApp->BarView()->Expando()) {
+               && barApp->BarView()->ExpandoState()) {
                fAppsShowExpanders->SetEnabled(true);
                fAppsExpandNew->SetEnabled(fAppsShowExpanders->Value());
        } else {
diff --git a/src/apps/deskbar/TeamMenuItem.cpp 
b/src/apps/deskbar/TeamMenuItem.cpp
index 982d19d..a98a523 100644
--- a/src/apps/deskbar/TeamMenuItem.cpp
+++ b/src/apps/deskbar/TeamMenuItem.cpp
@@ -404,7 +404,7 @@ TTeamMenuItem::DrawContent()
        // Draw the expandable icon.
        TBarView* barView = (static_cast<TBarApp*>(be_app))->BarView();
        if (fVertical && static_cast<TBarApp*>(be_app)->Settings()->superExpando
-               && barView->Expando()) {
+               && barView->ExpandoState()) {
                BRect frame(Frame());
                BRect rect(0, 0, kSwitchWidth, 10);
                rect.OffsetTo(BPoint(frame.right - rect.Width(),
diff --git a/src/apps/deskbar/WindowMenu.cpp b/src/apps/deskbar/WindowMenu.cpp
index 0e2cf2d..7ce5c02 100644
--- a/src/apps/deskbar/WindowMenu.cpp
+++ b/src/apps/deskbar/WindowMenu.cpp
@@ -105,7 +105,7 @@ TWindowMenu::AttachedToWindow()
                        // and then.
                        Window()->Hide();
                        // if in expando (horizontal or vertical)
-                       if (barview->Expando()) {
+                       if (barview->ExpandoState()) {
                                SetTrackingHook(barview->MenuTrackingHook,
                                        barview->GetTrackingHookData());
                        }
@@ -232,7 +232,7 @@ TWindowMenu::DetachedFromWindow()
        // in expando mode the teammenu will not call DragStop, thus, it needs 
to
        // be called from here
        TBarView* barview = (dynamic_cast<TBarApp*>(be_app))->BarView();
-       if (barview && barview->Expando() && barview->Dragging()
+       if (barview && barview->ExpandoState() && barview->Dragging()
                && barview->LockLooper()) {
                // We changed the show level in AttachedToWindow(). Undo it.
                Window()->Show();


Other related posts:

  • » [haiku-commits] haiku: hrev43976 - src/apps/deskbar - jscipione