Deskbar: Don’t save fHasLabel and fVertical
in the TTeamMenuItem, get it from the parent or settings instead.
This commit is contained in:
@@ -382,8 +382,9 @@ TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->HasLabel()) {
|
if (!dynamic_cast<TBarApp*>(be_app)->Settings()->hideLabels) {
|
||||||
// item has a visible label, remove the tooltip and break out
|
// item has a visible label, remove the tooltip
|
||||||
|
// and break out
|
||||||
fLastMousedOverItem = menuItem;
|
fLastMousedOverItem = menuItem;
|
||||||
SetToolTip((const char*)NULL);
|
SetToolTip((const char*)NULL);
|
||||||
break;
|
break;
|
||||||
@@ -584,7 +585,7 @@ TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name,
|
|||||||
float itemHeight = -1.0f;
|
float itemHeight = -1.0f;
|
||||||
|
|
||||||
TTeamMenuItem* item = new TTeamMenuItem(team, icon, name, signature,
|
TTeamMenuItem* item = new TTeamMenuItem(team, icon, name, signature,
|
||||||
itemWidth, itemHeight, fDrawLabel, fVertical);
|
itemWidth, itemHeight);
|
||||||
|
|
||||||
if (settings->trackerAlwaysFirst
|
if (settings->trackerAlwaysFirst
|
||||||
&& strcasecmp(signature, kTrackerSignature) == 0) {
|
&& strcasecmp(signature, kTrackerSignature) == 0) {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ TTeamMenu::AttachedToWindow()
|
|||||||
BarTeamInfo* barInfo = (BarTeamInfo*)teamList.ItemAt(i);
|
BarTeamInfo* barInfo = (BarTeamInfo*)teamList.ItemAt(i);
|
||||||
TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams,
|
TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams,
|
||||||
barInfo->icon, barInfo->name, barInfo->sig,
|
barInfo->icon, barInfo->name, barInfo->sig,
|
||||||
width, -1, !settings->hideLabels, true);
|
width, -1);
|
||||||
|
|
||||||
if (settings->trackerAlwaysFirst
|
if (settings->trackerAlwaysFirst
|
||||||
&& strcmp(barInfo->sig, kTrackerSignature) == 0) {
|
&& strcmp(barInfo->sig, kTrackerSignature) == 0) {
|
||||||
|
|||||||
@@ -66,20 +66,19 @@ const float kSwitchWidth = 12.0f;
|
|||||||
|
|
||||||
|
|
||||||
TTeamMenuItem::TTeamMenuItem(BList* team, BBitmap* icon, char* name, char* sig,
|
TTeamMenuItem::TTeamMenuItem(BList* team, BBitmap* icon, char* name, char* sig,
|
||||||
float width, float height, bool drawLabel, bool vertical)
|
float width, float height)
|
||||||
:
|
:
|
||||||
BMenuItem(new TWindowMenu(team, sig))
|
BMenuItem(new TWindowMenu(team, sig))
|
||||||
{
|
{
|
||||||
_InitData(team, icon, name, sig, width, height, drawLabel, vertical);
|
_InitData(team, icon, name, sig, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TTeamMenuItem::TTeamMenuItem(float width, float height, bool vertical)
|
TTeamMenuItem::TTeamMenuItem(float width, float height)
|
||||||
:
|
:
|
||||||
BMenuItem("", NULL)
|
BMenuItem("", NULL)
|
||||||
{
|
{
|
||||||
_InitData(NULL, NULL, strdup(""), strdup(""), width, height, false,
|
_InitData(NULL, NULL, strdup(""), strdup(""), width, height);
|
||||||
vertical);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -169,17 +168,21 @@ TTeamMenuItem::GetContentSize(float* width, float* height)
|
|||||||
*width = fOverrideWidth;
|
*width = fOverrideWidth;
|
||||||
else {
|
else {
|
||||||
*width = kHPad + iconBounds.Width() + kHPad;
|
*width = kHPad + iconBounds.Width() + kHPad;
|
||||||
if (iconBounds.Width() <= 32 && fDrawLabel)
|
if (iconBounds.Width() <= 32
|
||||||
|
&& !static_cast<TBarApp*>(be_app)->Settings()->hideLabels) {
|
||||||
*width += LabelWidth() + kHPad;
|
*width += LabelWidth() + kHPad;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fOverrideHeight != -1.0f)
|
if (fOverrideHeight != -1.0f)
|
||||||
*height = fOverrideHeight;
|
*height = fOverrideHeight;
|
||||||
else {
|
else {
|
||||||
if (fVertical) {
|
if (fBarView->Vertical()) {
|
||||||
*height = iconBounds.Height() + kVPad * 4;
|
*height = iconBounds.Height() + kVPad * 4;
|
||||||
if (fDrawLabel && iconBounds.Width() > 32)
|
if (!static_cast<TBarApp*>(be_app)->Settings()->hideLabels
|
||||||
|
&& iconBounds.Width() > 32) {
|
||||||
*height += fLabelAscent + fLabelDescent;
|
*height += fLabelAscent + fLabelDescent;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
*height = iconBounds.Height() + kVPad * 4;
|
*height = iconBounds.Height() + kVPad * 4;
|
||||||
}
|
}
|
||||||
@@ -204,7 +207,7 @@ TTeamMenuItem::Draw()
|
|||||||
flags |= BControlLook::B_ACTIVATED;
|
flags |= BControlLook::B_ACTIVATED;
|
||||||
|
|
||||||
uint32 borders = BControlLook::B_TOP_BORDER;
|
uint32 borders = BControlLook::B_TOP_BORDER;
|
||||||
if (fVertical) {
|
if (fBarView->Vertical()) {
|
||||||
menu->SetHighColor(tint_color(menuColor, B_DARKEN_1_TINT));
|
menu->SetHighColor(tint_color(menuColor, B_DARKEN_1_TINT));
|
||||||
borders |= BControlLook::B_LEFT_BORDER
|
borders |= BControlLook::B_LEFT_BORDER
|
||||||
| BControlLook::B_RIGHT_BORDER;
|
| BControlLook::B_RIGHT_BORDER;
|
||||||
@@ -247,11 +250,12 @@ TTeamMenuItem::DrawContent()
|
|||||||
BRect frame(Frame());
|
BRect frame(Frame());
|
||||||
BRect iconBounds(fIcon->Bounds());
|
BRect iconBounds(fIcon->Bounds());
|
||||||
BRect dstRect(iconBounds);
|
BRect dstRect(iconBounds);
|
||||||
float extra = fVertical ? 0.0f : -1.0f;
|
float extra = fBarView->Vertical() ? 0.0f : -1.0f;
|
||||||
BPoint contLoc = ContentLocation();
|
BPoint contLoc = ContentLocation();
|
||||||
BPoint drawLoc = contLoc + BPoint(kHPad, kVPad);
|
BPoint drawLoc = contLoc + BPoint(kHPad, kVPad);
|
||||||
|
|
||||||
if (!fDrawLabel || (fVertical && iconBounds.Width() > 32)) {
|
if (static_cast<TBarApp*>(be_app)->Settings()->hideLabels
|
||||||
|
|| (fBarView->Vertical() && iconBounds.Width() > 32)) {
|
||||||
float offsetx = contLoc.x
|
float offsetx = contLoc.x
|
||||||
+ ((frame.Width() - iconBounds.Width()) / 2) + extra;
|
+ ((frame.Width() - iconBounds.Width()) / 2) + extra;
|
||||||
float offsety = contLoc.y + 3.0f + extra;
|
float offsety = contLoc.y + 3.0f + extra;
|
||||||
@@ -271,13 +275,14 @@ TTeamMenuItem::DrawContent()
|
|||||||
|
|
||||||
float labelHeight = fLabelAscent + fLabelDescent;
|
float labelHeight = fLabelAscent + fLabelDescent;
|
||||||
drawLoc.x += iconBounds.Width() + kLabelOffset;
|
drawLoc.x += iconBounds.Width() + kLabelOffset;
|
||||||
drawLoc.y = frame.top + ((frame.Height() - labelHeight) / 2) + extra;
|
drawLoc.y = frame.top + ((frame.Height() - labelHeight) / 2)
|
||||||
|
+ extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
menu->MovePenTo(drawLoc);
|
menu->MovePenTo(drawLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fDrawLabel) {
|
if (!static_cast<TBarApp*>(be_app)->Settings()->hideLabels) {
|
||||||
menu->SetDrawingMode(B_OP_OVER);
|
menu->SetDrawingMode(B_OP_OVER);
|
||||||
menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
|
menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
|
||||||
|
|
||||||
@@ -287,7 +292,8 @@ TTeamMenuItem::DrawContent()
|
|||||||
DrawContentLabel();
|
DrawContentLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fVertical && static_cast<TBarApp*>(be_app)->Settings()->superExpando
|
if (fBarView->Vertical()
|
||||||
|
&& static_cast<TBarApp*>(be_app)->Settings()->superExpando
|
||||||
&& fBarView->ExpandoState()) {
|
&& fBarView->ExpandoState()) {
|
||||||
DrawExpanderArrow();
|
DrawExpanderArrow();
|
||||||
}
|
}
|
||||||
@@ -301,16 +307,17 @@ TTeamMenuItem::DrawContentLabel()
|
|||||||
menu->MovePenBy(0, fLabelAscent);
|
menu->MovePenBy(0, fLabelAscent);
|
||||||
|
|
||||||
float cachedWidth = menu->StringWidth(Label());
|
float cachedWidth = menu->StringWidth(Label());
|
||||||
if (Submenu() && fVertical)
|
if (Submenu() != NULL && fBarView->Vertical())
|
||||||
cachedWidth += 18;
|
cachedWidth += 18;
|
||||||
|
|
||||||
const char* label = Label();
|
const char* label = Label();
|
||||||
char* truncLabel = NULL;
|
char* truncLabel = NULL;
|
||||||
float max = 0;
|
float max = 0;
|
||||||
|
|
||||||
if (fVertical && static_cast<TBarApp*>(be_app)->Settings()->superExpando)
|
if (fBarView->Vertical()
|
||||||
|
&& static_cast<TBarApp*>(be_app)->Settings()->superExpando) {
|
||||||
max = menu->MaxContentWidth() - kSwitchWidth;
|
max = menu->MaxContentWidth() - kSwitchWidth;
|
||||||
else
|
} else
|
||||||
max = menu->MaxContentWidth() - 4.0f;
|
max = menu->MaxContentWidth() - 4.0f;
|
||||||
|
|
||||||
if (max > 0) {
|
if (max > 0) {
|
||||||
@@ -462,7 +469,7 @@ TTeamMenuItem::ExpanderBounds() const
|
|||||||
|
|
||||||
void
|
void
|
||||||
TTeamMenuItem::_InitData(BList* team, BBitmap* icon, char* name, char* sig,
|
TTeamMenuItem::_InitData(BList* team, BBitmap* icon, char* name, char* sig,
|
||||||
float width, float height, bool drawLabel, bool vertical)
|
float width, float height)
|
||||||
{
|
{
|
||||||
fTeam = team;
|
fTeam = team;
|
||||||
fIcon = icon;
|
fIcon = icon;
|
||||||
@@ -476,8 +483,6 @@ TTeamMenuItem::_InitData(BList* team, BBitmap* icon, char* name, char* sig,
|
|||||||
SetLabel(fName);
|
SetLabel(fName);
|
||||||
fOverrideWidth = width;
|
fOverrideWidth = width;
|
||||||
fOverrideHeight = height;
|
fOverrideHeight = height;
|
||||||
fDrawLabel = drawLabel;
|
|
||||||
fVertical = vertical;
|
|
||||||
|
|
||||||
fBarView = static_cast<TBarApp*>(be_app)->BarView();
|
fBarView = static_cast<TBarApp*>(be_app)->BarView();
|
||||||
BFont font(be_plain_font);
|
BFont font(be_plain_font);
|
||||||
|
|||||||
@@ -53,12 +53,9 @@ class TTeamMenuItem : public BMenuItem {
|
|||||||
public:
|
public:
|
||||||
TTeamMenuItem(BList* team, BBitmap* icon,
|
TTeamMenuItem(BList* team, BBitmap* icon,
|
||||||
char* name, char* sig,
|
char* name, char* sig,
|
||||||
float width = -1.0f, float height = -1.0f,
|
float width = -1.0f, float height = -1.0f);
|
||||||
bool drawLabel = true,
|
|
||||||
bool vertical = true);
|
|
||||||
TTeamMenuItem(float width = -1.0f,
|
TTeamMenuItem(float width = -1.0f,
|
||||||
float height = -1.0f,
|
float height = -1.0f);
|
||||||
bool vertical = true);
|
|
||||||
virtual ~TTeamMenuItem();
|
virtual ~TTeamMenuItem();
|
||||||
|
|
||||||
status_t Invoke(BMessage* msg = NULL);
|
status_t Invoke(BMessage* msg = NULL);
|
||||||
@@ -94,9 +91,7 @@ private:
|
|||||||
friend class TExpandoMenuBar;
|
friend class TExpandoMenuBar;
|
||||||
void _InitData(BList* team, BBitmap* icon,
|
void _InitData(BList* team, BBitmap* icon,
|
||||||
char* name, char* sig,
|
char* name, char* sig,
|
||||||
float width = -1.0f, float height = -1.0f,
|
float width = -1.0f, float height = -1.0f);
|
||||||
bool drawLabel = true,
|
|
||||||
bool vertical = true);
|
|
||||||
|
|
||||||
bool _IsSelected() const;
|
bool _IsSelected() const;
|
||||||
|
|
||||||
@@ -107,8 +102,6 @@ private:
|
|||||||
char* fSig;
|
char* fSig;
|
||||||
float fOverrideWidth;
|
float fOverrideWidth;
|
||||||
float fOverrideHeight;
|
float fOverrideHeight;
|
||||||
bool fDrawLabel;
|
|
||||||
bool fVertical;
|
|
||||||
|
|
||||||
TBarView* fBarView;
|
TBarView* fBarView;
|
||||||
float fLabelWidth;
|
float fLabelWidth;
|
||||||
|
|||||||
Reference in New Issue
Block a user