From 18bcf77ab08a66f3820fa608a124b199742a0070 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Mon, 6 Jan 2014 23:41:34 -0500 Subject: [PATCH] =?UTF-8?q?Deskbar:=20Don=E2=80=99t=20save=20fHasLabel=20a?= =?UTF-8?q?nd=20fVertical?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in the TTeamMenuItem, get it from the parent or settings instead. --- src/apps/deskbar/ExpandoMenuBar.cpp | 7 +++-- src/apps/deskbar/TeamMenu.cpp | 2 +- src/apps/deskbar/TeamMenuItem.cpp | 45 ++++++++++++++++------------- src/apps/deskbar/TeamMenuItem.h | 13 ++------- 4 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 9e340076a8..e962c50482 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -382,8 +382,9 @@ TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message) break; } - if (item->HasLabel()) { - // item has a visible label, remove the tooltip and break out + if (!dynamic_cast(be_app)->Settings()->hideLabels) { + // item has a visible label, remove the tooltip + // and break out fLastMousedOverItem = menuItem; SetToolTip((const char*)NULL); break; @@ -584,7 +585,7 @@ TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name, float itemHeight = -1.0f; TTeamMenuItem* item = new TTeamMenuItem(team, icon, name, signature, - itemWidth, itemHeight, fDrawLabel, fVertical); + itemWidth, itemHeight); if (settings->trackerAlwaysFirst && strcasecmp(signature, kTrackerSignature) == 0) { diff --git a/src/apps/deskbar/TeamMenu.cpp b/src/apps/deskbar/TeamMenu.cpp index 434f4dd7bd..fc98d14b2c 100644 --- a/src/apps/deskbar/TeamMenu.cpp +++ b/src/apps/deskbar/TeamMenu.cpp @@ -93,7 +93,7 @@ TTeamMenu::AttachedToWindow() BarTeamInfo* barInfo = (BarTeamInfo*)teamList.ItemAt(i); TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams, barInfo->icon, barInfo->name, barInfo->sig, - width, -1, !settings->hideLabels, true); + width, -1); if (settings->trackerAlwaysFirst && strcmp(barInfo->sig, kTrackerSignature) == 0) { diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp index 6977d06a13..8567e87b75 100644 --- a/src/apps/deskbar/TeamMenuItem.cpp +++ b/src/apps/deskbar/TeamMenuItem.cpp @@ -66,20 +66,19 @@ const float kSwitchWidth = 12.0f; 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)) { - _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) { - _InitData(NULL, NULL, strdup(""), strdup(""), width, height, false, - vertical); + _InitData(NULL, NULL, strdup(""), strdup(""), width, height); } @@ -169,17 +168,21 @@ TTeamMenuItem::GetContentSize(float* width, float* height) *width = fOverrideWidth; else { *width = kHPad + iconBounds.Width() + kHPad; - if (iconBounds.Width() <= 32 && fDrawLabel) + if (iconBounds.Width() <= 32 + && !static_cast(be_app)->Settings()->hideLabels) { *width += LabelWidth() + kHPad; + } } if (fOverrideHeight != -1.0f) *height = fOverrideHeight; else { - if (fVertical) { + if (fBarView->Vertical()) { *height = iconBounds.Height() + kVPad * 4; - if (fDrawLabel && iconBounds.Width() > 32) + if (!static_cast(be_app)->Settings()->hideLabels + && iconBounds.Width() > 32) { *height += fLabelAscent + fLabelDescent; + } } else { *height = iconBounds.Height() + kVPad * 4; } @@ -204,7 +207,7 @@ TTeamMenuItem::Draw() flags |= BControlLook::B_ACTIVATED; uint32 borders = BControlLook::B_TOP_BORDER; - if (fVertical) { + if (fBarView->Vertical()) { menu->SetHighColor(tint_color(menuColor, B_DARKEN_1_TINT)); borders |= BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER; @@ -247,11 +250,12 @@ TTeamMenuItem::DrawContent() BRect frame(Frame()); BRect iconBounds(fIcon->Bounds()); BRect dstRect(iconBounds); - float extra = fVertical ? 0.0f : -1.0f; + float extra = fBarView->Vertical() ? 0.0f : -1.0f; BPoint contLoc = ContentLocation(); BPoint drawLoc = contLoc + BPoint(kHPad, kVPad); - if (!fDrawLabel || (fVertical && iconBounds.Width() > 32)) { + if (static_cast(be_app)->Settings()->hideLabels + || (fBarView->Vertical() && iconBounds.Width() > 32)) { float offsetx = contLoc.x + ((frame.Width() - iconBounds.Width()) / 2) + extra; float offsety = contLoc.y + 3.0f + extra; @@ -271,13 +275,14 @@ TTeamMenuItem::DrawContent() float labelHeight = fLabelAscent + fLabelDescent; 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); } - if (fDrawLabel) { + if (!static_cast(be_app)->Settings()->hideLabels) { menu->SetDrawingMode(B_OP_OVER); menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); @@ -287,7 +292,8 @@ TTeamMenuItem::DrawContent() DrawContentLabel(); } - if (fVertical && static_cast(be_app)->Settings()->superExpando + if (fBarView->Vertical() + && static_cast(be_app)->Settings()->superExpando && fBarView->ExpandoState()) { DrawExpanderArrow(); } @@ -301,16 +307,17 @@ TTeamMenuItem::DrawContentLabel() menu->MovePenBy(0, fLabelAscent); float cachedWidth = menu->StringWidth(Label()); - if (Submenu() && fVertical) + if (Submenu() != NULL && fBarView->Vertical()) cachedWidth += 18; const char* label = Label(); char* truncLabel = NULL; float max = 0; - if (fVertical && static_cast(be_app)->Settings()->superExpando) + if (fBarView->Vertical() + && static_cast(be_app)->Settings()->superExpando) { max = menu->MaxContentWidth() - kSwitchWidth; - else + } else max = menu->MaxContentWidth() - 4.0f; if (max > 0) { @@ -462,7 +469,7 @@ TTeamMenuItem::ExpanderBounds() const void TTeamMenuItem::_InitData(BList* team, BBitmap* icon, char* name, char* sig, - float width, float height, bool drawLabel, bool vertical) + float width, float height) { fTeam = team; fIcon = icon; @@ -476,8 +483,6 @@ TTeamMenuItem::_InitData(BList* team, BBitmap* icon, char* name, char* sig, SetLabel(fName); fOverrideWidth = width; fOverrideHeight = height; - fDrawLabel = drawLabel; - fVertical = vertical; fBarView = static_cast(be_app)->BarView(); BFont font(be_plain_font); diff --git a/src/apps/deskbar/TeamMenuItem.h b/src/apps/deskbar/TeamMenuItem.h index 14c86b4893..25559762bc 100644 --- a/src/apps/deskbar/TeamMenuItem.h +++ b/src/apps/deskbar/TeamMenuItem.h @@ -53,12 +53,9 @@ class TTeamMenuItem : public BMenuItem { public: TTeamMenuItem(BList* team, BBitmap* icon, char* name, char* sig, - float width = -1.0f, float height = -1.0f, - bool drawLabel = true, - bool vertical = true); + float width = -1.0f, float height = -1.0f); TTeamMenuItem(float width = -1.0f, - float height = -1.0f, - bool vertical = true); + float height = -1.0f); virtual ~TTeamMenuItem(); status_t Invoke(BMessage* msg = NULL); @@ -94,9 +91,7 @@ private: friend class TExpandoMenuBar; void _InitData(BList* team, BBitmap* icon, char* name, char* sig, - float width = -1.0f, float height = -1.0f, - bool drawLabel = true, - bool vertical = true); + float width = -1.0f, float height = -1.0f); bool _IsSelected() const; @@ -107,8 +102,6 @@ private: char* fSig; float fOverrideWidth; float fOverrideHeight; - bool fDrawLabel; - bool fVertical; TBarView* fBarView; float fLabelWidth;