[haiku-commits] haiku: hrev51524 - in src/apps: deskbar powerstatus

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 6 Nov 2017 06:20:58 +0100 (CET)

hrev51524 adds 11 changesets to branch 'master'
old head: 9df5205c653cecdeefb1d948a9b33ef373e3af39
new head: 2d27c2d003a154f7ad375446e2c6dd291cf97018
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=2d27c2d003a1+%5E9df5205c653c

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

70ad528943bd: Deskbar: Position clock & replicants better
  
  This fixes some subtle layout issues. The replicant icon
  positions and clock position has been made more consistent
  in both vertical mode, and horizontal mode.
  
  There is a fixed amount of space between the last replicant
  and the clock before it wraps to next row. This now works
  at different font sizes.
  
  Use matching 3px of space between the clock and the dragger
  on one side and and between the replicant and the dragger
  on the other side.
  
  Reparent ResizeControl from ReplicantTray onto DragRegion and
  readjust everything.

c3c3360f40a6: Deskbar and PowerStatus: style updates
  
  80 char limit in BarApp.cpp
  2 newlines and remove unnecessary curly braces in StatusView.cpp
  
  Replicant: tiny whitespace style fix and remove trailing tab chars

c0dc265c3b39: Deskbar & PowerStatus: Realign Replicants
  
  Added a new message constant to Deskbar kRealignReplicants which
  is called to realign replicant icons. Add routing so that if you knock on
  Deskbar's front door (Application) it will get routed to the right view, in
  this case the repliant tray that knows how to realign replicants.
  
  Send a message with this newly created constant in PowerStatus when
  the width changes because you turned the label on or off. This makes
  it so that when you show or hide the battery percentage it will not overrun
  the clock.
  
  Realign Replicants is a common case.
  
  Fixes the rest of #8641

3b8cb3003417: Deskbar: Set app menu width to drag region width
  
  ...in vertical mode. This is a simplication that is possible because
  I am confident that the drag region is the right size at this point
  so we don't have to lookup the window width or app width setting.
  
  This led to further code simplications to vertical frame sizing.
  Use MenuBar frame for right dimension always because it is set even
  if fTrayLocation were to be set to 0.

c62a389196c2: PowerStatus: Make battery 16x16 in Deskbar
  
  Frame was a bit wider than it needed to be to fit, battery is same
  size as before.
  
  Moved the lightning right 1px and down 1px to fit better
  
  expands to show battery percentage more compactly as well.

32b0035a9ffe: Deskbar: Rename some methods, variables, and call method
  
  Rename IconCount() method to ReplicantCount()
  
  Rename fChild and child to fReplicantTray and replicantTray

d8357181eb2b: Minor whitespace style fix in TReplicantTray class
  
  spacing private variables, no functional change intended.

a44504a16854: Deskbar: Refactor TRelicantTray::LocationForReplicant()
  
  * if index == 0 return right away, no calculation required.
  * rename rect to rowRect then copy it into replicantRect.
    - This makes it clearer to me what's going on.
  * don't have to check if index > 0 in horizontal mode anymore since
    we are checking it upfront.
  * introduce replicantWidth variable for understanding
  * reduce indent
  
  Was calculating the height in multi-row mode twice. Instead, use
  the saved height, if that isn't set calculate height as before,
  if no replicants, use minimum height (16px) and don't calculate.

7b7bf68d7134: Deskbar: create new constant kClockMargin and use it
  
  defines the (minimum) margin between clock and replicant icons
  
  Was used in a couple different forms, now all in 1 constant

c0be54904f3e: Deskbar: Fix bug calculating position of replicant icons
  
  ...in horizontal mode.
  
  fTime->Frame().left was not in the correct position because the
  window isn't yet done resizing. Instead calculate left from the
  right edge of the drag region instead.

2d27c2d003a1: Deskbar: Fix bug where items are sometimes wrong size
  
  in vertical mode because the menu's MaxContentWidth is too small.
  
  Fixes #13715

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

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

10 files changed, 168 insertions(+), 132 deletions(-)
src/apps/deskbar/BarApp.cpp              |   4 +-
src/apps/deskbar/BarApp.h                |   3 +
src/apps/deskbar/BarView.cpp             |  61 ++++++-----
src/apps/deskbar/DeskbarMenu.cpp         |   1 +
src/apps/deskbar/ExpandoMenuBar.cpp      |   5 +-
src/apps/deskbar/StatusView.cpp          | 156 ++++++++++++++-------------
src/apps/deskbar/StatusView.h            |  22 ++--
src/apps/deskbar/TimeView.cpp            |   8 +-
src/apps/powerstatus/PowerStatus.cpp     |   2 +-
src/apps/powerstatus/PowerStatusView.cpp |  38 ++++---

############################################################################

Commit:      70ad528943bd5953fb5fef835402841b281cf69c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=70ad528943bd
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Thu Oct 19 23:07:34 2017 UTC

Deskbar: Position clock & replicants better

This fixes some subtle layout issues. The replicant icon
positions and clock position has been made more consistent
in both vertical mode, and horizontal mode.

There is a fixed amount of space between the last replicant
and the clock before it wraps to next row. This now works
at different font sizes.

Use matching 3px of space between the clock and the dragger
on one side and and between the replicant and the dragger
on the other side.

Reparent ResizeControl from ReplicantTray onto DragRegion and
readjust everything.

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

diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index 8f57856..64f478d 100644
--- a/src/apps/deskbar/BarView.cpp
+++ b/src/apps/deskbar/BarView.cpp
@@ -160,16 +160,22 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, 
bool top,
        fBarMenuBar = new TBarMenuBar(menuFrame, "BarMenuBar", this);
        AddChild(fBarMenuBar);
 
-       // create and add the status tray
+       // create the status tray
        fReplicantTray = new TReplicantTray(this, fVertical);
+
+       // create the resize control
+       fResizeControl = new TResizeControl(this);
+
+       // create the drag region and add the resize control
+       // and replicant tray to it
        fDragRegion = new TDragRegion(this, fReplicantTray);
+       fDragRegion->AddChild(fResizeControl);
        fDragRegion->AddChild(fReplicantTray);
+
+       // Add the drag region
        if (fTrayLocation != 0)
                AddChild(fDragRegion);
 
-       fResizeControl = new TResizeControl(this);
-       fReplicantTray->AddChild(fResizeControl);
-
        // create and add the application menubar
        fExpandoMenuBar = new TExpandoMenuBar(this, fVertical);
        fInlineScrollView = new TInlineScrollView(fExpandoMenuBar,
@@ -455,15 +461,27 @@ TBarView::PlaceTray(bool vertSwap, bool leftSwap)
                fReplicantTray->SetMultiRow(fVertical);
                fReplicantTray->RealignReplicants();
                fDragRegion->ResizeToPreferred();
+                       // also resizes replicant tray
 
-               fResizeControl->ResizeTo(kDragWidth, 
fDragRegion->Bounds().Height());
+               fResizeControl->ResizeTo(kDragWidth, 
fDragRegion->Bounds().Height()
+                       - 2); // make room for top and bottom border
 
                if (fVertical) {
                        if (fResizeControl->IsHidden())
                                fResizeControl->Show();
-                       // move replicant tray past dragger width on left
-                       // also down 1 pixel so that it won't cover the border
-                       fReplicantTray->MoveTo(fLeft ? kDragWidth + kGutter : 
0, kGutter);
+
+                       if (fLeft) {
+                               // move replicant tray past dragger width on 
left
+                               // also down 1px so it won't cover the border
+                               fReplicantTray->MoveTo(kDragWidth + kGutter, 
kGutter);
+
+                               // shrink width by same amount
+                               fReplicantTray->ResizeBy(-(kDragWidth + 
kGutter), 0);
+                       } else {
+                               // move replicant tray down 1px so it won't 
cover the border
+                               fReplicantTray->MoveTo(0, kGutter);
+                       }
+
                        statusLoc.x = 0;
                        statusLoc.y = fBarMenuBar->Frame().bottom + 1;
                } else {
@@ -481,9 +499,9 @@ TBarView::PlaceTray(bool vertSwap, bool leftSwap)
                fDragRegion->Invalidate();
 
                if (fVertical && fLeft)
-                       fResizeControl->MoveTo(fReplicantTray->Bounds().right - 
3, 0);
+                       fResizeControl->MoveTo(fDragRegion->Bounds().right - 
kDragWidth, 1);
                else
-                       fResizeControl->MoveTo(0, 0);
+                       fResizeControl->MoveTo(0, 1);
 
                fResizeControl->Invalidate();
        }
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index 5fd30a0..112ce97 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -173,11 +173,7 @@ TReplicantTray::AttachedToWindow()
 
        AddChild(fTime);
 
-       float deltaX = Bounds().right - fTime->Bounds().Width() - 1;
-       if (fBarView->Vertical() && !fBarView->Left())
-               deltaX -= kDragWidth;
-
-       fTime->MoveTo(deltaX, 2);
+       fTime->MoveTo(Bounds().right - fTime->Bounds().Width() - kTrayPadding, 
2);
 
        if (!((TBarApp*)be_app)->Settings()->showClock)
                fTime->Hide();
@@ -234,7 +230,7 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, 
float* preferredHeight)
                                width = fRightBottomReplicant.right + 12
                                        + fTime->Frame().Width();
                        } else
-                               width = fRightBottomReplicant.right + 3;
+                               width = fRightBottomReplicant.right + kIconGap 
+ kGutter;
                }
 
                // this view has a fixed minimum width
@@ -1156,11 +1152,12 @@ TReplicantTray::AcceptAddon(BRect replicantFrame, 
BMessage* message)
 BPoint
 TReplicantTray::LocationForReplicant(int32 index, float width)
 {
-       BPoint loc(kIconGap + 1, kGutter + 1);
-       if (fBarView->Vertical() && !fBarView->Left())
-               loc.x += kDragWidth;
-       else if (!fBarView->Vertical())
-               loc.x += kGutter;
+       BPoint loc(kTrayPadding, 2);
+       if (fBarView->Vertical()) {
+               if (!fBarView->Left())
+                       loc.x += kDragWidth; // move past dragger
+       } else
+               loc.x += 1; // keeps everything lined up nicely
 
        if (fMultiRowMode) {
                // try to find free space in every row
@@ -1168,11 +1165,11 @@ TReplicantTray::LocationForReplicant(int32 index, float 
width)
                        // determine free space in this row
                        BRect rect(loc.x, loc.y,
                                loc.x + 
static_cast<TBarApp*>(be_app)->Settings()->width
-                                       - kDragRegionWidth - kGutter,
+                                       - kDragRegionWidth * 2,
                                loc.y + kMaxReplicantHeight);
                        if (row == 0 && !fTime->IsHidden()) {
-                               rect.right -= fTime->Frame().Width() + 
kDragRegionWidth
-                                       + kIconGap + kDragWidth;
+                               rowRect.right -= kClockMargin + 
fTime->Frame().Width()
+                                       + kTrayPadding;
                        }
 
                        for (int32 i = 0; i < index; i++) {
@@ -1347,7 +1344,7 @@ TDragRegion::GetPreferredSize(float* width, float* height)
 
 
 void
-TDragRegion::Draw(BRect)
+TDragRegion::Draw(BRect updateRect)
 {
        rgb_color menuColor = ViewColor();
        rgb_color hilite = tint_color(menuColor, B_DARKEN_1_TINT);
diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h
index 888989a..6c1761f 100644
--- a/src/apps/deskbar/StatusView.h
+++ b/src/apps/deskbar/StatusView.h
@@ -53,6 +53,7 @@ const int32 kMinimumReplicantCount = 6;
 const int32 kIconGap = 2;
 const int32 kGutter = 1;
 const int32 kDragRegionWidth = 6;
+const int32 kTrayPadding = 3;
 
 // 1 pixel for left gutter
 // space for replicant tray (6 items)
diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp
index b811ce7..4187a91 100644
--- a/src/apps/deskbar/TimeView.cpp
+++ b/src/apps/deskbar/TimeView.cpp
@@ -178,13 +178,13 @@ TTimeView::GetPreferredSize(float* width, float* height)
 
        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,
-                       kHMargin + StringWidth(fCurrentTimeStr))
-               : kHMargin + StringWidth(fCurrentTimeStr);
+       *width = fOrientation ? std::min(fMaxWidth - kHMargin, timeWidth)
+               : timeWidth;
 }
 
 

############################################################################

Commit:      c3c3360f40a6d4fc4045d02065de2abef819b0da
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c3c3360f40a6
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Thu Oct 19 23:42:46 2017 UTC

Deskbar and PowerStatus: style updates

80 char limit in BarApp.cpp
2 newlines and remove unnecessary curly braces in StatusView.cpp

Replicant: tiny whitespace style fix and remove trailing tab chars

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

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index daad133..c6949f9 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -475,7 +475,8 @@ TBarApp::MessageReceived(BMessage* message)
                        if (fPreferencesWindow != NULL)
                                
fPreferencesWindow->PostMessage(kUpdatePreferences);
 
-                       fBarWindow->SetFeel(fSettings.alwaysOnTop ? 
B_FLOATING_ALL_WINDOW_FEEL
+                       fBarWindow->SetFeel(fSettings.alwaysOnTop
+                               ? B_FLOATING_ALL_WINDOW_FEEL
                                : B_NORMAL_WINDOW_FEEL);
                        break;
 
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index 112ce97..6d720fa 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -90,6 +90,7 @@ const char* const kReplicantPathField = "replicant_path";
 float gMinimumWindowWidth = kGutter + kMinimumTrayWidth + kDragRegionWidth;
 float gMaximumWindowWidth = gMinimumWindowWidth * 2;
 
+
 static void
 DumpItem(DeskbarItemInfo* item)
 {
@@ -271,7 +272,6 @@ TReplicantTray::MessageReceived(BMessage* message)
 {
        switch (message->what) {
                case B_LOCALE_CHANGED:
-               {
                        if (fTime == NULL)
                                return;
 
@@ -281,7 +281,6 @@ TReplicantTray::MessageReceived(BMessage* message)
                        RealignReplicants();
                        AdjustPlacement();
                        break;
-               }
 
                case kShowHideTime:
                        // from context menu in clock and in this view
diff --git a/src/apps/powerstatus/PowerStatus.cpp 
b/src/apps/powerstatus/PowerStatus.cpp
index 06b9355..bf342b0 100644
--- a/src/apps/powerstatus/PowerStatus.cpp
+++ b/src/apps/powerstatus/PowerStatus.cpp
@@ -84,7 +84,7 @@ PowerStatus::ReadyToRun()
                isInstalled = deskbar.HasItem(kDeskbarItemName);
        }
 
-       if (isDeskbarRunning && !isInstalled) {         
+       if (isDeskbarRunning && !isInstalled) {
                BAlert* alert = new BAlert("", 
                        B_TRANSLATE("You can run PowerStatus in a window "
                        "or install it in the Deskbar."), B_TRANSLATE("Run in 
window"),

############################################################################

Commit:      c0dc265c3b3917a3eca1c7f2f952f7e8b2e8b4dc
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c0dc265c3b39
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Thu Oct 19 23:48:32 2017 UTC

Ticket:      https://dev.haiku-os.org/ticket/8641

Deskbar & PowerStatus: Realign Replicants

Added a new message constant to Deskbar kRealignReplicants which
is called to realign replicant icons. Add routing so that if you knock on
Deskbar's front door (Application) it will get routed to the right view, in
this case the repliant tray that knows how to realign replicants.

Send a message with this newly created constant in PowerStatus when
the width changes because you turned the label on or off. This makes
it so that when you show or hide the battery percentage it will not overrun
the clock.

Realign Replicants is a common case.

Fixes the rest of #8641

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

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index c6949f9..03ff770 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -660,6 +660,7 @@ TBarApp::MessageReceived(BMessage* message)
                }
                // fall-through
 
+               case kRealignReplicants:
                case kShowHideTime:
                case kShowSeconds:
                case kShowDayOfWeek:
diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
index 362b62d..d857638 100644
--- a/src/apps/deskbar/BarApp.h
+++ b/src/apps/deskbar/BarApp.h
@@ -76,6 +76,9 @@ const int32 kIconCacheCount = (kMaximumIconSize - 
kMinimumIconSize)
 // update preferences message constant
 const uint32 kUpdatePreferences = 'Pref';
 
+// realign replicants message constant
+const uint32 kRealignReplicants = 'Algn';
+
 /* --------------------------------------------- */
 
 class BBitmap;
diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index 64f478d..22b0aaa 100644
--- a/src/apps/deskbar/BarView.cpp
+++ b/src/apps/deskbar/BarView.cpp
@@ -251,6 +251,7 @@ TBarView::MessageReceived(BMessage* message)
 {
        switch (message->what) {
                case B_LOCALE_CHANGED:
+               case kRealignReplicants:
                case kShowHideTime:
                case kShowSeconds:
                case kShowDayOfWeek:
diff --git a/src/apps/deskbar/DeskbarMenu.cpp b/src/apps/deskbar/DeskbarMenu.cpp
index 144b1bc..ac4a288 100644
--- a/src/apps/deskbar/DeskbarMenu.cpp
+++ b/src/apps/deskbar/DeskbarMenu.cpp
@@ -379,6 +379,7 @@ TDeskbarMenu::ResetTargets()
                                case kRebootSystem:
                                case kSuspendSystem:
                                case kShutdownSystem:
+                               case kRealignReplicants:
                                case kShowHideTime:
                                case kShowSeconds:
                                case kShowDayOfWeek:
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index 6d720fa..7321ac6 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -276,11 +276,8 @@ TReplicantTray::MessageReceived(BMessage* message)
                                return;
 
                        fTime->Update();
-
                        // time string reformat -> realign
-                       RealignReplicants();
-                       AdjustPlacement();
-                       break;
+                       goto realignReplicants;
 
                case kShowHideTime:
                        // from context menu in clock and in this view
@@ -294,9 +291,7 @@ TReplicantTray::MessageReceived(BMessage* message)
                        fTime->SetShowSeconds(!fTime->ShowSeconds());
 
                        // time string reformat -> realign
-                       RealignReplicants();
-                       AdjustPlacement();
-                       break;
+                       goto realignReplicants;
 
                case kShowDayOfWeek:
                        if (fTime == NULL)
@@ -305,9 +300,7 @@ TReplicantTray::MessageReceived(BMessage* message)
                        fTime->SetShowDayOfWeek(!fTime->ShowDayOfWeek());
 
                        // time string reformat -> realign
-                       RealignReplicants();
-                       AdjustPlacement();
-                       break;
+                       goto realignReplicants;
 
                case kShowTimeZone:
                        if (fTime == NULL)
@@ -316,9 +309,7 @@ TReplicantTray::MessageReceived(BMessage* message)
                        fTime->SetShowTimeZone(!fTime->ShowTimeZone());
 
                        // time string reformat -> realign
-                       RealignReplicants();
-                       AdjustPlacement();
-                       break;
+                       goto realignReplicants;
 
                case kGetClockSettings:
                {
@@ -345,6 +336,12 @@ TReplicantTray::MessageReceived(BMessage* message)
                        break;
 #endif
 
+               case kRealignReplicants:
+realignReplicants:
+                       RealignReplicants();
+                       AdjustPlacement();
+                       break;
+
                default:
                        BView::MessageReceived(message);
                        break;
diff --git a/src/apps/powerstatus/PowerStatusView.cpp 
b/src/apps/powerstatus/PowerStatusView.cpp
index 8539a24..a13edc3 100644
--- a/src/apps/powerstatus/PowerStatusView.cpp
+++ b/src/apps/powerstatus/PowerStatusView.cpp
@@ -440,8 +440,20 @@ PowerStatusView::Update(bool force)
                        width = 8;
                }
 
-               if (width != Bounds().Width())
+               if (width != Bounds().Width()) {
                        ResizeTo(width, Bounds().Height());
+
+                       // inform Deskbar that it needs to realign its 
replicants
+                       BWindow* window = Window();
+                       if (window != NULL) {
+                               BView* view = window->FindView("Status");
+                               if (view != NULL) {
+                                       BMessenger target((BHandler*)view);
+                                       BMessage realignReplicants('Algn');
+                                       target.SendMessage(&realignReplicants);
+                               }
+                       }
+               }
        }
 
        if (force || wasOnline != fOnline

############################################################################

Commit:      3b8cb30034177fb5667554ba4b71d22a6bf7a618
URL:         http://cgit.haiku-os.org/haiku/commit/?id=3b8cb3003417
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Sat Oct 21 06:52:08 2017 UTC

Deskbar: Set app menu width to drag region width

...in vertical mode. This is a simplication that is possible because
I am confident that the drag region is the right size at this point
so we don't have to lookup the window width or app width setting.

This led to further code simplications to vertical frame sizing.
Use MenuBar frame for right dimension always because it is set even
if fTrayLocation were to be set to 0.

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

diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index 22b0aaa..3fb1b84 100644
--- a/src/apps/deskbar/BarView.cpp
+++ b/src/apps/deskbar/BarView.cpp
@@ -529,19 +529,12 @@ TBarView::PlaceApplicationBar()
        BRect expandoFrame(0, 0, 0, 0);
        if (fVertical) {
                // left or right
-               if (fTrayLocation != 0) {
-                       expandoFrame.left = fDragRegion->Frame().left;
-                       expandoFrame.top = fDragRegion->Frame().bottom + 1;
-               } else {
-                       expandoFrame.left = fDragRegion->Frame().left;
-                       expandoFrame.top = fBarMenuBar->Frame().bottom + 1;
-               }
-
-               expandoFrame.right = expandoFrame.left + (Window() != NULL
-                       ? Window()->Frame().Width() : 
fBarApp->Settings()->width);
-               expandoFrame.bottom = fState == kFullState
-                       ? screenFrame.bottom
-                       : expandoFrame.top;
+               expandoFrame.left = fDragRegion->Frame().left;
+               expandoFrame.top = fTrayLocation != 0 ? 
fDragRegion->Frame().bottom + 1
+                       : fBarMenuBar->Frame().bottom + 1;
+               expandoFrame.right = fBarMenuBar->Frame().right;
+               expandoFrame.bottom = fState == kFullState ? screenFrame.bottom
+                       : Frame().bottom;
        } else {
                // top or bottom
                expandoFrame.top = 0;

############################################################################

Commit:      c62a389196c25c864358cefb34a5bca5f778d3d4
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c62a389196c2
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Sun Oct 22 02:13:55 2017 UTC

PowerStatus: Make battery 16x16 in Deskbar

Frame was a bit wider than it needed to be to fit, battery is same
size as before.

Moved the lightning right 1px and down 1px to fit better

expands to show battery percentage more compactly as well.

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

diff --git a/src/apps/powerstatus/PowerStatusView.cpp 
b/src/apps/powerstatus/PowerStatusView.cpp
index a13edc3..31ff712 100644
--- a/src/apps/powerstatus/PowerStatusView.cpp
+++ b/src/apps/powerstatus/PowerStatusView.cpp
@@ -241,12 +241,12 @@ PowerStatusView::_DrawBattery(BRect rect)
                SetScale(std::min(Bounds().Width(), Bounds().Height()) / 16);
 
                static const BPoint points[] = {
-                       BPoint(2, 13),
-                       BPoint(9, 5),
-                       BPoint(9, 7),
-                       BPoint(16, 2),
-                       BPoint(8, 11),
-                       BPoint(8, 9)
+                       BPoint(3, 14),
+                       BPoint(10, 6),
+                       BPoint(10, 8),
+                       BPoint(17, 3),
+                       BPoint(9, 12),
+                       BPoint(9, 10)
                };
                FillPolygon(points, 6);
 
@@ -286,9 +286,9 @@ PowerStatusView::Draw(BRect updateRect)
                iconRect = Bounds();
                if (showLabel) {
                        if (below)
-                               iconRect.bottom -= textHeight + 4;
+                               iconRect.bottom -= textHeight + 2;
                        else
-                               iconRect.right -= textWidth + 4;
+                               iconRect.right -= textWidth + 2;
                }
 
                // make a square
@@ -395,15 +395,15 @@ PowerStatusView::Update(bool force)
        }
 
        if (fInDeskbar) {
-               // make sure the tray icon is large enough
-               float width = fShowStatusIcon ? kMinIconWidth + 2 : 0;
+               // make sure the tray icon is (just) large enough
+               float width = fShowStatusIcon ? kMinIconWidth - 1 : 0;
 
                if (fShowLabel) {
                        char text[64];
                        _SetLabel(text, sizeof(text));
 
                        if (text[0])
-                               width += ceilf(StringWidth(text)) + 4;
+                               width += ceilf(StringWidth(text)) + 2;
                } else {
                        char text[256];
                        const char* open = "";
@@ -435,7 +435,7 @@ PowerStatusView::Update(bool force)
                                strcpy(text, B_TRANSLATE("no battery"));
                        SetToolTip(text);
                }
-               if (width == 0) {
+               if (width < 8) {
                        // make sure we're not going away completely
                        width = 8;
                }

############################################################################

Commit:      32b0035a9ffedb1d062be485307b84ff0e83b885
URL:         http://cgit.haiku-os.org/haiku/commit/?id=32b0035a9ffe
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Oct 24 03:55:52 2017 UTC

Deskbar: Rename some methods, variables, and call method

Rename IconCount() method to ReplicantCount()

Rename fChild and child to fReplicantTray and replicantTray

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

diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index 3fb1b84..9f46a53 100644
--- a/src/apps/deskbar/BarView.cpp
+++ b/src/apps/deskbar/BarView.cpp
@@ -488,6 +488,7 @@ TBarView::PlaceTray(bool vertSwap, bool leftSwap)
                } else {
                        if (!fResizeControl->IsHidden())
                                fResizeControl->Hide();
+
                        // move right and down to not cover border then resize 
to fit
                        fReplicantTray->MoveTo(kGutter, kGutter);
                        fReplicantTray->ResizeBy(-kGutter, -kGutter);
@@ -1111,7 +1112,7 @@ TBarView::ItemExists(const char* name, DeskbarShelf)
 int32
 TBarView::CountItems(DeskbarShelf)
 {
-       return fReplicantTray->IconCount();
+       return fReplicantTray->ReplicantCount();
 }
 
 
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index 7321ac6..7943f5a 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -215,7 +215,7 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, 
float* preferredHeight)
        if (fMultiRowMode) {
                width = static_cast<TBarApp*>(be_app)->Settings()->width
                        - kDragWidth - kGutter;
-               if (fShelf->CountReplicants() > 0)
+               if (ReplicantCount() > 0)
                        height = fRightBottomReplicant.bottom;
                // the height will be uniform for the number of rows necessary 
to show
                // all the reps + any gutters necessary for spacing
@@ -225,7 +225,7 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, 
float* preferredHeight)
                height = std::max(kMinimumTrayHeight, height);
        } else {
                // if last replicant overruns clock then resize to accomodate
-               if (fShelf->CountReplicants() > 0) {
+               if (ReplicantCount() > 0) {
                        if (!fTime->IsHidden()
                                && fTime->Frame().left < 
fRightBottomReplicant.right + 12) {
                                width = fRightBottomReplicant.right + 12
@@ -889,7 +889,7 @@ TReplicantTray::IconExists(const char* name)
 
 
 int32
-TReplicantTray::IconCount() const
+TReplicantTray::ReplicantCount() const
 {
        return fShelf->CountReplicants();
 }
@@ -955,7 +955,7 @@ TReplicantTray::AddIcon(BMessage* archive, int32* id, const 
entry_ref* addOn)
        if (status != B_OK)
                return status;
 
-       int32 count = fShelf->CountReplicants();
+       int32 count = ReplicantCount();
        BView* view;
        fShelf->ReplicantAt(count - 1, &view, (uint32*)id, NULL);
 
@@ -1062,7 +1062,7 @@ TReplicantTray::ViewAt(int32* index, int32* id, int32 
target, bool byIndex)
                        }
                }
        } else {
-               int32 count = fShelf->CountReplicants() - 1;
+               int32 count = ReplicantCount() - 1;
                int32 localid;
                for (int32 repIndex = count; repIndex >= 0; repIndex--) {
                        fShelf->ReplicantAt(repIndex, &view, (uint32*)&localid);
@@ -1090,7 +1090,7 @@ TReplicantTray::ViewAt(int32* index, int32* id, const 
char* name)
        *id = -1;
 
        BView* view;
-       int32 count = fShelf->CountReplicants() - 1;
+       int32 count = ReplicantCount() - 1;
        for (int32 repIndex = count; repIndex >= 0; repIndex--) {
                fShelf->ReplicantAt(repIndex, &view, (uint32*)id);
                if (view != NULL && view->Name() != NULL
@@ -1132,7 +1132,7 @@ TReplicantTray::AcceptAddon(BRect replicantFrame, 
BMessage* message)
        else
                align = B_ALIGN_LEFT;
 
-       BPoint loc = LocationForReplicant(fShelf->CountReplicants(),
+       BPoint loc = LocationForReplicant(ReplicantCount(),
                replicantFrame.Width());
        message->AddPoint("_pjp_loc", loc);
 
@@ -1146,7 +1146,7 @@ TReplicantTray::AcceptAddon(BRect replicantFrame, 
BMessage* message)
  */
 
 BPoint
-TReplicantTray::LocationForReplicant(int32 index, float width)
+TReplicantTray::LocationForReplicant(int32 index, float replicantWidth)
 {
        BPoint loc(kTrayPadding, 2);
        if (fBarView->Vertical()) {
@@ -1243,8 +1243,8 @@ TReplicantTray::RealignReplicants(int32 startIndex)
        if (startIndex < 0)
                startIndex = 0;
 
-       int32 count = fShelf->CountReplicants();
-       if (count <= 0)
+       int32 replicantCount = ReplicantCount();
+       if (replicantCount <= 0)
                return;
 
        if (startIndex == 0)
@@ -1298,12 +1298,12 @@ TReplicantTray::SaveTimeSettings()
 /*! Draggable region that is asynchronous so that dragging does not block
        other activities.
 */
-TDragRegion::TDragRegion(TBarView* parent, BView* child)
+TDragRegion::TDragRegion(TBarView* parent, BView* replicantTray)
        :
        BControl(BRect(0, 0, 0, 0), "", "", NULL, B_FOLLOW_NONE,
                B_WILL_DRAW | B_FRAME_EVENTS),
        fBarView(parent),
-       fChild(child),
+       fReplicantTray(replicantTray),
        fDragLocation(kAutoPlaceDragRegion)
 {
 }
@@ -1326,9 +1326,9 @@ TDragRegion::AttachedToWindow()
 void
 TDragRegion::GetPreferredSize(float* width, float* height)
 {
-       fChild->ResizeToPreferred();
-       *width = fChild->Bounds().Width();
-       *height = fChild->Bounds().Height();
+       fReplicantTray->ResizeToPreferred();
+       *width = fReplicantTray->Bounds().Width();
+       *height = fReplicantTray->Bounds().Height();
 
        if (fDragLocation != kNoDragRegion)
                *width += kDragWidth + kGutter;
diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h
index 6c1761f..6fd8218 100644
--- a/src/apps/deskbar/StatusView.h
+++ b/src/apps/deskbar/StatusView.h
@@ -107,7 +107,7 @@ public:
                                bool                            
IconExists(int32 target, bool byIndex = false);
                                bool                            
IconExists(const char* name);
 
-                               int32                           IconCount() 
const;
+                               int32                           
ReplicantCount() const;
 
                                status_t                        
AddIcon(BMessage*, int32* id,
                                                                                
const entry_ref* = NULL);
@@ -160,7 +160,7 @@ private:
 #endif
 
                                BPoint                          
LocationForReplicant(int32 index,
-                                                                               
float width);
+                                                                               
float replicantWidth);
                                BShelf*                         Shelf() const;
 
                                status_t                        _SaveSettings();
@@ -196,7 +196,7 @@ enum {
 
 class TDragRegion : public BControl {
 public:
-       TDragRegion(TBarView* barView, BView* child);
+       TDragRegion(TBarView* barView, BView* replicantTray);
 
        virtual void AttachedToWindow();
        virtual void GetPreferredSize(float*, float*);
@@ -218,7 +218,7 @@ public:
 
 private:
        TBarView* fBarView;
-       BView* fChild;
+       BView* fReplicantTray;
        BPoint fPreviousPosition;
        int32 fDragLocation;
 };

############################################################################

Commit:      d8357181eb2b6a73c4171364c837bf184baf37de
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d8357181eb2b
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Oct 24 03:58:40 2017 UTC

Minor whitespace style fix in TReplicantTray class

spacing private variables, no functional change intended.

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

diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h
index 6fd8218..40d45bc 100644
--- a/src/apps/deskbar/StatusView.h
+++ b/src/apps/deskbar/StatusView.h
@@ -171,15 +171,15 @@ private:
                                TBarView*                       fBarView;
                                TReplicantShelf*        fShelf;
                                BRect                           
fRightBottomReplicant;
-       int32 fLastReplicant;
+                               int32                           fLastReplicant;
 
-       bool fMultiRowMode;
-       float fMinimumTrayWidth;
+                               bool                            fMultiRowMode;
+                               float                           
fMinimumTrayWidth;
 
-       bool fAlignmentSupport;
+                               bool                            
fAlignmentSupport;
 #ifdef DB_ADDONS
-       BList* fItemList;
-       BMessage fAddOnSettings;
+                               BList*                          fItemList;
+                               BMessage                        fAddOnSettings;
 #endif
 
 };

############################################################################

Commit:      a44504a168548e129e58eeace336a6a2315257ad
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a44504a16854
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Oct 24 04:07:18 2017 UTC

Deskbar: Refactor TRelicantTray::LocationForReplicant()

* if index == 0 return right away, no calculation required.
* rename rect to rowRect then copy it into replicantRect.
  - This makes it clearer to me what's going on.
* don't have to check if index > 0 in horizontal mode anymore since
  we are checking it upfront.
* introduce replicantWidth variable for understanding
* reduce indent

Was calculating the height in multi-row mode twice. Instead, use
the saved height, if that isn't set calculate height as before,
if no replicants, use minimum height (16px) and don't calculate.

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

diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index 7943f5a..633935f 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -215,14 +215,17 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, 
float* preferredHeight)
        if (fMultiRowMode) {
                width = static_cast<TBarApp*>(be_app)->Settings()->width
                        - kDragWidth - kGutter;
-               if (ReplicantCount() > 0)
+               if (fRightBottomReplicant.IsValid())
                        height = fRightBottomReplicant.bottom;
-               // the height will be uniform for the number of rows necessary 
to show
-               // all the reps + any gutters necessary for spacing
-               int32 rowCount = (int32)(height / kMaxReplicantHeight);
-               height = kGutter + (rowCount * kMaxReplicantHeight)
-                       + ((rowCount - 1) * kIconGap) + kGutter;
-               height = std::max(kMinimumTrayHeight, height);
+               else if (ReplicantCount() > 0) {
+                       // The height will be uniform for the number of rows 
necessary
+                       // to show all the replicants and gutters.
+                       int32 rowCount = (int32)(height / kMaxReplicantHeight);
+                       height = kGutter + (rowCount * kMaxReplicantHeight)
+                               + ((rowCount - 1) * kIconGap) + kGutter;
+                       height = std::max(kMinimumTrayHeight, height);
+               } else
+                       height = kMinimumTrayHeight;
        } else {
                // if last replicant overruns clock then resize to accomodate
                if (ReplicantCount() > 0) {
@@ -1155,11 +1158,14 @@ TReplicantTray::LocationForReplicant(int32 index, float 
replicantWidth)
        } else
                loc.x += 1; // keeps everything lined up nicely
 
+       if (index <= 0)
+               return loc;
+
        if (fMultiRowMode) {
                // try to find free space in every row
                for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, 
row++) {
                        // determine free space in this row
-                       BRect rect(loc.x, loc.y,
+                       BRect rowRect(loc.x, loc.y,
                                loc.x + 
static_cast<TBarApp*>(be_app)->Settings()->width
                                        - kDragRegionWidth * 2,
                                loc.y + kMaxReplicantHeight);
@@ -1168,38 +1174,38 @@ TReplicantTray::LocationForReplicant(int32 index, float 
replicantWidth)
                                        + kTrayPadding;
                        }
 
+                       BRect replicantRect = rowRect;
                        for (int32 i = 0; i < index; i++) {
                                BView* view = NULL;
                                fShelf->ReplicantAt(i, &view);
-                               if (view == NULL || view->Frame().top != 
rect.top)
+                               if (view == NULL || view->Frame().top != 
rowRect.top)
                                        continue;
 
-                               rect.left = view->Frame().right + kIconGap + 1;
+                               // push this replicant placement past the last 
one
+                               replicantRect.left = view->Frame().right + 
kIconGap + 1;
                        }
 
-                       if (rect.Width() >= width) {
+                       if (replicantRect.Width() >= replicantWidth) {
                                // the icon fits in this row
-                               loc = rect.LeftTop();
+                               loc = replicantRect.LeftTop();
                                break;
                        }
                }
        } else {
-               if (index > 0) {
-                       // get the last replicant added for placement reference
-                       BView* view = NULL;
-                       fShelf->ReplicantAt(index - 1, &view);
-                       if (view != NULL) {
-                               // push this rep placement past the last one
-                               loc.x = view->Frame().right + kIconGap + 1;
-                               loc.y = view->Frame().top;
-                       }
+               // get the last replicant added for placement reference
+               BView* view = NULL;
+               fShelf->ReplicantAt(index - 1, &view);
+               if (view != NULL) {
+                       // push this replicant placement past the last one
+                       loc.x = view->Frame().right + kIconGap + 1;
+                       loc.y = view->Frame().top;
                }
        }
 
        if (loc.y > fRightBottomReplicant.top
                || (loc.y == fRightBottomReplicant.top
                        && loc.x > fRightBottomReplicant.left)) {
-               fRightBottomReplicant.Set(loc.x, loc.y, loc.x + width,
+               fRightBottomReplicant.Set(loc.x, loc.y, loc.x + replicantWidth,
                        loc.y + kMaxReplicantHeight);
                fLastReplicant = index;
        }
@@ -1251,13 +1257,15 @@ TReplicantTray::RealignReplicants(int32 startIndex)
                fRightBottomReplicant.Set(0, 0, 0, 0);
 
        BView* view = NULL;
-       for (int32 i = startIndex; i < count; i++) {
-               fShelf->ReplicantAt(i, &view);
-               if (view != NULL) {
-                       BPoint loc = LocationForReplicant(i, 
view->Frame().Width());
-                       if (view->Frame().LeftTop() != loc)
-                               view->MoveTo(loc);
-               }
+       for (int32 index = startIndex; index < replicantCount; index++) {
+               fShelf->ReplicantAt(index, &view);
+               if (view == NULL)
+                       continue;
+
+               float replicantWidth = view->Frame().Width();
+               BPoint loc = LocationForReplicant(index, replicantWidth);
+               if (view->Frame().LeftTop() != loc)
+                       view->MoveTo(loc);
        }
 }
 

############################################################################

Commit:      7b7bf68d713451873ce3950954a87368fb322af5
URL:         http://cgit.haiku-os.org/haiku/commit/?id=7b7bf68d7134
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Oct 24 04:11:02 2017 UTC

Deskbar: create new constant kClockMargin and use it

defines the (minimum) margin between clock and replicant icons

Was used in a couple different forms, now all in 1 constant

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

diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index 633935f..db46c69 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -229,9 +229,9 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, 
float* preferredHeight)
        } else {
                // if last replicant overruns clock then resize to accomodate
                if (ReplicantCount() > 0) {
-                       if (!fTime->IsHidden()
-                               && fTime->Frame().left < 
fRightBottomReplicant.right + 12) {
-                               width = fRightBottomReplicant.right + 12
+                       if (!fTime->IsHidden() && fTime->Frame().left
+                                       < fRightBottomReplicant.right + 
kClockMargin) {
+                               width = fRightBottomReplicant.right + 
kClockMargin
                                        + fTime->Frame().Width();
                        } else
                                width = fRightBottomReplicant.right + kIconGap 
+ kGutter;
@@ -1167,7 +1167,7 @@ TReplicantTray::LocationForReplicant(int32 index, float 
replicantWidth)
                        // determine free space in this row
                        BRect rowRect(loc.x, loc.y,
                                loc.x + 
static_cast<TBarApp*>(be_app)->Settings()->width
-                                       - kDragRegionWidth * 2,
+                                       - kClockMargin,
                                loc.y + kMaxReplicantHeight);
                        if (row == 0 && !fTime->IsHidden()) {
                                rowRect.right -= kClockMargin + 
fTime->Frame().Width()
diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h
index 40d45bc..14f06e5 100644
--- a/src/apps/deskbar/StatusView.h
+++ b/src/apps/deskbar/StatusView.h
@@ -54,6 +54,7 @@ const int32 kIconGap = 2;
 const int32 kGutter = 1;
 const int32 kDragRegionWidth = 6;
 const int32 kTrayPadding = 3;
+const int32 kClockMargin = 12;
 
 // 1 pixel for left gutter
 // space for replicant tray (6 items)

############################################################################

Commit:      c0be54904f3e213f83ccb0e9106c83c70ccef5eb
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c0be54904f3e
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Oct 25 04:06:18 2017 UTC

Deskbar: Fix bug calculating position of replicant icons

...in horizontal mode.

fTime->Frame().left was not in the correct position because the
window isn't yet done resizing. Instead calculate left from the
right edge of the drag region instead.

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

diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index db46c69..b1b8bee 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -229,10 +229,11 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, 
float* preferredHeight)
        } else {
                // if last replicant overruns clock then resize to accomodate
                if (ReplicantCount() > 0) {
-                       if (!fTime->IsHidden() && fTime->Frame().left
+                       if (!fTime->IsHidden() && Bounds().right - kTrayPadding 
- 2
+                                               - fTime->Frame().Width() - 
kClockMargin
                                        < fRightBottomReplicant.right + 
kClockMargin) {
                                width = fRightBottomReplicant.right + 
kClockMargin
-                                       + fTime->Frame().Width();
+                                       + fTime->Frame().Width() + kTrayPadding 
+ 2;
                        } else
                                width = fRightBottomReplicant.right + kIconGap 
+ kGutter;
                }

############################################################################

Revision:    hrev51524
Commit:      2d27c2d003a154f7ad375446e2c6dd291cf97018
URL:         http://cgit.haiku-os.org/haiku/commit/?id=2d27c2d003a1
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon Nov  6 04:51:35 2017 UTC

Ticket:      https://dev.haiku-os.org/ticket/13715

Deskbar: Fix bug where items are sometimes wrong size

in vertical mode because the menu's MaxContentWidth is too small.

Fixes #13715

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

diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp 
b/src/apps/deskbar/ExpandoMenuBar.cpp
index 643d013..6b9ebd9 100644
--- a/src/apps/deskbar/ExpandoMenuBar.cpp
+++ b/src/apps/deskbar/ExpandoMenuBar.cpp
@@ -469,9 +469,10 @@ TExpandoMenuBar::BuildItems()
        desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
 
        float itemWidth = -1.0f;
-       if (fVertical)
+       if (fVertical) {
                itemWidth = Frame().Width();
-       else {
+               SetMaxContentWidth(itemWidth);
+       } else {
                itemWidth = iconSize;
                if (!settings->hideLabels)
                        itemWidth += gMinimumWindowWidth - kMinimumIconSize;



Other related posts: