From cb6afcb1464e92f0134232e6179215295e17bc79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 21 Mar 2009 17:27:06 +0000 Subject: [PATCH] * Give Deskbar a refreshed and cleaner look. * Fixed a bunch of problems in layouting the various views. (For example, the last app menu entry is no longer one pixel too short, but there was more...) * Fixed Deskbar being not wide enough for the Haiku logo in certain modes. * Enabled the mount menu. I think it's a good idea to have at a more prominent location where new Haiku users may look for it (Gnome also has this in the main panel). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29631 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/deskbar/BarMenuTitle.cpp | 51 ++++++++- src/apps/deskbar/BarView.cpp | 35 +++--- src/apps/deskbar/BarView.h | 11 +- src/apps/deskbar/ExpandoMenuBar.cpp | 65 +++++++---- src/apps/deskbar/ExpandoMenuBar.h | 14 +-- src/apps/deskbar/Jamfile | 2 +- src/apps/deskbar/StatusView.cpp | 161 ++++++++++++++++++---------- src/apps/deskbar/StatusView.h | 3 +- src/apps/deskbar/TeamMenuItem.cpp | 148 +++++++++++++++---------- 9 files changed, 324 insertions(+), 166 deletions(-) diff --git a/src/apps/deskbar/BarMenuTitle.cpp b/src/apps/deskbar/BarMenuTitle.cpp index 8e052daf1a..78e92707fd 100644 --- a/src/apps/deskbar/BarMenuTitle.cpp +++ b/src/apps/deskbar/BarMenuTitle.cpp @@ -33,10 +33,13 @@ All rights reserved. */ #include + +#include "BarMenuTitle.h" + #include +#include #include "BarApp.h" -#include "BarMenuTitle.h" #include "BarView.h" #include "BarWindow.h" #include "ExpandoMenuBar.h" @@ -77,7 +80,31 @@ TBarMenuTitle::GetContentSize(float *width, float *height) void TBarMenuTitle::Draw() { - BMenuItem::Draw(); + if (be_control_look == NULL) { + BMenuItem::Draw(); + return; + } + + // fill background if selected + rgb_color base = Menu()->LowColor(); + BRect rect = Frame(); + + BRect windowBounds = Menu()->Window()->Bounds(); + if (rect.right > windowBounds.right) + rect.right = windowBounds.right; + + if (IsSelected()) { + be_control_look->DrawMenuItemBackground(Menu(), rect, rect, base, + BControlLook::B_ACTIVATED); + } else { + be_control_look->DrawButtonBackground(Menu(), rect, rect, base); + } + + // draw content + DrawContent(); + + // make sure we restore state + Menu()->SetLowColor(base); } @@ -86,6 +113,21 @@ TBarMenuTitle::DrawContent() { BMenu *menu = Menu(); BRect frame(Frame()); + + if (be_control_look != NULL) { + menu->SetDrawingMode(B_OP_ALPHA); + + if (fIcon != NULL) { + BRect dstRect(fIcon->Bounds()); + dstRect.OffsetTo(frame.LeftTop()); + dstRect.OffsetBy(rintf(((frame.Width() - dstRect.Width()) / 2) - 1.0f), + rintf(((frame.Height() - dstRect.Height()) / 2) - 0.0f)); + + menu->DrawBitmapAsync(fIcon, dstRect); + } + return; + } + rgb_color menuColor = menu->ViewColor(); rgb_color dark = tint_color(menuColor, B_DARKEN_1_TINT); rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT); @@ -94,7 +136,7 @@ TBarMenuTitle::DrawContent() bool inExpandoMode = dynamic_cast(menu) != NULL; BRect bounds(menu->Window()->Bounds()); - if (bounds.right < frame.right) + if (bounds.right < frame.right) frame.right = bounds.right; menu->SetDrawingMode(B_OP_COPY); @@ -108,7 +150,8 @@ TBarMenuTitle::DrawContent() menu->AddLine(frame.RightBottom(), frame.RightTop(), dark); if (inExpandoMode) { frame.top += 1; - menu->AddLine(frame.LeftTop(), frame.RightTop() + BPoint(-1, 0), light); + menu->AddLine(frame.LeftTop(), frame.RightTop() + BPoint(-1, 0), + light); } menu->EndLineArray(); diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index b04e6402b3..6cf3de5bd7 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -67,7 +67,6 @@ const int32 kDefaultRecentAppCount = 10; const int32 kMenuTrackMargin = 20; - TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, bool showInterval, uint32 state, float, bool showTime) : BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), @@ -86,7 +85,7 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, fMaxRecentDocs(kDefaultRecentDocCount), fMaxRecentApps(kDefaultRecentAppCount), fLastDragItem(NULL) -{ +{ } @@ -94,10 +93,6 @@ TBarView::~TBarView() { delete fDragMessage; delete fCachedTypesList; - - // !! this should be done in DetachedFromWindow - // to be symetric - delete fTrackingHookData.fDragMessage; } @@ -124,6 +119,14 @@ TBarView::AttachedToWindow() } +void +TBarView::DetachedFromWindow() +{ + delete fTrackingHookData.fDragMessage; + fTrackingHookData.fDragMessage = NULL; +} + + void TBarView::Draw(BRect) { @@ -220,7 +223,7 @@ TBarView::PlaceBeMenu() if (!fBarMenuBar) return; - float width = kMinimumWindowWidth; + float width = sMinimumWindowWidth; BPoint loc(B_ORIGIN); BRect menuFrame(fBarMenuBar->Frame()); if (fState == kFullState) { @@ -276,7 +279,7 @@ TBarView::PlaceTray(bool, bool, BRect screenFrame) else fReplicantTray->MoveTo(2, 2); } else { - statusLoc.x = screenFrame.Width() - fDragRegion->Bounds().Width(); + statusLoc.x = screenFrame.right - fDragRegion->Bounds().Width(); statusLoc.y = -1; } @@ -300,21 +303,21 @@ TBarView::PlaceApplicationBar(BRect screenFrame) if (fVertical) { // top left/right if (fTrayLocation != 0) - expandoFrame.top = fDragRegion->Frame().bottom + 2; + expandoFrame.top = fDragRegion->Frame().bottom + 1; else - expandoFrame.top = fBarMenuBar->Frame().bottom + 2; + expandoFrame.top = fBarMenuBar->Frame().bottom + 1; expandoFrame.bottom = expandoFrame.top + 1; if (fState == kFullState) expandoFrame.right = fBarMenuBar->Frame().Width(); else - expandoFrame.right = kMinimumWindowWidth; + expandoFrame.right = sMinimumWindowWidth; } else { // top or bottom - expandoFrame.top = -1; + expandoFrame.top = 0; expandoFrame.bottom = kHModeHeight; if (fTrayLocation != 0) - expandoFrame.right = fDragRegion->Frame().left; + expandoFrame.right = fDragRegion->Frame().left - 1; else expandoFrame.right = screenFrame.Width(); } @@ -328,15 +331,15 @@ TBarView::PlaceApplicationBar(BRect screenFrame) void TBarView::GetPreferredWindowSize(BRect screenFrame, float *width, float *height) { - float windowHeight = 0; - float windowWidth = kMinimumWindowWidth; + float windowHeight = 0; + float windowWidth = sMinimumWindowWidth; if (fState == kFullState) { windowHeight = screenFrame.bottom; windowWidth = fBarMenuBar->Frame().Width(); } else if (fState == kExpandoState) { if (fVertical) { // top left or right - windowHeight = fExpando->Frame().bottom - 1; + windowHeight = fExpando->Frame().bottom; } else { // top or bottom, full fExpando->CheckItemSizes(0); diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h index 309e79bc9b..dc091c4e4e 100644 --- a/src/apps/deskbar/BarView.h +++ b/src/apps/deskbar/BarView.h @@ -72,6 +72,7 @@ class TBarView : public BView { ~TBarView(); virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); virtual void Draw(BRect updateRect); virtual void MessageReceived(BMessage* message); virtual void MouseMoved(BPoint where, uint32 transit, @@ -148,11 +149,11 @@ class TBarView : public BView { TDragRegion *fDragRegion; TReplicantTray *fReplicantTray; - bool fShowInterval; - bool fShowClock; - bool fVertical; - bool fTop; - bool fLeft; + bool fShowInterval : 1; + bool fShowClock : 1; + bool fVertical : 1; + bool fTop : 1; + bool fLeft : 1; int32 fState; diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 8aafe4eb25..8e3a973df2 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -33,12 +33,15 @@ All rights reserved. */ #include + #include + +#include +#include +#include #include #include #include -#include -#include #include "icons.h" #include "icons_logo.h" @@ -55,7 +58,7 @@ All rights reserved. #include "WindowMenu.h" #include "WindowMenuItem.h" -const float kBeMenuWidth = 50.0f; +const float kDefaultBeMenuWidth = 50.0f; const float kSepItemWidth = 5.0f; const uint32 M_MINIMIZE_TEAM = 'mntm'; @@ -77,6 +80,7 @@ TExpandoMenuBar::TExpandoMenuBar(TBarView *bar, BRect frame, const char *name, fIsScrolling(false), fShowTeamExpander(static_cast(be_app)->Settings()->superExpando), fExpandNewTeams(static_cast(be_app)->Settings()->expandNewTeams), + fBeMenuWidth(kDefaultBeMenuWidth), fBarView(bar), fFirstApp(0), fPreviousDragTargetItem(NULL) @@ -88,7 +92,7 @@ TExpandoMenuBar::TExpandoMenuBar(TBarView *bar, BRect frame, const char *name, SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f); SetFont(be_plain_font); - SetMaxContentWidth(kMinimumWindowWidth); + SetMaxContentWidth(sMinimumWindowWidth); } @@ -106,15 +110,19 @@ TExpandoMenuBar::AttachedToWindow() BMessenger self(this); BList teamList; TBarApp::Subscribe(self, &teamList); - float width = fVertical ? Frame().Width() : kMinimumWindowWidth; + float width = fVertical ? Frame().Width() : sMinimumWindowWidth; float height = -1.0f; // top or bottom mode, add be menu and sep for menubar tracking consistency if (!fVertical) { TBeMenu *beMenu = new TBeMenu(fBarView); TBarWindow::SetBeMenu(beMenu); - fBeMenuItem = new TBarMenuTitle(kBeMenuWidth, Frame().Height(), - AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_BeLogoIcon), beMenu, true); + const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE, + R_BeLogoIcon); + if (logoBitmap != NULL) + fBeMenuWidth = logoBitmap->Bounds().Width() + 16; + fBeMenuItem = new TBarMenuTitle(fBeMenuWidth, Frame().Height(), + logoBitmap, beMenu, true); AddItem(fBeMenuItem); fSeparatorItem = new TTeamMenuItem(kSepItemWidth, height, fVertical); @@ -521,7 +529,7 @@ TExpandoMenuBar::TeamItemAtPoint(BPoint point, BMenuItem **_item) void TExpandoMenuBar::AddTeam(BList *team, BBitmap *icon, char *name, char *signature) { - float itemWidth = fVertical ? fBarView->Bounds().Width() : kMinimumWindowWidth; + float itemWidth = fVertical ? fBarView->Bounds().Width() : sMinimumWindowWidth; float itemHeight = -1.0f; desk_settings *settings = ((TBarApp *)be_app)->Settings(); @@ -630,14 +638,14 @@ TExpandoMenuBar::CheckItemSizes(int32 delta) int32 count = CountItems(); bool reset = false; float newWidth = 0; - float fullWidth = (kMinimumWindowWidth * count); + float fullWidth = (sMinimumWindowWidth * count); if (!fBarView->Vertical()) { // in this case there are 2 extra items: // The Be Menu // The little separator item - fullWidth = fullWidth - (kMinimumWindowWidth * 2) + (kBeMenuWidth + kSepItemWidth); - width -= (kBeMenuWidth + kSepItemWidth); + fullWidth = fullWidth - (sMinimumWindowWidth * 2) + (fBeMenuWidth + kSepItemWidth); + width -= (fBeMenuWidth + kSepItemWidth); count -= 2; } @@ -650,14 +658,14 @@ TExpandoMenuBar::CheckItemSizes(int32 delta) if (fullWidth > width) newWidth = floorf(width/count); else - newWidth = kMinimumWindowWidth; + newWidth = sMinimumWindowWidth; } - if (newWidth > kMinimumWindowWidth) - newWidth = kMinimumWindowWidth; + if (newWidth > sMinimumWindowWidth) + newWidth = sMinimumWindowWidth; if (reset) { SetMaxContentWidth(newWidth); - if (newWidth == kMinimumWindowWidth) + if (newWidth == sMinimumWindowWidth) fOverflow = false; InvalidateLayout(); @@ -691,25 +699,36 @@ TExpandoMenuBar::Draw(BRect update) void TExpandoMenuBar::DrawBackground(BRect) { + if (fVertical) + return; + BRect bounds(Bounds()); rgb_color menuColor = ViewColor(); rgb_color hilite = tint_color(menuColor, B_DARKEN_1_TINT); rgb_color dark = tint_color(menuColor, B_DARKEN_2_TINT); rgb_color vlight = tint_color(menuColor, B_LIGHTEN_2_TINT); + int32 last = CountItems() - 1; - float start; - if (last >= 0) - start = ItemAt(last)->Frame().right + 1; + bounds.left = ItemAt(last)->Frame().right + 1; else - start = 0; + bounds.left = 0; - if (!fVertical) { + if (be_control_look != NULL) { + SetHighColor(tint_color(menuColor, 1.22)); + StrokeLine(bounds.LeftTop(), bounds.LeftBottom()); + bounds.left++; + uint32 borders = BControlLook::B_TOP_BORDER + | BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER; + + be_control_look->DrawButtonBackground(this, bounds, bounds, menuColor, + 0, borders); + } else { SetHighColor(vlight); - StrokeLine(BPoint(start, bounds.top+1), bounds.RightTop() + BPoint(0,1)); - StrokeLine(BPoint(start, bounds.top+1), BPoint(start, bounds.bottom)); + StrokeLine(bounds.LeftTop(), bounds.RightTop()); + StrokeLine(BPoint(bounds.left, bounds.top + 1), bounds.LeftBottom()); SetHighColor(hilite); - StrokeLine(BPoint(start+1, bounds.bottom), bounds.RightBottom()); + StrokeLine(BPoint(bounds.left + 1, bounds.bottom), bounds.RightBottom()); } } diff --git a/src/apps/deskbar/ExpandoMenuBar.h b/src/apps/deskbar/ExpandoMenuBar.h index beb8b33585..5d26c6446d 100644 --- a/src/apps/deskbar/ExpandoMenuBar.h +++ b/src/apps/deskbar/ExpandoMenuBar.h @@ -91,12 +91,14 @@ class TExpandoMenuBar : public BMenuBar { void _FinishedDrag(bool invoke = false); - bool fVertical; - bool fOverflow; - bool fDrawLabel; - bool fIsScrolling; - bool fShowTeamExpander; - bool fExpandNewTeams; + bool fVertical : 1; + bool fOverflow : 1; + bool fDrawLabel : 1; + bool fIsScrolling : 1; + bool fShowTeamExpander : 1; + bool fExpandNewTeams : 1; + + float fBeMenuWidth; TBarView *fBarView; int32 fFirstApp; diff --git a/src/apps/deskbar/Jamfile b/src/apps/deskbar/Jamfile index 0f445cbe0b..d55ca58fef 100644 --- a/src/apps/deskbar/Jamfile +++ b/src/apps/deskbar/Jamfile @@ -18,7 +18,7 @@ local targetSource ; if $(TARGET_PLATFORM) = haiku { targetLib = libshared.a ; targetSource = CalendarMenuWindow.cpp ; -SubDirC++Flags -D_SHOW_CALENDAR_MENU_WINDOW=1 ; +SubDirC++Flags -D_SHOW_CALENDAR_MENU_WINDOW=1 -DMOUNT_MENU_IN_DESKBAR=1 ; } else { SubDirC++Flags -D_SHOW_CALENDAR_MENU_ITEM=1 ; } diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index b560c8198e..20e8434aaf 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -44,9 +44,10 @@ All rights reserved. #include #include -#include #include #include +#include +#include #include #include #include @@ -60,11 +61,13 @@ All rights reserved. #include #include +#include "icons_logo.h" +#include "BarApp.h" #include "DeskBarUtils.h" +#include "ResourceSet.h" #include "StatusView.h" #include "StatusViewShelf.h" #include "TimeView.h" -#include "BarApp.h" using std::max; @@ -83,6 +86,8 @@ const char *const kStatusPredicate = "be:deskbar_item_status"; const char *const kEnabledPredicate = "be:deskbar_item_status=enabled"; const char *const kDisabledPredicate = "be:deskbar_item_status=disabled"; +float sMinimumWindowWidth = kGutter + kMinimumTrayWidth + kDragRegionWidth; + static void DumpItem(DeskbarItemInfo *item) @@ -122,8 +127,17 @@ TReplicantTray::TReplicantTray(TBarView *parent, bool vertical) fBarView(parent), fShelf(new TReplicantShelf(this)), fMultiRowMode(vertical), + fMinimumTrayWidth(kMinimumTrayWidth), fAlignmentSupport(false) { + // init the minimum window width according to the logo. + const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE, + R_BeLogoIcon); + if (logoBitmap != NULL) { + sMinimumWindowWidth = max_c(sMinimumWindowWidth, + 2 * (logoBitmap->Bounds().Width() + 8)); + fMinimumTrayWidth = sMinimumWindowWidth - kGutter - kDragRegionWidth; + } } @@ -138,8 +152,12 @@ TReplicantTray::AttachedToWindow() { BView::AttachedToWindow(); - SetViewColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), - B_DARKEN_1_TINT)); + if (be_control_look != NULL) { + SetViewColor(Parent()->ViewColor()); + } else { + SetViewColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), + B_DARKEN_1_TINT)); + } SetDrawingMode(B_OP_COPY); Window()->SetPulseRate(1000000); @@ -236,7 +254,7 @@ TReplicantTray::DealWithClock(bool showClock) if (!fClock) { desk_settings *settings = ((TBarApp *)be_app)->Settings(); - fClock = new TTimeView(kMinimumTrayWidth, kMaxReplicantHeight - 1.0, + fClock = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0, settings->timeShowSeconds, settings->timeShowMil, settings->timeFullDate, settings->timeShowEuro, false); AddChild(fClock); @@ -278,7 +296,7 @@ TReplicantTray::GetPreferredSize(float *preferredWidth, float *preferredHeight) height = kGutter + (rowCount * kMaxReplicantHeight) + ((rowCount - 1) * kIconGap) + kGutter; height = max(kMinimumTrayHeight, height); - width = kMinimumTrayWidth; + width = fMinimumTrayWidth; } else { // if last replicant overruns clock then // resize to accomodate @@ -291,7 +309,7 @@ TReplicantTray::GetPreferredSize(float *preferredWidth, float *preferredHeight) width = fRightBottomReplicant.right + 3; } // this view has a fixed minimum width - width = max(kMinimumTrayWidth, width); + width = max(fMinimumTrayWidth, width); } *preferredWidth = width; @@ -325,6 +343,7 @@ TReplicantTray::AdjustPlacement() void TReplicantTray::Draw(BRect) { +return; rgb_color menuColor = ViewColor(); rgb_color vdark = tint_color(menuColor, B_DARKEN_3_TINT); rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT); @@ -1276,7 +1295,7 @@ TReplicantTray::LocationForReplicant(int32 index, float width) // try to find free space in every row for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) { // determine free space in this row - BRect rect(loc.x, loc.y, loc.x + kMinimumTrayWidth - kIconGap - 2.0, loc.y + kMaxReplicantHeight); + BRect rect(loc.x, loc.y, loc.x + fMinimumTrayWidth - kIconGap - 2.0, loc.y + kMaxReplicantHeight); if (row == 0 && fBarView->ShowingClock()) rect.right -= fClock->Frame().Width() + kIconGap; @@ -1407,7 +1426,10 @@ void TDragRegion::AttachedToWindow() { BView::AttachedToWindow(); - SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); + if (be_control_look != NULL) + SetViewColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), 1.1)); + else + SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); ResizeToPreferred(); } @@ -1443,6 +1465,8 @@ TDragRegion::Draw(BRect) { rgb_color menuColor = ViewColor(); rgb_color hilite = tint_color(menuColor, B_DARKEN_1_TINT); + rgb_color ldark = tint_color(menuColor, 1.02); + rgb_color dark = tint_color(menuColor, B_DARKEN_2_TINT); rgb_color vdark = tint_color(menuColor, B_DARKEN_3_TINT); rgb_color vvdark = tint_color(menuColor, B_DARKEN_4_TINT); rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT); @@ -1450,23 +1474,43 @@ TDragRegion::Draw(BRect) BRect frame(Bounds()); BeginLineArray(4); - if (fBarView->Vertical()) { - AddLine(frame.LeftTop(), frame.RightTop(), light); - AddLine(frame.LeftTop(), frame.LeftBottom(), light); - AddLine(frame.RightBottom(), frame.RightTop(), hilite); - } else if (fBarView->AcrossTop()) { - AddLine(frame.LeftTop()+BPoint(0, 1), frame.RightTop()+BPoint(-1, 1), - light); - AddLine(frame.RightTop(), frame.RightBottom(), vvdark); - AddLine(frame.RightTop()+BPoint(-1, 2),frame.RightBottom()+BPoint(-1, -1), - hilite); - AddLine(frame.LeftBottom(), frame.RightBottom()+BPoint(-1, 0), hilite); - } else if (fBarView->AcrossBottom()) { - AddLine(frame.LeftTop()+BPoint(0, 1), frame.RightTop()+BPoint(-1, 1), light); - AddLine(frame.LeftBottom(), frame.RightBottom(), hilite); - AddLine(frame.RightTop(), frame.RightBottom(), vvdark); - AddLine(frame.RightTop()+BPoint(-1, 1),frame.RightBottom()+BPoint(-1, -1), - hilite); + if (be_control_look != NULL) { + if (fBarView->Vertical()) { + AddLine(frame.LeftTop(), frame.RightTop(), dark); + AddLine(BPoint(frame.left, frame.top + 1), + BPoint(frame.right, frame.top + 1), ldark); + AddLine(frame.LeftBottom(), frame.RightBottom(), hilite); + } else if (fBarView->AcrossTop() || fBarView->AcrossBottom()) { + AddLine(frame.LeftTop(), + BPoint(frame.left, frame.bottom), dark); + AddLine(BPoint(frame.left + 1, frame.top + 1), + BPoint(frame.right - 1, frame.top + 1), light); + AddLine(BPoint(frame.right, frame.top + 2), + BPoint(frame.right, frame.bottom), hilite); + AddLine(BPoint(frame.left + 1, frame.bottom), + BPoint(frame.right - 1, frame.bottom), hilite); + } + } else { + if (fBarView->Vertical()) { + AddLine(frame.LeftTop(), frame.RightTop(), light); + AddLine(frame.LeftTop(), frame.LeftBottom(), light); + AddLine(frame.RightBottom(), frame.RightTop(), hilite); + } else if (fBarView->AcrossTop()) { + AddLine(BPoint(frame.left, frame.top + 1), + BPoint(frame.right - 1, frame.top + 1), light); + AddLine(frame.RightTop(), frame.RightBottom(), vvdark); + AddLine(BPoint(frame.right - 1, frame.top + 2), + BPoint(frame.right - 1, frame.bottom - 1), hilite); + AddLine(frame.LeftBottom(), + BPoint(frame.right - 1, frame.bottom), hilite); + } else if (fBarView->AcrossBottom()) { + AddLine(BPoint(frame.left, frame.top + 1), + BPoint(frame.right - 1, frame.top + 1), light); + AddLine(frame.LeftBottom(), frame.RightBottom(), hilite); + AddLine(frame.RightTop(), frame.RightBottom(), vvdark); + AddLine(BPoint(frame.right - 1, frame.top + 1), + BPoint(frame.right - 1, frame.bottom - 1), hilite); + } } EndLineArray(); @@ -1479,33 +1523,29 @@ TDragRegion::Draw(BRect) void TDragRegion::DrawDragRegion() { - rgb_color menuColor = ViewColor(); - rgb_color menuHilite = tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT); - rgb_color vdark = tint_color(menuColor, B_DARKEN_3_TINT); - rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT); - BRect dragRegion(DragRegion()); - - BeginLineArray(dragRegion.IntegerHeight()); - BPoint pt = dragRegion.LeftTop() + BPoint(1,1); - - // Draw drag region highlighted if tracking mouse + + rgb_color menuColor = ViewColor(); + rgb_color menuHilite = menuColor; if (IsTracking()) { + // Draw drag region highlighted if tracking mouse + menuHilite = tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT); SetHighColor(menuHilite); FillRect(dragRegion); - while (pt.y + 1 <= dragRegion.bottom) { - AddLine(pt, pt, light); - AddLine(pt+BPoint(1,1), pt+BPoint(1,1), vdark); - - pt.y += 3; - } - } else { - while (pt.y + 1 <= dragRegion.bottom) { - AddLine(pt, pt, vdark); - AddLine(pt+BPoint(1,1), pt+BPoint(1,1), light); - - pt.y += 3; - } + } + rgb_color vdark = tint_color(menuHilite, B_DARKEN_3_TINT); + rgb_color light = tint_color(menuHilite, B_LIGHTEN_2_TINT); + + BeginLineArray(dragRegion.IntegerHeight()); + BPoint pt; + pt.x = floorf((dragRegion.left + dragRegion.right) / 2 + 0.5) - 1; + pt.y = dragRegion.top + 2; + + while (pt.y + 1 <= dragRegion.bottom) { + AddLine(pt, pt, vdark); + AddLine(pt + BPoint(1, 1), pt + BPoint(1, 1), light); + + pt.y += 3; } EndLineArray(); } @@ -1514,9 +1554,18 @@ TDragRegion::DrawDragRegion() BRect TDragRegion::DragRegion() const { + float kTopBottomInset = 2; + float kLeftRightInset = 1; + float kDragWidth = 3; + if (be_control_look != NULL) { + kTopBottomInset = 1; + kLeftRightInset = 0; + kDragWidth = 4; + } + BRect dragRegion(Bounds()); - dragRegion.top += 2; - dragRegion.bottom -= 2; + dragRegion.top += kTopBottomInset; + dragRegion.bottom -= kTopBottomInset; bool placeOnLeft=false; if (fDragLocation == kAutoPlaceDragRegion) { @@ -1530,11 +1579,11 @@ TDragRegion::DragRegion() const placeOnLeft = false; if (placeOnLeft) { - dragRegion.left += 1; - dragRegion.right = dragRegion.left + 3; + dragRegion.left += kLeftRightInset; + dragRegion.right = dragRegion.left + kDragWidth; } else { - dragRegion.right -= 1; - dragRegion.left = dragRegion.right - 3; + dragRegion.right -= kLeftRightInset; + dragRegion.left = dragRegion.right - kDragWidth; } return dragRegion; @@ -1612,7 +1661,7 @@ TDragRegion::MouseMoved(BPoint where, uint32 code, const BMessage *message) BRect frame = screen.Frame(); float hDivider = frame.Width() / 6; - hDivider = (hDivider < kMinimumWindowWidth + 10.0f) ? kMinimumWindowWidth + 10.0f : hDivider; + hDivider = (hDivider < sMinimumWindowWidth + 10.0f) ? sMinimumWindowWidth + 10.0f : hDivider; float miniDivider = frame.top + kMiniHeight + 10.0f; float vDivider = frame.Height() / 2; #ifdef FULL_MODE diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h index 5e81f6b37a..723995b0fe 100644 --- a/src/apps/deskbar/StatusView.h +++ b/src/apps/deskbar/StatusView.h @@ -59,7 +59,7 @@ const float kMinimumTrayWidth = kIconGap + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter; const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter; -const float kMinimumWindowWidth = kGutter + kMinimumTrayWidth + kDragRegionWidth; +extern float sMinimumWindowWidth; #ifdef DB_ADDONS struct DeskbarItemInfo { @@ -161,6 +161,7 @@ private: int32 fLastReplicant; bool fMultiRowMode; + float fMinimumTrayWidth; bool fAlignmentSupport; #ifdef DB_ADDONS diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp index 0ab7e80288..5dd360548e 100644 --- a/src/apps/deskbar/TeamMenuItem.cpp +++ b/src/apps/deskbar/TeamMenuItem.cpp @@ -34,11 +34,14 @@ All rights reserved. #include +#include "TeamMenuItem.h" + #include #include #include #include +#include #include #include #include @@ -50,7 +53,6 @@ All rights reserved. #include "ResourceSet.h" #include "ShowHideMenuItem.h" #include "TeamMenu.h" -#include "TeamMenuItem.h" #include "WindowMenu.h" #include "WindowMenuItem.h" @@ -229,12 +231,49 @@ TTeamMenuItem::Draw() BRect frame(Frame()); BMenu *menu = Menu(); menu->PushState(); - rgb_color menuColor = menu->ViewColor(); + rgb_color menuColor = menu->LowColor(); + + TBarView *barview = (static_cast(be_app))->BarView(); + bool canHandle = !barview->Dragging() + || barview->AppCanHandleTypes(Signature()); + + if (be_control_look != NULL) { + uint32 flags = 0; + if (_IsSelected() && canHandle) + flags |= BControlLook::B_ACTIVATED; + + uint32 borders = BControlLook::B_TOP_BORDER; + if (fVertical) { + menu->SetHighColor(tint_color(menuColor, B_DARKEN_1_TINT)); + borders |= BControlLook::B_LEFT_BORDER + | BControlLook::B_RIGHT_BORDER; + menu->StrokeLine(frame.LeftBottom(), frame.RightBottom()); + frame.bottom--; + + be_control_look->DrawMenuBarBackground(menu, frame, frame, + menuColor, flags, borders); + } else { + if (flags & BControlLook::B_ACTIVATED) + menu->SetHighColor(tint_color(menuColor, B_DARKEN_3_TINT)); + else + menu->SetHighColor(tint_color(menuColor, 1.22)); + borders |= BControlLook::B_BOTTOM_BORDER; + menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()); + frame.left++; + + be_control_look->DrawButtonBackground(menu, frame, frame, + menuColor, flags, borders); + } + + menu->MovePenTo(ContentLocation()); + DrawContent(); + menu->PopState(); + return; + } // if not selected or being tracked on, fill with gray - TBarView *barview = (static_cast(be_app))->BarView(); - bool canHandle = !barview->Dragging() || barview->AppCanHandleTypes(Signature()); - if (!_IsSelected() && !menu->IsRedrawAfterSticky() || !canHandle || !IsEnabled()) { + if (!_IsSelected() && !menu->IsRedrawAfterSticky() || !canHandle + || !IsEnabled()) { frame.InsetBy(1, 1); menu->SetHighColor(menuColor); menu->FillRect(frame); @@ -246,8 +285,6 @@ TTeamMenuItem::Draw() rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT); frame = Frame(); - if (!fVertical) - frame.top += 1; menu->SetHighColor(shadow); if (fVertical) @@ -301,9 +338,6 @@ TTeamMenuItem::DrawContent() } BRect frame(Frame()); - if (!fVertical) - frame.top += 1; - BRect iconBounds(fIcon->Bounds()); BRect dstRect(iconBounds); float extra = fVertical ? 0.0f : 1.0f; @@ -312,8 +346,6 @@ TTeamMenuItem::DrawContent() ((frame.Height() - iconBounds.Height()) / 2) + extra)); menu->DrawBitmapAsync(fIcon, dstRect); - menu->SetDrawingMode(B_OP_COPY); - float labelHeight = fLabelAscent + fLabelDescent; BPoint drawLoc = contLoc + BPoint(kHPad, kVPad); drawLoc.x += iconBounds.Width() + kLabelOffset; @@ -322,14 +354,16 @@ TTeamMenuItem::DrawContent() } // set the pen to black so that either method will draw in the same color - // low color is set in inherited::DrawContent, override makes sure its what we want + // low color is set in inherited::DrawContent, override makes sure its + // what we want if (fDrawLabel) { + menu->SetDrawingMode(B_OP_OVER); menu->SetHighColor(0, 0, 0); // override the drawing of the content when the item is disabled // the wrong lowcolor is used when the item is disabled since the // text color does not change - DrawContentLabel(); + DrawContentLabel(); } // Draw the expandable icon. @@ -341,46 +375,53 @@ TTeamMenuItem::DrawContent() rect.OffsetTo(BPoint(frame.right - rect.Width(), ContentLocation().y + ((frame.Height() - rect.Height()) / 2))); - rgb_color outlineColor = {80, 80, 80, 255}; - rgb_color middleColor = {200, 200, 200, 255}; - - menu->SetDrawingMode(B_OP_OVER); - - if (!fExpanded) { - menu->BeginLineArray(6); - - menu->AddLine(BPoint(rect.left + 3, rect.top + 1), - BPoint(rect.left + 3, rect.bottom - 1), outlineColor); - menu->AddLine(BPoint(rect.left + 3, rect.top + 1), - BPoint(rect.left + 7, rect.top + 5), outlineColor); - menu->AddLine(BPoint(rect.left + 7, rect.top + 5), - BPoint(rect.left + 3, rect.bottom - 1), outlineColor); - - menu->AddLine(BPoint(rect.left + 4, rect.top + 3), - BPoint(rect.left + 4, rect.bottom - 3), middleColor); - menu->AddLine(BPoint(rect.left + 5, rect.top + 4), - BPoint(rect.left + 5, rect.bottom - 4), middleColor); - menu->AddLine(BPoint(rect.left + 5, rect.top + 5), - BPoint(rect.left + 6, rect.top + 5), middleColor); - menu->EndLineArray(); + if (be_control_look != NULL) { + uint32 arrowDirection = fExpanded + ? BControlLook::B_UP_ARROW : BControlLook::B_DOWN_ARROW; + be_control_look->DrawArrowShape(menu, rect, rect, menu->LowColor(), + arrowDirection, 0, B_DARKEN_3_TINT); } else { - // expanded state - - menu->BeginLineArray(6); - menu->AddLine(BPoint(rect.left + 1, rect.top + 3), - BPoint(rect.right - 3, rect.top + 3), outlineColor); - menu->AddLine(BPoint(rect.left + 1, rect.top + 3), - BPoint(rect.left + 5, rect.top + 7), outlineColor); - menu->AddLine(BPoint(rect.left + 5, rect.top + 7), - BPoint(rect.right - 3, rect.top + 3), outlineColor); - - menu->AddLine(BPoint(rect.left + 3, rect.top + 4), - BPoint(rect.right - 5, rect.top + 4), middleColor); - menu->AddLine(BPoint(rect.left + 4, rect.top + 5), - BPoint(rect.right - 6, rect.top + 5), middleColor); - menu->AddLine(BPoint(rect.left + 5, rect.top + 5), - BPoint(rect.left + 5, rect.top + 6), middleColor); - menu->EndLineArray(); + rgb_color outlineColor = {80, 80, 80, 255}; + rgb_color middleColor = {200, 200, 200, 255}; + + menu->SetDrawingMode(B_OP_OVER); + + if (!fExpanded) { + menu->BeginLineArray(6); + + menu->AddLine(BPoint(rect.left + 3, rect.top + 1), + BPoint(rect.left + 3, rect.bottom - 1), outlineColor); + menu->AddLine(BPoint(rect.left + 3, rect.top + 1), + BPoint(rect.left + 7, rect.top + 5), outlineColor); + menu->AddLine(BPoint(rect.left + 7, rect.top + 5), + BPoint(rect.left + 3, rect.bottom - 1), outlineColor); + + menu->AddLine(BPoint(rect.left + 4, rect.top + 3), + BPoint(rect.left + 4, rect.bottom - 3), middleColor); + menu->AddLine(BPoint(rect.left + 5, rect.top + 4), + BPoint(rect.left + 5, rect.bottom - 4), middleColor); + menu->AddLine(BPoint(rect.left + 5, rect.top + 5), + BPoint(rect.left + 6, rect.top + 5), middleColor); + menu->EndLineArray(); + } else { + // expanded state + + menu->BeginLineArray(6); + menu->AddLine(BPoint(rect.left + 1, rect.top + 3), + BPoint(rect.right - 3, rect.top + 3), outlineColor); + menu->AddLine(BPoint(rect.left + 1, rect.top + 3), + BPoint(rect.left + 5, rect.top + 7), outlineColor); + menu->AddLine(BPoint(rect.left + 5, rect.top + 7), + BPoint(rect.right - 3, rect.top + 3), outlineColor); + + menu->AddLine(BPoint(rect.left + 3, rect.top + 4), + BPoint(rect.right - 5, rect.top + 4), middleColor); + menu->AddLine(BPoint(rect.left + 4, rect.top + 5), + BPoint(rect.right - 6, rect.top + 5), middleColor); + menu->AddLine(BPoint(rect.left + 5, rect.top + 5), + BPoint(rect.left + 5, rect.top + 6), middleColor); + menu->EndLineArray(); + } } } } @@ -391,7 +432,6 @@ TTeamMenuItem::DrawContentLabel() { BMenu *menu = Menu(); menu->MovePenBy(0, fLabelAscent); - menu->SetDrawingMode(B_OP_COPY); float cachedWidth = menu->StringWidth(Label()); if (Submenu() && fVertical)