Rebuild application menu bar less. Fixes #8539 (I hope)

Instead of destroying and rebuilding the application menu bar each time we
change state, create it at startup and then only update it from there on. This
means that bugs that rely on the app bar being constantly destroyed and rebuilt
will be much less likely to occur.

Unfortunatly, there is still one case where the application menu bar is being
destroyed and recreated and that is when you are switching between horizontal
and vertical mode, and that is because a menu bar cannot be altered from
B_ITEMS_IN_ROWS to B_ITEMS_IN_COLUMNS anywhere but in the constructor.

* Renamed fExpando to fExpandoMenuBar
* Updated TExpandoMenuBar to be more flexible after construction, the menu
  items are built in the new BuildItems() method. Also, don't pass the BarView
  object in at contruction, that can happen in AttachedToWindow(). Also, set
  fDeskbarMenuWidth just once at constructor, no reason to keep setting it over   and over again.
This commit is contained in:
John Scipione
2013-03-23 14:59:09 -04:00
parent 7b8c0971ce
commit 53ec5d1f33
5 changed files with 176 additions and 145 deletions
+9 -9
View File
@@ -126,13 +126,11 @@ TBarApp::TBarApp()
} }
sSubscribers.MakeEmpty(); sSubscribers.MakeEmpty();
fSwitcherMessenger = BMessenger(new TSwitchManager(fSettings.switcherLoc)); fSwitcherMessenger = BMessenger(new TSwitchManager(fSettings.switcherLoc));
fBarWindow->Show(); fBarWindow->Show();
// Call UpdatePlacement() after the window is shown because expanded apps // Call UpdatePlacement() after the window is shown because expanded
// need to resize the window. // apps need to resize the window.
if (fBarWindow->Lock()) { if (fBarWindow->Lock()) {
fBarView->UpdatePlacement(); fBarView->UpdatePlacement();
fBarWindow->Unlock(); fBarWindow->Unlock();
@@ -578,11 +576,13 @@ TBarApp::MessageReceived(BMessage* message)
break; break;
fBarWindow->Lock(); fBarWindow->Lock();
if (fBarView->Vertical()) if (!fBarView->Vertical()) {
fBarView->PlaceApplicationBar(); // Must also resize the Deskbar menu and replicant tray in
else // horizontal mode
fBarView->UpdatePlacement(); fBarView->PlaceDeskbarMenu();
fBarView->PlaceTray(false, false);
}
fBarView->PlaceApplicationBar();
fBarWindow->Unlock(); fBarWindow->Unlock();
if (fPreferencesWindow != NULL) if (fPreferencesWindow != NULL)
+80 -62
View File
@@ -130,11 +130,12 @@ BarViewMessageFilter::Filter(BMessage* message, BHandler** target)
TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
uint32 state, float) uint32 state, float)
: BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), :
BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW),
fInlineScrollView(NULL), fInlineScrollView(NULL),
fBarMenuBar(NULL), fBarMenuBar(NULL),
fExpando(NULL), fExpandoMenuBar(NULL),
fTrayLocation(1), fTrayLocation(1),
fVertical(vertical), fVertical(vertical),
fTop(top), fTop(top),
@@ -153,6 +154,15 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
fDragRegion->AddChild(fReplicantTray); fDragRegion->AddChild(fReplicantTray);
if (fTrayLocation != 0) if (fTrayLocation != 0)
AddChild(fDragRegion); AddChild(fDragRegion);
fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0),
"ExpandoMenuBar", fVertical);
fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0),
fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL);
AddChild(fInlineScrollView);
if (state == kMiniState)
fInlineScrollView->Hide();
} }
@@ -177,8 +187,6 @@ TBarView::AttachedToWindow()
fMouseFilter = new BarViewMessageFilter(this); fMouseFilter = new BarViewMessageFilter(this);
Window()->AddCommonFilter(fMouseFilter); Window()->AddCommonFilter(fMouseFilter);
UpdatePlacement();
fTrackingHookData.fTrackingHook = MenuTrackingHook; fTrackingHookData.fTrackingHook = MenuTrackingHook;
fTrackingHookData.fTarget = BMessenger(this); fTrackingHookData.fTarget = BMessenger(this);
fTrackingHookData.fDragMessage = new BMessage(B_REFS_RECEIVED); fTrackingHookData.fDragMessage = new BMessage(B_REFS_RECEIVED);
@@ -211,7 +219,7 @@ TBarView::Draw(BRect)
if (fVertical && fState == kExpandoState) { if (fVertical && fState == kExpandoState) {
SetHighColor(hilite); SetHighColor(hilite);
BRect frame(fExpando->Frame()); BRect frame(fExpandoMenuBar->Frame());
StrokeLine(BPoint(frame.left, frame.top - 1), StrokeLine(BPoint(frame.left, frame.top - 1),
BPoint(frame.right, frame.top -1)); BPoint(frame.right, frame.top -1));
} }
@@ -450,22 +458,10 @@ TBarView::PlaceTray(bool vertSwap, bool leftSwap)
void void
TBarView::PlaceApplicationBar() TBarView::PlaceApplicationBar()
{ {
SaveExpandedItems();
if (fInlineScrollView != NULL) {
fInlineScrollView->DetachScrollers();
fInlineScrollView->RemoveSelf();
delete fInlineScrollView;
fInlineScrollView = NULL;
}
if (fExpando != NULL) {
delete fExpando;
fExpando = NULL;
}
BRect screenFrame = (BScreen(Window())).Frame(); BRect screenFrame = (BScreen(Window())).Frame();
if (fState == kMiniState) { if (fState == kMiniState) {
if (!fInlineScrollView->IsHidden())
fInlineScrollView->Hide();
SizeWindow(screenFrame); SizeWindow(screenFrame);
PositionWindow(screenFrame); PositionWindow(screenFrame);
Window()->UpdateIfNeeded(); Window()->UpdateIfNeeded();
@@ -473,23 +469,25 @@ TBarView::PlaceApplicationBar()
return; return;
} }
if (fInlineScrollView->IsHidden())
fInlineScrollView->Show();
BRect expandoFrame(0, 0, 0, 0); BRect expandoFrame(0, 0, 0, 0);
BRect menuScrollFrame(0, 0, 0, 0);
if (fVertical) { if (fVertical) {
// top left/right // left or right
if (fTrayLocation != 0) if (fTrayLocation != 0) {
expandoFrame.top = fDragRegion->Frame().bottom + 1; expandoFrame.top = fDragRegion->Frame().bottom + 1;
else expandoFrame.left = fDragRegion->Frame().left;
} else {
expandoFrame.top = fBarMenuBar->Frame().bottom + 1; expandoFrame.top = fBarMenuBar->Frame().bottom + 1;
expandoFrame.left = fDragRegion->Frame().left;
}
expandoFrame.bottom = expandoFrame.top + 1; expandoFrame.right = expandoFrame.left + sMinimumWindowWidth;
if (fState == kFullState) if (fState == kFullState)
expandoFrame.right = fBarMenuBar->Frame().Width(); expandoFrame.bottom = screenFrame.bottom;
else else
expandoFrame.right = sMinimumWindowWidth; expandoFrame.bottom = expandoFrame.top + 1;
menuScrollFrame = expandoFrame;
menuScrollFrame.bottom = screenFrame.bottom;
} else { } else {
// top or bottom // top or bottom
expandoFrame.top = 0; expandoFrame.top = 0;
@@ -504,28 +502,25 @@ TBarView::PlaceApplicationBar()
- fDragRegion->Frame().Width() - 1; - fDragRegion->Frame().Width() - 1;
} else } else
expandoFrame.right = screenFrame.Width(); expandoFrame.right = screenFrame.Width();
menuScrollFrame = expandoFrame;
} }
bool hideLabels = ((TBarApp*)be_app)->Settings()->hideLabels; fInlineScrollView->DetachScrollers();
fInlineScrollView->MoveTo(expandoFrame.LeftTop());
fExpando = new TExpandoMenuBar(this, expandoFrame, "ExpandoMenuBar", fInlineScrollView->ResizeTo(expandoFrame.Width(), fVertical
fVertical, !hideLabels && fState != kFullState); ? screenFrame.bottom - expandoFrame.top
: expandoFrame.Height());
fInlineScrollView = new TInlineScrollView(menuScrollFrame, fExpando, fExpandoMenuBar->MoveTo(0, 0);
fVertical ? B_VERTICAL : B_HORIZONTAL); fExpandoMenuBar->ResizeTo(expandoFrame.Width(), expandoFrame.Height());
AddChild(fInlineScrollView);
fExpandoMenuBar->BuildItems();
if (fVertical) if (fVertical)
ExpandItems(); ExpandItems();
SizeWindow(screenFrame); SizeWindow(screenFrame);
PositionWindow(screenFrame); PositionWindow(screenFrame);
fExpando->DoLayout(); fExpandoMenuBar->DoLayout();
// force menu to autosize // force menu to autosize
CheckForScrolling(); CheckForScrolling();
Window()->UpdateIfNeeded(); Window()->UpdateIfNeeded();
Invalidate(); Invalidate();
} }
@@ -545,7 +540,7 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height)
if (fState == kExpandoState && !fVertical) { if (fState == kExpandoState && !fVertical) {
// top or bottom, full // top or bottom, full
fExpando->CheckItemSizes(0); fExpandoMenuBar->CheckItemSizes(0);
windowWidth = screenFrame.Width(); windowWidth = screenFrame.Width();
} else } else
windowWidth = kHiddenDimension; windowWidth = kHiddenDimension;
@@ -561,10 +556,10 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height)
else else
windowHeight = fBarMenuBar->Frame().bottom + 1; windowHeight = fBarMenuBar->Frame().bottom + 1;
windowHeight += fExpando->Bounds().Height(); windowHeight += fExpandoMenuBar->Bounds().Height();
} else { } else {
// top or bottom, full // top or bottom, full
fExpando->CheckItemSizes(0); fExpandoMenuBar->CheckItemSizes(0);
windowHeight = iconSize + 4; windowHeight = iconSize + 4;
windowWidth = screenFrame.Width(); windowWidth = screenFrame.Width();
} }
@@ -617,8 +612,8 @@ TBarView::PositionWindow(BRect screenFrame)
void void
TBarView::CheckForScrolling() TBarView::CheckForScrolling()
{ {
if (fInlineScrollView != NULL && fExpando != NULL) { if (fInlineScrollView != NULL && fExpandoMenuBar != NULL) {
if (fExpando->CheckForSizeOverrun()) if (fExpandoMenuBar->CheckForSizeOverrun())
fInlineScrollView->AttachScrollers(); fInlineScrollView->AttachScrollers();
else else
fInlineScrollView->DetachScrollers(); fInlineScrollView->DetachScrollers();
@@ -668,14 +663,14 @@ TBarView::ChangeState(int32 state, bool vertical, bool left, bool top,
void void
TBarView::SaveExpandedItems() TBarView::SaveExpandedItems()
{ {
if (fExpando == NULL || fExpando->CountItems() <= 0) if (fExpandoMenuBar == NULL || fExpandoMenuBar->CountItems() <= 0)
return; return;
// Get a list of the signatures of expanded apps. Can't use // Get a list of the signatures of expanded apps. Can't use
// team_id because there can be more than one team per application // team_id because there can be more than one team per application
for (int32 i = 0; i < fExpando->CountItems(); i++) { for (int32 i = 0; i < fExpandoMenuBar->CountItems(); i++) {
TTeamMenuItem* teamItem TTeamMenuItem* teamItem
= dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(i)); = dynamic_cast<TTeamMenuItem*>(fExpandoMenuBar->ItemAt(i));
if (teamItem != NULL && teamItem->IsExpanded()) if (teamItem != NULL && teamItem->IsExpanded())
AddExpandedItem(teamItem->Signature()); AddExpandedItem(teamItem->Signature());
@@ -695,20 +690,20 @@ TBarView::RemoveExpandedItems()
void void
TBarView::ExpandItems() TBarView::ExpandItems()
{ {
if (fExpando == NULL || !fVertical || fState != kExpandoState if (fExpandoMenuBar == NULL || !fVertical || fState != kExpandoState
|| !static_cast<TBarApp*>(be_app)->Settings()->superExpando || !static_cast<TBarApp*>(be_app)->Settings()->superExpando
|| fExpandedItems.CountItems() <= 0) || fExpandedItems.CountItems() <= 0)
return; return;
// Start at the 'bottom' of the list working up. // Start at the 'bottom' of the list working up.
// Prevents being thrown off by expanding items. // Prevents being thrown off by expanding items.
for (int32 i = fExpando->CountItems() - 1; i >= 0; i--) { for (int32 i = fExpandoMenuBar->CountItems() - 1; i >= 0; i--) {
TTeamMenuItem* teamItem TTeamMenuItem* teamItem
= dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(i)); = dynamic_cast<TTeamMenuItem*>(fExpandoMenuBar->ItemAt(i));
if (teamItem != NULL) { if (teamItem != NULL) {
// Start at the 'bottom' of the fExpandedItems list working up // Start at the 'bottom' of the fExpandedItems list working up
// matching the order of the fExpando list in the outer loop. // matching the order of the fExpandoMenuBar list in the outer loop.
for (int32 j = fExpandedItems.CountItems() - 1; j >= 0; j--) { for (int32 j = fExpandedItems.CountItems() - 1; j >= 0; j--) {
BString* itemSig = BString* itemSig =
static_cast<BString*>(fExpandedItems.ItemAt(j)); static_cast<BString*>(fExpandedItems.ItemAt(j));
@@ -747,10 +742,33 @@ TBarView::_ChangeState(BMessage* message)
fLeft = left; fLeft = left;
fTop = top; fTop = top;
// Send a message to the preferences window to let it know to enable SaveExpandedItems();
// or disable preference items
if (stateChanged || vertSwap) if (stateChanged || vertSwap) {
be_app->PostMessage(kStateChanged); be_app->PostMessage(kStateChanged);
// Send a message to the preferences window to let it know to
// enable or disable preference items.
// If switching to expando state, rebuild expando menu bar.
if (fState == kExpandoState) {
if (fInlineScrollView != NULL) {
fInlineScrollView->DetachScrollers();
fInlineScrollView->RemoveSelf();
delete fInlineScrollView;
fInlineScrollView = NULL;
}
if (fExpandoMenuBar != NULL) {
delete fExpandoMenuBar;
fExpandoMenuBar = NULL;
}
fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0),
"ExpandoMenuBar", fVertical);
fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0),
fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL);
AddChild(fInlineScrollView);
}
}
PlaceDeskbarMenu(); PlaceDeskbarMenu();
PlaceTray(vertSwap, leftSwap); PlaceTray(vertSwap, leftSwap);
@@ -847,10 +865,10 @@ TBarView::DragStart()
uint32 buttons; uint32 buttons;
GetMouse(&loc, &buttons); GetMouse(&loc, &buttons);
if (fExpando && fExpando->Frame().Contains(loc)) { if (fExpandoMenuBar && fExpandoMenuBar->Frame().Contains(loc)) {
ConvertToScreen(&loc); ConvertToScreen(&loc);
BPoint expandoLocation = fExpando->ConvertFromScreen(loc); BPoint expandoLocation = fExpandoMenuBar->ConvertFromScreen(loc);
TTeamMenuItem* item = fExpando->TeamItemAtPoint(expandoLocation); TTeamMenuItem* item = fExpandoMenuBar->TeamItemAtPoint(expandoLocation);
if (fLastDragItem) if (fLastDragItem)
init_tracking_hook(fLastDragItem, NULL, NULL); init_tracking_hook(fLastDragItem, NULL, NULL);
@@ -940,8 +958,8 @@ TBarView::DragStop(bool full)
if (!Dragging()) if (!Dragging())
return; return;
if (fExpando) { if (fExpandoMenuBar != NULL) {
if (fLastDragItem) { if (fLastDragItem != NULL) {
init_tracking_hook(fLastDragItem, NULL, NULL); init_tracking_hook(fLastDragItem, NULL, NULL);
fLastDragItem = NULL; fLastDragItem = NULL;
} }
+2 -2
View File
@@ -172,7 +172,7 @@ class TBarView : public BView {
TInlineScrollView* fInlineScrollView; TInlineScrollView* fInlineScrollView;
TBarMenuBar* fBarMenuBar; TBarMenuBar* fBarMenuBar;
TExpandoMenuBar* fExpando; TExpandoMenuBar* fExpandoMenuBar;
int32 fTrayLocation; int32 fTrayLocation;
TDragRegion* fDragRegion; TDragRegion* fDragRegion;
@@ -202,7 +202,7 @@ class TBarView : public BView {
inline TExpandoMenuBar* inline TExpandoMenuBar*
TBarView::ExpandoMenuBar() const TBarView::ExpandoMenuBar() const
{ {
return fExpando; return fExpandoMenuBar;
} }
+77 -68
View File
@@ -45,6 +45,7 @@ All rights reserved.
#include <NodeInfo.h> #include <NodeInfo.h>
#include <Roster.h> #include <Roster.h>
#include <Screen.h> #include <Screen.h>
#include <Window.h>
#include "icons.h" #include "icons.h"
@@ -75,18 +76,17 @@ thread_id TExpandoMenuBar::sMonThread = B_ERROR;
BLocker TExpandoMenuBar::sMonLocker("expando monitor"); BLocker TExpandoMenuBar::sMonLocker("expando monitor");
TExpandoMenuBar::TExpandoMenuBar(TBarView* bar, BRect frame, const char* name, TExpandoMenuBar::TExpandoMenuBar(BRect frame, const char* name, bool vertical)
bool vertical, bool drawLabel)
: :
BMenuBar(frame, name, B_FOLLOW_NONE, BMenuBar(frame, name, B_FOLLOW_NONE,
vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW), vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW),
fVertical(vertical), fVertical(vertical),
fOverflow(false), fOverflow(false),
fDrawLabel(drawLabel), fDrawLabel(!static_cast<TBarApp*>(be_app)->Settings()->hideLabels),
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(kMinMenuItemWidth), fDeskbarMenuWidth(kMinMenuItemWidth),
fBarView(bar), fBarView(NULL),
fPreviousDragTargetItem(NULL), fPreviousDragTargetItem(NULL),
fLastClickItem(NULL) fLastClickItem(NULL)
{ {
@@ -101,6 +101,13 @@ TExpandoMenuBar::TExpandoMenuBar(TBarView* bar, BRect frame, const char* name,
- kMinimumIconSize; - kMinimumIconSize;
SetMaxContentWidth(maxContentWidth); SetMaxContentWidth(maxContentWidth);
} }
// top or bottom mode, add deskbar menu and sep for menubar tracking
// consistency
const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE,
R_LeafLogoBitmap);
if (logoBitmap != NULL)
fDeskbarMenuWidth = logoBitmap->Bounds().Width() + 16;
} }
@@ -115,68 +122,10 @@ TExpandoMenuBar::CompareByName(const void* first, const void* second)
void void
TExpandoMenuBar::AttachedToWindow() TExpandoMenuBar::AttachedToWindow()
{ {
BMessenger self(this);
BList teamList;
TBarApp::Subscribe(self, &teamList);
int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
float itemWidth = -0.1f;
if (fVertical)
itemWidth = Frame().Width();
else {
itemWidth = iconSize;
if (fDrawLabel)
itemWidth += sMinimumWindowWidth - kMinimumIconSize;
else
itemWidth += kIconPadding * 2;
}
float itemHeight = -1.0f;
// top or bottom mode, add deskbar menu and sep for menubar tracking
// consistency
if (!fVertical) {
const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE,
R_LeafLogoBitmap);
if (logoBitmap != NULL)
fDeskbarMenuWidth = logoBitmap->Bounds().Width() + 16;
}
if (settings->sortRunningApps)
teamList.SortItems(CompareByName);
int32 count = teamList.CountItems();
for (int32 i = 0; i < count; i++) {
BarTeamInfo* barInfo = (BarTeamInfo*)teamList.ItemAt(i);
if ((barInfo->flags & B_BACKGROUND_APP) == 0
&& strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {
if (settings->trackerAlwaysFirst
&& !strcmp(barInfo->sig, kTrackerSignature)) {
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
barInfo->name, barInfo->sig, itemWidth, itemHeight,
fDrawLabel, fVertical), 0);
} else {
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
barInfo->name, barInfo->sig, itemWidth, itemHeight,
fDrawLabel, fVertical));
}
barInfo->teams = NULL;
barInfo->icon = NULL;
barInfo->name = NULL;
barInfo->sig = NULL;
}
delete barInfo;
}
BMenuBar::AttachedToWindow(); BMenuBar::AttachedToWindow();
if (CountItems() == 0) { fBarView = static_cast<TBarWindow*>(Window())->BarView();
// If we're empty, BMenuBar::AttachedToWindow() resizes us to some fTeamList.MakeEmpty();
// weird value - we just override it again
ResizeTo(itemWidth, 0);
}
if (fVertical) { if (fVertical) {
sDoMonitor = true; sDoMonitor = true;
@@ -525,6 +474,70 @@ TExpandoMenuBar::MouseUp(BPoint where)
} }
void
TExpandoMenuBar::BuildItems()
{
BMessenger self(this);
TBarApp::Subscribe(self, &fTeamList);
int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
fDrawLabel = !settings->hideLabels;
fShowTeamExpander = settings->superExpando;
fExpandNewTeams = settings->expandNewTeams;
float itemWidth = -0.1f;
if (fVertical)
itemWidth = Frame().Width();
else {
itemWidth = iconSize;
if (fDrawLabel)
itemWidth += sMinimumWindowWidth - kMinimumIconSize;
else
itemWidth += kIconPadding * 2;
}
float itemHeight = -1.0f;
RemoveItems(0, CountItems(), true);
// remove all items
if (settings->sortRunningApps)
fTeamList.SortItems(CompareByName);
int32 count = fTeamList.CountItems();
for (int32 i = 0; i < count; i++) {
// add them again
BarTeamInfo* barInfo = (BarTeamInfo*)fTeamList.ItemAt(i);
if ((barInfo->flags & B_BACKGROUND_APP) == 0
&& strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {
if (settings->trackerAlwaysFirst
&& !strcmp(barInfo->sig, kTrackerSignature)) {
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
barInfo->name, barInfo->sig, itemWidth, itemHeight,
fDrawLabel, fVertical), 0);
} else {
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
barInfo->name, barInfo->sig, itemWidth, itemHeight,
fDrawLabel, fVertical));
}
barInfo->teams = NULL;
barInfo->icon = NULL;
barInfo->name = NULL;
barInfo->sig = NULL;
}
delete barInfo;
}
if (CountItems() == 0) {
// If we're empty, BMenuBar::AttachedToWindow() resizes us to some
// weird value - we just override it again
ResizeTo(itemWidth, 0);
}
}
bool bool
TExpandoMenuBar::InDeskbarMenu(BPoint loc) const TExpandoMenuBar::InDeskbarMenu(BPoint loc) const
{ {
@@ -636,7 +649,6 @@ TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name,
} }
SizeWindow(1); SizeWindow(1);
Window()->UpdateIfNeeded(); Window()->UpdateIfNeeded();
} }
@@ -676,11 +688,8 @@ TExpandoMenuBar::RemoveTeam(team_id team, bool partial)
#endif #endif
RemoveItem(i); RemoveItem(i);
SizeWindow(-1); SizeWindow(-1);
Window()->UpdateIfNeeded(); Window()->UpdateIfNeeded();
delete item; delete item;
return; return;
} }
+8 -4
View File
@@ -61,18 +61,21 @@ enum drag_and_drop_selection {
class TExpandoMenuBar : public BMenuBar { class TExpandoMenuBar : public BMenuBar {
public: public:
TExpandoMenuBar(TBarView* bar, BRect frame, const char* name, TExpandoMenuBar(BRect frame, const char* name, bool vertical);
bool vertical, bool drawLabel = true);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void DetachedFromWindow(); virtual void DetachedFromWindow();
virtual void Draw(BRect update);
virtual void DrawBackground(BRect update);
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
virtual void MouseDown(BPoint where); virtual void MouseDown(BPoint where);
virtual void MouseMoved(BPoint where, uint32 code, const BMessage*); virtual void MouseMoved(BPoint where, uint32 code, const BMessage*);
virtual void MouseUp(BPoint where); virtual void MouseUp(BPoint where);
virtual void Draw(BRect update); void BuildItems();
virtual void DrawBackground(BRect update);
TTeamMenuItem* TeamItemAtPoint(BPoint location, TTeamMenuItem* TeamItemAtPoint(BPoint location,
BMenuItem** _item = NULL); BMenuItem** _item = NULL);
@@ -109,6 +112,7 @@ class TExpandoMenuBar : public BMenuBar {
BMenuItem* fLastMousedOverItem; BMenuItem* fLastMousedOverItem;
BMenuItem* fLastClickItem; BMenuItem* fLastClickItem;
BList fTeamList;
static bool sDoMonitor; static bool sDoMonitor;
static thread_id sMonThread; static thread_id sMonThread;