From 341f767dfde3f3d2b4340eac3089cb6ddc3e2dd1 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 26 Aug 2022 19:27:18 -0400 Subject: [PATCH] Terminal: Use BControlLook for scrollbar sizing. Improves appearance under HiDPI. --- src/apps/terminal/SmartTabView.cpp | 3 ++- src/apps/terminal/TermWindow.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/apps/terminal/SmartTabView.cpp b/src/apps/terminal/SmartTabView.cpp index f09f1084a0..ec6d0e288f 100644 --- a/src/apps/terminal/SmartTabView.cpp +++ b/src/apps/terminal/SmartTabView.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -52,7 +53,7 @@ SmartTabView::SmartTabView(BRect frame, const char* name, button_width width, ContainerView()->ResizeTo(frame.Width(), frame.Height()); BRect buttonRect(frame); - buttonRect.left = frame.right - B_V_SCROLL_BAR_WIDTH + 1; + buttonRect.left = frame.right - be_control_look->GetScrollBarWidth(B_VERTICAL) + 1; buttonRect.bottom = frame.top + TabHeight() - 1; fFullScreenButton = new BBitmapButton(kWindowIconBits, kWindowIconWidth, kWindowIconHeight, kWindowIconFormat, new BMessage(FULLSCREEN)); diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 22c2e61e97..1ffe0db88b 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -949,7 +950,7 @@ TermWindow::MessageReceived(BMessage *message) for (int32 i = fTabView->CountTabs() - 1; i >= 0; i--) _TermViewAt(i)->ScrollBar()->ResizeBy(0, - (B_H_SCROLL_BAR_HEIGHT - 1)); + (be_control_look->GetScrollBarWidth(B_VERTICAL) - 1)); fMenuBar->Hide(); fTabView->ResizeBy(0, mbHeight); @@ -969,7 +970,7 @@ TermWindow::MessageReceived(BMessage *message) for (int32 i = fTabView->CountTabs() - 1; i >= 0; i--) _TermViewAt(i)->ScrollBar()->ResizeBy(0, - -(B_H_SCROLL_BAR_HEIGHT - 1)); + -(be_control_look->GetScrollBarWidth(B_VERTICAL) - 1)); ResizeTo(fSavedFrame.Width(), fSavedFrame.Height()); MoveTo(fSavedFrame.left, fSavedFrame.top); @@ -1325,7 +1326,7 @@ TermWindow::_AddTab(Arguments* args, const BString& currentDirectory) containerView, view, fSessions.IsEmpty()); if (!fFullScreen) scrollView->ScrollBar(B_VERTICAL) - ->ResizeBy(0, -(B_H_SCROLL_BAR_HEIGHT - 1)); + ->ResizeBy(0, -(be_control_look->GetScrollBarWidth(B_VERTICAL) - 1)); if (fSessions.IsEmpty()) fTabView->SetScrollView(scrollView); @@ -1360,7 +1361,7 @@ TermWindow::_AddTab(Arguments* args, const BString& currentDirectory) containerView->GetPreferredSize(&viewWidth, &viewHeight); // Resize Window - ResizeTo(viewWidth + B_V_SCROLL_BAR_WIDTH, + ResizeTo(viewWidth + be_control_look->GetScrollBarWidth(B_HORIZONTAL), viewHeight + fMenuBar->Bounds().Height() + 1); // NOTE: Width is one pixel too small, since the scroll view // is one pixel wider than its parent. @@ -1741,7 +1742,7 @@ TermWindow::_ResizeView(TermView *view) float height; view->Parent()->GetPreferredSize(&width, &height); - width += B_V_SCROLL_BAR_WIDTH; + width += be_control_look->GetScrollBarWidth(B_HORIZONTAL); // NOTE: Width is one pixel too small, since the scroll view // is one pixel wider than its parent. if (fMenuBar != NULL)