diff --git a/src/apps/terminal/SmartTabView.cpp b/src/apps/terminal/SmartTabView.cpp index 015e064005..81bec44ac1 100644 --- a/src/apps/terminal/SmartTabView.cpp +++ b/src/apps/terminal/SmartTabView.cpp @@ -21,11 +21,15 @@ const static uint32 kCloseTab = 'ClTb'; SmartTabView::SmartTabView(BRect frame, const char *name, button_width width, uint32 resizingMode, uint32 flags) : - BTabView(frame, name, width, resizingMode, flags) + BTabView(frame, name, width, resizingMode, flags), + fInsets(0, 0, 0, 0) { - // See BTabView::_InitObject() to see why we are doing this - ContainerView()->MoveBy(-3, -TabHeight() - 3); - ContainerView()->ResizeBy(10, TabHeight() + 9); + // Resize the container view to fill the complete tab view for single-tab + // mode. Later, when more than one tab is added, we shrink the container + // view again. + frame.OffsetTo(B_ORIGIN); + ContainerView()->MoveTo(frame.LeftTop()); + ContainerView()->ResizeTo(frame.Width(), frame.Height()); } @@ -34,6 +38,16 @@ SmartTabView::~SmartTabView() } +void +SmartTabView::SetInsets(float left, float top, float right, float bottom) +{ + fInsets.left = left; + fInsets.top = top; + fInsets.right = right; + fInsets.bottom = bottom; +} + + void SmartTabView::MouseDown(BPoint point) { @@ -106,8 +120,10 @@ SmartTabView::Select(int32 index) BTabView::Select(index); BView *view = ViewForTab(index); if (view != NULL) { - view->ResizeTo(ContainerView()->Bounds().Width(), - ContainerView()->Bounds().Height()); + view->MoveTo(fInsets.LeftTop()); + view->ResizeTo(ContainerView()->Bounds().Width() + - fInsets.left - fInsets.right, + ContainerView()->Bounds().Height() - fInsets.top - fInsets.bottom); } } diff --git a/src/apps/terminal/SmartTabView.h b/src/apps/terminal/SmartTabView.h index 84de73a194..56efecd244 100644 --- a/src/apps/terminal/SmartTabView.h +++ b/src/apps/terminal/SmartTabView.h @@ -21,6 +21,8 @@ public: B_FRAME_EVENTS | B_NAVIGABLE); virtual ~SmartTabView(); + void SetInsets(float left, float top, float right, float bottom); + virtual void MouseDown(BPoint where); virtual void AttachedToWindow(); @@ -39,6 +41,9 @@ public: private: int32 _ClickedTabIndex(const BPoint &point); + +private: + BRect fInsets; }; #endif // __SMARTTABVIEW_H diff --git a/src/apps/terminal/TermScrollView.cpp b/src/apps/terminal/TermScrollView.cpp index 8d0a6f621f..8e3f1e2ce4 100644 --- a/src/apps/terminal/TermScrollView.cpp +++ b/src/apps/terminal/TermScrollView.cpp @@ -32,13 +32,18 @@ public: TermScrollView::TermScrollView(const char* name, BView* child, BView* target, uint32 resizingMode) : - BScrollView(name, child, resizingMode, 0, false, true) + BScrollView(name, child, resizingMode, 0, false, true, B_NO_BORDER) { // replace the vertical scroll bar with our own if (fVerticalScrollBar != NULL) { BRect frame(fVerticalScrollBar->Frame()); RemoveChild(fVerticalScrollBar); + // Overlap one pixel at the top and the bottom of the scroll bar with + // the menu respectively resize knob for aesthetical reasons. + frame.top -= 1; + frame.bottom += 1; + TermScrollBar* scrollBar = new TermScrollBar(frame, "_VSB_", target, 0, 1000, B_VERTICAL); AddChild(scrollBar); diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index 9a65714936..af9c9eae67 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -456,9 +456,9 @@ void TermView::GetPreferredSize(float *width, float *height) { if (width) - *width = fTermColumns * fFontWidth; + *width = fTermColumns * fFontWidth - 1; if (height) - *height = fTermRows * fFontHeight; + *height = fTermRows * fFontHeight - 1; } diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index a6adc9d729..ea1e42f5c5 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -179,6 +179,10 @@ TermWindow::_InitWindow() fTabView = new TabView(this, textFrame, "tab view"); AddChild(fTabView); + + // Make the scroll view one pixel wider than the tab view container view, so + // the scroll bar will look good. + fTabView->SetInsets(0, 0, -1, 0); } @@ -670,10 +674,6 @@ TermWindow::_AddTab(Arguments *args) tab->SetLabel(session->name.String()); view->SetScrollBar(scrollView->ScrollBar(B_VERTICAL)); - // Resize the vertical scrollbar to take the window gripping handle into account - // TODO: shouldn't this be done in BScrollView itself ? At least BScrollBar does that. - scrollView->ScrollBar(B_VERTICAL)->ResizeBy(0, -13); - view->SetEncoding(EncodingID(PrefHandler::Default()->getString(PREF_TEXT_ENCODING))); BFont font; @@ -685,14 +685,14 @@ TermWindow::_AddTab(Arguments *args) int width, height; view->GetFontSize(&width, &height); - float minimumHeight = 0; + float minimumHeight = -1; if (fMenubar) - minimumHeight += fMenubar->Bounds().Height(); + minimumHeight += fMenubar->Bounds().Height() + 1; if (fTabView && fTabView->CountTabs() > 1) - minimumHeight += fTabView->TabHeight(); - SetSizeLimits(MIN_COLS * width, MAX_COLS * width, - minimumHeight + MIN_ROWS * height, - minimumHeight + MAX_ROWS * height); + minimumHeight += fTabView->TabHeight() + 1; + SetSizeLimits(MIN_COLS * width - 1, MAX_COLS * width - 1, + minimumHeight + MIN_ROWS * height - 1, + minimumHeight + MAX_ROWS * height - 1); // If it's the first time we're called, setup the window if (fTabView->CountTabs() == 1) { @@ -701,7 +701,9 @@ TermWindow::_AddTab(Arguments *args) // Resize Window ResizeTo(viewWidth + B_V_SCROLL_BAR_WIDTH, - viewHeight + fMenubar->Bounds().Height()); + viewHeight + fMenubar->Bounds().Height() + 1); + // NOTE: Width is one pixel too small, since the scroll view + // is one pixel wider than its parent. } // TODO: No fTabView->Select(tab); ? fTabView->Select(fTabView->CountTabs() - 1); @@ -789,24 +791,26 @@ TermWindow::_ResizeView(TermView *view) { int fontWidth, fontHeight; view->GetFontSize(&fontWidth, &fontHeight); - - float minimumHeight = 0; + + float minimumHeight = -1; if (fMenubar) - minimumHeight += fMenubar->Bounds().Height(); + minimumHeight += fMenubar->Bounds().Height() + 1; if (fTabView && fTabView->CountTabs() > 1) - minimumHeight += fTabView->TabHeight(); - - SetSizeLimits(MIN_COLS * fontWidth, MAX_COLS * fontWidth, - minimumHeight + MIN_ROWS * fontHeight, - minimumHeight + MAX_ROWS * fontHeight); + minimumHeight += fTabView->TabHeight() + 1; + + SetSizeLimits(MIN_COLS * fontWidth - 1, MAX_COLS * fontWidth - 1, + minimumHeight + MIN_ROWS * fontHeight - 1, + minimumHeight + MAX_ROWS * fontHeight - 1); float width, height; view->Parent()->GetPreferredSize(&width, &height); width += B_V_SCROLL_BAR_WIDTH; - height += fMenubar->Bounds().Height() + 2; + // NOTE: Width is one pixel too small, since the scroll view + // is one pixel wider than its parent. + height += fMenubar->Bounds().Height() + 1; ResizeTo(width, height); - + view->Invalidate(); }