Revert "Deskbar: Scale cut-off leaf icon in horizontal mode"
This reverts commit 066137eb05.
Reverting while I figure out what is causing Deskbar to crash.
This commit is contained in:
@@ -66,6 +66,7 @@ All rights reserved.
|
||||
#include "Switcher.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include "icons.h"
|
||||
#include "tracker_private.h"
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
TBarMenuTitle(float width, float height, const BBitmap* icon,
|
||||
BMenu* menu, bool expando = false);
|
||||
virtual ~TBarMenuTitle();
|
||||
|
||||
virtual void SetContentSize(float width, float height);
|
||||
virtual void Draw();
|
||||
void SetContentSize(float width, float height);
|
||||
void Draw();
|
||||
|
||||
virtual status_t Invoke(BMessage* message);
|
||||
|
||||
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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ private:
|
||||
bool fOverflow : 1;
|
||||
bool fFirstBuild : 1;
|
||||
|
||||
float fDeskbarMenuWidth;
|
||||
TTeamMenuItem* fPreviousDragTargetItem;
|
||||
BMenuItem* fLastMousedOverItem;
|
||||
BMenuItem* fLastClickedItem;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
enum {
|
||||
R_LeafLogoBitmap = 14,
|
||||
R_LeafLogoVector = 15,
|
||||
R_LargeNewGroupIcon = 16,
|
||||
R_SmallNewGroupIcon = 17,
|
||||
R_TeamIcon = 18,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user