BControlLook: Move tab frame drawing into DrawTabFrame()
The tab frame is drawn behind the tabs. Create a new DrawTabFrame method in BControlLook and HaikuControlLook that draws the tab frame background. Until now we've been reusing the DrawInactiveTab method to draw the tab frame in BTabView. While this works on HaikuControlLook, it doesn't work on other ControlLook's (such as BeControlLook) that draw their tab frame differently. Add FBC method to preserve binary compatibility on gcc2 and gcc4. Move DrawTabFrame method to where _ReservedControlLook1 was in header. Set rect to area of tab frame in TabView instead of doing the calculation in HaikuControlLook so that others may benefit. Change-Id: I513e238914f6d680f495659b6ec902df15555015 Reviewed-on: https://review.haiku-os.org/c/haiku/+/1936 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
7e27cd8e6f
commit
fb3493dfef
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include <ControlLook.h>
|
||||
|
||||
#include <binary_compatibility/Interface.h>
|
||||
|
||||
|
||||
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() {}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <Region.h>
|
||||
#include <Shape.h>
|
||||
#include <String.h>
|
||||
#include <TabView.h>
|
||||
#include <View.h>
|
||||
#include <Window.h>
|
||||
#include <WindowPrivate.h>
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user