Skip to content

Commit

Permalink
Deskbar: Restore old mini-mode
Browse files Browse the repository at this point in the history
... with the replicant tray below the menu bar.

Deskbar now has four modes:
1. vertical mini-mode (old mini-mode)
2. horizontal mini-mode (new mini-mode, was vertical)
3. vertical expando-mode (default)
4. horizonal expando-mode

Horizontal mini-mode gets the corner, then it switches to vertical
mini-mode above or below that, then to vertical expando-mode after
that. Horizontal expando mode is in center-screen top and bottom.

Clock vertical centering simplification.

Change-Id: I216008c20feb28f793693046792bbcfdf1e703e3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3146
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
  • Loading branch information
jscipione committed Aug 17, 2020
1 parent 2e4840b commit f9b3a3b
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 187 deletions.
2 changes: 1 addition & 1 deletion src/apps/deskbar/BarMenuTitle.cpp
Expand Up @@ -136,7 +136,7 @@ TBarMenuTitle::DrawContent()

// cut-off the leaf
bool isLeafMenu = dynamic_cast<TDeskbarMenu*>(fMenu) != NULL;
if (fBarView->Vertical() && isLeafMenu)
if (isLeafMenu)
iconRect.OffsetBy(widthOffset, frame.Height() - iconRect.Height() + 2);
else
iconRect.OffsetBy(widthOffset, heightOffset);
Expand Down
171 changes: 84 additions & 87 deletions src/apps/deskbar/BarView.cpp
Expand Up @@ -465,16 +465,19 @@ TBarView::PlaceDeskbarMenu()
// Calculate the size of the deskbar menu
BRect menuFrame(Bounds());
if (fVertical) {
if (fState == kMiniState)
width = gMinimumWindowWidth;
else
width = fBarApp->Settings()->width;

width = static_cast<TBarApp*>(be_app)->Settings()->width;
height = fTabHeight;
} else {
width = gMinimumWindowWidth / 2 + kIconPadding;
height = std::max(TeamMenuItemHeight(),
kGutter + fReplicantTray->MaxReplicantHeight() + kGutter);
// horizontal
if (fState == kMiniState) {
width = gMinimumWindowWidth;
height = std::max(fTabHeight,
kGutter + fReplicantTray->MaxReplicantHeight() + kGutter);
} else {
width = gMinimumWindowWidth / 2 + kIconPadding;
height = std::max(TeamMenuItemHeight(),
kGutter + fReplicantTray->MaxReplicantHeight() + kGutter);
}
}
menuFrame.bottom = menuFrame.top + height;

Expand All @@ -485,24 +488,14 @@ TBarView::PlaceDeskbarMenu()
} else
fBarMenuBar->SmartResize(-1, -1);

if (fVertical) {
switch (fState) {
case kFullState:
case kExpandoState:
default:
// shows apps below tray
fBarMenuBar->RemoveTeamMenu();
fBarMenuBar->RemoveSeperatorItem();
break;

case kMiniState:
// leaf menu next to team menu
fBarMenuBar->RemoveSeperatorItem();
fBarMenuBar->AddTeamMenu();
break;
}
if (fState == kMiniState) {
// vertical or horizontal mini
fBarMenuBar->RemoveSeperatorItem();
fBarMenuBar->AddTeamMenu();
} else if (fVertical) {
fBarMenuBar->RemoveSeperatorItem();
fBarMenuBar->RemoveTeamMenu();
} else {
// shows apps to the right of the leaf menu
fBarMenuBar->RemoveTeamMenu();
fBarMenuBar->AddSeparatorItem();
}
Expand All @@ -529,46 +522,50 @@ TBarView::PlaceTray(bool vertSwap, bool leftSwap)
// also resizes replicant tray

if (fVertical) {
if (fState == kExpandoState || fState == kFullState) {
// move replicant tray down by 2px
if (fLeft) {
// move replicant tray past dragger and shrink by same amount
fReplicantTray->MoveTo(kDragWidth + 1, 2);
fReplicantTray->ResizeBy(-(kDragWidth + 1), -2);
} else {
fReplicantTray->MoveTo(0, 2);
fReplicantTray->ResizeBy(0, -2);
}
if (fResizeControl->IsHidden())
fResizeControl->Show();

statusLoc.x = 0;
statusLoc.y = fBarMenuBar->Frame().bottom + 1;
} else if (fState == kMiniState) {
if (fLeft) {
// move replicant tray past dragger width on left
// also down 1px so it won't cover the border
fReplicantTray->MoveTo(kDragWidth + kGutter, kGutter);

// shrink width by same amount
fReplicantTray->ResizeBy(-(kDragWidth + kGutter), 0);
} else {
// move replicant tray down 1px so it won't cover the border
fReplicantTray->MoveTo(0, kGutter);
}

statusLoc.x = 0;
statusLoc.y = fBarMenuBar->Frame().bottom + 1;
} else {
// horizontal
if (fState == kMiniState) {
// horizontal mini
statusLoc.x = fLeft ? fBarMenuBar->Frame().right + 1 : 0;
statusLoc.y = 0;

// move past dragger and top border
// and make room for the top and bottom borders
fReplicantTray->MoveTo(fLeft ? kDragWidth : 0, kGutter);
fReplicantTray->ResizeBy(0, -4);
} else {
// move tray right and down to not cover border, resize by same
fReplicantTray->MoveTo(2, 0);
fReplicantTray->ResizeBy(-2, 0);
BRect screenFrame = (BScreen(Window())).Frame();
statusLoc.x = screenFrame.right - fDragRegion->Bounds().Width();
statusLoc.y = 0;
}
} else {
// horizontal

// move tray right and down to not cover border, resize by same
fReplicantTray->MoveTo(2, 0);
fReplicantTray->ResizeBy(-2, 0);
BRect screenFrame = (BScreen(Window())).Frame();
statusLoc.x = screenFrame.right - fDragRegion->Bounds().Width();
statusLoc.y = 0;
}

fDragRegion->MoveTo(statusLoc);

// make room for top and bottom border
fResizeControl->ResizeTo(kDragWidth, fDragRegion->Bounds().Height() - 2);
fResizeControl->ResizeTo(kDragWidth, fDragRegion->Bounds().Height() - 2);

// resize control is only used in vertical expando and full state
if (fVertical && fState != kMiniState) {
if (fVertical) {
// move resize control into place based on width setting
fResizeControl->MoveTo(
fLeft ? fBarApp->Settings()->width - kDragWidth : 0, 1);
Expand All @@ -588,16 +585,19 @@ void
TBarView::PlaceApplicationBar()
{
BRect screenFrame = (BScreen(Window())).Frame();
if (fVertical && fState == kMiniState) {
if (fState == kMiniState) {
if (!fInlineScrollView->IsHidden())
fInlineScrollView->Hide();

SizeWindow(screenFrame);
PositionWindow(screenFrame);
Window()->UpdateIfNeeded();
// move the menu bar into place after the window has been resized
// based on replicant tray
fBarMenuBar->MoveTo(fLeft ? 0 : fDragRegion->Bounds().right + 1, 0);
if (!fVertical) {
// move the menu bar into place after the window has been resized
// based on replicant tray
fBarMenuBar->MoveTo(fLeft ? 0 : fDragRegion->Bounds().right + 1,
0);
}
Invalidate();
return;
}
Expand Down Expand Up @@ -652,40 +652,37 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width,
windowWidth = screenFrame.Width();
} else
windowWidth = kHiddenDimension;
} else if (!fVertical) {
// horizontal top or bottom
windowHeight = std::max(TeamMenuItemHeight(),
kGutter + fReplicantTray->MaxReplicantHeight() + kGutter);
windowWidth = screenFrame.Width();
} else {
// vertical
switch (fState) {
case kFullState:
case kExpandoState:
default:
// top left or right
if (fTrayLocation != 0)
windowHeight = fDragRegion->Frame().bottom + 1;
else
windowHeight = fBarMenuBar->Frame().bottom + 1;

// use Height() here not bottom because view can be scrolled
if (fExpandoMenuBar != NULL)
windowHeight += fExpandoMenuBar->Bounds().Height();

// full state has minimum screen window height
if (fState == kFullState)
windowHeight = std::max(screenFrame.bottom, windowHeight);
} else if (fVertical) {
if (fState == kFullState) {
// full state has minimum screen window height
windowHeight = std::max(screenFrame.bottom, windowHeight);
} else {
// mini or expando
if (fTrayLocation != 0)
windowHeight = fDragRegion->Frame().bottom;
else
windowHeight = fBarMenuBar->Frame().bottom;

windowWidth = fBarApp->Settings()->width;
break;
if (fState == kExpandoState && fExpandoMenuBar != NULL) {
// top left or right
windowHeight += fExpandoMenuBar->Bounds().Height();
// use Height() here, not bottom so view can be scrolled
}
}

case kMiniState:
// four corners
windowHeight = fBarMenuBar->Frame().bottom;
windowWidth = fDragRegion->Frame().Width()
+ fBarMenuBar->Frame().Width() + 1;
break;
windowWidth = fBarApp->Settings()->width;
} else {
// horizontal
if (fState == kMiniState) {
// four corners horizontal
windowHeight = fBarMenuBar->Frame().Height();
windowWidth = fDragRegion->Frame().Width()
+ fBarMenuBar->Frame().Width() + 1;
} else {
// horizontal top or bottom
windowHeight = std::max(TeamMenuItemHeight(),
kGutter + fReplicantTray->MaxReplicantHeight() + kGutter);
windowWidth = screenFrame.Width();
}
}

Expand Down Expand Up @@ -714,7 +711,7 @@ TBarView::PositionWindow(BRect screenFrame)

BPoint moveLoc(0, 0);
// right, expanded, mini, or full
if (!fLeft && fVertical)
if (!fLeft && (fVertical || fState == kMiniState))
moveLoc.x = screenFrame.right - windowWidth;

// bottom, full
Expand Down
7 changes: 4 additions & 3 deletions src/apps/deskbar/BarView.h
Expand Up @@ -106,9 +106,10 @@ class TBarView : public BView {
bool Vertical() const { return fVertical; };
bool Left() const { return fLeft; };
bool Top() const { return fTop; };
bool AcrossTop() const { return fTop && !fVertical; };
bool AcrossBottom() const
{ return !fTop && !fVertical; };
bool AcrossTop() const { return fTop && !fVertical
&& fState != kMiniState; };
bool AcrossBottom() const { return !fTop && !fVertical
&& fState != kMiniState; };

// window state methods
bool ExpandoState() const
Expand Down
35 changes: 25 additions & 10 deletions src/apps/deskbar/BarWindow.cpp
Expand Up @@ -244,7 +244,7 @@ TBarWindow::Minimize(bool minimize)
void
TBarWindow::FrameResized(float width, float height)
{
if (fBarView->MiniState() || !fBarView->Vertical())
if (!fBarView->Vertical())
return BWindow::FrameResized(width, height);

bool setToHiddenSize = fBarApp->Settings()->autoHide
Expand Down Expand Up @@ -686,19 +686,34 @@ TBarWindow::SetSizeLimits()
0, kHiddenDimension);
}
} else {
float minHeight;
float maxHeight;
float minWidth;
float maxWidth;

if (fBarView->Vertical()) {
float minHeight = 0;
float maxHeight = B_SIZE_UNLIMITED;
float minWidth = gMinimumWindowWidth;
float maxWidth = fBarView->MiniState() ? B_SIZE_UNLIMITED
: gMaximumWindowWidth;
BWindow::SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
minHeight = fBarView->TabHeight();
maxHeight = B_SIZE_UNLIMITED;
minWidth = gMinimumWindowWidth;
maxWidth = gMaximumWindowWidth;
} else {
BWindow::SetSizeLimits(screenFrame.Width(), screenFrame.Width(),
kMenuBarHeight - 1, kMaximumIconSize + 4);
// horizontal
if (fBarView->MiniState()) {
minWidth = gMinimumWindowWidth;
maxWidth = B_SIZE_UNLIMITED;
minHeight = fBarView->TabHeight();
maxHeight = std::max(fBarView->TabHeight(), kGutter
+ fBarView->ReplicantTray()->MaxReplicantHeight()
+ kGutter);
} else {
minWidth = maxWidth = screenFrame.Width();
minHeight = kMenuBarHeight - 1;
maxHeight = kMaximumIconSize + 4;
}
}
}

BWindow::SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
}
}


Expand Down

0 comments on commit f9b3a3b

Please sign in to comment.