From John Scipione <jscipione@xxxxxxxxx>:
John Scipione has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/2255 ;)
Change subject: Deskbar: New single line mini-mode
......................................................................
Deskbar: New single line mini-mode
Mini mode is when Deskbar is in the 4 corners with the application
menu tucked away into the leaf menu bar. This commit switches mini
mode from putting the clock and replicants below the leaf menu to
attaching them to the side of leaf menu forming a single line.
The main advantage of this is that if Deskbar is in the top right
corner then you can maximize a window without losing any access to
Deskbar or any screen real-estate with any other corner losing
screen real-estate similar to horizontal mode.
Replace team icon with HVIF version kindly donated by meanwhile.
Scale icon size according to font size.
Switch order of leaf and app list menus on the right side so that
the leaf menu is the one on the screen edge.
Update SetSizeLimits for mini mode - same as horizontal mode but
doesn't need to scale vertically (except with font size.)
Add BarView pointer to TimeView. Ditch fVertical and SetOrientation
in TTimeView and get the information from BarView instead. This way
we don't have to keep the state in sync.
Truncate time in vertical expando mode, no longer truncate time in
vertical mini mode because now the time can expand itself
horizontally without limit (within reason.)
Pass BarView pointer to TTeamMenu constructor and use it instead of
getting the pointer in a roundabout way from be_app.
Adjust the width of the team menu for larger icon sizes. If app
names are hidden limit to half of min width so the menu doesn't
appear too short. SetMaxContentSize to width, this fixes a bug where
the menu item wasn't quite the right size for the menu.
Switch to mini-mode using 1/3 screen left and right of screen instead
of using 1/6. Mini mode is now wider and this change makes switching
between mini mode and horizontal mode more reliable.
* Rename frame to screenFrame here for clarity.
Eliminate kMiniHeight constant, the mini-mode height is now based
on the height of a window tab which changes with be_bold_font size.
Limit maximum height of replicants by be_bold_font size as well.
Also limit team menu and leaf menu icon heights by be_bold_font size.
Set menu bar height to window tab height in vertical mode. This is
so that when you maximize a window the tab size will match. The menu
bar height is also a few pixels taller (25px vs 21px) than it was in
vertical expando mode at the default 12px font size. The change was
made to match the tab height. 21px was the height of a window tab
on BeOS R5's default decorator.
Adjust leaf menu position so that it continues to be cut-off at the
bottom in vertical mode.
Constrain leaf bitmap to its menu item frame as it can bleed out
into the adjacent team menu item at larger font sizes.
Implements bug #5876 step 1.
Change-Id: Id9ddd60c997a785184208ba02938bee1416aeae9
fixup
---
M src/apps/deskbar/BarMenuBar.cpp
M src/apps/deskbar/BarMenuBar.h
M src/apps/deskbar/BarMenuTitle.cpp
M src/apps/deskbar/BarMenuTitle.h
M src/apps/deskbar/BarView.cpp
M src/apps/deskbar/BarView.h
M src/apps/deskbar/BarWindow.cpp
M src/apps/deskbar/StatusView.cpp
M src/apps/deskbar/StatusView.h
M src/apps/deskbar/TeamMenu.cpp
M src/apps/deskbar/TeamMenu.h
M src/apps/deskbar/TimeView.cpp
M src/apps/deskbar/TimeView.h
M src/apps/deskbar/icons.h
M src/apps/deskbar/icons.rdef
15 files changed, 350 insertions(+), 192 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/55/2255/1
diff --git a/src/apps/deskbar/BarMenuBar.cpp b/src/apps/deskbar/BarMenuBar.cpp
index 73e5ead..23dd670 100644
--- a/src/apps/deskbar/BarMenuBar.cpp
+++ b/src/apps/deskbar/BarMenuBar.cpp
@@ -104,7 +104,9 @@
BMenuBar(frame, name, B_FOLLOW_NONE, B_ITEMS_IN_ROW, false),
fBarView(barView),
fAppListMenuItem(NULL),
- fSeparatorItem(NULL)
+ fSeparatorItem(NULL),
+ fTeamIconData(NULL),
+ fTeamIconSize(0)
{
SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
@@ -118,7 +120,10 @@
if (data != NULL) {
// Scale bitmap according to font size
float width = std::max(63.f, ceilf(63 * be_plain_font->Size() /
12.f));
+ // but limit by be_bold_font size
+ width = std::min(width, ceilf(63.f * be_bold_font->Size() /
12.f));
float height = std::max(22.f, ceilf(22 * be_plain_font->Size()
/ 12.f));
+ height = std::min(height, ceilf(22.f * be_bold_font->Size() /
12.f));
icon = new BBitmap(BRect(0, 0, width - 1, height - 1),
B_RGBA32);
if (icon->InitCheck() != B_OK
|| BIconUtils::GetVectorIcon((const uint8*)data,
dataSize, icon)
@@ -128,7 +133,8 @@
}
}
- fDeskbarMenuItem = new TBarMenuTitle(0.0f, 0.0f, icon, beMenu);
+ fDeskbarMenuItem = new TBarMenuTitle(0.0f, 0.0f, icon, beMenu,
+ fBarView);
AddItem(fDeskbarMenuItem);
}
@@ -173,10 +179,10 @@
BRect frame(Frame());
delete fAppListMenuItem;
- fAppListMenuItem = new TBarMenuTitle(0.0f, 0.0f,
- AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_TeamIcon), new
TTeamMenu());
+ fAppListMenuItem = new TBarMenuTitle(0.0f, 0.0f, FetchTeamIcon(),
+ new TTeamMenu(fBarView), fBarView);
- bool added = AddItem(fAppListMenuItem);
+ bool added = AddItem(fAppListMenuItem, fBarView->Left() ? 1 : 0);
if (added)
SmartResize(frame.Width() - 1.0f, frame.Height());
@@ -324,3 +330,34 @@
if (fAppListMenuItem && (fAppListMenuItem->Frame().Contains(loc) ||
both))
init_tracking_hook(fAppListMenuItem, hookFunction, state);
}
+
+
+const BBitmap*
+TBarMenuBar::FetchTeamIcon()
+{
+ const BBitmap* teamIcon;
+ if (fTeamIconData == NULL || fTeamIconSize == 0) {
+ // we haven't fetched vector icon data yet, fetch it
+ fTeamIconData = (const uint8*)AppResSet()->FindResource(
+ B_VECTOR_ICON_TYPE, R_TeamIconVector, &fTeamIconSize);
+ }
+
+ // scale bitmap according to font size
+ float iconHeight = std::max(19.f, ceilf(19.f * be_plain_font->Size() /
12.f));
+ // but limit by be_bold_font_size
+ iconHeight = std::min(iconHeight, ceilf(19.f * be_bold_font->Size() /
12.f));
+ BRect iconRect = BRect(0, 0, iconHeight, iconHeight);
+ BBitmap* icon = new(std::nothrow) BBitmap(iconRect, B_RGBA32);
+ if (fTeamIconData != NULL && fTeamIconSize > 0 && icon != NULL
+ && BIconUtils::GetVectorIcon(fTeamIconData, fTeamIconSize, icon)
+ == B_OK) {
+ // rasterized vector icon into bitmap
+ teamIcon = icon;
+ } else {
+ // fetch bitmap instead
+ teamIcon = AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_TeamIcon);
+ delete icon;
+ }
+
+ return teamIcon;
+}
diff --git a/src/apps/deskbar/BarMenuBar.h b/src/apps/deskbar/BarMenuBar.h
index f470d38..4346e9f 100644
--- a/src/apps/deskbar/BarMenuBar.h
+++ b/src/apps/deskbar/BarMenuBar.h
@@ -79,11 +79,17 @@
bool (*
hookfunction)(BMenu*, void*),
void* state,
bool both = false);
+ const BBitmap* FetchTeamIcon();
+
private:
TBarView* fBarView;
TBarMenuTitle* fDeskbarMenuItem;
TBarMenuTitle* fAppListMenuItem;
TSeparatorItem* fSeparatorItem;
+
+ const uint8* fTeamIconData;
+ size_t fTeamIconSize;
};
+
#endif // BARMENUBAR_H
diff --git a/src/apps/deskbar/BarMenuTitle.cpp
b/src/apps/deskbar/BarMenuTitle.cpp
index 3327934..06d4e1a 100644
--- a/src/apps/deskbar/BarMenuTitle.cpp
+++ b/src/apps/deskbar/BarMenuTitle.cpp
@@ -39,20 +39,23 @@
#include <Bitmap.h>
#include <ControlLook.h>
#include <Debug.h>
+#include <Region.h>
#include "BarApp.h"
#include "BarView.h"
#include "BarWindow.h"
+#include "DeskbarMenu.h"
TBarMenuTitle::TBarMenuTitle(float width, float height, const BBitmap* icon,
- BMenu* menu, bool expando)
+ BMenu* menu, TBarView* barView)
:
BMenuItem(menu, new BMessage(B_REFS_RECEIVED)),
fWidth(width),
fHeight(height),
- fInExpando(expando),
- fIcon(icon)
+ fIcon(icon),
+ fMenu(menu),
+ fBarView(barView)
{
}
@@ -115,19 +118,33 @@
return;
BMenu* menu = Menu();
- BRect frame(Frame());
- BRect iconRect(fIcon->Bounds());
+ if (menu == NULL)
+ return;
menu->SetDrawingMode(B_OP_ALPHA);
- iconRect.OffsetTo(frame.LeftTop());
+
+ const BRect frame(Frame());
+ BRect iconRect(fIcon->Bounds().OffsetToCopy(frame.LeftTop()));
float widthOffset = rintf((frame.Width() - iconRect.Width()) / 2);
float heightOffset = 0;
if (frame.Height() > iconRect.Height() + 2)
heightOffset = rintf((frame.Height() - iconRect.Height()) / 2);
- iconRect.OffsetBy(widthOffset - 1.0f, heightOffset + 2.0f);
+ iconRect.OffsetBy(widthOffset, heightOffset);
+ // cut-off the leaf
+ if (dynamic_cast<TDeskbarMenu*>(fMenu) != NULL)
+ iconRect.OffsetBy(0, 2);
+
+ // clip to item frame
+ if (iconRect.Width() > frame.Width()) {
+ float diff = iconRect.Width() - frame.Width();
+ BRect mask(iconRect.InsetByCopy(floorf(diff / 2), 0));
+ BRegion clipping(mask);
+ menu->ConstrainClippingRegion(&clipping);
+ }
menu->DrawBitmapAsync(fIcon, iconRect);
+ menu->ConstrainClippingRegion(NULL);
}
diff --git a/src/apps/deskbar/BarMenuTitle.h b/src/apps/deskbar/BarMenuTitle.h
index f7bcac0..78c2915 100644
--- a/src/apps/deskbar/BarMenuTitle.h
+++ b/src/apps/deskbar/BarMenuTitle.h
@@ -44,13 +44,12 @@
#include <MenuItem.h>
-class BBitmap;
-class BMenu;
+class TBarView;
class TBarMenuTitle : public BMenuItem {
public:
TBarMenuTitle(float width, float height, const BBitmap* icon,
- BMenu* menu, bool expando = false);
+ BMenu* menu, TBarView* barView = NULL);
virtual ~TBarMenuTitle();
void SetContentSize(float width, float height);
@@ -65,8 +64,9 @@
private:
float fWidth;
float fHeight;
- bool fInExpando;
const BBitmap* fIcon;
+ BMenu* fMenu;
+ TBarView* fBarView;
};
diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index 52ba9de..8707927 100644
--- a/src/apps/deskbar/BarView.cpp
+++ b/src/apps/deskbar/BarView.cpp
@@ -147,13 +147,27 @@
fMaxRecentDocs(kDefaultRecentDocCount),
fMaxRecentApps(kDefaultRecentAppCount),
fLastDragItem(NULL),
- fMouseFilter(NULL)
+ fMouseFilter(NULL),
+ fTabHeight(kMenuBarHeight)
{
+ // get window tab height
+ BWindow* tmpWindow = new(std::nothrow) BWindow(BRect(), NULL,
+ B_TITLED_WINDOW, 0);
+ if (tmpWindow != NULL) {
+ BMessage settings;
+ if (tmpWindow->GetDecoratorSettings(&settings) == B_OK) {
+ BRect tabRect;
+ if (settings.FindRect("tab frame", &tabRect) == B_OK)
+ fTabHeight = tabRect.Height();
+ }
+ delete tmpWindow;
+ }
+
// determine the initial Be menu size
// (will be updated later)
BRect menuFrame(frame);
if (fVertical)
- menuFrame.bottom = menuFrame.top + kMenuBarHeight;
+ menuFrame.bottom = menuFrame.top + fTabHeight - 1;
else
menuFrame.bottom = menuFrame.top + fBarApp->IconSize() + 4;
@@ -162,7 +176,7 @@
AddChild(fBarMenuBar);
// create the status tray
- fReplicantTray = new TReplicantTray(this, fVertical);
+ fReplicantTray = new TReplicantTray(this);
// create the resize control
fResizeControl = new TResizeControl(this);
@@ -434,8 +448,12 @@
// Calculate the size of the deskbar menu
BRect menuFrame(Bounds());
if (fVertical) {
- width = static_cast<TBarApp*>(be_app)->Settings()->width;
- height = 4 + fReplicantTray->MaxReplicantHeight();
+ if (fState == kMiniState)
+ width = gMinimumWindowWidth;
+ else
+ width =
static_cast<TBarApp*>(be_app)->Settings()->width;
+
+ height = fTabHeight;
menuFrame.bottom = menuFrame.top + height;
} else {
width = gMinimumWindowWidth;
@@ -483,8 +501,9 @@
TBarView::PlaceTray(bool vertSwap, bool leftSwap)
{
BPoint statusLoc;
+
if (fState == kFullState) {
- fDragRegion->ResizeTo(fBarMenuBar->Frame().Width(),
kMenuBarHeight);
+ fDragRegion->ResizeTo(fBarMenuBar->Frame().Width(), fTabHeight);
statusLoc.y = fBarMenuBar->Frame().bottom + 1;
statusLoc.x = 0;
fDragRegion->MoveTo(statusLoc);
@@ -496,15 +515,33 @@
return;
}
- if (fReplicantTray->IsHidden())
- fReplicantTray->Show();
-
if (fTrayLocation != 0) {
- fReplicantTray->SetMultiRow(fVertical);
fReplicantTray->RealignReplicants();
fDragRegion->ResizeToPreferred();
// also resizes replicant tray
+ if (fState == kMiniState) {
+ if (!fResizeControl->IsHidden())
+ fResizeControl->Hide();
+
+ statusLoc.x = fLeft ? fBarMenuBar->Frame().right + 1 :
0;
+ statusLoc.y = 0;
+
+ fDragRegion->MoveTo(statusLoc);
+ fReplicantTray->MoveTo(fLeft ? 3 : -3, 1);
+
+ BRect screenFrame = (BScreen(Window())).Frame();
+ SizeWindow(screenFrame);
+ PositionWindow(screenFrame);
+ Window()->UpdateIfNeeded();
+
+ // move menubar into place after resizing window based
on
+ // replicant tray
+ fBarMenuBar->MoveTo(fLeft ? 0
+ : Bounds().right -
fBarMenuBar->Frame().Width(), 0);
+ return;
+ }
+
fResizeControl->ResizeTo(kDragWidth,
fDragRegion->Bounds().Height()
- 2); // make room for top and bottom border
@@ -554,20 +591,17 @@
void
TBarView::PlaceApplicationBar()
{
- BRect screenFrame = (BScreen(Window())).Frame();
if (fState == kMiniState) {
if (!fInlineScrollView->IsHidden())
fInlineScrollView->Hide();
- SizeWindow(screenFrame);
- PositionWindow(screenFrame);
- Window()->UpdateIfNeeded();
- Invalidate();
+
return;
}
if (fInlineScrollView->IsHidden())
fInlineScrollView->Show();
+ BRect screenFrame = (BScreen(Window())).Frame();
BRect expandoFrame(0, 0, 0, 0);
if (fVertical) {
// left or right
@@ -617,7 +651,7 @@
TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float*
height)
{
float windowHeight = 0;
- float windowWidth = fBarApp->Settings()->width;
+ float windowWidth = 0;
bool setToHiddenSize = fBarApp->Settings()->autoHide && IsHidden()
&& !fDragRegion->IsDragging();
@@ -643,6 +677,7 @@
windowHeight =
fBarMenuBar->Frame().bottom + 1;
windowHeight +=
fExpandoMenuBar->Bounds().Height();
+ windowWidth = fBarApp->Settings()->width;
} else {
// top or bottom, full
fExpandoMenuBar->CheckItemSizes(0);
@@ -670,6 +705,7 @@
float windowHeight;
GetPreferredWindowSize(screenFrame, &windowWidth, &windowHeight);
Window()->ResizeTo(windowWidth, windowHeight);
+ ResizeTo(windowWidth, windowHeight);
}
@@ -681,15 +717,11 @@
GetPreferredWindowSize(screenFrame, &windowWidth, &windowHeight);
BPoint moveLoc(0, 0);
- // right, expanded
- if (!fLeft && fVertical) {
- if (fState == kFullState)
- moveLoc.x = screenFrame.right -
fBarMenuBar->Frame().Width();
- else
- moveLoc.x = screenFrame.right - windowWidth;
- }
+ // right, expanded, mini, or full
+ if (!fLeft && fVertical)
+ moveLoc.x = screenFrame.right - windowWidth;
- // bottom, full or corners
+ // bottom, full
if (!fTop)
moveLoc.y = screenFrame.bottom - windowHeight;
@@ -769,22 +801,19 @@
// Send a message to the preferences window to let it
know to
// enable or disable preference items.
- if (vertSwap) {
- TBarWindow* window =
dynamic_cast<TBarWindow*>(Window());
- if (window != NULL)
- window->SetSizeLimits();
+ TBarWindow* barWindow = dynamic_cast<TBarWindow*>(Window());
+ if (barWindow != NULL)
+ barWindow->SetSizeLimits();
- fReplicantTray->fTime->SetOrientation(fVertical);
- if (fExpandoMenuBar != NULL) {
- if (fVertical) {
-
fInlineScrollView->SetOrientation(B_VERTICAL);
-
fExpandoMenuBar->SetMenuLayout(B_ITEMS_IN_COLUMN);
-
fExpandoMenuBar->StartMonitoringWindows();
- } else {
-
fInlineScrollView->SetOrientation(B_HORIZONTAL);
-
fExpandoMenuBar->SetMenuLayout(B_ITEMS_IN_ROW);
-
fExpandoMenuBar->StopMonitoringWindows();
- }
+ if (vertSwap && fExpandoMenuBar != NULL) {
+ if (fVertical) {
+ fInlineScrollView->SetOrientation(B_VERTICAL);
+
fExpandoMenuBar->SetMenuLayout(B_ITEMS_IN_COLUMN);
+ fExpandoMenuBar->StartMonitoringWindows();
+ } else {
+ fInlineScrollView->SetOrientation(B_HORIZONTAL);
+ fExpandoMenuBar->SetMenuLayout(B_ITEMS_IN_ROW);
+ fExpandoMenuBar->StopMonitoringWindows();
}
}
}
diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h
index b1da59f..8d42061 100644
--- a/src/apps/deskbar/BarView.h
+++ b/src/apps/deskbar/BarView.h
@@ -57,8 +57,6 @@
kFullState = 2
};
-
-const float kMiniHeight = 46.0f;
const float kHModeHeight = 21.0f;
const float kMenuBarHeight = 21.0f;
const float kStatusHeight = 22.0f;
@@ -170,6 +168,7 @@
TReplicantTray* ReplicantTray() const { return
fReplicantTray; }
float TeamMenuItemHeight() const;
+ float TabHeight() const { return
fTabHeight; };
private:
friend class TBarApp;
@@ -211,6 +210,8 @@
TTeamMenuItem* fLastDragItem;
BMessageFilter* fMouseFilter;
+
+ float fTabHeight;
};
diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp
index db65d94..3905249 100644
--- a/src/apps/deskbar/BarWindow.cpp
+++ b/src/apps/deskbar/BarWindow.cpp
@@ -227,7 +227,7 @@
void
TBarWindow::FrameResized(float width, float height)
{
- if (!fBarView->Vertical())
+ if (fBarView->MiniState() || !fBarView->Vertical())
return BWindow::FrameResized(width, height);
bool setToHiddenSize =
static_cast<TBarApp*>(be_app)->Settings()->autoHide
@@ -666,8 +666,15 @@
}
} else {
if (fBarView->Vertical()) {
- BWindow::SetSizeLimits(gMinimumWindowWidth,
gMaximumWindowWidth,
- kMenuBarHeight - 1, screenFrame.Height());
+ float minWidth = gMinimumWindowWidth;
+ float minHeight = fBarView->TabHeight() - 1;
+ if (fBarView->MiniState()) {
+ BWindow::SetSizeLimits(minWidth,
screenFrame.Width(),
+ minHeight, minHeight);
+ } else {
+ BWindow::SetSizeLimits(minWidth,
gMaximumWindowWidth,
+ minHeight, screenFrame.Height());
+ }
} else {
BWindow::SetSizeLimits(screenFrame.Width(),
screenFrame.Width(),
kMenuBarHeight - 1, kMaximumIconSize + 4);
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index 871f87c..3f30738 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -69,6 +69,7 @@
#include "icons.h"
#include "BarApp.h"
+#include "BarMenuBar.h"
#include "DeskbarUtils.h"
#include "ExpandoMenuBar.h"
#include "ResourceSet.h"
@@ -127,30 +128,37 @@
// don't change the name of this view to anything other than "Status"!
-TReplicantTray::TReplicantTray(TBarView* parent, bool vertical)
+TReplicantTray::TReplicantTray(TBarView* barView)
:
BView(BRect(0, 0, 1, 1), "Status", B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW | B_FRAME_EVENTS),
fTime(NULL),
- fBarView(parent),
+ fBarView(barView),
fShelf(new TReplicantShelf(this)),
- fMultiRowMode(vertical),
fAlignmentSupport(false)
{
+ // scale replicants by font size
fMaxReplicantHeight = std::max(kMinReplicantHeight,
floorf(kMinReplicantHeight * be_plain_font->Size() / 12));
+ // but not bigger than TabHeight which depends on be_bold_font
+ // TODO This should only apply to mini-mode but we set it once here for
all
+ fMaxReplicantHeight = std::min(fMaxReplicantHeight,
+ fBarView->TabHeight() - 4);
// TODO: depends on window size... (so use something like
// max(129, height * 3), and restrict the minimum window width for it)
fMaxReplicantWidth = 129;
fMinTrayHeight = kGutter + fMaxReplicantHeight + kGutter;
- if (vertical)
+
+ if (fBarView != NULL
+ && fBarView->Vertical() && fBarView->State() == kExpandoState) {
fMinimumTrayWidth = gMinimumWindowWidth - kGutter -
kDragRegionWidth;
- else
+ } else
fMinimumTrayWidth = kMinimumTrayWidth;
// Create the time view
- fTime = new TTimeView(fMinimumTrayWidth, fMaxReplicantHeight - 1.0);
+ fTime = new TTimeView(fMinimumTrayWidth, fMaxReplicantHeight - 1.0,
+ fBarView);
}
@@ -182,8 +190,8 @@
AddChild(fTime);
- fTime->MoveTo(Bounds().right - fTime->Bounds().Width() - kTrayPadding,
2);
- fTime->SetOrientation(fMultiRowMode);
+ fTime->MoveTo(Bounds().right - fTime->Bounds().Width() - kTrayPadding,
+ floorf((fBarView->TabHeight() - fMaxReplicantHeight) / 2) - 1);
if (!((TBarApp*)be_app)->Settings()->showClock)
fTime->Hide();
@@ -221,7 +229,7 @@
float width = 0;
float height = fMinTrayHeight;
- if (fMultiRowMode) {
+ if (fBarView->Vertical() && fBarView->State() == kExpandoState) {
width = static_cast<TBarApp*>(be_app)->Settings()->width
- kDragWidth - kGutter;
if (fRightBottomReplicant.IsValid())
@@ -249,7 +257,13 @@
// this view has a fixed minimum width
width = std::max(kMinimumTrayWidth, width);
- height = kGutter + static_cast<TBarApp*>(be_app)->IconSize() +
kGutter;
+
+ // if mini mode set to tab height
+ // else horizontal set to team menu item height
+ if (fBarView->Vertical() && fBarView->MiniState())
+ height = fBarView->TabHeight();
+ else
+ height = fBarView->TeamMenuItemHeight();
}
*preferredWidth = width;
@@ -425,13 +439,6 @@
void
-TReplicantTray::SetMultiRow(bool state)
-{
- fMultiRowMode = state;
-}
-
-
-void
TReplicantTray::ShowHideTime()
{
if (fTime == NULL)
@@ -1163,14 +1170,14 @@
BPoint
TReplicantTray::LocationForReplicant(int32 index, float replicantWidth)
{
- BPoint loc(kTrayPadding, 2);
+ BPoint loc(kTrayPadding, 1);
if (fBarView->Vertical()) {
if (!fBarView->Left())
loc.x += kDragWidth; // move past dragger
} else
loc.x += 1; // keeps everything lined up nicely
- if (fMultiRowMode) {
+ if (fBarView->Vertical() && fBarView->State() == kExpandoState) {
// try to find free space in every row
for (int32 row = 0; ; loc.y += fMaxReplicantHeight + kIconGap,
row++) {
// determine free space in this row
@@ -1206,8 +1213,8 @@
// check next row
}
- fTime->MoveTo(Bounds().right - fTime->Bounds().Width()
- - kTrayPadding, 2);
+ fTime->MoveTo(Bounds().right - fTime->Bounds().Width() -
kTrayPadding,
+ (fMaxReplicantHeight - fTime->Bounds().Height()) / 2);
} else {
if (index > 0) {
// get the last replicant added for placement reference
@@ -1221,7 +1228,8 @@
if (fBarView->Vertical()) {
// center vertically
- loc.y = floorf((kMenuBarHeight - fMaxReplicantHeight) /
2) - 1;
+ loc.y = floorf((fBarView->TabHeight() -
fMaxReplicantHeight) / 2)
+ - 1;
} else {
if (fBarView->Top()) {
// align top
@@ -1579,46 +1587,45 @@
TDragRegion::MouseMoved(BPoint where, uint32 code, const BMessage* message)
{
if (IsTracking()) {
- BScreen screen;
- BRect frame = screen.Frame();
+ const BRect screenFrame((BScreen(Window())).Frame());
- float hDivider = frame.Width() / 6;
- hDivider = (hDivider < gMinimumWindowWidth + 10)
- ? gMinimumWindowWidth + 10 : hDivider;
- float miniDivider = frame.top + kMiniHeight + 10;
- float vDivider = frame.Height() / 2;
+ float hDivider = std::max(gMinimumWindowWidth + 10,
+ floorf(screenFrame.Width() / 3));
+ float miniDivider = screenFrame.top
+ + fBarView->BarMenuBar()->Frame().Height();
+ float vDivider = floorf(screenFrame.Height() / 2);
#ifdef FULL_MODE
- float thirdScreen = frame.Height() / 3;
+ float thirdScreen = floorf(screenFrame.Height() / 3);
#endif
- BRect topLeft(frame.left, frame.top, frame.left + hDivider,
- miniDivider);
- BRect topMiddle(frame.left + hDivider, frame.top, frame.right
- - hDivider, vDivider);
- BRect topRight(frame.right - hDivider, frame.top, frame.right,
- miniDivider);
+ BRect topLeft(screenFrame.left, screenFrame.top,
+ screenFrame.left + hDivider, miniDivider);
+ BRect topMiddle(screenFrame.left + hDivider, screenFrame.top,
+ screenFrame.right - hDivider, vDivider);
+ BRect topRight(screenFrame.right - hDivider, screenFrame.top,
+ screenFrame.right, miniDivider);
#ifdef FULL_MODE
vDivider = miniDivider + thirdScreen;
#endif
- BRect middleLeft(frame.left, miniDivider, frame.left + hDivider,
- vDivider);
- BRect middleRight(frame.right - hDivider, miniDivider,
frame.right,
- vDivider);
+ BRect middleLeft(screenFrame.left, miniDivider,
+ screenFrame.left + hDivider, vDivider);
+ BRect middleRight(screenFrame.right - hDivider, miniDivider,
+ screenFrame.right, vDivider);
#ifdef FULL_MODE
- BRect leftSide(frame.left, vDivider, frame.left + hDivider,
- frame.bottom - thirdScreen);
- BRect rightSide(frame.right - hDivider, vDivider, frame.right,
- frame.bottom - thirdScreen);
+ BRect leftSide(screenFrame.left, vDivider,
+ screenFrame.left + hDivider, screenFrame.bottom -
thirdScreen);
+ BRect rightSide(screenFrame.right - hDivider, vDivider,
+ screenFrame.right, screenFrame.bottom - thirdScreen);
- vDivider = frame.bottom - thirdScreen;
+ vDivider = screenFrame.bottom - thirdScreen;
#endif
- BRect bottomLeft(frame.left, vDivider, frame.left + hDivider,
- frame.bottom);
- BRect bottomMiddle(frame.left + hDivider, vDivider, frame.right
- - hDivider, frame.bottom);
- BRect bottomRight(frame.right - hDivider, vDivider, frame.right,
- frame.bottom);
+ BRect bottomLeft(screenFrame.left, vDivider,
+ screenFrame.left + hDivider, screenFrame.bottom);
+ BRect bottomMiddle(screenFrame.left + hDivider, vDivider,
+ screenFrame.right - hDivider, screenFrame.bottom);
+ BRect bottomRight(screenFrame.right - hDivider, vDivider,
+ screenFrame.right, screenFrame.bottom);
if (where != fPreviousPosition) {
fPreviousPosition = where;
@@ -1784,34 +1791,33 @@
TResizeControl::MouseMoved(BPoint where, uint32 code,
const BMessage* dragMessage)
{
- if (fBarView->Vertical()) {
- if (IsResizing()) {
- float windowWidth = Window()->Frame().Width();
- float delta = 0;
- BPoint whereScreen = ConvertToScreen(where);
+ if (fBarView->Vertical() && fBarView->State() == kExpandoState
+ && IsResizing()) {
+ float windowWidth = Window()->Frame().Width();
+ float delta = 0;
+ BPoint whereScreen = ConvertToScreen(where);
- if (fBarView->Left()) {
- delta = whereScreen.x - Window()->Frame().right;
- if (delta > 0 && windowWidth >=
gMaximumWindowWidth)
- ; // do nothing
- else if (delta < 0 && windowWidth <=
gMinimumWindowWidth)
- ; // do nothing
- else
- Window()->ResizeBy(delta, 0);
- } else {
- delta = Window()->Frame().left - whereScreen.x;
- if (delta > 0 && windowWidth >=
gMaximumWindowWidth)
- ; // do nothing
- else if (delta < 0 && windowWidth <=
gMinimumWindowWidth)
- ; // do nothing
- else {
- Window()->MoveBy(delta, 0);
- Window()->ResizeBy(delta, 0);
- }
+ if (fBarView->Left()) {
+ delta = whereScreen.x - Window()->Frame().right;
+ if (delta > 0 && windowWidth >= gMaximumWindowWidth)
+ ; // do nothing
+ else if (delta < 0 && windowWidth <=
gMinimumWindowWidth)
+ ; // do nothing
+ else
+ Window()->ResizeBy(delta, 0);
+ } else {
+ delta = Window()->Frame().left - whereScreen.x;
+ if (delta > 0 && windowWidth >= gMaximumWindowWidth)
+ ; // do nothing
+ else if (delta < 0 && windowWidth <=
gMinimumWindowWidth)
+ ; // do nothing
+ else {
+ Window()->MoveBy(delta, 0);
+ Window()->ResizeBy(delta, 0);
}
-
- windowWidth = Window()->Frame().Width();
}
+
+ windowWidth = Window()->Frame().Width();
}
BControl::MouseMoved(where, code, dragMessage);
diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h
index aa9326f..c517daf 100644
--- a/src/apps/deskbar/StatusView.h
+++ b/src/apps/deskbar/StatusView.h
@@ -79,8 +79,7 @@
class TReplicantTray : public BView {
public:
-
TReplicantTray(TBarView* barView,
-
bool vertical);
+
TReplicantTray(TBarView* barView);
virtual
~TReplicantTray();
virtual void AttachedToWindow();
@@ -92,10 +91,6 @@
void
AdjustPlacement();
void
ShowReplicantMenu(BPoint);
- void
SetMultiRow(bool state);
- bool IsMultiRow()
const
-
{ return fMultiRowMode; }
-
TTimeView* Time() const {
return fTime; }
void ShowHideTime();
@@ -181,7 +176,6 @@
float
fMaxReplicantHeight;
float fMinTrayHeight;
- bool fMultiRowMode;
float
fMinimumTrayWidth;
bool
fAlignmentSupport;
diff --git a/src/apps/deskbar/TeamMenu.cpp b/src/apps/deskbar/TeamMenu.cpp
index 2816fe4..985ebfc 100644
--- a/src/apps/deskbar/TeamMenu.cpp
+++ b/src/apps/deskbar/TeamMenu.cpp
@@ -36,6 +36,7 @@
#include "TeamMenu.h"
+#include <algorithm>
#include <strings.h>
#include <Application.h>
@@ -51,12 +52,16 @@
#include "TeamMenuItem.h"
+const float kIconPadding = 8.0f;
+
+
// #pragma mark - TTeamMenuItem
-TTeamMenu::TTeamMenu()
+TTeamMenu::TTeamMenu(TBarView* barView)
:
- BMenu("Team Menu")
+ BMenu("Team Menu"),
+ fBarView(barView)
{
SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
SetFont(be_plain_font);
@@ -85,12 +90,24 @@
BList teamList;
TBarApp::Subscribe(self, &teamList);
- TBarView* barview = (dynamic_cast<TBarApp*>(be_app))->BarView();
- bool dragging = barview && barview->Dragging();
+ bool dragging = fBarView != NULL && fBarView->Dragging();
+ desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
- desk_settings* settings = ((TBarApp*)be_app)->Settings();
+ float iconOnlyWidth = kIconPadding + iconSize + kIconPadding;
- float width = gMinimumWindowWidth - iconSize - 4;
+ float itemWidth = 0;
+ if (settings->hideLabels) {
+ itemWidth = std::max(floorf(gMinimumWindowWidth / 2),
+ iconOnlyWidth);
+ } else {
+ float labelWidth = gMinimumWindowWidth - iconOnlyWidth
+ + (be_plain_font->Size() - 12) * 4;
+ if (iconSize <= 32) // icon wrap after 32x32
+ labelWidth += iconSize - kMinimumIconSize;
+ itemWidth = iconOnlyWidth + labelWidth;
+ }
+
+ SetMaxContentWidth(itemWidth);
if (settings->sortRunningApps)
teamList.SortItems(TTeamMenu::CompareByName);
@@ -100,7 +117,7 @@
// add items back
BarTeamInfo* barInfo = (BarTeamInfo*)teamList.ItemAt(i);
TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams,
- barInfo->icon, barInfo->name, barInfo->sig, width, -1);
+ barInfo->icon, barInfo->name, barInfo->sig, itemWidth);
if (settings->trackerAlwaysFirst
&& strcasecmp(barInfo->sig, kTrackerSignature) == 0) {
@@ -109,15 +126,14 @@
AddItem(item);
if (dragging && item != NULL) {
- bool canhandle =
(dynamic_cast<TBarApp*>(be_app))->BarView()->
- AppCanHandleTypes(item->Signature());
+ bool canhandle =
fBarView->AppCanHandleTypes(item->Signature());
if (item->IsEnabled() != canhandle)
item->SetEnabled(canhandle);
BMenu* menu = item->Submenu();
if (menu != NULL) {
- menu->SetTrackingHook(barview->MenuTrackingHook,
- barview->GetTrackingHookData());
+
menu->SetTrackingHook(fBarView->MenuTrackingHook,
+ fBarView->GetTrackingHookData());
}
}
}
@@ -128,11 +144,11 @@
AddItem(item);
}
- if (dragging && barview->LockLooper()) {
- SetTrackingHook(barview->MenuTrackingHook,
- barview->GetTrackingHookData());
- barview->DragStart();
- barview->UnlockLooper();
+ if (dragging && fBarView->LockLooper()) {
+ SetTrackingHook(fBarView->MenuTrackingHook,
+ fBarView->GetTrackingHookData());
+ fBarView->DragStart();
+ fBarView->UnlockLooper();
}
BMenu::AttachedToWindow();
@@ -142,11 +158,10 @@
void
TTeamMenu::DetachedFromWindow()
{
- TBarView* barView = (dynamic_cast<TBarApp*>(be_app))->BarView();
- if (barView != NULL) {
- BLooper* looper = barView->Looper();
+ if (fBarView != NULL) {
+ BLooper* looper = fBarView->Looper();
if (looper != NULL && looper->Lock()) {
- barView->DragStop();
+ fBarView->DragStop();
looper->Unlock();
}
}
diff --git a/src/apps/deskbar/TeamMenu.h b/src/apps/deskbar/TeamMenu.h
index 0c3ff41..552ab0e 100644
--- a/src/apps/deskbar/TeamMenu.h
+++ b/src/apps/deskbar/TeamMenu.h
@@ -44,15 +44,19 @@
#include <Menu.h>
+class TBarView;
+
class TTeamMenu : public BMenu {
public:
- TTeamMenu();
+ TTeamMenu(TBarView*
barView = NULL);
void AttachedToWindow();
void DetachedFromWindow();
static int CompareByName(const void* first,
const void*
second);
+private:
+ TBarView* fBarView;
};
diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp
index 05c9aec..4de4862 100644
--- a/src/apps/deskbar/TimeView.cpp
+++ b/src/apps/deskbar/TimeView.cpp
@@ -66,15 +66,15 @@
#define B_TRANSLATION_CONTEXT "TimeView"
-TTimeView::TTimeView(float maxWidth, float height)
+TTimeView::TTimeView(float maxWidth, float height, TBarView* barView)
:
BView(BRect(-100, -100, -90, -90), "_deskbar_tv_",
B_FOLLOW_RIGHT | B_FOLLOW_TOP,
B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS),
+ fBarView(barView),
fParent(NULL),
fMaxWidth(maxWidth),
fHeight(height),
- fOrientation(true),
fShowLevel(0),
fShowSeconds(false),
fShowDayOfWeek(false),
@@ -133,7 +133,7 @@
TTimeView::Archive(BMessage* data, bool deep) const
{
BView::Archive(data, deep);
- data->AddBool("orientation", fOrientation);
+ data->AddBool("orientation", Vertical());
data->AddInt16("showLevel", fShowLevel);
data->AddBool("showSeconds", fShowSeconds);
data->AddBool("showDayOfWeek", fShowDayOfWeek);
@@ -320,16 +320,6 @@
// # pragma mark - Public methods
-void
-TTimeView::SetOrientation(bool orientation)
-{
- fOrientation = orientation;
- ResizeToPreferred();
- CalculateTextPlacement();
- Invalidate();
-}
-
-
bool
TTimeView::ShowSeconds() const
{
@@ -480,7 +470,7 @@
fTimeLocation.y = fDateLocation.y = ceilf((Bounds().Height()
- rectArray[0].Height() + 1.0) / 2.0 - rectArray[0].top);
- if (fOrientation) {
+ if (Vertical()) {
float timeWidth = StringWidth(fCurrentTimeStr);
if (timeWidth > fMaxWidth) {
// time does not fit, push it over to truncate the left
side
@@ -533,3 +523,13 @@
if (fParent != NULL)
fParent->Invalidate();
}
+
+
+bool
+TTimeView::Vertical()
+{
+ if (fBarView == NULL)
+ return true;
+
+ return fBarView->Vertical() && fBarView->State() == kExpandoState;
+}
diff --git a/src/apps/deskbar/TimeView.h b/src/apps/deskbar/TimeView.h
index 4f01976..a4f385e 100644
--- a/src/apps/deskbar/TimeView.h
+++ b/src/apps/deskbar/TimeView.h
@@ -69,6 +69,7 @@
class BCountry;
class BMessageRunner;
class CalendarMenuWindow;
+class TBarView;
#ifdef AS_REPLICANT
class _EXPORT TTimeView;
@@ -76,7 +77,8 @@
class TTimeView : public BView {
public:
- TTimeView(float
maxWidth, float height);
+ TTimeView(float
maxWidth, float height,
+
TBarView* barView = NULL);
TTimeView(BMessage* data);
~TTimeView();
@@ -95,9 +97,6 @@
void Pulse();
void ResizeToPreferred();
- bool Orientation() const;
- void SetOrientation(bool o);
-
bool ShowSeconds() const;
void SetShowSeconds(bool
show);
@@ -120,6 +119,9 @@
void ShowTimeOptions(BPoint);
void Update();
+ bool Vertical();
+
+ TBarView* fBarView;
BView* fParent;
bool fNeedToUpdate;
@@ -137,8 +139,7 @@
float fMaxWidth;
float fHeight;
- bool fOrientation;
- //
vertical = true
+
int16 fShowLevel;
bool fShowSeconds;
@@ -157,11 +158,4 @@
};
-inline bool
-TTimeView::Orientation() const
-{
- return fOrientation;
-}
-
-
#endif /* TIME_VIEW_H */
diff --git a/src/apps/deskbar/icons.h b/src/apps/deskbar/icons.h
index e5e65e0..610dfd5 100644
--- a/src/apps/deskbar/icons.h
+++ b/src/apps/deskbar/icons.h
@@ -8,6 +8,7 @@
R_WindowHiddenIcon = 21,
R_ResizeIcon = 22,
R_WindowShownSwitchIcon = 23,
- R_WindowHiddenSwitchIcon = 24
+ R_WindowHiddenSwitchIcon = 24,
+ R_TeamIconVector = 25
};
diff --git a/src/apps/deskbar/icons.rdef b/src/apps/deskbar/icons.rdef
index 1ce1d01..44f9035 100644
--- a/src/apps/deskbar/icons.rdef
+++ b/src/apps/deskbar/icons.rdef
@@ -106,6 +106,53 @@
}
};
+resource(R_TeamIconVector) #'VICN' array {
+ $"6E6369661905FF03000001020006023F900F3DA311BDA3113F900F49E579C426"
+ $"607B77AD779F66986605F905F905F9020006023D81E73ACACFBCF5653FB7664A"
+ $"22313F685CA6A4D0FFB781C0FF036697CB020006023C194E3ADC9FBE40D23F4E"
+ $"144B496242BB7E7FB17739AA98663203986632020016023FC4083CB28EBCB28E"
+ $"3FC40848893EC4953E00E0FFC403FFC286020006023BE99139F3D7BD9B633F92"
+ $"024ACC68409DE571FFDDBB91FFC38805D805A805A805D80540055805B0058805"
+ $"4B020016023E4C7A3CD81CBE1ABA3F66D44AD4A8C3A4EF0057EE3E0373849505"
+ $"62200A0434384438444834480A0434384238424234420A043539413941413541"
+ $"0802BC5DBDDBBC5D3F080239BDCEBD02BF4D0404BEBBDDBE4EBCCFBE5B37BE67"
+ $"BCCFBE5BBCCFBE5BBCCFBE5BBD35BEB43BBECD0A043F393F48434843BD0F0A04"
+ $"BF1A4643464348BEDAC2FC0A0444C1E4C14BBEA743BE0143C2570A05BDA8C131"
+ $"3C44424442433C430A0440464246424040400A0442444344434642460A044046"
+ $"3F47424742460A09C098BE9A3F3D3F3F413F4141424142424342C0E5BF000A07"
+ $"3FBFE6BF0DBF27BEB4BECD3C3DBD9BBE1BBEE7BE5B3F3E0807BEA7BD82BE01BD"
+ $"82BD68BDCEBD753C3F3C3F3B3E3B0A043B3C3C3C3C3B3B3B0A043F3AC019BD82"
+ $"413C3F3C0A04413B423B423C413C0A043C3BBF1ABE01BF40BECD3C3C0A043E3C"
+ $"3F3C3F3D3E3D0A04423F4243C019C065413F0A053F3F3F3D413D414040400A06"
+ $"3F3D413D413F403F403E3F3E0A04413C423C423D413D0A03C04CBEC1423F413F"
+ $"0A04433C443C443D433D0A0443464446444843480A0442424342434342430A06"
+ $"3F3A413A413B423B42393F390A0440404140414140410A043F3C413C413D3F3D"
+ $"200A000002446D790000000000004465B9CD404DCDCBF80A0101010242C64100"
+ $"000000000042BD66CADC64CB7BD60A0201020242C64100000000000042BD66CA"
+ $"DC64CB7BD60A0301031242C64100000000000042D4C7CADC64CBA92201178100"
+ $"040A0401041242774C00000000000042D493CA4D4ACBA31901178100040A0501"
+ $"051242C64100000000000042BD66CADC64CB7BD601178100040A0101060242C6"
+ $"4100000000000042BD66CADC64CB7BD60A0101070242C64100000000000042BD"
+ $"66CADC64CB7BD60A01010802431F0A00000000000042BD66CBA426CB7BD60A06"
+ $"010A0242C64100000000000042BD66CADC64CB7BD60A0101090242C641000000"
+ $"00000042BD66CADC64CB7BD60A07010B0242C64100000000000042BD66CADC64"
+ $"CB7BD60A08010C0242C64100000000000042BD66CADC64CB7BD60A0A010D0242"
+ $"C64100000000000042BD66CADC64CB7BD60A01010E0242C64100000000000042"
+ $"BD66CADC64CB7BD60A01010F0242C64100000000000042BD66CADC64CB7BD60A"
+ $"0B01100242C64100000000000042BD66CADC64CB7BD60A0C01110242C6410000"
+ $"0000000042BD66CADC64CB7BD60A0901120242C64100000000000042BD66CADC"
+ $"64CB7BD60A0D01130242C64100000000000042BD66CADC64CB7BD60A0D011402"
+ $"42C64100000000000042BD66CADC64CB7BD60A1501150242C641000000000000"
+ $"42BD66CADC64CB7BD60A1001160242C64100000000000042BD66CADC64CB7BD6"
+ $"0A1001170242C64100000000000042BD66CADC64CB7BD60A1101180242C64100"
+ $"000000000042BD66CADC64CB7BD60A1201190242C64100000000000042BD66CA"
+ $"DC64CB7BD60A13000242C64100000000000042BD66CADC64CB7BD60A14000242"
+ $"C64100000000000042BD66CADC64CB7BD60A0B011C0242C64100000000000042"
+ $"BD66CADC64CB7BD60A16011D0242C64100000000000042BD66CADC64CB7BD60A"
+ $"17011E0242C64100000000000042BD66CADC64CB7BD60A18011F0242C6410000"
+ $"0000000042BD66CADC64CB7BD6"
+};
+
resource(R_GenericAppIcon) archive(, 0x00000000) BBitmap {
"_frame" = rect { 0.0, 0.0, 15.0, 15.0 },
"_cspace" = 4,
--
To view, visit https://review.haiku-os.org/c/haiku/+/2255
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I30f236c73324b2f9f759346baca54aed661079ca
Gerrit-Change-Number: 2255
Gerrit-PatchSet: 1
Gerrit-Owner: John Scipione <jscipione@xxxxxxxxx>
Gerrit-MessageType: newchange