Set the scroll arrow limit based on the min menu item widths

... rather than the current menu item widths. This means that
Deskbar will shrink the menu items until they are at their minimum
size before it activates the scroll arrows. Previous to this
change the scroll arrows were being turned on prematurely. Also
lower the minimum menu item width to the icon width + 50pixels which
is arbitrary but looks good to my eye.
This commit is contained in:
John Scipione 2012-10-26 02:58:45 -04:00
parent c07e6ff292
commit ed75ca7201

View File

@ -63,7 +63,7 @@ All rights reserved.
#include "WindowMenuItem.h" #include "WindowMenuItem.h"
const float kDefaultDeskbarMenuWidth = 50.0f; const float kMinMenuItemWidth = 50.0f;
const float kSepItemWidth = 5.0f; const float kSepItemWidth = 5.0f;
const float kIconPadding = 8.0f; const float kIconPadding = 8.0f;
@ -85,7 +85,7 @@ TExpandoMenuBar::TExpandoMenuBar(TBarView* bar, BRect frame, const char* name,
fDrawLabel(drawLabel), fDrawLabel(drawLabel),
fShowTeamExpander(static_cast<TBarApp*>(be_app)->Settings()->superExpando), fShowTeamExpander(static_cast<TBarApp*>(be_app)->Settings()->superExpando),
fExpandNewTeams(static_cast<TBarApp*>(be_app)->Settings()->expandNewTeams), fExpandNewTeams(static_cast<TBarApp*>(be_app)->Settings()->expandNewTeams),
fDeskbarMenuWidth(kDefaultDeskbarMenuWidth), fDeskbarMenuWidth(kMinMenuItemWidth),
fBarView(bar), fBarView(bar),
fPreviousDragTargetItem(NULL), fPreviousDragTargetItem(NULL),
fLastClickItem(NULL) fLastClickItem(NULL)
@ -682,7 +682,7 @@ TExpandoMenuBar::CheckItemSizes(int32 delta)
- fDeskbarMenuWidth - kSepItemWidth; - fDeskbarMenuWidth - kSepItemWidth;
int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize(); int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
float iconOnlyWidth = kIconPadding + iconSize + kIconPadding; float iconOnlyWidth = kIconPadding + iconSize + kIconPadding;
float minItemWidth = fDrawLabel ? iconOnlyWidth + fDeskbarMenuWidth float minItemWidth = fDrawLabel ? iconOnlyWidth + kMinMenuItemWidth
: iconOnlyWidth; : iconOnlyWidth;
float maxItemWidth = sMinimumWindowWidth + iconSize - kMinimumIconSize; float maxItemWidth = sMinimumWindowWidth + iconSize - kMinimumIconSize;
float menuWidth = maxItemWidth * CountItems() + fDeskbarMenuWidth float menuWidth = maxItemWidth * CountItems() + fDeskbarMenuWidth
@ -800,9 +800,14 @@ TExpandoMenuBar::CheckForSizeOverrun()
if (count < 0) if (count < 0)
return false; return false;
float menuWidth = ItemAt(count)->Frame().right + fDeskbarMenuWidth int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
+ kSepItemWidth + 1; float iconOnlyWidth = kIconPadding + iconSize + kIconPadding;
float maxWidth = fBarView->DragRegion()->Frame().left - 1; float minItemWidth = fDrawLabel ? iconOnlyWidth + kMinMenuItemWidth
: iconOnlyWidth;
float menuWidth = minItemWidth * CountItems() + fDeskbarMenuWidth
+ kSepItemWidth;
float maxWidth = fBarView->DragRegion()->Frame().left
- fDeskbarMenuWidth - kSepItemWidth;
return menuWidth > maxWidth; return menuWidth > maxWidth;
} }