Set a tooltip with the application name if hidden.
If Deskbar is set to hide application names show the application name as a tooltip when you hover your mouse over the item. * Style fixes. * Save CountItems() into a variable outside the loop so that it only gets called once (micro-optimization/best-practice). * Convert a for loop to a while loop that wasn't really being used used as a for loop anyway, the variables are declared and used outside the loop.
This commit is contained in:
@@ -721,7 +721,7 @@ TBarView::DragStart()
|
|||||||
if (fLastDragItem)
|
if (fLastDragItem)
|
||||||
init_tracking_hook(fLastDragItem, NULL, NULL);
|
init_tracking_hook(fLastDragItem, NULL, NULL);
|
||||||
|
|
||||||
if (item) {
|
if (item != NULL) {
|
||||||
if (item == fLastDragItem)
|
if (item == fLastDragItem)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
|
|||||||
@@ -390,18 +390,27 @@ TExpandoMenuBar::MouseDown(BPoint where)
|
|||||||
void
|
void
|
||||||
TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
|
TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
|
||||||
{
|
{
|
||||||
if (!message) {
|
if (message == NULL) {
|
||||||
// force a cleanup
|
// force a cleanup
|
||||||
_FinishedDrag();
|
_FinishedDrag();
|
||||||
|
|
||||||
|
if (code == B_INSIDE_VIEW) {
|
||||||
|
// set the tooltip
|
||||||
|
TTeamMenuItem* item = TeamItemAtPoint(where);
|
||||||
|
if (item != NULL && !item->DrawLabel() && item->Name() != '\0')
|
||||||
|
SetToolTip(item->Name());
|
||||||
|
}
|
||||||
|
|
||||||
BMenuBar::MouseMoved(where, code, message);
|
BMenuBar::MouseMoved(where, code, message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 buttons;
|
uint32 buttons;
|
||||||
if (!(Window()->CurrentMessage())
|
if (Window()->CurrentMessage() == NULL
|
||||||
|| Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons)
|
|| Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons)
|
||||||
< B_OK)
|
< B_OK) {
|
||||||
buttons = 0;
|
buttons = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (buttons == 0)
|
if (buttons == 0)
|
||||||
return;
|
return;
|
||||||
@@ -426,7 +435,8 @@ TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
|
|||||||
case B_INSIDE_VIEW:
|
case B_INSIDE_VIEW:
|
||||||
if (fBarView->Dragging()) {
|
if (fBarView->Dragging()) {
|
||||||
TTeamMenuItem* item = NULL;
|
TTeamMenuItem* item = NULL;
|
||||||
for (int32 i = 0; i < CountItems(); i++) {
|
int32 itemCount = CountItems();
|
||||||
|
for (int32 i = 0; i < itemCount; i++) {
|
||||||
BMenuItem* _item = ItemAt(i);
|
BMenuItem* _item = ItemAt(i);
|
||||||
if (_item->Frame().Contains(where)) {
|
if (_item->Frame().Contains(where)) {
|
||||||
item = dynamic_cast<TTeamMenuItem*>(_item);
|
item = dynamic_cast<TTeamMenuItem*>(_item);
|
||||||
@@ -552,16 +562,18 @@ TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name,
|
|||||||
firstApp++;
|
firstApp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 count = CountItems(), i;
|
int32 i = firstApp;
|
||||||
for (i = firstApp; i < count; i++) {
|
int32 itemCount = CountItems();
|
||||||
|
while (i < itemCount) {
|
||||||
teamItem = dynamic_cast<TTeamMenuItem*>(ItemAt(i));
|
teamItem = dynamic_cast<TTeamMenuItem*>(ItemAt(i));
|
||||||
if (teamItem != NULL && strcasecmp(teamItem->Name(), name) > 0) {
|
if (teamItem != NULL && strcasecmp(teamItem->Name(), name) > 0) {
|
||||||
AddItem(item, i);
|
AddItem(item, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
// was the item added to the list yet?
|
// was the item added to the list yet?
|
||||||
if (i == count)
|
if (i == itemCount)
|
||||||
AddItem(item);
|
AddItem(item);
|
||||||
} else
|
} else
|
||||||
AddItem(item);
|
AddItem(item);
|
||||||
|
|||||||
@@ -170,6 +170,13 @@ TTeamMenuItem::SetOverrideSelected(bool selected)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
TTeamMenuItem::DrawLabel() const
|
||||||
|
{
|
||||||
|
return fDrawLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTeamMenuItem::SetDrawLabel(bool drawLabel)
|
TTeamMenuItem::SetDrawLabel(bool drawLabel)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ class TTeamMenuItem : public BMenuItem {
|
|||||||
void SetOverrideWidth(float width);
|
void SetOverrideWidth(float width);
|
||||||
void SetOverrideHeight(float height);
|
void SetOverrideHeight(float height);
|
||||||
void SetOverrideSelected(bool selected);
|
void SetOverrideSelected(bool selected);
|
||||||
|
|
||||||
|
bool DrawLabel() const;
|
||||||
void SetDrawLabel(bool drawLabel);
|
void SetDrawLabel(bool drawLabel);
|
||||||
|
|
||||||
bool IsExpanded();
|
bool IsExpanded();
|
||||||
|
|||||||
Reference in New Issue
Block a user