From cafee0b7f50e601f89a7c81a64e53908b99ce8e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 23 Mar 2009 11:26:53 +0000 Subject: [PATCH] Improved/fixed the look of file panels. If I feel motivated enough, I may also fix the font-sensitivity issues. * The CountView can now draw part of the PoseView focus indication. Though I am not convinced anymore that I am approaching this the right way. Maybe scroll views should simply leave room for drawing a frame between child and scroll bars... * ContainerWindow::BackgroundView uses the new BControlLook method to draw the scroll view frame to look just like a regular scroll view. * Some fixes to layout of controls in file panels and minimum window size. There would be much more left to do... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29663 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/ContainerWindow.cpp | 56 ++++++++++++++++++++++++++-- src/kits/tracker/CountView.cpp | 30 ++++++++++++++- src/kits/tracker/CountView.h | 8 +++- src/kits/tracker/FilePanelPriv.cpp | 14 ++++--- src/kits/tracker/PoseView.h | 11 +++++- 5 files changed, 104 insertions(+), 15 deletions(-) diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index 4d32953c8f..5d2f8a6ec0 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -65,6 +65,7 @@ All rights reserved. #include "BackgroundImage.h" #include "Commands.h" #include "ContainerWindow.h" +#include "CountView.h" #include "DeskWindow.h" #include "FavoritesMenu.h" #include "FindPanel.h" @@ -3967,9 +3968,25 @@ BackgroundView::FrameResized(float, float) void -BackgroundView::PoseViewFocused(bool) +BackgroundView::PoseViewFocused(bool focused) { Invalidate(); + + BContainerWindow* window = dynamic_cast(Window()); + if (!window) + return; + + BScrollBar* hScrollBar = window->PoseView()->HScrollBar(); + if (hScrollBar != NULL) + hScrollBar->SetBorderHighlighted(focused); + + BScrollBar* vScrollBar = window->PoseView()->VScrollBar(); + if (vScrollBar != NULL) + vScrollBar->SetBorderHighlighted(focused); + + BCountView* countView = window->PoseView()->CountView(); + if (countView != NULL) + countView->SetBorderHighlighted(focused); } @@ -3981,18 +3998,49 @@ BackgroundView::WindowActivated(bool) void -BackgroundView::Draw(BRect) +BackgroundView::Draw(BRect updateRect) { BContainerWindow *window = dynamic_cast(Window()); if (!window) return; - BRect frame(window->PoseView()->Frame()); - + BPoseView* poseView = window->PoseView(); + BRect frame(poseView->Frame()); frame.InsetBy(-1, -1); frame.top -= kTitleViewHeight; frame.bottom += B_H_SCROLL_BAR_HEIGHT; frame.right += B_V_SCROLL_BAR_WIDTH; + + if (be_control_look != NULL) { + uint32 flags = 0; + if (window->IsActive() && window->PoseView()->IsFocus()) + flags |= BControlLook::B_FOCUSED; + + frame.top--; + frame.InsetBy(-1, -1); + BRect rect(frame); + rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + + BScrollBar* hScrollBar = poseView->HScrollBar(); + BScrollBar* vScrollBar = poseView->VScrollBar(); + + BRect verticalScrollBarFrame(0, 0, -1, -1); + if (vScrollBar) + verticalScrollBarFrame = vScrollBar->Frame(); + BRect horizontalScrollBarFrame(0, 0, -1, -1); + if (hScrollBar) { + horizontalScrollBarFrame = hScrollBar->Frame(); + // CountView extends horizontal scroll bar frame: + horizontalScrollBarFrame.left = frame.left + 1; + } + + be_control_look->DrawScrollViewFrame(this, rect, updateRect, + verticalScrollBarFrame, horizontalScrollBarFrame, base, + B_FANCY_BORDER, flags); + + return; + } + SetHighColor(100, 100, 100); StrokeRect(frame); diff --git a/src/kits/tracker/CountView.cpp b/src/kits/tracker/CountView.cpp index 9353cde769..360eaf6415 100644 --- a/src/kits/tracker/CountView.cpp +++ b/src/kits/tracker/CountView.cpp @@ -55,6 +55,7 @@ BCountView::BCountView(BRect bounds, BPoseView* view) fLastCount(-1), fPoseView(view), fShowingBarberPole(false), + fBorderHighlighted(false), fBarberPoleMap(NULL), fLastBarberPoleOffset(5), fStartSpinningAfter(0), @@ -98,6 +99,17 @@ BCountView::Pulse() } +void +BCountView::WindowActivated(bool active) +{ + if (fBorderHighlighted) { + BRect dirty(Bounds()); + dirty.bottom = dirty.top; + Invalidate(dirty); + } +} + + void BCountView::EndBarberPole() { @@ -186,7 +198,10 @@ BCountView::Draw(BRect updateRect) if (be_control_look != NULL) { rgb_color base = ViewColor(); - SetHighColor(tint_color(base, B_DARKEN_2_TINT)); + if (fBorderHighlighted && Window()->IsActive()) + SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); + else + SetHighColor(tint_color(base, B_DARKEN_2_TINT)); StrokeLine(bounds.LeftTop(), bounds.RightTop()); bounds.top++; be_control_look->DrawMenuBarBackground(this, bounds, updateRect, @@ -329,3 +344,16 @@ BCountView::IsTypingAhead() const { return fTypeAheadString.Length() != 0; } + + +void +BCountView::SetBorderHighlighted(bool highlighted) +{ + if (fBorderHighlighted == highlighted) + return; + + fBorderHighlighted = highlighted; + BRect dirty(Bounds()); + dirty.bottom = dirty.top; + Invalidate(dirty); +} diff --git a/src/kits/tracker/CountView.h b/src/kits/tracker/CountView.h index 0172978ad2..52392194a9 100644 --- a/src/kits/tracker/CountView.h +++ b/src/kits/tracker/CountView.h @@ -53,6 +53,7 @@ public: virtual void MouseDown(BPoint); virtual void AttachedToWindow(); virtual void Pulse(); + virtual void WindowActivated(bool active); void CheckCount(); void StartBarberPole(); @@ -61,7 +62,9 @@ public: void SetTypeAhead(const char *); const char *TypeAhead() const; bool IsTypingAhead() const; - + + void SetBorderHighlighted(bool highlighted); + private: BRect BarberPoleInnerRect() const; BRect BarberPoleOuterRect() const; @@ -71,7 +74,8 @@ private: int32 fLastCount; BPoseView *fPoseView; - bool fShowingBarberPole; + bool fShowingBarberPole : 1; + bool fBorderHighlighted : 1; BBitmap *fBarberPoleMap; float fLastBarberPoleOffset; bigtime_t fStartSpinningAfter; diff --git a/src/kits/tracker/FilePanelPriv.cpp b/src/kits/tracker/FilePanelPriv.cpp index 5eaf902987..d494a8d5b8 100644 --- a/src/kits/tracker/FilePanelPriv.cpp +++ b/src/kits/tracker/FilePanelPriv.cpp @@ -661,8 +661,8 @@ TFilePanel::Init(const BMessage *) float f_height = ht.ascent + ht.descent + ht.leading; BRect rect; - rect.top = fMenuBar->Bounds().Height() + 2; - rect.left = windRect.left + 9; + rect.top = fMenuBar->Bounds().Height() + 8; + rect.left = windRect.left + 8; rect.right = rect.left + 300; rect.bottom = rect.top + (f_height > 22 ? f_height : 22); @@ -687,7 +687,7 @@ TFilePanel::Init(const BMessage *) if (fIsSavePanel) { BRect rect(windRect); rect.top = rect.bottom - 35; - rect.left = 9; + rect.left = 8; rect.right = rect.left + 170; rect.bottom = rect.top + 13; @@ -704,7 +704,7 @@ TFilePanel::Init(const BMessage *) fButtonText = "Open"; rect = windRect; - rect.OffsetTo(10, fMenuBar->Bounds().Height() * 2 + 16); + rect.OffsetTo(10, fDirMenuField->Frame().bottom + 10); rect.bottom = windRect.bottom - 60; rect.right -= B_V_SCROLL_BAR_WIDTH + 20; @@ -725,7 +725,9 @@ TFilePanel::Init(const BMessage *) PoseView()->SetSelectionHandler(this); PoseView()->SetSelectionChangedHook(true); PoseView()->DisableSaveLocation(); - + PoseView()->VScrollBar()->MoveBy(0, -1); + PoseView()->VScrollBar()->ResizeBy(0, 1); + AddShortcut('W', B_COMMAND_KEY, new BMessage(kCancelButton)); AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome)); @@ -780,7 +782,7 @@ TFilePanel::Init(const BMessage *) SetTitle(title.String()); - SetSizeLimits(360, 10000, 200, 10000); + SetSizeLimits(370, 10000, 200, 10000); } diff --git a/src/kits/tracker/PoseView.h b/src/kits/tracker/PoseView.h index dee64e4614..9f48ac4da8 100644 --- a/src/kits/tracker/PoseView.h +++ b/src/kits/tracker/PoseView.h @@ -189,8 +189,9 @@ class BPoseView : public BView { virtual void UpdateScrollRange(); virtual void SetScrollBarsTo(BPoint); virtual void AddScrollBars(); - BHScrollBar *HScrollBar() const; - BScrollBar *VScrollBar() const ; + BHScrollBar* HScrollBar() const; + BScrollBar* VScrollBar() const ; + BCountView* CountView() const; void DisableScrollBars(); void EnableScrollBars(); @@ -786,6 +787,12 @@ BPoseView::VScrollBar() const return fVScrollBar; } +inline BCountView* +BPoseView::CountView() const +{ + return fCountView; +} + inline bool BPoseView::StateNeedsSaving() {