diff --git a/headers/os/interface/ControlLook.h b/headers/os/interface/ControlLook.h index 72746a5cf0..b914f833b4 100644 --- a/headers/os/interface/ControlLook.h +++ b/headers/os/interface/ControlLook.h @@ -289,7 +289,6 @@ public: const rgb_color& base, uint32 flags = 0, uint32 borders = B_ALL_BORDERS, uint32 side = B_TOP_BORDER) = 0; - virtual void DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base, uint32 flags = 0, @@ -396,9 +395,14 @@ public: void SetBackgroundInfo( const BMessage& backgroundInfo); + virtual void DrawTabFrame(BView* view, BRect& rect, + const BRect& updateRect, + const rgb_color& base, uint32 flags = 0, + uint32 borders = B_ALL_BORDERS, + border_style borderStyle = B_FANCY_BORDER, + uint32 side = B_TOP_BORDER) = 0; private: // FBC padding - virtual void _ReservedControlLook1(); virtual void _ReservedControlLook2(); virtual void _ReservedControlLook3(); virtual void _ReservedControlLook4(); diff --git a/headers/private/interface/HaikuControlLook.h b/headers/private/interface/HaikuControlLook.h index 09d8e69614..ef995c12fa 100644 --- a/headers/private/interface/HaikuControlLook.h +++ b/headers/private/interface/HaikuControlLook.h @@ -217,12 +217,17 @@ public: hash_mark_location location, uint32 flags, orientation orientation); + virtual void DrawTabFrame(BView* view, BRect& rect, + const BRect& updateRect, + const rgb_color& base, uint32 flags = 0, + uint32 borders = B_ALL_BORDERS, + border_style borderStyle = B_FANCY_BORDER, + uint32 side = B_TOP_BORDER); virtual void DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base, uint32 flags = 0, uint32 borders = B_ALL_BORDERS, uint32 side = B_TOP_BORDER); - virtual void DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base, uint32 flags = 0, diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index 7d410a7f4a..740f23332e 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -6,6 +6,8 @@ #include +#include + namespace BPrivate { @@ -77,7 +79,18 @@ BControlLook::SetBackgroundInfo(const BMessage& backgroundInfo) } -void BControlLook::_ReservedControlLook1() {} +extern "C" void +B_IF_GCC_2(_ReservedControlLook1__Q28BPrivate12BControlLook, + _ZN8BPrivate12BControlLook21_ReservedControlLook1Ev)( + BControlLook* controlLook, BView* view, BRect& rect, + const BRect& updateRect, const rgb_color& base, uint32 flags, + uint32 borders, border_style borderStyle, uint32 side) +{ + controlLook->DrawTabFrame(view, rect, updateRect, base, flags, borders, + borderStyle, side); +} + + void BControlLook::_ReservedControlLook2() {} void BControlLook::_ReservedControlLook3() {} void BControlLook::_ReservedControlLook4() {} diff --git a/src/kits/interface/HaikuControlLook.cpp b/src/kits/interface/HaikuControlLook.cpp index 5cc1148aa6..f680618efa 100644 --- a/src/kits/interface/HaikuControlLook.cpp +++ b/src/kits/interface/HaikuControlLook.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -1332,6 +1333,50 @@ HaikuControlLook::DrawSliderHashMarks(BView* view, BRect& rect, } +void +HaikuControlLook::DrawTabFrame(BView* view, BRect& rect, + const BRect& updateRect, const rgb_color& base, uint32 flags, + uint32 borders, border_style borderStyle, uint32 side) +{ + if (!rect.IsValid() || !rect.Intersects(updateRect)) + return; + + if (side == BTabView::kTopSide || side == BTabView::kBottomSide) { + // draw an inactive tab frame behind all tabs + borders = B_TOP_BORDER | B_BOTTOM_BORDER; + if (borderStyle == B_NO_BORDER) { + // removes left border that is an artifact of DrawInactiveTab() + rect.left -= 1; + } else + borders |= B_LEFT_BORDER | B_RIGHT_BORDER; + + // DrawInactiveTab draws 2px border + // draw a little wider tab frame to align B_PLAIN_BORDER with it + if (borderStyle == B_PLAIN_BORDER) { + rect.left -= 1; + rect.right += 1; + } + } else if (side == BTabView::kLeftSide || side == BTabView::kRightSide) { + // draw an inactive tab frame behind all tabs + borders = B_LEFT_BORDER | B_RIGHT_BORDER; + if (borderStyle == B_NO_BORDER) { + // removes top border that is an artifact of DrawInactiveTab() + rect.top -= 1; + } else + borders |= B_TOP_BORDER | B_BOTTOM_BORDER; + + // DrawInactiveTab draws 2px border + // draw a little wider tab frame to align B_PLAIN_BORDER with it + if (borderStyle == B_PLAIN_BORDER) { + rect.top -= 1; + rect.bottom += 1; + } + } + + DrawInactiveTab(view, rect, rect, base, 0, borders, side); +} + + void HaikuControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base, uint32 flags, uint32 borders, uint32 side) diff --git a/src/kits/interface/TabView.cpp b/src/kits/interface/TabView.cpp index 03d2a3c696..9cefad36f4 100644 --- a/src/kits/interface/TabView.cpp +++ b/src/kits/interface/TabView.cpp @@ -868,63 +868,28 @@ BRect BTabView::DrawTabs() { BRect bounds(Bounds()); - BRect tabsBounds; + BRect tabFrame(bounds); uint32 borders = 0; rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + + // set tabFrame to area around tabs if (fTabSide == kTopSide || fTabSide == kBottomSide) { if (fTabSide == kTopSide) - bounds.bottom = fTabHeight; + tabFrame.bottom = fTabHeight; else - bounds.top = bounds.bottom - fTabHeight; - tabsBounds = bounds; - // make a copy for later - - // draw an inactive tab frame behind all tabs - borders = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER; - if (fBorderStyle == B_NO_BORDER) { - // removes left border that is an artifact of DrawInactiveTab() - bounds.left -= 1; - } else { - borders |= BControlLook::B_LEFT_BORDER - | BControlLook::B_RIGHT_BORDER; - } - - // DrawInactiveTab draws 2px border - // draw a little wider tab frame to align B_PLAIN_BORDER with it - if (fBorderStyle == B_PLAIN_BORDER) { - bounds.left -= 1; - bounds.right += 1; - } + tabFrame.top = tabFrame.bottom - fTabHeight; } else if (fTabSide == kLeftSide || fTabSide == kRightSide) { if (fTabSide == kLeftSide) - bounds.right = fTabHeight; + tabFrame.right = fTabHeight; else - bounds.left = bounds.right - fTabHeight; - tabsBounds = bounds; - // make a copy for later - - // draw an inactive tab frame behind all tabs - borders = BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER; - if (fBorderStyle == B_NO_BORDER) { - // removes top border that is an artifact of DrawInactiveTab() - bounds.top -= 1; - } else { - borders |= BControlLook::B_TOP_BORDER - | BControlLook::B_BOTTOM_BORDER; - } - - // DrawInactiveTab draws 2px border - // draw a little wider tab frame to align B_PLAIN_BORDER with it - if (fBorderStyle == B_PLAIN_BORDER) { - bounds.top -= 1; - bounds.bottom += 1; - } + tabFrame.left = tabFrame.right - fTabHeight; } - be_control_look->DrawInactiveTab(this, bounds, bounds, base, 0, - borders, fTabSide); + // draw frame behind tabs + be_control_look->DrawTabFrame(this, tabFrame, bounds, base, 0, + borders, fBorderStyle, fTabSide); - // draw the tabs on top of the inactive tab bounds + // draw the tabs on top of the tab frame BRect activeTabFrame; int32 tabCount = CountTabs(); for (int32 i = 0; i < tabCount; i++) { @@ -938,16 +903,17 @@ BTabView::DrawTabs() i + 1 != fSelection); } + BRect tabsBounds; float last = 0.0f; float lastTab = 0.0f; if (fTabSide == kTopSide || fTabSide == kBottomSide) { lastTab = TabFrame(tabCount - 1).right; - last = bounds.right; + last = tabFrame.right; tabsBounds.left = tabsBounds.right = lastTab; borders = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER; } else if (fTabSide == kLeftSide || fTabSide == kRightSide) { lastTab = TabFrame(tabCount - 1).bottom; - last = bounds.bottom; + last = tabFrame.bottom; tabsBounds.top = tabsBounds.bottom = lastTab; borders = BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER; }