From 6b65d934dfcf372c2c527a6cc4c2d3536754834f Mon Sep 17 00:00:00 2001 From: John Scipione Date: Thu, 19 Feb 2015 20:12:32 -0500 Subject: [PATCH] Deskbar: some more style fixes, reorg methods --- src/apps/deskbar/ExpandoMenuBar.cpp | 2 + src/apps/deskbar/TeamMenuItem.cpp | 18 ++++----- src/apps/deskbar/TeamMenuItem.h | 2 + src/apps/deskbar/WindowMenuItem.cpp | 62 ++++++++++++++--------------- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index a37bab4465..2ed206fce8 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -1055,9 +1055,11 @@ TExpandoMenuBar::_FinishedDrag(bool invoke) if (fPreviousDragTargetItem != NULL) { if (invoke) fPreviousDragTargetItem->Invoke(); + fPreviousDragTargetItem->SetOverrideSelected(false); fPreviousDragTargetItem = NULL; } + if (!invoke && fBarView->Dragging()) fBarView->DragStop(true); } diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp index da06dc14f4..dd28890818 100644 --- a/src/apps/deskbar/TeamMenuItem.cpp +++ b/src/apps/deskbar/TeamMenuItem.cpp @@ -176,7 +176,7 @@ TTeamMenuItem::GetContentSize(float* width, float* height) void TTeamMenuItem::Draw() { - BRect frame(Frame()); + BRect frame = Frame(); BMenu* menu = Menu(); menu->PushState(); @@ -229,9 +229,9 @@ TTeamMenuItem::DrawContent() } else menu->SetDrawingMode(B_OP_OVER); - BRect frame(Frame()); - BRect iconBounds(fIcon->Bounds()); - BRect dstRect(iconBounds); + BRect frame = Frame(); + BRect iconBounds = fIcon->Bounds(); + BRect updateRect = iconBounds; float extra = fBarView->Vertical() ? 0.0f : -1.0f; BPoint contentLocation = ContentLocation(); BPoint drawLocation = contentLocation + BPoint(kHPad, kVPad); @@ -242,8 +242,8 @@ TTeamMenuItem::DrawContent() + ((frame.Width() - iconBounds.Width()) / 2) + extra; float offsety = contentLocation.y + 3.0f + extra; - dstRect.OffsetTo(BPoint(offsetx, offsety)); - menu->DrawBitmapAsync(fIcon, dstRect); + updateRect.OffsetTo(BPoint(offsetx, offsety)); + menu->DrawBitmapAsync(fIcon, updateRect); drawLocation.x = ((frame.Width() - LabelWidth()) / 2); drawLocation.y = frame.top + iconBounds.Height() + kVPad * 2; @@ -252,8 +252,8 @@ TTeamMenuItem::DrawContent() float offsety = contentLocation.y + ((frame.Height() - iconBounds.Height()) / 2) + extra; - dstRect.OffsetTo(BPoint(offsetx, offsety)); - menu->DrawBitmapAsync(fIcon, dstRect); + updateRect.OffsetTo(BPoint(offsetx, offsety)); + menu->DrawBitmapAsync(fIcon, updateRect); float labelHeight = fLabelAscent + fLabelDescent; drawLocation.x += iconBounds.Width() + kLabelOffset; @@ -304,7 +304,7 @@ void TTeamMenuItem::DrawExpanderArrow() { BMenu* menu = Menu(); - BRect frame(Frame()); + BRect frame = Frame(); BRect rect(0.0f, 0.0f, kSwitchWidth, kHPad + 2.0f); rect.OffsetTo(BPoint(frame.right - rect.Width(), diff --git a/src/apps/deskbar/TeamMenuItem.h b/src/apps/deskbar/TeamMenuItem.h index 29a448a47b..b109a3e825 100644 --- a/src/apps/deskbar/TeamMenuItem.h +++ b/src/apps/deskbar/TeamMenuItem.h @@ -76,6 +76,7 @@ public: bool IsExpanded() const { return fExpanded; }; void ToggleExpandState(bool resizeWindow); + BRect ExpanderBounds() const; TWindowMenuItem* ExpandedWindowItem(int32 id); @@ -103,6 +104,7 @@ private: BBitmap* fIcon; char* fName; char* fSignature; + float fOverrideWidth; float fOverrideHeight; diff --git a/src/apps/deskbar/WindowMenuItem.cpp b/src/apps/deskbar/WindowMenuItem.cpp index f051469637..de740ccb1e 100644 --- a/src/apps/deskbar/WindowMenuItem.cpp +++ b/src/apps/deskbar/WindowMenuItem.cpp @@ -77,37 +77,6 @@ TWindowMenuItem::TWindowMenuItem(const char* label, int32 id, bool mini, } -void -TWindowMenuItem::SetTo(const char* label, int32 id, bool mini, - bool currentWorkspace, bool dragging) -{ - fModified = fCurrentWorkSpace != currentWorkspace || fMini != mini; - - fID = id; - fMini = mini; - fCurrentWorkSpace = currentWorkspace; - fDragging = dragging; - fRequireUpdate = false; - - _Init(label); -} - - -/*static*/ int32 -TWindowMenuItem::InsertIndexFor(BMenu* menu, int32 startIndex, - TWindowMenuItem* newItem) -{ - for (int32 index = startIndex;; index++) { - TWindowMenuItem* item - = dynamic_cast(menu->ItemAt(index)); - if (item == NULL - || NaturalCompare(item->Label(), newItem->Label()) > 0) { - return index; - } - } -} - - void TWindowMenuItem::GetContentSize(float* width, float* height) { @@ -252,6 +221,37 @@ TWindowMenuItem::Invoke(BMessage* /*message*/) } +void +TWindowMenuItem::SetTo(const char* label, int32 id, bool mini, + bool currentWorkspace, bool dragging) +{ + fModified = fCurrentWorkSpace != currentWorkspace || fMini != mini; + + fID = id; + fMini = mini; + fCurrentWorkSpace = currentWorkspace; + fDragging = dragging; + fRequireUpdate = false; + + _Init(label); +} + + +/*static*/ int32 +TWindowMenuItem::InsertIndexFor(BMenu* menu, int32 startIndex, + TWindowMenuItem* newItem) +{ + for (int32 index = startIndex;; index++) { + TWindowMenuItem* item + = dynamic_cast(menu->ItemAt(index)); + if (item == NULL + || NaturalCompare(item->Label(), newItem->Label()) > 0) { + return index; + } + } +} + + // #pragma mark - private methods