summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Scipione <jscipione@gmail.com>2017-01-09 10:31:41 (GMT)
committerJohn Scipione <jscipione@gmail.com>2017-01-09 10:32:56 (GMT)
commitb1967b1012c09e5e41f876bf07343cb1ca29898b (patch)
tree0c1db51c8dc1f72f9965b5ebb11ec172e2db9f73
parent2154128845326c963e37c20edd05bef348f6c7e4 (diff)
Revert "Deskbar: Scale cut-off leaf icon in horizontal mode"hrev50849
This reverts commit 066137eb05fc965261d6e50f24e41b9dcf79a5a7. Reverting while I figure out what is causing Deskbar to crash.
-rw-r--r--src/apps/deskbar/BarApp.cpp1
-rw-r--r--src/apps/deskbar/BarMenuBar.cpp8
-rw-r--r--src/apps/deskbar/BarMenuBar.h8
-rw-r--r--src/apps/deskbar/BarMenuTitle.cpp106
-rw-r--r--src/apps/deskbar/BarMenuTitle.h48
-rw-r--r--src/apps/deskbar/BarView.cpp5
-rw-r--r--src/apps/deskbar/ExpandoMenuBar.cpp24
-rw-r--r--src/apps/deskbar/ExpandoMenuBar.h1
-rw-r--r--src/apps/deskbar/StatusView.cpp11
-rw-r--r--src/apps/deskbar/StatusView.h12
-rw-r--r--src/apps/deskbar/icons.h1
-rw-r--r--src/apps/deskbar/icons.rdef13
12 files changed, 53 insertions, 185 deletions
diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index 2187d7f..d196bd8 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -66,6 +66,7 @@ All rights reserved.
#include "Switcher.h"
#include "Utilities.h"
+#include "icons.h"
#include "tracker_private.h"
diff --git a/src/apps/deskbar/BarMenuBar.cpp b/src/apps/deskbar/BarMenuBar.cpp
index 2211d6b..2189d12 100644
--- a/src/apps/deskbar/BarMenuBar.cpp
+++ b/src/apps/deskbar/BarMenuBar.cpp
@@ -43,7 +43,6 @@ All rights reserved.
#include "icons.h"
-#include "BarApp.h"
#include "BarMenuTitle.h"
#include "BarView.h"
#include "BarWindow.h"
@@ -109,9 +108,8 @@ TBarMenuBar::TBarMenuBar(BRect frame, const char* name, TBarView* barView)
TDeskbarMenu* beMenu = new TDeskbarMenu(barView);
TBarWindow::SetDeskbarMenu(beMenu);
- fDeskbarMenuItem = new TDeskbarMenuTitle(frame.Width(), frame.Height(),
- NULL, beMenu);
- fDeskbarMenuItem->FetchIcon();
+ fDeskbarMenuItem = new TBarMenuTitle(0.0f, 0.0f,
+ AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_LeafLogoBitmap), beMenu);
AddItem(fDeskbarMenuItem);
}
@@ -143,8 +141,6 @@ TBarMenuBar::SmartResize(float width, float height)
fAppListMenuItem->SetContentSize(width / count, height);
}
- fDeskbarMenuItem->FetchIcon();
-
InvalidateLayout();
}
diff --git a/src/apps/deskbar/BarMenuBar.h b/src/apps/deskbar/BarMenuBar.h
index 0a16c72..f470d38 100644
--- a/src/apps/deskbar/BarMenuBar.h
+++ b/src/apps/deskbar/BarMenuBar.h
@@ -47,7 +47,6 @@ All rights reserved.
class TBarMenuTitle;
class TBarView;
-class TDeskbarMenuTitle;
class TSeparatorItem : public BSeparatorItem {
public:
@@ -64,10 +63,9 @@ public:
virtual void MouseMoved(BPoint where, uint32 code,
const BMessage* message);
-
virtual void Draw(BRect);
- void DrawBackground(BRect);
+ void DrawBackground(BRect);
void SmartResize(float width = -1.0f,
float height = -1.0f);
@@ -81,11 +79,9 @@ public:
bool (* hookfunction)(BMenu*, void*),
void* state, bool both = false);
- TDeskbarMenuTitle* DeskbarMenuTitle() { return fDeskbarMenuItem; };
-
private:
TBarView* fBarView;
- TDeskbarMenuTitle* fDeskbarMenuItem;
+ TBarMenuTitle* fDeskbarMenuItem;
TBarMenuTitle* fAppListMenuItem;
TSeparatorItem* fSeparatorItem;
};
diff --git a/src/apps/deskbar/BarMenuTitle.cpp b/src/apps/deskbar/BarMenuTitle.cpp
index bd589f4..48b1bf7 100644
--- a/src/apps/deskbar/BarMenuTitle.cpp
+++ b/src/apps/deskbar/BarMenuTitle.cpp
@@ -36,28 +36,22 @@ All rights reserved.
#include "BarMenuTitle.h"
-#include <algorithm>
-
#include <Bitmap.h>
#include <ControlLook.h>
#include <Debug.h>
-#include <IconUtils.h>
#include "BarApp.h"
#include "BarView.h"
#include "BarWindow.h"
-#include "ResourceSet.h"
-#include "StatusView.h"
-
-#include "icons.h"
TBarMenuTitle::TBarMenuTitle(float width, float height, const BBitmap* icon,
- BMenu* menu)
+ BMenu* menu, bool expando)
:
BMenuItem(menu, new BMessage(B_REFS_RECEIVED)),
fWidth(width),
fHeight(height),
+ fInExpando(expando),
fIcon(icon)
{
}
@@ -129,7 +123,7 @@ TBarMenuTitle::DrawContent()
float widthOffset = rintf((frame.Width() - iconRect.Width()) / 2);
float heightOffset = rintf((frame.Height() - iconRect.Height()) / 2);
- iconRect.OffsetBy(widthOffset - 1, heightOffset - 1);
+ iconRect.OffsetBy(widthOffset - 1.0f, heightOffset + 2.0f);
menu->DrawBitmapAsync(fIcon, iconRect);
}
@@ -150,97 +144,3 @@ TBarMenuTitle::Invoke(BMessage* message)
return BMenuItem::Invoke(message);
}
-
-
-void
-TBarMenuTitle::SetIcon(const BBitmap* icon)
-{
- delete fIcon;
- fIcon = icon;
-}
-
-
-// #pragma mark - TDeskbarMenuTitle
-
-
-const int32 kIconSizeCutoff = 48;
- // icon size to stop increasing logo width in horizontal mode
-
-
-TDeskbarMenuTitle::TDeskbarMenuTitle(float width, float height,
- const BBitmap* icon, BMenu* menu)
- :
- TBarMenuTitle(width, height, icon, menu),
- fVectorIconData(NULL),
- fVectorIconSize(0)
-{
-}
-
-
-void
-TDeskbarMenuTitle::DrawContent()
-{
- if (fIcon == NULL)
- return;
-
- BMenu* menu = Menu();
- BRect frame(Frame());
- BRect iconRect(fIcon->Bounds());
-
- menu->SetDrawingMode(B_OP_ALPHA);
- iconRect.OffsetTo(frame.LeftTop());
-
- float widthOffset = rintf((frame.Width() - iconRect.Width()) / 2);
- float heightOffset = rintf((frame.Height() - iconRect.Height()) / 2);
-
- // move bitmap down a few pixels so leaf gets cut off
- heightOffset += 3;
-
- iconRect.OffsetBy(widthOffset - 1, heightOffset - 1);
-
- menu->DrawBitmapAsync(fIcon, iconRect);
-}
-
-
-const BBitmap*
-TDeskbarMenuTitle::FetchIcon()
-{
- if (fVectorIconData == NULL || fVectorIconSize == 0) {
- // haven't fetched vector icon data yet, fetch it
- fVectorIconData = (const uint8*)AppResSet()->FindResource(
- B_VECTOR_ICON_TYPE, R_LeafLogoVector, &fVectorIconSize);
- }
-
- float width = CalcIconWidth();
- BBitmap* icon = new BBitmap(BRect(0, 0, width - 1, width - 1),
- B_RGBA32);
- if (fVectorIconData != NULL && fVectorIconSize > 0
- && BIconUtils::GetVectorIcon(fVectorIconData, fVectorIconSize, icon)
- == B_OK) {
- // rasterized vector icon into a bitmap
- fIcon = icon;
- } else {
- // fetched bitmap instead
- fIcon = AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_LeafLogoBitmap);
- // TODO: scale the bitmap into icon
- delete icon;
- }
-
- return fIcon;
-}
-
-
-float
-TDeskbarMenuTitle::CalcIconWidth()
-{
- TBarApp* barApp = static_cast<TBarApp*>(be_app);
- bool isVertical = barApp->BarView()->Vertical();
- bool hasBitmapIcon = fVectorIconData == NULL;
-
- float m = 3;
- float x = (isVertical || hasBitmapIcon) ? kMinimumIconSize
- : std::min(barApp->IconSize(), kIconSizeCutoff);
- float b = kMinimumIconSize;
-
- return m * x + b;
-}
diff --git a/src/apps/deskbar/BarMenuTitle.h b/src/apps/deskbar/BarMenuTitle.h
index a4f68cd..f7bcac0 100644
--- a/src/apps/deskbar/BarMenuTitle.h
+++ b/src/apps/deskbar/BarMenuTitle.h
@@ -32,8 +32,8 @@ brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
-#ifndef BAR_MENU_TITLE_H
-#define BAR_MENU_TITLE_H
+#ifndef BARMENUTITLE_H
+#define BARMENUTITLE_H
//
@@ -47,45 +47,27 @@ All rights reserved.
class BBitmap;
class BMenu;
-
class TBarMenuTitle : public BMenuItem {
public:
- TBarMenuTitle(float width, float height,
- const BBitmap* icon, BMenu* menu);
- virtual ~TBarMenuTitle();
-
- virtual void SetContentSize(float width, float height);
- virtual void Draw();
+ TBarMenuTitle(float width, float height, const BBitmap* icon,
+ BMenu* menu, bool expando = false);
+ virtual ~TBarMenuTitle();
- virtual status_t Invoke(BMessage* message);
+ void SetContentSize(float width, float height);
+ void Draw();
- const BBitmap* Icon() { return fIcon; };
- virtual void SetIcon(const BBitmap* icon);
+ status_t Invoke(BMessage* message);
protected:
- virtual void DrawContent();
- virtual void GetContentSize(float* width, float* height);
-
- float fWidth;
- float fHeight;
- const BBitmap* fIcon;
-};
-
-
-class TDeskbarMenuTitle : public TBarMenuTitle {
-public:
- TDeskbarMenuTitle(float width, float height,
- const BBitmap* icon, BMenu* menu);
-
- virtual void DrawContent();
-
- const BBitmap* FetchIcon();
- float CalcIconWidth();
+ void DrawContent();
+ void GetContentSize(float* width, float* height);
private:
- const uint8* fVectorIconData;
- size_t fVectorIconSize;
+ float fWidth;
+ float fHeight;
+ bool fInExpando;
+ const BBitmap* fIcon;
};
-#endif // BAR_MENU_TITLE_H
+#endif // BARMENUTITLE_H
diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index 809f78b..bd45e30 100644
--- a/src/apps/deskbar/BarView.cpp
+++ b/src/apps/deskbar/BarView.cpp
@@ -49,7 +49,6 @@ All rights reserved.
#include "icons.h"
#include "BarApp.h"
#include "BarMenuBar.h"
-#include "BarMenuTitle.h"
#include "BarWindow.h"
#include "DeskbarMenu.h"
#include "DeskbarUtils.h"
@@ -395,10 +394,8 @@ TBarView::PlaceDeskbarMenu()
width += 1;
} else {
// shows apps to the right of bemenu
- width = fBarMenuBar->DeskbarMenuTitle()->CalcIconWidth()
- + kMinimumIconSize;
fBarMenuBar->AddSeparatorItem();
- width += kSepItemWidth;
+ width = floorf(width) / 2 + kSepItemWidth;
}
loc = Bounds().LeftTop();
} else {
diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp
index 3dacb7e..f3226f8 100644
--- a/src/apps/deskbar/ExpandoMenuBar.cpp
+++ b/src/apps/deskbar/ExpandoMenuBar.cpp
@@ -55,7 +55,6 @@ All rights reserved.
#include "icons.h"
#include "BarApp.h"
-#include "BarMenuBar.h"
#include "BarMenuTitle.h"
#include "BarView.h"
#include "BarWindow.h"
@@ -96,6 +95,7 @@ TExpandoMenuBar::TExpandoMenuBar(TBarView* barView, bool vertical)
fVertical(vertical),
fOverflow(false),
fFirstBuild(true),
+ fDeskbarMenuWidth(kMinMenuItemWidth),
fPreviousDragTargetItem(NULL),
fLastMousedOverItem(NULL),
fLastClickedItem(NULL)
@@ -103,6 +103,13 @@ TExpandoMenuBar::TExpandoMenuBar(TBarView* barView, bool vertical)
SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
SetFont(be_plain_font);
SetMaxItemWidth();
+
+ // 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;
}
@@ -362,7 +369,7 @@ TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
break;
}
- if (!static_cast<TBarApp*>(be_app)->Settings()->hideLabels) {
+ if (!dynamic_cast<TBarApp*>(be_app)->Settings()->hideLabels) {
// item has a visible label, set tool tip if truncated
fLastMousedOverItem = menuItem;
if (strcasecmp(item->TruncatedLabel(), item->Label()) > 0) {
@@ -734,11 +741,8 @@ TExpandoMenuBar::CheckItemSizes(int32 delta)
bool drawLabels = !static_cast<TBarApp*>(be_app)->Settings()->hideLabels;
- float deskbarMenuWidth
- = fBarView->BarMenuBar()->DeskbarMenuTitle()->CalcIconWidth();
-
float maxWidth = fBarView->DragRegion()->Frame().left
- - deskbarMenuWidth - kSepItemWidth;
+ - fDeskbarMenuWidth - kSepItemWidth;
int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
float iconOnlyWidth = kIconPadding + iconSize + kIconPadding;
float minItemWidth = drawLabels
@@ -747,7 +751,7 @@ TExpandoMenuBar::CheckItemSizes(int32 delta)
float maxItemWidth = drawLabels
? gMinimumWindowWidth + iconSize - kMinimumIconSize
: iconOnlyWidth;
- float menuWidth = maxItemWidth * CountItems() + deskbarMenuWidth
+ float menuWidth = maxItemWidth * CountItems() + fDeskbarMenuWidth
+ kSepItemWidth;
bool reset = false;
@@ -877,12 +881,10 @@ TExpandoMenuBar::CheckForSizeOverrun()
float minItemWidth = !static_cast<TBarApp*>(be_app)->Settings()->hideLabels
? iconOnlyWidth + kMinMenuItemWidth
: iconOnlyWidth - kIconPadding;
- float deskbarMenuWidth
- = fBarView->BarMenuBar()->DeskbarMenuTitle()->CalcIconWidth();
- float menuWidth = minItemWidth * CountItems() + deskbarMenuWidth
+ float menuWidth = minItemWidth * CountItems() + fDeskbarMenuWidth
+ kSepItemWidth;
float maxWidth = fBarView->DragRegion()->Frame().left
- - deskbarMenuWidth - kSepItemWidth;
+ - fDeskbarMenuWidth - kSepItemWidth;
return menuWidth > maxWidth;
}
diff --git a/src/apps/deskbar/ExpandoMenuBar.h b/src/apps/deskbar/ExpandoMenuBar.h
index 5be5f24..5f338c5 100644
--- a/src/apps/deskbar/ExpandoMenuBar.h
+++ b/src/apps/deskbar/ExpandoMenuBar.h
@@ -116,6 +116,7 @@ private:
bool fOverflow : 1;
bool fFirstBuild : 1;
+ float fDeskbarMenuWidth;
TTeamMenuItem* fPreviousDragTargetItem;
BMenuItem* fLastMousedOverItem;
BMenuItem* fLastClickedItem;
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index 1137f4d..89913dc 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -69,8 +69,6 @@ All rights reserved.
#include "icons.h"
#include "BarApp.h"
-#include "BarMenuBar.h"
-#include "BarMenuTitle.h"
#include "DeskbarUtils.h"
#include "ResourceSet.h"
#include "StatusViewShelf.h"
@@ -140,8 +138,15 @@ TReplicantTray::TReplicantTray(TBarView* parent, bool vertical)
fMinimumTrayWidth(kMinimumTrayWidth),
fAlignmentSupport(false)
{
+ // init the minimum window width according to the logo.
+ const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE,
+ R_LeafLogoBitmap);
+ if (logoBitmap != NULL) {
+ gMinimumWindowWidth = std::max(gMinimumWindowWidth,
+ 2 * (logoBitmap->Bounds().Width() + 8));
+ }
gMinimumWindowWidth = std::max(gMinimumWindowWidth,
- be_plain_font->StringWidth("WWWWWWWWW") + 20);
+ be_plain_font->StringWidth("WWWWWWWWW") + 20);
if (vertical)
fMinimumTrayWidth = gMinimumWindowWidth - kGutter - kDragRegionWidth;
diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h
index 9a61685..8a7e88d 100644
--- a/src/apps/deskbar/StatusView.h
+++ b/src/apps/deskbar/StatusView.h
@@ -48,15 +48,17 @@ All rights reserved.
const float kMaxReplicantHeight = 16.0f;
const float kMaxReplicantWidth = 16.0f;
-const int32 kMinimumReplicantCount = 7;
+const int32 kMinimumReplicantCount = 6;
const int32 kIconGap = 2;
const int32 kGutter = 1;
const int32 kDragRegionWidth = 6;
-// space for replicant tray with gap on each side (7 items)
-// minus 6 pixel drag region
-const float kMinimumTrayWidth = kMinimumReplicantCount
- * (kIconGap + kMaxReplicantWidth + kIconGap) - kDragRegionWidth;
+// 1 pixel for left gutter
+// space for replicant tray (6 items)
+// 6 pixel drag region
+const float kMinimumTrayWidth = kIconGap
+ + (kMinimumReplicantCount * kIconGap)
+ + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter;
const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter;
extern float gMinimumWindowWidth;
diff --git a/src/apps/deskbar/icons.h b/src/apps/deskbar/icons.h
index 9bc9db5..e5e65e0 100644
--- a/src/apps/deskbar/icons.h
+++ b/src/apps/deskbar/icons.h
@@ -1,6 +1,5 @@
enum {
R_LeafLogoBitmap = 14,
- R_LeafLogoVector = 15,
R_LargeNewGroupIcon = 16,
R_SmallNewGroupIcon = 17,
R_TeamIcon = 18,
diff --git a/src/apps/deskbar/icons.rdef b/src/apps/deskbar/icons.rdef
index 88a3052..d023d86 100644
--- a/src/apps/deskbar/icons.rdef
+++ b/src/apps/deskbar/icons.rdef
@@ -192,19 +192,6 @@ resource(R_LeafLogoBitmap) archive(, 0x00000000) BBitmap {
}
};
-resource(R_LeafLogoVector) #'VICN' array {
- $"6E6369660102010602407715BE05F73AC66F3D61964A3C0A4C40170000AAFFFF"
- $"00337F010216B9CBCB3DB9CBCB3DBC63CDC0C1BACE05BF13CE7BC14B63C0EACC"
- $"FAC116CD4DC3DFCEAEC644CBE0C55BCC8FC5F4CB9FC4F0CB0CC592CBD1C5BFCB"
- $"29C704CB1CC646CB1DC77DCAACC8A0C9CEC831CA54C929C92BCA66C78FC9D7C8"
- $"4ACA0BC757C9D5C6DEC9F8C725CA29C6F4CAD1C6FCCA7EC6FECB42C624CC6EC5"
- $"62CBF6C59CCA78C4B2C625C52AC7F6C4CAC58AC5B0C55DC77DC58EC65EC4FBC6"
- $"FCC509C57DC4D0C65CC3C1C5E4C14FC703C283C671C0D8C73BBF09C852BFB3C8"
- $"10BEB8C8CCBE3DC9B2BE74C943BE3AC94BBE32C87BBE2AC8E5BBFFC8D4B96CCA"
- $"A7BACBC96BB67CCAA9B337C8EFB331C964B337C8EFB328CA02B328CA02B328CA"
- $"02B9CDCB3EB6D2CB6AB9CDCB3E010A000100202009"
-};
-
resource(R_LargeNewGroupIcon) archive(, 0x00000000) BBitmap {
"_frame" = rect { 0.0, 0.0, 31.0, 31.0 },
"_cspace" = 4,