Fisher Price Deskbar icon support
Implements the feature described in #7132 Also fixes #2387 (menu items too big in horizontal mode when font size > 12) Adds a slider to Deskbar preferences which allows you to resize your Deskbar team icons from 16x16 to 96x96. The default is 16x16. This works both in vertical and horizontal mode. In vertical mode when icon sizes are greater than 32x32 the label moves underneath the icon where there is more room. In horizontal mode the width of the menu item increases to make room for the icon while keeping room for the label the same. As many applications are added the labels are truncated as usual. This patch also adds a checkbox to the Deskbar preferences to hide application names to make more room for icons if you wish. It doesn't make a lot of sense at 16x16 but does >32x32. If the kResizeTeamIcons message gets dropped, don't resize to current value, just do nothing. This fixes a bug where sometimes the slider wouldn't trigger a resize. Fix a spelling error in a comment. Take out a redundant paren pair.
This commit is contained in:
@@ -74,7 +74,6 @@ const uint32 kShowDeskbarMenu = 'BeMn';
|
|||||||
const uint32 kShowTeamMenu = 'TmMn';
|
const uint32 kShowTeamMenu = 'TmMn';
|
||||||
|
|
||||||
|
|
||||||
const BRect kIconRect(0.0f, 0.0f, 15.0f, 15.0f);
|
|
||||||
static const color_space kIconFormat = B_RGBA32;
|
static const color_space kIconFormat = B_RGBA32;
|
||||||
|
|
||||||
|
|
||||||
@@ -215,6 +214,8 @@ TBarApp::SaveSettings()
|
|||||||
storedSettings.AddBool("sortRunningApps", fSettings.sortRunningApps);
|
storedSettings.AddBool("sortRunningApps", fSettings.sortRunningApps);
|
||||||
storedSettings.AddBool("superExpando", fSettings.superExpando);
|
storedSettings.AddBool("superExpando", fSettings.superExpando);
|
||||||
storedSettings.AddBool("expandNewTeams", fSettings.expandNewTeams);
|
storedSettings.AddBool("expandNewTeams", fSettings.expandNewTeams);
|
||||||
|
storedSettings.AddBool("hideLabels", fSettings.hideLabels);
|
||||||
|
storedSettings.AddInt32("iconSize", fSettings.iconSize);
|
||||||
storedSettings.AddBool("autoRaise", fSettings.autoRaise);
|
storedSettings.AddBool("autoRaise", fSettings.autoRaise);
|
||||||
storedSettings.AddBool("autoHide", fSettings.autoHide);
|
storedSettings.AddBool("autoHide", fSettings.autoHide);
|
||||||
storedSettings.AddBool("recentAppsEnabled",
|
storedSettings.AddBool("recentAppsEnabled",
|
||||||
@@ -251,6 +252,8 @@ TBarApp::InitSettings()
|
|||||||
settings.sortRunningApps = false;
|
settings.sortRunningApps = false;
|
||||||
settings.superExpando = false;
|
settings.superExpando = false;
|
||||||
settings.expandNewTeams = false;
|
settings.expandNewTeams = false;
|
||||||
|
settings.hideLabels = false;
|
||||||
|
settings.iconSize = kMinimumIconSize;
|
||||||
settings.autoRaise = false;
|
settings.autoRaise = false;
|
||||||
settings.autoHide = false;
|
settings.autoHide = false;
|
||||||
settings.recentAppsEnabled = true;
|
settings.recentAppsEnabled = true;
|
||||||
@@ -301,6 +304,8 @@ TBarApp::InitSettings()
|
|||||||
&settings.sortRunningApps);
|
&settings.sortRunningApps);
|
||||||
storedSettings.FindBool("superExpando", &settings.superExpando);
|
storedSettings.FindBool("superExpando", &settings.superExpando);
|
||||||
storedSettings.FindBool("expandNewTeams", &settings.expandNewTeams);
|
storedSettings.FindBool("expandNewTeams", &settings.expandNewTeams);
|
||||||
|
storedSettings.FindBool("hideLabels", &settings.hideLabels);
|
||||||
|
storedSettings.FindInt32("iconSize", (int32*)&settings.iconSize);
|
||||||
storedSettings.FindBool("autoRaise", &settings.autoRaise);
|
storedSettings.FindBool("autoRaise", &settings.autoRaise);
|
||||||
storedSettings.FindBool("autoHide", &settings.autoHide);
|
storedSettings.FindBool("autoHide", &settings.autoHide);
|
||||||
storedSettings.FindBool("recentAppsEnabled",
|
storedSettings.FindBool("recentAppsEnabled",
|
||||||
@@ -484,6 +489,36 @@ TBarApp::MessageReceived(BMessage* message)
|
|||||||
fBarWindow->Unlock();
|
fBarWindow->Unlock();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kHideLabels:
|
||||||
|
fSettings.hideLabels = !fSettings.hideLabels;
|
||||||
|
|
||||||
|
fBarWindow->Lock();
|
||||||
|
BarView()->UpdatePlacement();
|
||||||
|
fBarWindow->Unlock();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kResizeTeamIcons:
|
||||||
|
{
|
||||||
|
int32 iconSize;
|
||||||
|
|
||||||
|
if (message->FindInt32("be:value", &iconSize) < B_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
fSettings.iconSize = iconSize * kIconSizeInterval;
|
||||||
|
|
||||||
|
if (fSettings.iconSize < kMinimumIconSize)
|
||||||
|
fSettings.iconSize = kMinimumIconSize;
|
||||||
|
else if (fSettings.iconSize > kMaximumIconSize)
|
||||||
|
fSettings.iconSize = kMaximumIconSize;
|
||||||
|
|
||||||
|
ResizeTeamIcons();
|
||||||
|
|
||||||
|
fBarWindow->Lock();
|
||||||
|
BarView()->UpdatePlacement();
|
||||||
|
fBarWindow->Unlock();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'TASK':
|
case 'TASK':
|
||||||
fSwitcherMessenger.SendMessage(message);
|
fSwitcherMessenger.SendMessage(message);
|
||||||
break;
|
break;
|
||||||
@@ -647,11 +682,13 @@ TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)
|
|||||||
name = ref->name;
|
name = ref->name;
|
||||||
|
|
||||||
BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
|
BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
|
||||||
new BBitmap(kIconRect, kIconFormat), strdup(name.String()));
|
new BBitmap(IconRect(), kIconFormat), strdup(ref->name));
|
||||||
|
|
||||||
|
if ((barInfo->flags & B_BACKGROUND_APP) == 0
|
||||||
|
&& strcasecmp(barInfo->sig, kDeskbarSignature) != 0)
|
||||||
|
FetchAppIcon(barInfo->sig, barInfo->icon);
|
||||||
|
|
||||||
barInfo->teams->AddItem((void*)team);
|
barInfo->teams->AddItem((void*)team);
|
||||||
if (appMime.GetIcon(barInfo->icon, B_MINI_ICON) != B_OK)
|
|
||||||
appMime.GetTrackerIcon(barInfo->icon, B_MINI_ICON);
|
|
||||||
|
|
||||||
sBarTeamInfoList.AddItem(barInfo);
|
sBarTeamInfoList.AddItem(barInfo);
|
||||||
|
|
||||||
@@ -715,6 +752,27 @@ TBarApp::RemoveTeam(team_id team)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TBarApp::ResizeTeamIcons()
|
||||||
|
{
|
||||||
|
for (int32 i = 0; i < sBarTeamInfoList.CountItems(); i++) {
|
||||||
|
BarTeamInfo* barInfo = (BarTeamInfo*)sBarTeamInfoList.ItemAt(i);
|
||||||
|
if ((barInfo->flags & B_BACKGROUND_APP) == 0
|
||||||
|
&& strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {
|
||||||
|
barInfo->icon = new BBitmap(IconRect(), kIconFormat);
|
||||||
|
FetchAppIcon(barInfo->sig, barInfo->icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
TBarApp::IconSize()
|
||||||
|
{
|
||||||
|
return fSettings.iconSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TBarApp::ShowPreferencesWindow()
|
TBarApp::ShowPreferencesWindow()
|
||||||
{
|
{
|
||||||
@@ -727,6 +785,31 @@ TBarApp::ShowPreferencesWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TBarApp::FetchAppIcon(const char* signature, BBitmap* icon)
|
||||||
|
{
|
||||||
|
app_info appInfo;
|
||||||
|
|
||||||
|
if (be_roster->GetAppInfo(signature, &appInfo) == B_OK) {
|
||||||
|
BFile file(&appInfo.ref, B_READ_ONLY);
|
||||||
|
BAppFileInfo appMime(&file);
|
||||||
|
icon_size size = icon->Bounds().IntegerHeight() >= 32
|
||||||
|
? B_LARGE_ICON : B_MINI_ICON;
|
||||||
|
|
||||||
|
if (appMime.GetIcon(icon, size) != B_OK)
|
||||||
|
appMime.GetTrackerIcon(icon, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
TBarApp::IconRect()
|
||||||
|
{
|
||||||
|
int32 iconSize = IconSize();
|
||||||
|
return BRect(0, 0, iconSize - 1, iconSize - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@@ -758,4 +841,3 @@ BarTeamInfo::~BarTeamInfo()
|
|||||||
delete icon;
|
delete icon;
|
||||||
free(name);
|
free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ const uint32 kTrackerFirst = 'TkFt';
|
|||||||
const uint32 kSortRunningApps = 'SAps';
|
const uint32 kSortRunningApps = 'SAps';
|
||||||
const uint32 kSuperExpando = 'SprE';
|
const uint32 kSuperExpando = 'SprE';
|
||||||
const uint32 kExpandNewTeams = 'ExTm';
|
const uint32 kExpandNewTeams = 'ExTm';
|
||||||
|
const uint32 kHideLabels = 'hLbs';
|
||||||
|
const uint32 kResizeTeamIcons = 'RTIs';
|
||||||
const uint32 kAutoRaise = 'AtRs';
|
const uint32 kAutoRaise = 'AtRs';
|
||||||
const uint32 kAutoHide = 'AtHd';
|
const uint32 kAutoHide = 'AtHd';
|
||||||
const uint32 kRestartTracker = 'Trak';
|
const uint32 kRestartTracker = 'Trak';
|
||||||
@@ -89,6 +91,11 @@ const uint32 kShutdownSystem = 301;
|
|||||||
const uint32 kRebootSystem = 302;
|
const uint32 kRebootSystem = 302;
|
||||||
const uint32 kSuspendSystem = 304;
|
const uint32 kSuspendSystem = 304;
|
||||||
|
|
||||||
|
// icon size constants
|
||||||
|
const int32 kMinimumIconSize = 16;
|
||||||
|
const int32 kMaximumIconSize = 96;
|
||||||
|
const int32 kIconSizeInterval = 8;
|
||||||
|
|
||||||
/* --------------------------------------------- */
|
/* --------------------------------------------- */
|
||||||
|
|
||||||
struct desk_settings {
|
struct desk_settings {
|
||||||
@@ -110,6 +117,8 @@ struct desk_settings {
|
|||||||
bool sortRunningApps;
|
bool sortRunningApps;
|
||||||
bool superExpando;
|
bool superExpando;
|
||||||
bool expandNewTeams;
|
bool expandNewTeams;
|
||||||
|
bool hideLabels;
|
||||||
|
int32 iconSize;
|
||||||
bool autoRaise;
|
bool autoRaise;
|
||||||
bool autoHide;
|
bool autoHide;
|
||||||
bool recentAppsEnabled;
|
bool recentAppsEnabled;
|
||||||
@@ -128,7 +137,7 @@ class TBarApp : public BApplication {
|
|||||||
TBarApp();
|
TBarApp();
|
||||||
virtual ~TBarApp();
|
virtual ~TBarApp();
|
||||||
|
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void RefsReceived(BMessage* refs);
|
virtual void RefsReceived(BMessage* refs);
|
||||||
|
|
||||||
@@ -141,6 +150,7 @@ class TBarApp : public BApplication {
|
|||||||
|
|
||||||
static void Subscribe(const BMessenger &subscriber, BList*);
|
static void Subscribe(const BMessenger &subscriber, BList*);
|
||||||
static void Unsubscribe(const BMessenger &subscriber);
|
static void Unsubscribe(const BMessenger &subscriber);
|
||||||
|
int32 IconSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddTeam(team_id team, uint32 flags, const char* sig, entry_ref*);
|
void AddTeam(team_id team, uint32 flags, const char* sig, entry_ref*);
|
||||||
@@ -150,6 +160,9 @@ class TBarApp : public BApplication {
|
|||||||
void SaveSettings();
|
void SaveSettings();
|
||||||
|
|
||||||
void ShowPreferencesWindow();
|
void ShowPreferencesWindow();
|
||||||
|
void ResizeTeamIcons();
|
||||||
|
void FetchAppIcon(const char* signature, BBitmap* icon);
|
||||||
|
BRect IconRect();
|
||||||
|
|
||||||
TBarWindow* fBarWindow;
|
TBarWindow* fBarWindow;
|
||||||
BMessenger fSwitcherMessenger;
|
BMessenger fSwitcherMessenger;
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ TBarView::PlaceDeskbarMenu()
|
|||||||
BRect menuFrame(fBarMenuBar->Frame());
|
BRect menuFrame(fBarMenuBar->Frame());
|
||||||
if (fState == kFullState) {
|
if (fState == kFullState) {
|
||||||
fBarMenuBar->RemoveTeamMenu();
|
fBarMenuBar->RemoveTeamMenu();
|
||||||
|
// TODO: Magic constants need explanation
|
||||||
width = 8 + 16 + 8;
|
width = 8 + 16 + 8;
|
||||||
loc = Bounds().LeftTop();
|
loc = Bounds().LeftTop();
|
||||||
} else if (fState == kExpandoState) {
|
} else if (fState == kExpandoState) {
|
||||||
@@ -381,15 +382,18 @@ TBarView::PlaceApplicationBar(BRect screenFrame)
|
|||||||
} else {
|
} else {
|
||||||
// top or bottom
|
// top or bottom
|
||||||
expandoFrame.top = 0;
|
expandoFrame.top = 0;
|
||||||
expandoFrame.bottom = kHModeHeight;
|
int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
|
||||||
|
expandoFrame.bottom = iconSize + 4;
|
||||||
if (fTrayLocation != 0)
|
if (fTrayLocation != 0)
|
||||||
expandoFrame.right = fDragRegion->Frame().left - 1;
|
expandoFrame.right = fDragRegion->Frame().left - 1;
|
||||||
else
|
else
|
||||||
expandoFrame.right = screenFrame.Width();
|
expandoFrame.right = screenFrame.Width();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hideLabels = ((TBarApp*)be_app)->Settings()->hideLabels;
|
||||||
|
|
||||||
fExpando = new TExpandoMenuBar(this, expandoFrame, "ExpandoMenuBar",
|
fExpando = new TExpandoMenuBar(this, expandoFrame, "ExpandoMenuBar",
|
||||||
fVertical, fState != kFullState);
|
fVertical, !hideLabels && fState != kFullState);
|
||||||
AddChild(fExpando);
|
AddChild(fExpando);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,6 +405,7 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height)
|
|||||||
float windowWidth = sMinimumWindowWidth;
|
float windowWidth = sMinimumWindowWidth;
|
||||||
bool calcHiddenSize = ((TBarApp*)be_app)->Settings()->autoHide
|
bool calcHiddenSize = ((TBarApp*)be_app)->Settings()->autoHide
|
||||||
&& IsHidden() && !DragRegion()->IsDragging();
|
&& IsHidden() && !DragRegion()->IsDragging();
|
||||||
|
int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
|
||||||
|
|
||||||
if (!calcHiddenSize) {
|
if (!calcHiddenSize) {
|
||||||
if (fState == kFullState) {
|
if (fState == kFullState) {
|
||||||
@@ -413,7 +418,7 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height)
|
|||||||
} else {
|
} else {
|
||||||
// top or bottom, full
|
// top or bottom, full
|
||||||
fExpando->CheckItemSizes(0);
|
fExpando->CheckItemSizes(0);
|
||||||
windowHeight = kHModeHeight;
|
windowHeight = iconSize + 4;
|
||||||
windowWidth = screenFrame.Width();
|
windowWidth = screenFrame.Width();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -429,6 +434,7 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height)
|
|||||||
if (fState == kExpandoState && !fVertical) {
|
if (fState == kExpandoState && !fVertical) {
|
||||||
// top or bottom, full
|
// top or bottom, full
|
||||||
fExpando->CheckItemSizes(0);
|
fExpando->CheckItemSizes(0);
|
||||||
|
windowHeight = iconSize + 4;
|
||||||
windowWidth = screenFrame.Width();
|
windowWidth = screenFrame.Width();
|
||||||
} else
|
} else
|
||||||
windowWidth = kHModeHiddenHeight;
|
windowWidth = kHModeHiddenHeight;
|
||||||
@@ -1100,6 +1106,7 @@ BRect
|
|||||||
TBarView::OffsetIconFrame(BRect rect) const
|
TBarView::OffsetIconFrame(BRect rect) const
|
||||||
{
|
{
|
||||||
BRect frame(Frame());
|
BRect frame(Frame());
|
||||||
|
|
||||||
frame.left += fDragRegion->Frame().left + fReplicantTray->Frame().left
|
frame.left += fDragRegion->Frame().left + fReplicantTray->Frame().left
|
||||||
+ rect.left;
|
+ rect.left;
|
||||||
frame.top += fDragRegion->Frame().top + fReplicantTray->Frame().top
|
frame.top += fDragRegion->Frame().top + fReplicantTray->Frame().top
|
||||||
|
|||||||
@@ -138,11 +138,12 @@ class TBarView : public BView {
|
|||||||
float* height);
|
float* height);
|
||||||
void SizeWindow(BRect screenFrame);
|
void SizeWindow(BRect screenFrame);
|
||||||
void PositionWindow(BRect screenFrame);
|
void PositionWindow(BRect screenFrame);
|
||||||
|
void AddExpandedItem(const char* signature);
|
||||||
|
|
||||||
TExpandoMenuBar* ExpandoMenuBar() const;
|
TExpandoMenuBar* ExpandoMenuBar() const;
|
||||||
TBarMenuBar* BarMenuBar() const;
|
TBarMenuBar* BarMenuBar() const;
|
||||||
TDragRegion* DragRegion() const { return fDragRegion; }
|
TDragRegion* DragRegion() const { return fDragRegion; }
|
||||||
void AddExpandedItem(const char* signature);
|
TReplicantTray* ReplicantTray() const { return fReplicantTray; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class TDeskbarMenu;
|
friend class TDeskbarMenu;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ All rights reserved.
|
|||||||
|
|
||||||
const float kDefaultDeskbarMenuWidth = 50.0f;
|
const float kDefaultDeskbarMenuWidth = 50.0f;
|
||||||
const float kSepItemWidth = 5.0f;
|
const float kSepItemWidth = 5.0f;
|
||||||
|
const float kIconPadding = 8.0f;
|
||||||
|
|
||||||
const uint32 kMinimizeTeam = 'mntm';
|
const uint32 kMinimizeTeam = 'mntm';
|
||||||
const uint32 kBringTeamToFront = 'bftm';
|
const uint32 kBringTeamToFront = 'bftm';
|
||||||
@@ -90,7 +91,15 @@ TExpandoMenuBar::TExpandoMenuBar(TBarView* bar, BRect frame, const char* name,
|
|||||||
{
|
{
|
||||||
SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
|
SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
SetFont(be_plain_font);
|
SetFont(be_plain_font);
|
||||||
SetMaxContentWidth(sMinimumWindowWidth);
|
if (fVertical)
|
||||||
|
SetMaxContentWidth(sMinimumWindowWidth);
|
||||||
|
else {
|
||||||
|
// Make more room for the icon in horizontal mode
|
||||||
|
int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
|
||||||
|
float maxContentWidth = sMinimumWindowWidth + iconSize
|
||||||
|
- kMinimumIconSize;
|
||||||
|
SetMaxContentWidth(maxContentWidth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -108,8 +117,20 @@ TExpandoMenuBar::AttachedToWindow()
|
|||||||
BMessenger self(this);
|
BMessenger self(this);
|
||||||
BList teamList;
|
BList teamList;
|
||||||
TBarApp::Subscribe(self, &teamList);
|
TBarApp::Subscribe(self, &teamList);
|
||||||
float width = fVertical ? Frame().Width() : sMinimumWindowWidth;
|
int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
|
||||||
float height = -1.0f;
|
desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
|
||||||
|
|
||||||
|
float itemWidth = -0.1f;
|
||||||
|
if (fVertical) {
|
||||||
|
itemWidth = Frame().Width();
|
||||||
|
} else {
|
||||||
|
itemWidth = iconSize;
|
||||||
|
if (fDrawLabel)
|
||||||
|
itemWidth += sMinimumWindowWidth - kMinimumIconSize;
|
||||||
|
else
|
||||||
|
itemWidth += kIconPadding * 2;
|
||||||
|
}
|
||||||
|
float itemHeight = -1.0f;
|
||||||
|
|
||||||
// top or bottom mode, add deskbar menu and sep for menubar tracking
|
// top or bottom mode, add deskbar menu and sep for menubar tracking
|
||||||
// consistency
|
// consistency
|
||||||
@@ -124,7 +145,7 @@ TExpandoMenuBar::AttachedToWindow()
|
|||||||
logoBitmap, beMenu, true);
|
logoBitmap, beMenu, true);
|
||||||
AddItem(fDeskbarMenuItem);
|
AddItem(fDeskbarMenuItem);
|
||||||
|
|
||||||
fSeparatorItem = new TTeamMenuItem(kSepItemWidth, height, fVertical);
|
fSeparatorItem = new TTeamMenuItem(kSepItemWidth, itemHeight, fVertical);
|
||||||
AddItem(fSeparatorItem);
|
AddItem(fSeparatorItem);
|
||||||
fSeparatorItem->SetEnabled(false);
|
fSeparatorItem->SetEnabled(false);
|
||||||
fFirstApp = 2;
|
fFirstApp = 2;
|
||||||
@@ -133,8 +154,6 @@ TExpandoMenuBar::AttachedToWindow()
|
|||||||
fSeparatorItem = NULL;
|
fSeparatorItem = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
desk_settings* settings = ((TBarApp*)be_app)->Settings();
|
|
||||||
|
|
||||||
if (settings->sortRunningApps)
|
if (settings->sortRunningApps)
|
||||||
teamList.SortItems(CompareByName);
|
teamList.SortItems(CompareByName);
|
||||||
|
|
||||||
@@ -146,11 +165,11 @@ TExpandoMenuBar::AttachedToWindow()
|
|||||||
if (settings->trackerAlwaysFirst
|
if (settings->trackerAlwaysFirst
|
||||||
&& !strcmp(barInfo->sig, kTrackerSignature)) {
|
&& !strcmp(barInfo->sig, kTrackerSignature)) {
|
||||||
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
|
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
|
||||||
barInfo->name, barInfo->sig, width, height,
|
barInfo->name, barInfo->sig, itemWidth, itemHeight,
|
||||||
fDrawLabel, fVertical), fFirstApp);
|
fDrawLabel, fVertical), fFirstApp);
|
||||||
} else {
|
} else {
|
||||||
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
|
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
|
||||||
barInfo->name, barInfo->sig, width, height,
|
barInfo->name, barInfo->sig, itemWidth, itemHeight,
|
||||||
fDrawLabel, fVertical));
|
fDrawLabel, fVertical));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +187,7 @@ TExpandoMenuBar::AttachedToWindow()
|
|||||||
if (CountItems() == 0) {
|
if (CountItems() == 0) {
|
||||||
// If we're empty, BMenuBar::AttachedToWindow() resizes us to some
|
// If we're empty, BMenuBar::AttachedToWindow() resizes us to some
|
||||||
// weird value - we just override it again
|
// weird value - we just override it again
|
||||||
ResizeTo(width, 0);
|
ResizeTo(itemWidth, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fVertical) {
|
if (fVertical) {
|
||||||
@@ -500,11 +519,21 @@ void
|
|||||||
TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name,
|
TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name,
|
||||||
char* signature)
|
char* signature)
|
||||||
{
|
{
|
||||||
float itemWidth = fVertical ? fBarView->Bounds().Width()
|
desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
|
||||||
: sMinimumWindowWidth;
|
int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
|
||||||
|
|
||||||
|
float itemWidth = -1.0f;
|
||||||
|
if (fVertical) {
|
||||||
|
itemWidth = fBarView->Bounds().Width();
|
||||||
|
} else {
|
||||||
|
itemWidth = iconSize;
|
||||||
|
if (fDrawLabel)
|
||||||
|
itemWidth += sMinimumWindowWidth - kMinimumIconSize;
|
||||||
|
else
|
||||||
|
itemWidth += kIconPadding * 2;
|
||||||
|
}
|
||||||
float itemHeight = -1.0f;
|
float itemHeight = -1.0f;
|
||||||
|
|
||||||
desk_settings* settings = ((TBarApp*)be_app)->Settings();
|
|
||||||
TTeamMenuItem* item = new TTeamMenuItem(team, icon, name, signature,
|
TTeamMenuItem* item = new TTeamMenuItem(team, icon, name, signature,
|
||||||
itemWidth, itemHeight, fDrawLabel, fVertical);
|
itemWidth, itemHeight, fDrawLabel, fVertical);
|
||||||
|
|
||||||
@@ -558,7 +587,6 @@ TExpandoMenuBar::AddTeam(team_id team, const char* signature)
|
|||||||
if (strcasecmp(item->Signature(), signature) == 0) {
|
if (strcasecmp(item->Signature(), signature) == 0) {
|
||||||
if (!(item->Teams()->HasItem((void*)team)))
|
if (!(item->Teams()->HasItem((void*)team)))
|
||||||
item->Teams()->AddItem((void*)team);
|
item->Teams()->AddItem((void*)team);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -607,39 +635,48 @@ TExpandoMenuBar::RemoveTeam(team_id team, bool partial)
|
|||||||
void
|
void
|
||||||
TExpandoMenuBar::CheckItemSizes(int32 delta)
|
TExpandoMenuBar::CheckItemSizes(int32 delta)
|
||||||
{
|
{
|
||||||
float width = Frame().Width();
|
if (fBarView->Vertical())
|
||||||
int32 count = CountItems();
|
return;
|
||||||
|
|
||||||
|
int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
|
||||||
|
float maxContentWidth = sMinimumWindowWidth + iconSize - kMinimumIconSize;
|
||||||
|
|
||||||
|
// There are 2 extra items:
|
||||||
|
// The Be Menu
|
||||||
|
// The little separator item
|
||||||
|
int32 count = CountItems() - 2;
|
||||||
|
float maxWidth = Frame().Width() - fDeskbarMenuWidth - kSepItemWidth * 2;
|
||||||
|
float fullWidth = maxContentWidth * count + fDeskbarMenuWidth
|
||||||
|
+ kSepItemWidth;
|
||||||
|
float iconOnlyWidth = kIconPadding + iconSize + kIconPadding;
|
||||||
|
|
||||||
bool reset = false;
|
bool reset = false;
|
||||||
float newWidth = 0;
|
float newWidth = 0.0f;
|
||||||
float fullWidth = (sMinimumWindowWidth * count);
|
|
||||||
|
|
||||||
if (!fBarView->Vertical()) {
|
if (delta >= 0 && fullWidth > maxWidth) {
|
||||||
// in this case there are 2 extra items:
|
|
||||||
// - The Be Menu
|
|
||||||
// - The little separator item
|
|
||||||
fullWidth = fullWidth - (sMinimumWindowWidth * 2)
|
|
||||||
+ (fDeskbarMenuWidth + kSepItemWidth);
|
|
||||||
width -= (fDeskbarMenuWidth + kSepItemWidth);
|
|
||||||
count -= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (delta >= 0 && fullWidth > width) {
|
|
||||||
fOverflow = true;
|
fOverflow = true;
|
||||||
reset = true;
|
reset = true;
|
||||||
newWidth = floorf(width / count);
|
if (fDrawLabel)
|
||||||
|
newWidth = floorf(maxWidth / count);
|
||||||
|
else
|
||||||
|
newWidth = iconOnlyWidth;
|
||||||
} else if (delta < 0 && fOverflow) {
|
} else if (delta < 0 && fOverflow) {
|
||||||
reset = true;
|
reset = true;
|
||||||
if (fullWidth > width)
|
if (fullWidth > maxWidth) {
|
||||||
newWidth = floorf(width / count);
|
if (fDrawLabel)
|
||||||
else
|
newWidth = floorf(maxWidth / count);
|
||||||
newWidth = sMinimumWindowWidth;
|
else
|
||||||
|
newWidth = iconOnlyWidth;
|
||||||
|
} else
|
||||||
|
newWidth = maxContentWidth;
|
||||||
}
|
}
|
||||||
if (newWidth > sMinimumWindowWidth)
|
|
||||||
newWidth = sMinimumWindowWidth;
|
if (newWidth > maxContentWidth)
|
||||||
|
newWidth = maxContentWidth;
|
||||||
|
|
||||||
if (reset) {
|
if (reset) {
|
||||||
SetMaxContentWidth(newWidth);
|
SetMaxContentWidth(newWidth);
|
||||||
if (newWidth == sMinimumWindowWidth)
|
if (newWidth == maxContentWidth)
|
||||||
fOverflow = false;
|
fOverflow = false;
|
||||||
InvalidateLayout();
|
InvalidateLayout();
|
||||||
|
|
||||||
@@ -647,7 +684,12 @@ TExpandoMenuBar::CheckItemSizes(int32 delta)
|
|||||||
TTeamMenuItem* item = (TTeamMenuItem*)ItemAt(index);
|
TTeamMenuItem* item = (TTeamMenuItem*)ItemAt(index);
|
||||||
if (!item)
|
if (!item)
|
||||||
break;
|
break;
|
||||||
item->SetOverrideWidth(newWidth);
|
|
||||||
|
if (!fDrawLabel && newWidth > iconOnlyWidth) {
|
||||||
|
item->SetOverrideWidth(iconOnlyWidth);
|
||||||
|
} else {
|
||||||
|
item->SetOverrideWidth(newWidth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <OpenWithTracker.h>
|
#include <OpenWithTracker.h>
|
||||||
#include <RadioButton.h>
|
#include <RadioButton.h>
|
||||||
#include <SeparatorView.h>
|
#include <SeparatorView.h>
|
||||||
|
#include <Slider.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -55,6 +56,17 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
|||||||
new BMessage(kSuperExpando));
|
new BMessage(kSuperExpando));
|
||||||
fAppsExpandNew = new BCheckBox(B_TRANSLATE("Expand new applications"),
|
fAppsExpandNew = new BCheckBox(B_TRANSLATE("Expand new applications"),
|
||||||
new BMessage(kExpandNewTeams));
|
new BMessage(kExpandNewTeams));
|
||||||
|
fAppsHideLabels = new BCheckBox(B_TRANSLATE("Hide application names"),
|
||||||
|
new BMessage(kHideLabels));
|
||||||
|
fAppsIconSizeSlider = new BSlider("icon_size", B_TRANSLATE("Icon size"),
|
||||||
|
NULL, kMinimumIconSize / kIconSizeInterval,
|
||||||
|
kMaximumIconSize / kIconSizeInterval, B_HORIZONTAL);
|
||||||
|
fAppsIconSizeSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
||||||
|
fAppsIconSizeSlider->SetHashMarkCount((kMaximumIconSize - kMinimumIconSize)
|
||||||
|
/ kIconSizeInterval + 1);
|
||||||
|
fAppsIconSizeSlider->SetLimitLabels(B_TRANSLATE("Small"),
|
||||||
|
B_TRANSLATE("Large"));
|
||||||
|
fAppsIconSizeSlider->SetModificationMessage(new BMessage(kResizeTeamIcons));
|
||||||
|
|
||||||
fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"),
|
fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"),
|
||||||
new BMessage(kShowSeconds));
|
new BMessage(kShowSeconds));
|
||||||
@@ -89,6 +101,8 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
|||||||
fAppsSortTrackerFirst->SetValue(appSettings->trackerAlwaysFirst);
|
fAppsSortTrackerFirst->SetValue(appSettings->trackerAlwaysFirst);
|
||||||
fAppsShowExpanders->SetValue(appSettings->superExpando);
|
fAppsShowExpanders->SetValue(appSettings->superExpando);
|
||||||
fAppsExpandNew->SetValue(appSettings->expandNewTeams);
|
fAppsExpandNew->SetValue(appSettings->expandNewTeams);
|
||||||
|
fAppsHideLabels->SetValue(appSettings->hideLabels);
|
||||||
|
fAppsIconSizeSlider->SetValue(appSettings->iconSize / kIconSizeInterval);
|
||||||
|
|
||||||
int32 docCount = appSettings->recentDocsCount;
|
int32 docCount = appSettings->recentDocsCount;
|
||||||
int32 appCount = appSettings->recentAppsCount;
|
int32 appCount = appSettings->recentAppsCount;
|
||||||
@@ -132,6 +146,8 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
|||||||
fAppsSort->SetTarget(be_app);
|
fAppsSort->SetTarget(be_app);
|
||||||
fAppsSortTrackerFirst->SetTarget(be_app);
|
fAppsSortTrackerFirst->SetTarget(be_app);
|
||||||
fAppsExpandNew->SetTarget(be_app);
|
fAppsExpandNew->SetTarget(be_app);
|
||||||
|
fAppsHideLabels->SetTarget(be_app);
|
||||||
|
fAppsIconSizeSlider->SetTarget(be_app);
|
||||||
|
|
||||||
fClockSeconds->SetTarget(replicantTray);
|
fClockSeconds->SetTarget(replicantTray);
|
||||||
|
|
||||||
@@ -181,6 +197,8 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
|||||||
.SetInsets(20, 0, 0, 0)
|
.SetInsets(20, 0, 0, 0)
|
||||||
.Add(fAppsExpandNew)
|
.Add(fAppsExpandNew)
|
||||||
.End()
|
.End()
|
||||||
|
.Add(fAppsIconSizeSlider)
|
||||||
|
.Add(fAppsHideLabels)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.SetInsets(10, 10, 10, 10)
|
.SetInsets(10, 10, 10, 10)
|
||||||
.End()
|
.End()
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <CheckBox.h>
|
#include <CheckBox.h>
|
||||||
#include <RadioButton.h>
|
#include <RadioButton.h>
|
||||||
|
#include <Slider.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
@@ -52,6 +53,8 @@ private:
|
|||||||
BCheckBox* fAppsSortTrackerFirst;
|
BCheckBox* fAppsSortTrackerFirst;
|
||||||
BCheckBox* fAppsShowExpanders;
|
BCheckBox* fAppsShowExpanders;
|
||||||
BCheckBox* fAppsExpandNew;
|
BCheckBox* fAppsExpandNew;
|
||||||
|
BCheckBox* fAppsHideLabels;
|
||||||
|
BSlider* fAppsIconSizeSlider;
|
||||||
|
|
||||||
BCheckBox* fClockSeconds;
|
BCheckBox* fClockSeconds;
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ DumpList(BList* itemlist)
|
|||||||
printf("no items in list\n");
|
printf("no items in list\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int32 i = count ; i >= 0 ; i--) {
|
for (int32 i = count; i >= 0; i--) {
|
||||||
DeskbarItemInfo* item = (DeskbarItemInfo*)itemlist->ItemAt(i);
|
DeskbarItemInfo* item = (DeskbarItemInfo*)itemlist->ItemAt(i);
|
||||||
if (!item)
|
if (!item)
|
||||||
continue;
|
continue;
|
||||||
@@ -193,7 +193,7 @@ TReplicantTray::DetachedFromWindow()
|
|||||||
void
|
void
|
||||||
TReplicantTray::RememberClockSettings()
|
TReplicantTray::RememberClockSettings()
|
||||||
{
|
{
|
||||||
if (fClock) {
|
if (fClock) {
|
||||||
desk_settings* settings = ((TBarApp*)be_app)->Settings();
|
desk_settings* settings = ((TBarApp*)be_app)->Settings();
|
||||||
|
|
||||||
settings->timeShowSeconds = fClock->ShowingSeconds();
|
settings->timeShowSeconds = fClock->ShowingSeconds();
|
||||||
@@ -240,8 +240,7 @@ TReplicantTray::DealWithClock(bool showClock)
|
|||||||
|
|
||||||
/*! Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth
|
/*! Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth
|
||||||
if not in multirowmode and greater than kMinimumReplicantCount
|
if not in multirowmode and greater than kMinimumReplicantCount
|
||||||
the width should be calculated based on the actual
|
the width should be calculated based on the actual replicant widths
|
||||||
replicant widths
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
|
TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
|
||||||
@@ -262,8 +261,8 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
|
|||||||
} else {
|
} else {
|
||||||
// if last replicant overruns clock then resize to accomodate
|
// if last replicant overruns clock then resize to accomodate
|
||||||
if (fShelf->CountReplicants() > 0) {
|
if (fShelf->CountReplicants() > 0) {
|
||||||
if (fBarView->ShowingClock()
|
if (fBarView->ShowingClock() && fRightBottomReplicant.right + 6
|
||||||
&& fRightBottomReplicant.right + 6 >= fClock->Frame().left) {
|
>= fClock->Frame().left) {
|
||||||
width = fRightBottomReplicant.right + 6
|
width = fRightBottomReplicant.right + 6
|
||||||
+ fClock->Frame().Width();
|
+ fClock->Frame().Width();
|
||||||
} else
|
} else
|
||||||
@@ -272,6 +271,7 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
|
|||||||
|
|
||||||
// this view has a fixed minimum width
|
// this view has a fixed minimum width
|
||||||
width = max(fMinimumTrayWidth, width);
|
width = max(fMinimumTrayWidth, width);
|
||||||
|
height = kGutter + static_cast<TBarApp*>(be_app)->IconSize() + kGutter;
|
||||||
}
|
}
|
||||||
|
|
||||||
*preferredWidth = width;
|
*preferredWidth = width;
|
||||||
@@ -1095,8 +1095,8 @@ TReplicantTray::LocationForReplicant(int32 index, float width)
|
|||||||
// try to find free space in every row
|
// try to find free space in every row
|
||||||
for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) {
|
for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) {
|
||||||
// determine free space in this row
|
// determine free space in this row
|
||||||
BRect rect(loc.x, loc.y, loc.x + fMinimumTrayWidth - kIconGap - 2.0,
|
BRect rect(loc.x, loc.y, loc.x + fMinimumTrayWidth - kIconGap
|
||||||
loc.y + kMaxReplicantHeight);
|
- 2.0, loc.y + kMaxReplicantHeight);
|
||||||
if (row == 0 && fBarView->ShowingClock())
|
if (row == 0 && fBarView->ShowingClock())
|
||||||
rect.right -= fClock->Frame().Width() + kIconGap;
|
rect.right -= fClock->Frame().Width() + kIconGap;
|
||||||
|
|
||||||
|
|||||||
@@ -48,15 +48,16 @@ All rights reserved.
|
|||||||
const float kMaxReplicantHeight = 16.0f;
|
const float kMaxReplicantHeight = 16.0f;
|
||||||
const float kMaxReplicantWidth = 16.0f;
|
const float kMaxReplicantWidth = 16.0f;
|
||||||
const int32 kMinimumReplicantCount = 6;
|
const int32 kMinimumReplicantCount = 6;
|
||||||
const int32 kIconGap = 2;
|
const int32 kIconGap = 2;
|
||||||
const int32 kGutter = 1;
|
const int32 kGutter = 1;
|
||||||
const int32 kDragRegionWidth = 6;
|
const int32 kDragRegionWidth = 6;
|
||||||
|
|
||||||
// 1 pixel left gutter
|
// 1 pixel for left gutter
|
||||||
// space for replicant tray (6 items)
|
// space for replicant tray (6 items)
|
||||||
// 6 pixel drag region
|
// 6 pixel drag region
|
||||||
const float kMinimumTrayWidth = kIconGap + (kMinimumReplicantCount * kIconGap)
|
const float kMinimumTrayWidth = kIconGap
|
||||||
+ (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter;
|
+ (kMinimumReplicantCount * kIconGap)
|
||||||
|
+ (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter;
|
||||||
const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter;
|
const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter;
|
||||||
|
|
||||||
extern float sMinimumWindowWidth;
|
extern float sMinimumWindowWidth;
|
||||||
|
|||||||
@@ -86,7 +86,8 @@ TTeamMenu::AttachedToWindow()
|
|||||||
if (((barInfo->flags & B_BACKGROUND_APP) == 0)
|
if (((barInfo->flags & B_BACKGROUND_APP) == 0)
|
||||||
&& (strcasecmp(barInfo->sig, kDeskbarSignature) != 0)) {
|
&& (strcasecmp(barInfo->sig, kDeskbarSignature) != 0)) {
|
||||||
TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams,
|
TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams,
|
||||||
barInfo->icon, barInfo->name, barInfo->sig, -1, -1, true, true);
|
barInfo->icon, barInfo->name, barInfo->sig, -1, -1,
|
||||||
|
!settings->hideLabels, true);
|
||||||
|
|
||||||
if ((settings->trackerAlwaysFirst)
|
if ((settings->trackerAlwaysFirst)
|
||||||
&& (strcmp(barInfo->sig, kTrackerSignature) == 0))
|
&& (strcmp(barInfo->sig, kTrackerSignature) == 0))
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ TTeamMenuItem::InitData(BList* team, BBitmap* icon, char* name, char* sig,
|
|||||||
fOverrideHeight = height;
|
fOverrideHeight = height;
|
||||||
fOverriddenSelected = false;
|
fOverriddenSelected = false;
|
||||||
|
|
||||||
fDrawLabel = drawLabel;
|
|
||||||
fVertical = vertical;
|
fVertical = vertical;
|
||||||
|
fDrawLabel = drawLabel;
|
||||||
|
|
||||||
fExpanded = false;
|
fExpanded = false;
|
||||||
}
|
}
|
||||||
@@ -127,21 +127,21 @@ status_t
|
|||||||
TTeamMenuItem::Invoke(BMessage* message)
|
TTeamMenuItem::Invoke(BMessage* message)
|
||||||
{
|
{
|
||||||
if ((static_cast<TBarApp*>(be_app))->BarView()->InvokeItem(Signature()))
|
if ((static_cast<TBarApp*>(be_app))->BarView()->InvokeItem(Signature()))
|
||||||
// handles drop on application
|
// handles drop on application
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
// if the app could not handle the drag message
|
// if the app could not handle the drag message
|
||||||
// and we were dragging, then kill the drag
|
// and we were dragging, then kill the drag
|
||||||
// should never get here, disabled item will not invoke
|
// should never get here, disabled item will not invoke
|
||||||
TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView();
|
TBarView* barView = (static_cast<TBarApp*>(be_app))->BarView();
|
||||||
if (barview && barview->Dragging())
|
if (barView && barView->Dragging())
|
||||||
barview->DragStop();
|
barView->DragStop();
|
||||||
|
|
||||||
// bring to front or minimize shortcuts
|
// bring to front or minimize shortcuts
|
||||||
uint32 mods = modifiers();
|
uint32 mods = modifiers();
|
||||||
if (mods & B_CONTROL_KEY) {
|
if (mods & B_CONTROL_KEY) {
|
||||||
TShowHideMenuItem::TeamShowHideCommon((mods & B_SHIFT_KEY)
|
TShowHideMenuItem::TeamShowHideCommon((mods & B_SHIFT_KEY)
|
||||||
? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT, Teams());
|
? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT, Teams());
|
||||||
}
|
}
|
||||||
|
|
||||||
return BMenuItem::Invoke(message);
|
return BMenuItem::Invoke(message);
|
||||||
@@ -170,6 +170,13 @@ TTeamMenuItem::SetOverrideSelected(bool selected)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TTeamMenuItem::SetDrawLabel(bool drawLabel)
|
||||||
|
{
|
||||||
|
fDrawLabel = drawLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
TTeamMenuItem::LabelWidth() const
|
TTeamMenuItem::LabelWidth() const
|
||||||
{
|
{
|
||||||
@@ -206,24 +213,28 @@ TTeamMenuItem::GetContentSize(float* width, float* height)
|
|||||||
if (fIcon)
|
if (fIcon)
|
||||||
iconBounds = fIcon->Bounds();
|
iconBounds = fIcon->Bounds();
|
||||||
else
|
else
|
||||||
iconBounds = BRect(0, 0, 15, 15);
|
iconBounds = BRect(0, 0, kMinimumIconSize - 1, kMinimumIconSize - 1);
|
||||||
|
|
||||||
BMenuItem::GetContentSize(width, height);
|
BMenuItem::GetContentSize(width, height);
|
||||||
|
|
||||||
if (fOverrideWidth != -1.0f)
|
if (fOverrideWidth != -1.0f)
|
||||||
*width = fOverrideWidth;
|
*width = fOverrideWidth;
|
||||||
else
|
else {
|
||||||
*width = kHPad + iconBounds.Width() + kLabelOffset + fLabelWidth + kHPad
|
*width = kHPad + iconBounds.Width() + kHPad;
|
||||||
+ 20;
|
if (iconBounds.Width() <= 32 && fDrawLabel)
|
||||||
|
*width += LabelWidth() + kHPad;
|
||||||
|
}
|
||||||
|
|
||||||
if (fOverrideHeight != -1.0f)
|
if (fOverrideHeight != -1.0f)
|
||||||
*height = fOverrideHeight;
|
*height = fOverrideHeight;
|
||||||
else {
|
else {
|
||||||
*height = iconBounds.Height();
|
if (fVertical) {
|
||||||
float labelHeight = fLabelAscent + fLabelDescent;
|
*height = iconBounds.Height() + kVPad * 4;
|
||||||
if (labelHeight > *height)
|
if (fDrawLabel && iconBounds.Width() > 32)
|
||||||
*height = labelHeight;
|
*height += fLabelAscent + fLabelDescent;
|
||||||
*height += (kVPad * 2) + 2;
|
} else {
|
||||||
|
*height = iconBounds.Height() - kVPad * 8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*height += 2;
|
*height += 2;
|
||||||
}
|
}
|
||||||
@@ -236,10 +247,10 @@ TTeamMenuItem::Draw()
|
|||||||
BMenu* menu = Menu();
|
BMenu* menu = Menu();
|
||||||
menu->PushState();
|
menu->PushState();
|
||||||
rgb_color menuColor = menu->LowColor();
|
rgb_color menuColor = menu->LowColor();
|
||||||
TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView();
|
TBarView* barView = (static_cast<TBarApp*>(be_app))->BarView();
|
||||||
|
|
||||||
bool canHandle = !barview->Dragging()
|
bool canHandle = !barView->Dragging()
|
||||||
|| barview->AppCanHandleTypes(Signature());
|
|| barView->AppCanHandleTypes(Signature());
|
||||||
|
|
||||||
if (be_control_look != NULL) {
|
if (be_control_look != NULL) {
|
||||||
uint32 flags = 0;
|
uint32 flags = 0;
|
||||||
@@ -275,7 +286,7 @@ TTeamMenuItem::Draw()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if not selected or being tracked on, fill with gray
|
// if not selected or being tracked on, fill with gray
|
||||||
if ((!_IsSelected() && !menu->IsRedrawAfterSticky()) || !canHandle
|
if ((!_IsSelected() && !menu->IsRedrawAfterSticky()) || !canHandle
|
||||||
|| !IsEnabled()) {
|
|| !IsEnabled()) {
|
||||||
frame.InsetBy(1, 1);
|
frame.InsetBy(1, 1);
|
||||||
@@ -283,7 +294,7 @@ TTeamMenuItem::Draw()
|
|||||||
menu->FillRect(frame);
|
menu->FillRect(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the gray, unselected item, border
|
// draw the gray, unselected item, border
|
||||||
if (!_IsSelected() || !IsEnabled()) {
|
if (!_IsSelected() || !IsEnabled()) {
|
||||||
rgb_color shadow = tint_color(menuColor, B_DARKEN_1_TINT);
|
rgb_color shadow = tint_color(menuColor, B_DARKEN_1_TINT);
|
||||||
rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT);
|
rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT);
|
||||||
@@ -308,7 +319,7 @@ TTeamMenuItem::Draw()
|
|||||||
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
|
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
// if selected or being tracked on, fill with the hilite gray color
|
// if selected or being tracked on, fill with the hilite gray color
|
||||||
if (IsEnabled() && _IsSelected() && !menu->IsRedrawAfterSticky()
|
if (IsEnabled() && _IsSelected() && !menu->IsRedrawAfterSticky()
|
||||||
&& canHandle) {
|
&& canHandle) {
|
||||||
// fill
|
// fill
|
||||||
@@ -337,7 +348,7 @@ void
|
|||||||
TTeamMenuItem::DrawContent()
|
TTeamMenuItem::DrawContent()
|
||||||
{
|
{
|
||||||
BMenu* menu = Menu();
|
BMenu* menu = Menu();
|
||||||
if (fIcon) {
|
if (fIcon != NULL) {
|
||||||
if (fIcon->ColorSpace() == B_RGBA32) {
|
if (fIcon->ColorSpace() == B_RGBA32) {
|
||||||
menu->SetDrawingMode(B_OP_ALPHA);
|
menu->SetDrawingMode(B_OP_ALPHA);
|
||||||
menu->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
menu->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||||
@@ -347,17 +358,33 @@ 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 = fVertical ? 0.0f : -1.0f;
|
||||||
BPoint contLoc = ContentLocation();
|
BPoint contLoc = ContentLocation();
|
||||||
|
|
||||||
dstRect.OffsetTo(BPoint(contLoc.x + kHPad, contLoc.y +
|
|
||||||
((frame.Height() - iconBounds.Height()) / 2) + extra));
|
|
||||||
menu->DrawBitmapAsync(fIcon, dstRect);
|
|
||||||
|
|
||||||
float labelHeight = fLabelAscent + fLabelDescent;
|
|
||||||
BPoint drawLoc = contLoc + BPoint(kHPad, kVPad);
|
BPoint drawLoc = contLoc + BPoint(kHPad, kVPad);
|
||||||
drawLoc.x += iconBounds.Width() + kLabelOffset;
|
|
||||||
drawLoc.y = frame.top + ((frame.Height() - labelHeight) / 2) + 1.0f;
|
if (!fDrawLabel || (fVertical && iconBounds.Width() > 32)) {
|
||||||
|
float offsetx = contLoc.x
|
||||||
|
+ ((frame.Width() - iconBounds.Width()) / 2) + extra;
|
||||||
|
float offsety = contLoc.y + 3.0f + extra;
|
||||||
|
|
||||||
|
dstRect.OffsetTo(BPoint(offsetx, offsety));
|
||||||
|
menu->DrawBitmapAsync(fIcon, dstRect);
|
||||||
|
|
||||||
|
drawLoc.x = ((frame.Width() - LabelWidth()) / 2);
|
||||||
|
drawLoc.y = frame.top + iconBounds.Height() + 4.0f;
|
||||||
|
} else {
|
||||||
|
float offsetx = contLoc.x + kHPad;
|
||||||
|
float offsety = contLoc.y +
|
||||||
|
((frame.Height() - iconBounds.Height()) / 2) + extra;
|
||||||
|
|
||||||
|
dstRect.OffsetTo(BPoint(offsetx, offsety));
|
||||||
|
menu->DrawBitmapAsync(fIcon, dstRect);
|
||||||
|
|
||||||
|
float labelHeight = fLabelAscent + fLabelDescent;
|
||||||
|
drawLoc.x += iconBounds.Width() + kLabelOffset;
|
||||||
|
drawLoc.y = frame.top + ((frame.Height() - labelHeight) / 2) + extra;
|
||||||
|
}
|
||||||
|
|
||||||
menu->MovePenTo(drawLoc);
|
menu->MovePenTo(drawLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,10 +476,10 @@ TTeamMenuItem::DrawContentLabel()
|
|||||||
char* truncLabel = NULL;
|
char* truncLabel = NULL;
|
||||||
float max = 0;
|
float max = 0;
|
||||||
|
|
||||||
if (static_cast<TBarApp*>(be_app)->Settings()->superExpando && fVertical)
|
if (fVertical && static_cast<TBarApp*>(be_app)->Settings()->superExpando)
|
||||||
max = menu->MaxContentWidth() - kSwitchWidth;
|
max = menu->MaxContentWidth() - kSwitchWidth;
|
||||||
else
|
else
|
||||||
max = menu->MaxContentWidth();
|
max = menu->MaxContentWidth() - 4.0f;
|
||||||
|
|
||||||
if (max > 0) {
|
if (max > 0) {
|
||||||
BPoint penloc = menu->PenLocation();
|
BPoint penloc = menu->PenLocation();
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ 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);
|
||||||
|
void SetDrawLabel(bool drawLabel);
|
||||||
|
|
||||||
bool IsExpanded();
|
bool IsExpanded();
|
||||||
void ToggleExpandState(bool resizeWindow);
|
void ToggleExpandState(bool resizeWindow);
|
||||||
|
|||||||
@@ -332,13 +332,8 @@ TTimeView::Pulse()
|
|||||||
Update();
|
Update();
|
||||||
|
|
||||||
strlcpy(fLastTimeStr, fTimeStr, sizeof(fLastTimeStr));
|
strlcpy(fLastTimeStr, fTimeStr, sizeof(fLastTimeStr));
|
||||||
fNeedToUpdate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the tooltip if the date has changed
|
|
||||||
if (strcmp(fDateStr, fLastDateStr) != 0) {
|
|
||||||
strlcpy(fLastDateStr, fDateStr, sizeof(fLastDateStr));
|
strlcpy(fLastDateStr, fDateStr, sizeof(fLastDateStr));
|
||||||
SetToolTip(fDateStr);
|
fNeedToUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fNeedToUpdate) {
|
if (fNeedToUpdate) {
|
||||||
|
|||||||
Reference in New Issue
Block a user