From 54c746641ae240867f0730d9d1f810666f079706 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Tue, 8 Oct 2013 20:51:32 -0400 Subject: [PATCH] Deskbar: Re-add tooltip code for truncated items I accidentally removed it last commit, sorry about that. --- src/apps/deskbar/ExpandoMenuBar.cpp | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 7129fc07b1..2cb1994068 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -348,6 +348,55 @@ TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message) // force a cleanup _FinishedDrag(); + switch (code) { + case B_INSIDE_VIEW: + { + BMenuItem* menuItem; + TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem); + TWindowMenuItem* windowMenuItem + = dynamic_cast(menuItem); + + if (item == NULL || menuItem == NULL) { + // item is NULL, remove the tooltip and break out + fLastMousedOverItem = NULL; + SetToolTip((const char*)NULL); + break; + } + + if (menuItem == fLastMousedOverItem) { + // already set the tooltip for this item, break out + break; + } + + if (windowMenuItem != NULL && fBarView->Vertical() + && fBarView->ExpandoState() && item->IsExpanded()) { + // expando mode window menu item + fLastMousedOverItem = menuItem; + if (strcmp(windowMenuItem->Label(), + windowMenuItem->FullTitle()) != 0) { + // label is truncated, set tooltip + SetToolTip(windowMenuItem->FullTitle()); + } else + SetToolTip((const char*)NULL); + + break; + } + + if (item->HasLabel()) { + // item has a visible label, remove the tooltip and break out + fLastMousedOverItem = menuItem; + SetToolTip((const char*)NULL); + break; + } + + SetToolTip(item->Name()); + // new item, set the tooltip to the item name + fLastMousedOverItem = menuItem; + // save the current menuitem for the next MouseMoved() call + break; + } + } + BMenuBar::MouseMoved(where, code, message); return; }