hrev45493 adds 15 changesets to branch 'master' old head: 1f4fe8a48a47754ddc2c6feb4f171a10e7c03360 new head: a5172b441536faa918de50b2d248ce900cf047f9 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=a5172b4+%5E1f4fe8a ---------------------------------------------------------------------------- 10a5b69: Remove unneeded includes fe624b3: Style fixes only Most indentation and newlines with a few comment updates b54536b: Don't need to check if Lock() succeeded here, I don't anywhere else. 2de4b04: Remove unneeded includes from BarView ee78e4d: Convert state variable from a uint32 to an int32 9439677: Check if icon size is the same, if so, don't resize 5d6f247: Reverse loop to eliminate checking count each iteration bec7990: Remove yet another unneeded include 03f7c11: Rename SetWidthHeight to SetContentSize e83b2f0: Create a SetMaxItemWidth() method and set it in horizontal mode on update 4ae3e54: Fix a bug where the Deskbar menu was incorrectly sized in horizontal mode Actually, the Deskbar menu was sized correctly but the separator item was not, so, I've replaced the separator item with a new TSeparatorItem class that is derived from BSeparatorItem but does it's own drawing. This neatly avoids the bug since the TSeperatorItem doesn't need to be resized explicitly. Also, there were some instances of AddSeperatorItem (with an e) that I renamed to AddSeparatorItem (with an a). I also eliminated includes in the header which means I added them in some cpp files where they were needed. 541decf: Remove this code from FullState. Use default sMinimumWindowWidth 777fffe: Build the fBarMenu object in the BarView constructor ... then resize it and move it to the desired size and location on update. * Create an fBarApp pointer and use it, this is easier than having to keep casting to TBarApp. 251ece3: Style fixes in BarView.h a5172b4: Fix bug where application menu items were wrong size ...in horizontal mode, also make CheckItemSizes more efficient [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 15 files changed, 387 insertions(+), 366 deletions(-) src/apps/deskbar/BarApp.cpp | 55 ++++--- src/apps/deskbar/BarMenuBar.cpp | 81 +++++++--- src/apps/deskbar/BarMenuBar.h | 67 ++++---- src/apps/deskbar/BarMenuTitle.cpp | 132 ++++------------ src/apps/deskbar/BarMenuTitle.h | 6 +- src/apps/deskbar/BarSettings.h | 2 +- src/apps/deskbar/BarView.cpp | 83 +++++----- src/apps/deskbar/BarView.h | 261 +++++++++++++++++--------------- src/apps/deskbar/BarWindow.cpp | 1 + src/apps/deskbar/DeskbarMenu.cpp | 3 +- src/apps/deskbar/ExpandoMenuBar.cpp | 55 ++++--- src/apps/deskbar/ExpandoMenuBar.h | 2 + src/apps/deskbar/TeamMenu.cpp | 1 + src/apps/deskbar/TeamMenuItem.cpp | 3 + src/apps/deskbar/WindowMenuItem.cpp | 1 + ############################################################################ Commit: 10a5b6946c0c2871b280b06b2d491bf218dacdc5 URL: http://cgit.haiku-os.org/haiku/commit/?id=10a5b69 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 05:47:57 2013 UTC Remove unneeded includes ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 0c1b936..9838653 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -37,8 +37,6 @@ All rights reserved. #include "BarApp.h" #include <locale.h> -#include <stdlib.h> -#include <string.h> #include <AppFileInfo.h> #include <Autolock.h> ############################################################################ Commit: fe624b3937dc8b7a4551dbc66b5e5c81dfb468d6 URL: http://cgit.haiku-os.org/haiku/commit/?id=fe624b3 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 05:53:03 2013 UTC Style fixes only Most indentation and newlines with a few comment updates ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 9838653..f6c604e 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -92,10 +92,11 @@ main() TBarApp::TBarApp() - : BApplication(kDeskbarSignature), - fSettingsFile(NULL), - fClockSettingsFile(NULL), - fPreferencesWindow(NULL) + : + BApplication(kDeskbarSignature), + fSettingsFile(NULL), + fClockSettingsFile(NULL), + fPreferencesWindow(NULL) { InitSettings(); InitIconPreloader(); @@ -585,6 +586,7 @@ TBarApp::MessageReceived(BMessage* message) if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kUpdatePreferences); + break; } @@ -952,22 +954,24 @@ TBarApp::IconRect() BarTeamInfo::BarTeamInfo(BList* teams, uint32 flags, char* sig, BBitmap* icon, char* name) - : teams(teams), - flags(flags), - sig(sig), - icon(icon), - name(name) + : + teams(teams), + flags(flags), + sig(sig), + icon(icon), + name(name) { _Init(); } BarTeamInfo::BarTeamInfo(const BarTeamInfo &info) - : teams(new BList(*info.teams)), - flags(info.flags), - sig(strdup(info.sig)), - icon(new BBitmap(*info.icon)), - name(strdup(info.name)) + : + teams(new BList(*info.teams)), + flags(info.flags), + sig(strdup(info.sig)), + icon(new BBitmap(*info.icon)), + name(strdup(info.name)) { _Init(); } diff --git a/src/apps/deskbar/BarMenuBar.cpp b/src/apps/deskbar/BarMenuBar.cpp index 1383bd6..8725863 100644 --- a/src/apps/deskbar/BarMenuBar.cpp +++ b/src/apps/deskbar/BarMenuBar.cpp @@ -221,14 +221,15 @@ TBarMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message) BPoint loc; uint32 buttons; GetMouse(&loc, &buttons); - // attempt to start DnD tracking - if (message && buttons != 0) { + if (message != NULL && buttons != 0) { + // attempt to start DnD tracking fBarView->CacheDragData(const_cast<BMessage*>(message)); MouseDown(loc); } break; } } + BMenuBar::MouseMoved(where, code, message); } diff --git a/src/apps/deskbar/BarMenuTitle.cpp b/src/apps/deskbar/BarMenuTitle.cpp index cf877a1..36877d4 100644 --- a/src/apps/deskbar/BarMenuTitle.cpp +++ b/src/apps/deskbar/BarMenuTitle.cpp @@ -47,12 +47,13 @@ All rights reserved. TBarMenuTitle::TBarMenuTitle(float width, float height, const BBitmap* icon, - BMenu* menu, bool inexpando) - : BMenuItem(menu, new BMessage(B_REFS_RECEIVED)), - fWidth(width), - fHeight(height), - fInExpando(inexpando), - fIcon(icon) + BMenu* menu, bool expando) + : + BMenuItem(menu, new BMessage(B_REFS_RECEIVED)), + fWidth(width), + fHeight(height), + fInExpando(expando), + fIcon(icon) { } diff --git a/src/apps/deskbar/BarMenuTitle.h b/src/apps/deskbar/BarMenuTitle.h index 0a4a9f6..94caceb 100644 --- a/src/apps/deskbar/BarMenuTitle.h +++ b/src/apps/deskbar/BarMenuTitle.h @@ -70,4 +70,4 @@ private: }; -#endif /* BARMENUTITLE_H */ +#endif // BARMENUTITLE_H diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 8969a0d..1702e5f 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -519,7 +519,7 @@ TBarView::PlaceApplicationBar() SizeWindow(screenFrame); PositionWindow(screenFrame); fExpandoMenuBar->DoLayout(); - // force menu to autosize + // force menu to resize CheckForScrolling(); Window()->UpdateIfNeeded(); Invalidate(); diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h index 3f9b144..d6f5390 100644 --- a/src/apps/deskbar/BarView.h +++ b/src/apps/deskbar/BarView.h @@ -234,4 +234,4 @@ TBarView::CachedTypesList() const } -#endif /* BARVIEW_H */ +#endif // BARVIEW_H diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp index addf402..08adad8 100644 --- a/src/apps/deskbar/BarWindow.cpp +++ b/src/apps/deskbar/BarWindow.cpp @@ -100,6 +100,7 @@ TBarWindow::TBarWindow() desk_settings* settings = ((TBarApp*)be_app)->Settings(); if (settings->alwaysOnTop) SetFeel(B_FLOATING_ALL_WINDOW_FEEL); + fBarView = new TBarView(Bounds(), settings->vertical, settings->left, settings->top, settings->state, settings->width); AddChild(fBarView); diff --git a/src/apps/deskbar/DeskbarMenu.cpp b/src/apps/deskbar/DeskbarMenu.cpp index 24d5265..60d7567 100644 --- a/src/apps/deskbar/DeskbarMenu.cpp +++ b/src/apps/deskbar/DeskbarMenu.cpp @@ -88,7 +88,8 @@ using namespace BPrivate; TDeskbarMenu::TDeskbarMenu(TBarView* barView) - : BNavMenu("DeskbarMenu", B_REFS_RECEIVED, DefaultTarget()), + : + BNavMenu("DeskbarMenu", B_REFS_RECEIVED, DefaultTarget()), fAddState(kStart), fBarView(barView) { diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp index 76d20f0..7c393cd 100644 --- a/src/apps/deskbar/TeamMenuItem.cpp +++ b/src/apps/deskbar/TeamMenuItem.cpp @@ -190,6 +190,7 @@ TTeamMenuItem::Draw() { BRect frame(Frame()); BMenu* menu = Menu(); + menu->PushState(); rgb_color menuColor = menu->LowColor(); @@ -224,6 +225,7 @@ TTeamMenuItem::Draw() menu->MovePenTo(ContentLocation()); DrawContent(); + menu->PopState(); } ############################################################################ Commit: b54536b20d58ea1795e0cf9de1a925670e51c4b9 URL: http://cgit.haiku-os.org/haiku/commit/?id=b54536b Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 05:53:43 2013 UTC Don't need to check if Lock() succeeded here, I don't anywhere else. ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index f6c604e..5e35451 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -130,10 +130,9 @@ TBarApp::TBarApp() // Call UpdatePlacement() after the window is shown because expanded // apps need to resize the window. - if (fBarWindow->Lock()) { - fBarView->UpdatePlacement(); - fBarWindow->Unlock(); - } + fBarWindow->Lock(); + fBarView->UpdatePlacement(); + fBarWindow->Unlock(); // this messenger now targets the barview instead of the // statusview so that all additions to the tray ############################################################################ Commit: 2de4b0463fa09f983d7fcd13056c6dca1eaaf958 URL: http://cgit.haiku-os.org/haiku/commit/?id=2de4b04 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 05:55:47 2013 UTC Remove unneeded includes from BarView ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 1702e5f..e2bcd3b 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -36,10 +36,6 @@ All rights reserved. #include "BarView.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #include <AppFileInfo.h> #include <Bitmap.h> #include <Debug.h> ############################################################################ Commit: ee78e4de9f1ee2293d9e1c4b8b44db1bcf981530 URL: http://cgit.haiku-os.org/haiku/commit/?id=ee78e4d Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 05:59:34 2013 UTC Convert state variable from a uint32 to an int32 ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 5e35451..8ed7cd6 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -191,7 +191,7 @@ TBarApp::SaveSettings() prefs.AddBool("vertical", fSettings.vertical); prefs.AddBool("left", fSettings.left); prefs.AddBool("top", fSettings.top); - prefs.AddUInt32("state", fSettings.state); + prefs.AddInt32("state", fSettings.state); prefs.AddFloat("width", fSettings.width); prefs.AddPoint("switcherLoc", fSettings.switcherLoc); prefs.AddBool("showClock", fSettings.showClock); @@ -291,7 +291,7 @@ TBarApp::InitSettings() fDefaultSettings.left); settings.top = prefs.GetBool("top", fDefaultSettings.top); - settings.state = prefs.GetUInt32("state", + settings.state = prefs.GetInt32("state", fDefaultSettings.state); settings.width = prefs.GetFloat("width", fDefaultSettings.width); diff --git a/src/apps/deskbar/BarSettings.h b/src/apps/deskbar/BarSettings.h index 21b3e1a..1b75610 100644 --- a/src/apps/deskbar/BarSettings.h +++ b/src/apps/deskbar/BarSettings.h @@ -40,7 +40,7 @@ struct desk_settings { bool vertical; bool left; bool top; - uint32 state; + int32 state; float width; BPoint switcherLoc; bool showClock; diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index e2bcd3b..6b2a3e8 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -126,9 +126,10 @@ BarViewMessageFilter::Filter(BMessage* message, BHandler** target) TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, - uint32 state, float) + int32 state, float) : BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), + fBarApp(static_cast<TBarApp*>(be_app)), fInlineScrollView(NULL), fBarMenuBar(NULL), fExpandoMenuBar(NULL), @@ -136,7 +137,7 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, fVertical(vertical), fTop(top), fLeft(left), - fState(static_cast<int32>(state)), + fState(state), fRefsRcvdOnly(true), fDragMessage(NULL), fCachedTypesList(NULL), @@ -625,7 +626,7 @@ TBarView::SaveSettings() settings->vertical = fVertical; settings->left = fLeft; settings->top = fTop; - settings->state = (uint32)fState; + settings->state = fState; settings->width = 0; fReplicantTray->SaveTimeSettings(); diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h index d6f5390..ca43aed 100644 --- a/src/apps/deskbar/BarView.h +++ b/src/apps/deskbar/BarView.h @@ -77,7 +77,7 @@ class TTeamMenuItem; class TBarView : public BView { public: TBarView(BRect frame, bool vertical, bool left, bool top, - uint32 state, float width); + int32 state, float width); ~TBarView(); virtual void AttachedToWindow(); ############################################################################ Commit: 9439677a9c21d7ccb9b07898f988e0090812331a URL: http://cgit.haiku-os.org/haiku/commit/?id=9439677 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 06:01:14 2013 UTC Check if icon size is the same, if so, don't resize ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 8ed7cd6..599f1f2 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -556,20 +556,26 @@ TBarApp::MessageReceived(BMessage* message) case kResizeTeamIcons: { + int32 oldIconSize = fSettings.iconSize; int32 iconSize; - if (message->FindInt32("be:value", &iconSize) != B_OK) break; fSettings.iconSize = iconSize * kIconSizeInterval; + // pin icon size between min and max values if (fSettings.iconSize < kMinimumIconSize) fSettings.iconSize = kMinimumIconSize; else if (fSettings.iconSize > kMaximumIconSize) fSettings.iconSize = kMaximumIconSize; + // don't resize if icon size hasn't changed + if (fSettings.iconSize == oldIconSize) + break; + ResizeTeamIcons(); + // if mini mode we don't need to update the view if (fBarView->MiniState()) break; ############################################################################ Commit: 5d6f247bb30ca8cd6b6a1170402db7d1c7300528 URL: http://cgit.haiku-os.org/haiku/commit/?id=5d6f247 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 06:02:31 2013 UTC Reverse loop to eliminate checking count each iteration ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 599f1f2..75b60b6 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -840,7 +840,7 @@ TBarApp::RemoveTeam(team_id team) void TBarApp::ResizeTeamIcons() { - for (int32 i = 0; i < sBarTeamInfoList.CountItems(); i++) { + for (int32 i = sBarTeamInfoList.CountItems() - 1; i >= 0; i--) { BarTeamInfo* barInfo = (BarTeamInfo*)sBarTeamInfoList.ItemAt(i); if ((barInfo->flags & B_BACKGROUND_APP) == 0 && strcasecmp(barInfo->sig, kDeskbarSignature) != 0) { ############################################################################ Commit: bec79905623d1b1954a3b2bcde7fc0a1e1928732 URL: http://cgit.haiku-os.org/haiku/commit/?id=bec7990 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 06:03:33 2013 UTC Remove yet another unneeded include ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarMenuBar.cpp b/src/apps/deskbar/BarMenuBar.cpp index 8725863..8179d50 100644 --- a/src/apps/deskbar/BarMenuBar.cpp +++ b/src/apps/deskbar/BarMenuBar.cpp @@ -36,8 +36,6 @@ All rights reserved. #include "BarMenuBar.h" -#include <string.h> - #include <Bitmap.h> #include <Debug.h> #include <NodeInfo.h> ############################################################################ Commit: 03f7c11ece0869967f2dc6b36cca8da7403594af URL: http://cgit.haiku-os.org/haiku/commit/?id=03f7c11 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 06:08:01 2013 UTC Rename SetWidthHeight to SetContentSize ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarMenuBar.cpp b/src/apps/deskbar/BarMenuBar.cpp index 8179d50..c1873f4 100644 --- a/src/apps/deskbar/BarMenuBar.cpp +++ b/src/apps/deskbar/BarMenuBar.cpp @@ -88,13 +88,13 @@ TBarMenuBar::SmartResize(float width, float height) width -= 1; if (fSeparatorItem != NULL) - fDeskbarMenuItem->SetWidthHeight(width - kSepItemWidth, height); + fDeskbarMenuItem->SetContentSize(width - kSepItemWidth, height); else { int32 count = CountItems(); if (fDeskbarMenuItem) - fDeskbarMenuItem->SetWidthHeight(width / count, height); + fDeskbarMenuItem->SetContentSize(width / count, height); if (fAppListMenuItem) - fAppListMenuItem->SetWidthHeight(width / count, height); + fAppListMenuItem->SetContentSize(width / count, height); } InvalidateLayout(); diff --git a/src/apps/deskbar/BarMenuTitle.cpp b/src/apps/deskbar/BarMenuTitle.cpp index 36877d4..a20b362 100644 --- a/src/apps/deskbar/BarMenuTitle.cpp +++ b/src/apps/deskbar/BarMenuTitle.cpp @@ -64,7 +64,7 @@ TBarMenuTitle::~TBarMenuTitle() void -TBarMenuTitle::SetWidthHeight(float width, float height) +TBarMenuTitle::SetContentSize(float width, float height) { fWidth = width; fHeight = height; diff --git a/src/apps/deskbar/BarMenuTitle.h b/src/apps/deskbar/BarMenuTitle.h index 94caceb..c875c06 100644 --- a/src/apps/deskbar/BarMenuTitle.h +++ b/src/apps/deskbar/BarMenuTitle.h @@ -53,7 +53,7 @@ public: BMenu* menu, bool inexpando = false); virtual ~TBarMenuTitle(); - void SetWidthHeight(float width, float height); + void SetContentSize(float width, float height); void Draw(); status_t Invoke(BMessage* message); ############################################################################ Commit: e83b2f0b9cf71e3830bce4041401d48e033f8696 URL: http://cgit.haiku-os.org/haiku/commit/?id=e83b2f0 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 06:12:41 2013 UTC Create a SetMaxItemWidth() method and set it in horizontal mode on update ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 6b2a3e8..0c5d6ba 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -509,6 +509,11 @@ TBarView::PlaceApplicationBar() fExpandoMenuBar->MoveTo(0, 0); fExpandoMenuBar->ResizeTo(expandoFrame.Width(), expandoFrame.Height()); + if (!fVertical) { + // Set the max item width based on icon size + fExpandoMenuBar->SetMaxItemWidth(); + } + fExpandoMenuBar->BuildItems(); if (fVertical) ExpandItems(); diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index ba3c377..5c7eff6 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -94,15 +94,7 @@ TExpandoMenuBar::TExpandoMenuBar(BRect frame, const char* name, { SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f); SetFont(be_plain_font); - 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); - } + SetMaxItemWidth(); // top or bottom mode, add deskbar menu and sep for menubar tracking // consistency @@ -914,6 +906,20 @@ TExpandoMenuBar::CheckForSizeOverrun() void +TExpandoMenuBar::SetMaxItemWidth() +{ + if (fVertical) + SetMaxContentWidth(sMinimumWindowWidth); + else { + // Make more room for the icon in horizontal mode + int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize(); + SetMaxContentWidth(sMinimumWindowWidth + iconSize + - kMinimumIconSize); + } +} + + +void TExpandoMenuBar::SizeWindow(int32 delta) { // instead of resizing the window here and there in the diff --git a/src/apps/deskbar/ExpandoMenuBar.h b/src/apps/deskbar/ExpandoMenuBar.h index cf242dd..663f8ea 100644 --- a/src/apps/deskbar/ExpandoMenuBar.h +++ b/src/apps/deskbar/ExpandoMenuBar.h @@ -87,6 +87,8 @@ public: menu_layout MenuLayout() const; + void SetMaxItemWidth(); + void SizeWindow(int32 delta); bool CheckForSizeOverrun(); ############################################################################ Commit: 4ae3e5421d4009205c273ec076bdcb5e1f21f936 URL: http://cgit.haiku-os.org/haiku/commit/?id=4ae3e54 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 06:22:40 2013 UTC Fix a bug where the Deskbar menu was incorrectly sized in horizontal mode Actually, the Deskbar menu was sized correctly but the separator item was not, so, I've replaced the separator item with a new TSeparatorItem class that is derived from BSeparatorItem but does it's own drawing. This neatly avoids the bug since the TSeperatorItem doesn't need to be resized explicitly. Also, there were some instances of AddSeperatorItem (with an e) that I renamed to AddSeparatorItem (with an a). I also eliminated includes in the header which means I added them in some cpp files where they were needed. ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarMenuBar.cpp b/src/apps/deskbar/BarMenuBar.cpp index c1873f4..7f3213e 100644 --- a/src/apps/deskbar/BarMenuBar.cpp +++ b/src/apps/deskbar/BarMenuBar.cpp @@ -37,11 +37,14 @@ All rights reserved. #include "BarMenuBar.h" #include <Bitmap.h> +#include <ControlLook.h> #include <Debug.h> #include <NodeInfo.h> #include "icons.h" +#include "BarMenuTitle.h" +#include "BarView.h" #include "BarWindow.h" #include "DeskbarMenu.h" #include "DeskbarUtils.h" @@ -51,21 +54,62 @@ All rights reserved. const float kSepItemWidth = 5.0f; -TBarMenuBar::TBarMenuBar(TBarView* bar, BRect frame, const char* name) - : BMenuBar(frame, name, B_FOLLOW_NONE, B_ITEMS_IN_ROW, false), - fBarView(bar), + +// #pragma mark - TSeparatorItem + + +TSeparatorItem::TSeparatorItem() + : + BSeparatorItem() +{ +} + + +void +TSeparatorItem::Draw() +{ + BMenu* menu = Menu(); + if (menu == NULL) + return; + + BRect frame(Frame()); + frame.right = frame.left + kSepItemWidth; + rgb_color base = menu->LowColor(); + + menu->PushState(); + + menu->SetHighColor(tint_color(base, 1.22)); + frame.top--; + // need to expand the frame for some reason + + // stroke a darker line on the left edge + menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()); + frame.left++; + + // fill in background + be_control_look->DrawButtonBackground(menu, frame, frame, base); + + menu->PopState(); +} + + +// #pragma mark - TBarMenuBar + + +TBarMenuBar::TBarMenuBar(BRect frame, const char* name, TBarView* barView) + : + BMenuBar(frame, name, B_FOLLOW_NONE, B_ITEMS_IN_ROW, false), + fBarView(barView), fAppListMenuItem(NULL), fSeparatorItem(NULL) { SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f); - TDeskbarMenu* beMenu = new TDeskbarMenu(bar); + TDeskbarMenu* beMenu = new TDeskbarMenu(barView); TBarWindow::SetDeskbarMenu(beMenu); - const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE, - R_LeafLogoBitmap); - fDeskbarMenuItem = new TBarMenuTitle(frame.Width(), frame.Height(), - logoBitmap, beMenu); + fDeskbarMenuItem = new TBarMenuTitle(0.0f, 0.0f, + AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_LeafLogoBitmap), beMenu); AddItem(fDeskbarMenuItem); } @@ -144,7 +188,7 @@ TBarMenuBar::RemoveTeamMenu() bool -TBarMenuBar::AddSeperatorItem() +TBarMenuBar::AddSeparatorItem() { if (CountItems() > 1) return false; @@ -152,9 +196,7 @@ TBarMenuBar::AddSeperatorItem() BRect frame(Frame()); delete fSeparatorItem; - fSeparatorItem = new TTeamMenuItem(kSepItemWidth, - frame.Height() - 2, false); - fSeparatorItem->SetEnabled(false); + fSeparatorItem = new TSeparatorItem(); bool added = AddItem(fSeparatorItem); @@ -189,7 +231,7 @@ TBarMenuBar::RemoveSeperatorItem() void TBarMenuBar::Draw(BRect updateRect) { - // want to skip the fancy BMenuBar drawing code. + // skip the fancy BMenuBar drawing code BMenu::Draw(updateRect); } diff --git a/src/apps/deskbar/BarMenuBar.h b/src/apps/deskbar/BarMenuBar.h index 75dfd24..f470d38 100644 --- a/src/apps/deskbar/BarMenuBar.h +++ b/src/apps/deskbar/BarMenuBar.h @@ -42,39 +42,48 @@ All rights reserved. #include <MenuBar.h> +#include <SeparatorItem.h> -#include "BarView.h" -#include "BarMenuTitle.h" -#include "TimeView.h" +class TBarMenuTitle; +class TBarView; -class TBarMenuBar : public BMenuBar { - public: - TBarMenuBar(TBarView* bar, BRect frame, const char* name); - virtual ~TBarMenuBar(); - - virtual void MouseMoved(BPoint where, uint32 code, - const BMessage* message); - virtual void Draw(BRect); - - void DrawBackground(BRect); - void SmartResize(float width = -1.0f, float height = -1.0f); - - bool AddTeamMenu(); - bool RemoveTeamMenu(); +class TSeparatorItem : public BSeparatorItem { +public: + TSeparatorItem(); - bool AddSeperatorItem(); - bool RemoveSeperatorItem(); - - void InitTrackingHook(bool (* hookfunction)(BMenu*, void*), void* state, - bool both = false); - - private: - TBarView* fBarView; - TBarMenuTitle* fDeskbarMenuItem; - TBarMenuTitle* fAppListMenuItem; - TTeamMenuItem* fSeparatorItem; + virtual void Draw(); }; +class TBarMenuBar : public BMenuBar { +public: + TBarMenuBar(BRect frame, const char* name, + TBarView* barView); + virtual ~TBarMenuBar(); + + virtual void MouseMoved(BPoint where, uint32 code, + const BMessage* message); + virtual void Draw(BRect); + + void DrawBackground(BRect); + void SmartResize(float width = -1.0f, + float height = -1.0f); + + bool AddTeamMenu(); + bool RemoveTeamMenu(); + + bool AddSeparatorItem(); + bool RemoveSeperatorItem(); + + void InitTrackingHook( + bool (* hookfunction)(BMenu*, void*), + void* state, bool both = false); + +private: + TBarView* fBarView; + TBarMenuTitle* fDeskbarMenuItem; + TBarMenuTitle* fAppListMenuItem; + TSeparatorItem* fSeparatorItem; +}; -#endif /* BARMENUBAR_H */ +#endif // BARMENUBAR_H diff --git a/src/apps/deskbar/BarMenuTitle.cpp b/src/apps/deskbar/BarMenuTitle.cpp index a20b362..50c0d79 100644 --- a/src/apps/deskbar/BarMenuTitle.cpp +++ b/src/apps/deskbar/BarMenuTitle.cpp @@ -82,120 +82,51 @@ TBarMenuTitle::GetContentSize(float* width, float* height) void TBarMenuTitle::Draw() { - if (be_control_look == NULL) { - BMenuItem::Draw(); + BMenu* menu = Menu(); + if (menu == NULL) return; - } - // fill background if selected - rgb_color base = Menu()->LowColor(); - BRect rect = Frame(); + BRect frame(Frame()); + rgb_color base = menu->LowColor(); + + menu->PushState(); - BRect windowBounds = Menu()->Window()->Bounds(); - if (rect.right > windowBounds.right) - rect.right = windowBounds.right; + BRect windowBounds = menu->Window()->Bounds(); + if (frame.right > windowBounds.right) + frame.right = windowBounds.right; + // fill in background if (IsSelected()) { - be_control_look->DrawMenuItemBackground(Menu(), rect, rect, base, + be_control_look->DrawMenuItemBackground(menu, frame, frame, base, BControlLook::B_ACTIVATED); - } else { - be_control_look->DrawButtonBackground(Menu(), rect, rect, base); - } + } else + be_control_look->DrawButtonBackground(menu, frame, frame, base); - // draw content + menu->MovePenTo(ContentLocation()); DrawContent(); - // make sure we restore state - Menu()->SetLowColor(base); + menu->PopState(); } void 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) - + 2.0f)); - - menu->DrawBitmapAsync(fIcon, dstRect); - } + if (fIcon == NULL) return; - } - rgb_color menuColor = menu->LowColor(); - rgb_color dark = tint_color(menuColor, B_DARKEN_1_TINT); - rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT); - - bool inExpandoMode = dynamic_cast<TExpandoMenuBar*>(menu) != NULL; - - BRect bounds(menu->Window()->Bounds()); - if (bounds.right < frame.right) - frame.right = bounds.right; - - menu->SetDrawingMode(B_OP_COPY); - - if (!IsSelected() && !menu->IsRedrawAfterSticky()) { - menu->BeginLineArray(8); - menu->AddLine(frame.RightTop(), frame.LeftTop(), light); - menu->AddLine(frame.LeftBottom(), frame.RightBottom(), dark); - menu->AddLine(frame.LeftTop(), - frame.LeftBottom()+BPoint(0, inExpandoMode ? 0 : -1), light); - menu->AddLine(frame.RightBottom(), frame.RightTop(), dark); - if (inExpandoMode) { - frame.top += 1; - menu->AddLine(frame.LeftTop(), frame.RightTop() + BPoint(-1, 0), - light); - } - - menu->EndLineArray(); - - frame.InsetBy(1, 1); - menu->SetHighColor(menuColor); - menu->FillRect(frame); - if (IsSelected()) - menu->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR)); - else - menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); - frame.InsetBy(-1, -1); - if (inExpandoMode) - frame.top -= 1; - } - - ASSERT(IsEnabled()); - if (IsSelected() && !menu->IsRedrawAfterSticky()) { - menu->SetHighColor(tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT)); - menu->FillRect(frame); - - if (menu->IndexOf(this) > 0) { - menu->SetHighColor(tint_color(menuColor, B_DARKEN_4_TINT)); - menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()); - } - - if (IsSelected()) - menu->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR)); - else - menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); - } + BMenu* menu = Menu(); + BRect frame(Frame()); + BRect iconRect(fIcon->Bounds()); menu->SetDrawingMode(B_OP_ALPHA); + iconRect.OffsetTo(frame.LeftTop()); - 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)); + float widthOffset = rintf((frame.Width() - iconRect.Width()) / 2); + float heightOffset = rintf((frame.Height() - iconRect.Height()) / 2); + iconRect.OffsetBy(widthOffset - 1.0f, heightOffset + 2.0f); - menu->DrawBitmapAsync(fIcon, dstRect); - } + menu->DrawBitmapAsync(fIcon, iconRect); } diff --git a/src/apps/deskbar/BarMenuTitle.h b/src/apps/deskbar/BarMenuTitle.h index c875c06..f7bcac0 100644 --- a/src/apps/deskbar/BarMenuTitle.h +++ b/src/apps/deskbar/BarMenuTitle.h @@ -50,7 +50,7 @@ class BMenu; class TBarMenuTitle : public BMenuItem { public: TBarMenuTitle(float width, float height, const BBitmap* icon, - BMenu* menu, bool inexpando = false); + BMenu* menu, bool expando = false); virtual ~TBarMenuTitle(); void SetContentSize(float width, float height); diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 0c5d6ba..95feb08 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -395,7 +395,7 @@ TBarView::PlaceDeskbarMenu() width += 1; } else { // shows apps to the right of bemenu - fBarMenuBar->AddSeperatorItem(); + fBarMenuBar->AddSeparatorItem(); width = floorf(width) / 2 + kSepItemWidth; } loc = Bounds().LeftTop(); diff --git a/src/apps/deskbar/TeamMenu.cpp b/src/apps/deskbar/TeamMenu.cpp index 7f5a7be..50aa6c1 100644 --- a/src/apps/deskbar/TeamMenu.cpp +++ b/src/apps/deskbar/TeamMenu.cpp @@ -44,6 +44,7 @@ All rights reserved. #include "BarApp.h" #include "BarMenuBar.h" +#include "BarView.h" #include "DeskbarUtils.h" #include "TeamMenuItem.h" diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp index 7c393cd..7c5d42f 100644 --- a/src/apps/deskbar/TeamMenuItem.cpp +++ b/src/apps/deskbar/TeamMenuItem.cpp @@ -50,6 +50,7 @@ All rights reserved. #include "BarApp.h" #include "BarMenuBar.h" +#include "BarView.h" #include "ExpandoMenuBar.h" #include "ResourceSet.h" #include "ShowHideMenuItem.h" diff --git a/src/apps/deskbar/WindowMenuItem.cpp b/src/apps/deskbar/WindowMenuItem.cpp index 21559c5..b6110d4 100644 --- a/src/apps/deskbar/WindowMenuItem.cpp +++ b/src/apps/deskbar/WindowMenuItem.cpp @@ -44,6 +44,7 @@ All rights reserved. #include "BarApp.h" #include "BarMenuBar.h" +#include "BarView.h" #include "ExpandoMenuBar.h" #include "icons.h" #include "ResourceSet.h" ############################################################################ Commit: 541decfaaba75c5b0451da0740ed0231080f7a53 URL: http://cgit.haiku-os.org/haiku/commit/?id=541decf Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 06:25:02 2013 UTC Remove this code from FullState. Use default sMinimumWindowWidth ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 95feb08..a2acd73 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -377,15 +377,12 @@ TBarView::PlaceDeskbarMenu() } else fBarMenuBar->SmartResize(-1, -1); - float width = sMinimumWindowWidth; BPoint loc(B_ORIGIN); + float width = sMinimumWindowWidth; if (fState == kFullState) { fBarMenuBar->RemoveTeamMenu(); fBarMenuBar->RemoveSeperatorItem(); - // TODO: Magic constants need explanation - width = 8 + 16 + 8; - fBarMenuBar->SmartResize(width, menuFrame.Height()); loc = Bounds().LeftTop(); } else if (fState == kExpandoState) { fBarMenuBar->RemoveTeamMenu(); ############################################################################ Commit: 777fffe8f75e05cc7b13c59404036b840794890e URL: http://cgit.haiku-os.org/haiku/commit/?id=777fffe Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 06:34:07 2013 UTC Build the fBarMenu object in the BarView constructor ... then resize it and move it to the desired size and location on update. * Create an fBarApp pointer and use it, this is easier than having to keep casting to TBarApp. ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index a2acd73..2eab008 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -146,19 +146,33 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, fLastDragItem(NULL), fMouseFilter(NULL) { + // determine the initial Be menu size + BRect menuFrame(frame); + if (fVertical) + menuFrame.bottom = menuFrame.top + kMenuBarHeight; + else + menuFrame.bottom = menuFrame.top + fBarApp->IconSize() + 4; + + // create and add the Be menu + fBarMenuBar = new TBarMenuBar(menuFrame, "BarMenuBar", this); + AddChild(fBarMenuBar); + + // create and add the status tray fReplicantTray = new TReplicantTray(this, fVertical); fDragRegion = new TDragRegion(this, fReplicantTray); fDragRegion->AddChild(fReplicantTray); if (fTrayLocation != 0) AddChild(fDragRegion); + // create and add the application menubar fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0), "ExpandoMenuBar", this, fVertical); fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0), fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL); AddChild(fInlineScrollView); - if (state == kMiniState) + // If mini mode, hide the application menubar + if (state != kMiniState) fInlineScrollView->Hide(); } @@ -276,7 +290,7 @@ TBarView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) if (transit == B_ENTERED_VIEW && EventMask() == 0) SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY); - desk_settings* settings = ((TBarApp*)be_app)->Settings(); + desk_settings* settings = fBarApp->Settings(); bool alwaysOnTop = settings->alwaysOnTop; bool autoRaise = settings->autoRaise; bool autoHide = settings->autoHide; @@ -343,7 +357,7 @@ TBarView::MouseDown(BPoint where) } } else { // hide deskbar if required - desk_settings* settings = ((TBarApp*)be_app)->Settings(); + desk_settings* settings = fBarApp->Settings(); bool alwaysOnTop = settings->alwaysOnTop; bool autoRaise = settings->autoRaise; bool autoHide = settings->autoHide; @@ -361,21 +375,8 @@ TBarView::MouseDown(BPoint where) void TBarView::PlaceDeskbarMenu() { - // Calculate the size of the deskbar menu - BRect menuFrame(Bounds()); - if (fVertical) - menuFrame.bottom = menuFrame.top + kMenuBarHeight; - else { - menuFrame.bottom = menuFrame.top - + static_cast<TBarApp*>(be_app)->IconSize() + 4; - } - - if (fBarMenuBar == NULL) { - // create the Be menu - fBarMenuBar = new TBarMenuBar(this, menuFrame, "BarMenuBar"); - AddChild(fBarMenuBar); - } else - fBarMenuBar->SmartResize(-1, -1); + float height; + height = fVertical ? kMenuBarHeight : fBarApp->IconSize() + 4; BPoint loc(B_ORIGIN); float width = sMinimumWindowWidth; @@ -402,7 +403,7 @@ TBarView::PlaceDeskbarMenu() fBarMenuBar->AddTeamMenu(); } - fBarMenuBar->SmartResize(width, menuFrame.Height()); + fBarMenuBar->SmartResize(width, height); fBarMenuBar->MoveTo(loc); } @@ -485,11 +486,10 @@ TBarView::PlaceApplicationBar() } else { // top or bottom expandoFrame.top = 0; - int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize(); - expandoFrame.bottom = iconSize + 4; + expandoFrame.bottom = fBarApp->IconSize() + 4; if (fBarMenuBar != NULL) - expandoFrame.left = fBarMenuBar->Frame().Width(); + expandoFrame.left = fBarMenuBar->Frame().Width() + 1; if (fTrayLocation != 0 && fDragRegion != NULL) { expandoFrame.right = screenFrame.Width() @@ -530,9 +530,8 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height) { float windowHeight = 0; float windowWidth = sMinimumWindowWidth; - bool setToHiddenSize = ((TBarApp*)be_app)->Settings()->autoHide - && IsHidden() && !fDragRegion->IsDragging(); - int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize(); + bool setToHiddenSize = fBarApp->Settings()->autoHide && IsHidden() + && !fDragRegion->IsDragging(); if (setToHiddenSize) { windowHeight = kHiddenDimension; @@ -559,7 +558,7 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height) } else { // top or bottom, full fExpandoMenuBar->CheckItemSizes(0); - windowHeight = iconSize + 4; + windowHeight = fBarApp->IconSize() + 4; windowWidth = screenFrame.Width(); } } else { @@ -623,7 +622,7 @@ TBarView::CheckForScrolling() void TBarView::SaveSettings() { - desk_settings* settings = ((TBarApp*)be_app)->Settings(); + desk_settings* settings = fBarApp->Settings(); settings->vertical = fVertical; settings->left = fLeft; @@ -691,9 +690,10 @@ void TBarView::ExpandItems() { if (fExpandoMenuBar == NULL || !fVertical || fState != kExpandoState - || !static_cast<TBarApp*>(be_app)->Settings()->superExpando - || fExpandedItems.CountItems() <= 0) + || !fBarApp->Settings()->superExpando + || fExpandedItems.CountItems() <= 0) { return; + } // Start at the 'bottom' of the list working up. // Prevents being thrown off by expanding items. diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h index ca43aed..b25edf1 100644 --- a/src/apps/deskbar/BarView.h +++ b/src/apps/deskbar/BarView.h @@ -66,6 +66,7 @@ const float kHiddenDimension = 1.0f; const float kMaxPreventHidingDist = 80.0f; class BShelf; +class TBarApp; class TBarMenuBar; class TExpandoMenuBar; class TReplicantTray; @@ -170,6 +171,7 @@ class TBarView : public BView { void ExpandItems(); void _ChangeState(BMessage* message); + TBarApp* fBarApp; TInlineScrollView* fInlineScrollView; TBarMenuBar* fBarMenuBar; TExpandoMenuBar* fExpandoMenuBar; ############################################################################ Commit: 251ece3c7492f7909025a2926c4084df1bf292a0 URL: http://cgit.haiku-os.org/haiku/commit/?id=251ece3 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 06:46:13 2013 UTC Style fixes in BarView.h ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h index b25edf1..af76aef 100644 --- a/src/apps/deskbar/BarView.h +++ b/src/apps/deskbar/BarView.h @@ -65,6 +65,7 @@ const float kStatusHeight = 22.0f; const float kHiddenDimension = 1.0f; const float kMaxPreventHidingDist = 80.0f; + class BShelf; class TBarApp; class TBarMenuBar; @@ -74,130 +75,142 @@ class TDragRegion; class TInlineScrollView; class TTeamMenuItem; - class TBarView : public BView { - public: - TBarView(BRect frame, bool vertical, bool left, bool top, - int32 state, float width); - ~TBarView(); - - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - virtual void Draw(BRect updateRect); - virtual void MessageReceived(BMessage* message); - virtual void MouseMoved(BPoint where, uint32 transit, - const BMessage* dragMessage); - virtual void MouseDown(BPoint where); - - void SaveSettings(); - void UpdatePlacement(); - void ChangeState(int32 state, bool vertical, bool left, bool top, - bool aSync = false); - void RaiseDeskbar(bool raise); - void HideDeskbar(bool hide); - - // window placement methods - 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; }; - - // window state methods - bool ExpandoState() const { return fState == kExpandoState; }; - bool FullState() const { return fState == kFullState; }; - bool MiniState() const { return fState == kMiniState; }; - int32 State() const { return fState; }; - - // drag and drop methods - void CacheDragData(const BMessage* incoming); - status_t DragStart(); - static bool MenuTrackingHook(BMenu* menu, void* castToThis); - void DragStop(bool full = false); - TrackingHookData* GetTrackingHookData(); - bool Dragging() const; - const BMessage* DragMessage() const; - BObjectList<BString>*CachedTypesList() const; - bool AppCanHandleTypes(const char* signature); - void SetDragOverride(bool); - bool DragOverride(); - bool InvokeItem(const char* signature); - - void HandleDeskbarMenu(BMessage* targetmessage); - - status_t ItemInfo(int32 id, const char** name, DeskbarShelf* shelf); - status_t ItemInfo(const char* name, int32* id, DeskbarShelf* shelf); - - bool ItemExists(int32 id, DeskbarShelf shelf); - bool ItemExists(const char* name, DeskbarShelf shelf); - - int32 CountItems(DeskbarShelf shelf); - - status_t AddItem(BMessage* archive, DeskbarShelf shelf, int32* id); - status_t AddItem(BEntry* entry, DeskbarShelf shelf, int32* id); - - void RemoveItem(int32 id); - void RemoveItem(const char* name, DeskbarShelf shelf); - - BRect OffsetIconFrame(BRect rect) const; - BRect IconFrame(int32 id) const; - BRect IconFrame(const char* name) const; - - void GetPreferredWindowSize(BRect screenFrame, float* width, - float* height); - void SizeWindow(BRect screenFrame); - void PositionWindow(BRect screenFrame); - void AddExpandedItem(const char* signature); - - void CheckForScrolling(); - - TExpandoMenuBar* ExpandoMenuBar() const; - TBarMenuBar* BarMenuBar() const; - TDragRegion* DragRegion() const { return fDragRegion; } - TReplicantTray* ReplicantTray() const { return fReplicantTray; } - - private: - friend class TBarApp; - friend class TDeskbarMenu; - friend class PreferencesWindow; - - status_t SendDragMessage(const char* signature, entry_ref* ref = NULL); - - void PlaceDeskbarMenu(); - void PlaceTray(bool vertSwap, bool leftSwap); - void PlaceApplicationBar(); - void SaveExpandedItems(); - void RemoveExpandedItems(); - void ExpandItems(); - void _ChangeState(BMessage* message); - - TBarApp* fBarApp; - TInlineScrollView* fInlineScrollView; - TBarMenuBar* fBarMenuBar; - TExpandoMenuBar* fExpandoMenuBar; - - int32 fTrayLocation; - TDragRegion* fDragRegion; - TReplicantTray* fReplicantTray; - - bool fVertical : 1; - bool fTop : 1; - bool fLeft : 1; - - int32 fState; - - bigtime_t fPulseRate; - bool fRefsRcvdOnly; - BMessage* fDragMessage; - BObjectList<BString>*fCachedTypesList; - TrackingHookData fTrackingHookData; - - uint32 fMaxRecentDocs; - uint32 fMaxRecentApps; - - TTeamMenuItem* fLastDragItem; - BList fExpandedItems; - BMessageFilter* fMouseFilter; +public: + TBarView(BRect frame, bool vertical, bool left, + bool top, int32 state, float width); + ~TBarView(); + + virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); + + virtual void Draw(BRect updateRect); + + virtual void MessageReceived(BMessage* message); + + virtual void MouseMoved(BPoint where, uint32 transit, + const BMessage* dragMessage); + virtual void MouseDown(BPoint where); + + void SaveSettings(); + + void UpdatePlacement(); + void ChangeState(int32 state, bool vertical, bool left, + bool top, bool aSync = false); + + void RaiseDeskbar(bool raise); + void HideDeskbar(bool hide); + + // window placement methods + 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; }; + + // window state methods + bool ExpandoState() const + { return fState == kExpandoState; }; + bool FullState() const { return fState == kFullState; }; + bool MiniState() const { return fState == kMiniState; }; + int32 State() const { return fState; }; + + // drag and drop methods + void CacheDragData(const BMessage* incoming); + status_t DragStart(); + static bool MenuTrackingHook(BMenu* menu, void* castToThis); + void DragStop(bool full = false); + TrackingHookData* GetTrackingHookData(); + bool Dragging() const; + const BMessage* DragMessage() const; + BObjectList<BString>* CachedTypesList() const; + bool AppCanHandleTypes(const char* signature); + void SetDragOverride(bool); + bool DragOverride(); + bool InvokeItem(const char* signature); + + void HandleDeskbarMenu(BMessage* targetmessage); + + status_t ItemInfo(int32 id, const char** name, + DeskbarShelf* shelf); + status_t ItemInfo(const char* name, int32* id, + DeskbarShelf* shelf); + + bool ItemExists(int32 id, DeskbarShelf shelf); + bool ItemExists(const char* name, DeskbarShelf shelf); + + int32 CountItems(DeskbarShelf shelf); + + status_t AddItem(BMessage* archive, DeskbarShelf shelf, + int32* id); + status_t AddItem(BEntry* entry, DeskbarShelf shelf, + int32* id); + + void RemoveItem(int32 id); + void RemoveItem(const char* name, DeskbarShelf shelf); + + BRect OffsetIconFrame(BRect rect) const; + BRect IconFrame(int32 id) const; + BRect IconFrame(const char* name) const; + + void GetPreferredWindowSize(BRect screenFrame, + float* width, float* height); + void SizeWindow(BRect screenFrame); + void PositionWindow(BRect screenFrame); + void AddExpandedItem(const char* signature); + + void CheckForScrolling(); + + TExpandoMenuBar* ExpandoMenuBar() const; + TBarMenuBar* BarMenuBar() const; + TDragRegion* DragRegion() const { return fDragRegion; } + TReplicantTray* ReplicantTray() const { return fReplicantTray; } + +private: + friend class TBarApp; + friend class TDeskbarMenu; + friend class PreferencesWindow; + + status_t SendDragMessage(const char* signature, + entry_ref* ref = NULL); + + void PlaceDeskbarMenu(); + void PlaceTray(bool vertSwap, bool leftSwap); + void PlaceApplicationBar(); + + void SaveExpandedItems(); + void RemoveExpandedItems(); + void ExpandItems(); + + void _ChangeState(BMessage* message); + + TBarApp* fBarApp; + TInlineScrollView* fInlineScrollView; + TBarMenuBar* fBarMenuBar; + TExpandoMenuBar* fExpandoMenuBar; + + int32 fTrayLocation; + TDragRegion* fDragRegion; + TReplicantTray* fReplicantTray; + + bool fVertical : 1; + bool fTop : 1; + bool fLeft : 1; + int32 fState; + + bigtime_t fPulseRate; + bool fRefsRcvdOnly; + BMessage* fDragMessage; + BObjectList<BString>* fCachedTypesList; + TrackingHookData fTrackingHookData; + + uint32 fMaxRecentDocs; + uint32 fMaxRecentApps; + + TTeamMenuItem* fLastDragItem; + BList fExpandedItems; + BMessageFilter* fMouseFilter; }; ############################################################################ Revision: hrev45493 Commit: a5172b441536faa918de50b2d248ce900cf047f9 URL: http://cgit.haiku-os.org/haiku/commit/?id=a5172b4 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Apr 14 06:48:32 2013 UTC Fix bug where application menu items were wrong size ...in horizontal mode, also make CheckItemSizes more efficient ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 5c7eff6..fb00e0f 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -776,15 +776,17 @@ TExpandoMenuBar::CheckItemSizes(int32 delta) - fDeskbarMenuWidth - kSepItemWidth; int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize(); float iconOnlyWidth = kIconPadding + iconSize + kIconPadding; - float minItemWidth = fDrawLabel ? iconOnlyWidth + kMinMenuItemWidth - : iconOnlyWidth - kIconPadding; - float maxItemWidth = fDrawLabel ? sMinimumWindowWidth + iconSize - - kMinimumIconSize : iconOnlyWidth; + float minItemWidth = fDrawLabel + ? iconOnlyWidth + kMinMenuItemWidth + : iconOnlyWidth - kIconPadding; + float maxItemWidth = fDrawLabel + ? sMinimumWindowWidth + iconSize - kMinimumIconSize + : iconOnlyWidth; float menuWidth = maxItemWidth * CountItems() + fDeskbarMenuWidth + kSepItemWidth; bool reset = false; - float newWidth = 0.0f; + float newWidth = -1.0f; if (delta >= 0 && menuWidth > maxWidth) { fOverflow = true; @@ -798,15 +800,16 @@ TExpandoMenuBar::CheckItemSizes(int32 delta) newWidth = maxItemWidth; } - if (newWidth > maxItemWidth) - newWidth = maxItemWidth; - else if (newWidth < minItemWidth) - newWidth = minItemWidth; - if (reset) { + if (newWidth > maxItemWidth) + newWidth = maxItemWidth; + else if (newWidth < minItemWidth) + newWidth = minItemWidth; + SetMaxContentWidth(newWidth); if (newWidth == maxItemWidth) fOverflow = false; + InvalidateLayout(); for (int32 index = 0; ; index++) { @@ -819,9 +822,8 @@ TExpandoMenuBar::CheckItemSizes(int32 delta) Invalidate(); Window()->UpdateIfNeeded(); + fBarView->CheckForScrolling(); } - - fBarView->CheckForScrolling(); } @@ -894,8 +896,9 @@ TExpandoMenuBar::CheckForSizeOverrun() int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize(); float iconOnlyWidth = kIconPadding + iconSize + kIconPadding; - float minItemWidth = fDrawLabel ? iconOnlyWidth + kMinMenuItemWidth - : iconOnlyWidth - kIconPadding; + float minItemWidth = fDrawLabel + ? iconOnlyWidth + kMinMenuItemWidth + : iconOnlyWidth - kIconPadding; float menuWidth = minItemWidth * CountItems() + fDeskbarMenuWidth + kSepItemWidth; float maxWidth = fBarView->DragRegion()->Frame().left