From e01bbf955faa8fecafd747b08240781320d496dd Mon Sep 17 00:00:00 2001 From: John Scipione Date: Wed, 14 Oct 2015 21:32:55 -0700 Subject: [PATCH] Tracker: Fix issue with vertical scroll bar border This issue only manifested itself when the navigation toolbar was shown. The scrollbar appeared to have no border while the rest did. This issue manifested when the scrollbar insets were adjusted in hrev49654. The scroll bar insets were really hiding the bug underlying bug though. I'll try to explain what was happening and how I fixed it. The PoseView container, called BorderedView, was showing its top border when the navigation bar was hidden, and hiding its top border when the navigation bar was shown. This (almost) worked because the menu bar provided a bottom border while the navigation toolbar didn't. However hiding BorderedView's top border also hid the scroll bar border. My solution was to draw a bottom border on the navigation toolbar and then remove the top border from BorderedView unconditionally. So either the menu bar or the navigation toolbar provides a bottom border and the BorderedView has no top border. Fixes #12392 --- src/kits/tracker/ContainerWindow.cpp | 9 +-------- src/kits/tracker/Navigator.cpp | 23 ++++++++++++++++++++++- src/kits/tracker/Navigator.h | 1 + 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index e96baf7220..dfac6e3ff7 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -731,9 +731,7 @@ BContainerWindow::CreatePoseView(Model* model) && !fPoseView->IsFilePanel()) { fNavigator = new BNavigator(model); fPoseContainer->GridLayout()->AddView(fNavigator, 0, 0, 2); - if (settings.ShowNavigator()) - fBorderedView->GroupLayout()->SetInsets(1); - else + if (!settings.ShowNavigator()) fNavigator->Hide(); } @@ -1618,8 +1616,6 @@ BContainerWindow::MessageReceived(BMessage* message) fPoseContainer->GridLayout()->AddView(fNavigator, 0, 0, 2); fNavigator->Hide(); - fBorderedView->GroupLayout()->SetInsets(1, 0, - 1, 1); SetPathWatchingEnabled(settings.ShowNavigator() || settings.ShowFullPathInTitleBar()); } @@ -4072,8 +4068,6 @@ BContainerWindow::ShowNavigator(bool show) if (PoseView()->VScrollBar()) PoseView()->UpdateScrollRange(); - - fBorderedView->GroupLayout()->SetInsets(1); } else { if (!Navigator() || Navigator()->IsHidden()) return; @@ -4082,7 +4076,6 @@ BContainerWindow::ShowNavigator(bool show) PoseView()->UpdateScrollRange(); fNavigator->Hide(); - fBorderedView->GroupLayout()->SetInsets(1, 0, 1, 1); } } diff --git a/src/kits/tracker/Navigator.cpp b/src/kits/tracker/Navigator.cpp index 679f58a58d..0f5eee9ba2 100644 --- a/src/kits/tracker/Navigator.cpp +++ b/src/kits/tracker/Navigator.cpp @@ -35,6 +35,7 @@ All rights reserved. #include "Navigator.h" +#include #include #include @@ -67,7 +68,12 @@ BNavigator::BNavigator(const Model* model) new BMessage(kNavigatorCommandLocation)); fLocation->SetDivider(0); - GroupLayout()->SetInsets(0, 0, B_USE_HALF_ITEM_INSETS, 0); + GroupLayout()->SetInsets(0.0f, 0.0f, B_USE_HALF_ITEM_INSETS, 1.0f); + // 1px bottom inset used for border + + // Needed to draw the bottom border + SetFlags(Flags() | B_WILL_DRAW); + SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); } @@ -114,6 +120,21 @@ BNavigator::AllAttached() } +void +BNavigator::Draw(BRect updateRect) +{ + // Draw a 1px bottom border, like BMenuBar + BRect rect(Bounds()); + rgb_color base = LowColor(); + uint32 flags = 0; + + be_control_look->DrawBorder(this, rect, updateRect, base, + B_PLAIN_BORDER, flags, BControlLook::B_BOTTOM_BORDER); + + _inherited::Draw(rect & updateRect); +} + + void BNavigator::MessageReceived(BMessage* message) { diff --git a/src/kits/tracker/Navigator.h b/src/kits/tracker/Navigator.h index 82e879c70c..cf24129afe 100644 --- a/src/kits/tracker/Navigator.h +++ b/src/kits/tracker/Navigator.h @@ -76,6 +76,7 @@ protected: virtual void MessageReceived(BMessage* msg); virtual void AttachedToWindow(); virtual void AllAttached(); + virtual void Draw(BRect updateRect); void GoForward(bool option); // is option key held down?