hrev50142 adds 2 changesets to branch 'master'
old head: cdd8523736cfb65f5a441498e1f02896aec8d142
new head: a0ea818b3f282370f1cebe0512886ba200cea45e
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=a0ea818b3f28+%5Ecdd8523736cf
----------------------------------------------------------------------------
31c8f7b193d9: BTabView: Style fixes
a0ea818b3f28: BTabView: Move first tab over by B_WINDOW_SPACING
BTabView::DrawTabs() got a makeover:
Draw the tab background across the whole view, then draw the tabs,
finally draw the rightmost tab's right border.
[ John Scipione <jscipione@xxxxxxxxx> ]
----------------------------------------------------------------------------
1 file changed, 42 insertions(+), 42 deletions(-)
src/kits/interface/TabView.cpp | 84 +++++++++++++++++++-------------------
############################################################################
Commit: 31c8f7b193d99e7d614d8b0a35a3b6ccbe461021
URL: http://cgit.haiku-os.org/haiku/commit/?id=31c8f7b193d9
Author: John Scipione <jscipione@xxxxxxxxx>
Date: Fri Mar 11 02:14:40 2016 UTC
BTabView: Style fixes
----------------------------------------------------------------------------
diff --git a/src/kits/interface/TabView.cpp b/src/kits/interface/TabView.cpp
index 734890b..3b7b72e 100644
--- a/src/kits/interface/TabView.cpp
+++ b/src/kits/interface/TabView.cpp
@@ -276,7 +276,7 @@ BTab::DrawTab(BView* owner, BRect frame, tab_position
position, bool full)
borders |= BControlLook::B_RIGHT_BORDER;
if (position == B_TAB_FRONT) {
- frame.bottom += 1;
+ frame.bottom += 1.0f;
be_control_look->DrawActiveTab(owner, frame, frame, no_tint, 0,
borders);
} else {
@@ -433,8 +433,10 @@ BTabView::Archive(BMessage* archive, bool deep) const
for (int32 i = 0; i < CountTabs(); i++) {
BTab* tab = TabAt(i);
- if ((result = archiver.AddArchivable("_l_items", tab,
deep)) != B_OK)
+ if ((result = archiver.AddArchivable("_l_items", tab,
deep))
+ != B_OK) {
break;
+ }
result = archiver.AddArchivable("_view_list",
tab->View(), deep);
}
}
@@ -544,7 +546,8 @@ BTabView::MessageReceived(BMessage* message)
int32 index;
int32 form;
const char* property;
- if (message->GetCurrentSpecifier(&index, &specifier,
&form, &property) == B_OK) {
+ if (message->GetCurrentSpecifier(&index, &specifier,
&form,
+ &property) == B_OK) {
if (strcmp(property, "Selection") == 0) {
if (message->what == B_GET_PROPERTY) {
reply.AddInt32("result",
fSelection);
@@ -856,11 +859,9 @@ BTabView::DrawBox(BRect selTabRect)
if (fBorderStyle == B_FANCY_BORDER)
be_control_look->DrawGroupFrame(this, rect, rect, base);
else {
- uint32 borders = BControlLook::B_TOP_BORDER;
- if (fBorderStyle == B_PLAIN_BORDER)
- borders = BControlLook::B_ALL_BORDERS;
be_control_look->DrawBorder(this, rect, rect, base,
B_PLAIN_BORDER,
- 0, borders);
+ 0, fBorderStyle == B_PLAIN_BORDER ?
BControlLook::B_ALL_BORDERS
+ : BControlLook::B_TOP_BORDER);
}
}
@@ -878,6 +879,7 @@ BTabView::TabFrame(int32 index) const
// again (handled in DrawTabs()).
if (fBorderStyle == B_PLAIN_BORDER)
borderOffset = 1.0f;
+
switch (fTabWidthSetting) {
case B_WIDTH_FROM_LABEL:
{
@@ -1295,8 +1297,10 @@ BTabView::_BorderWidth() const
default:
case B_FANCY_BORDER:
return 3.0f;
+
case B_PLAIN_BORDER:
return 1.0f;
+
case B_NO_BORDER:
return 0.0f;
}
@@ -1314,9 +1318,11 @@ BTabView::_LayoutContainerView(bool layouted)
case B_FANCY_BORDER:
topBorderOffset = 1.0f;
break;
+
case B_PLAIN_BORDER:
topBorderOffset = 0.0f;
break;
+
case B_NO_BORDER:
topBorderOffset = -1.0f;
break;
############################################################################
Revision: hrev50142
Commit: a0ea818b3f282370f1cebe0512886ba200cea45e
URL: http://cgit.haiku-os.org/haiku/commit/?id=a0ea818b3f28
Author: John Scipione <jscipione@xxxxxxxxx>
Date: Fri Mar 11 02:14:58 2016 UTC
BTabView: Move first tab over by B_WINDOW_SPACING
BTabView::DrawTabs() got a makeover:
Draw the tab background across the whole view, then draw the tabs,
finally draw the rightmost tab's right border.
----------------------------------------------------------------------------
diff --git a/src/kits/interface/TabView.cpp b/src/kits/interface/TabView.cpp
index 3b7b72e..727209f 100644
--- a/src/kits/interface/TabView.cpp
+++ b/src/kits/interface/TabView.cpp
@@ -801,49 +801,41 @@ BTabView::Draw(BRect updateRect)
BRect
BTabView::DrawTabs()
{
- float left = 0;
+ // draw an inactive tab frame behind all tabs
+ BRect frame(Bounds());
+ frame.bottom = fTabHeight;
+ rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
+ uint32 borders = BControlLook::B_TOP_BORDER
+ | BControlLook::B_BOTTOM_BORDER;
+ if (fBorderStyle == B_NO_BORDER) {
+ // removes left border that is an artifact of DrawInactiveTab()
+ frame.left -= 1.0f;
+ } else
+ borders |= BControlLook::B_LEFT_BORDER |
BControlLook::B_RIGHT_BORDER;
- for (int32 i = 0; i < CountTabs(); i++) {
+ be_control_look->DrawInactiveTab(this, frame, frame, base, 0, borders);
+
+ // draw the tabs on top of the inactive tab frame
+ float right = 0.0f;
+ int32 tabCount = CountTabs();
+ for (int32 i = 0; i < tabCount; i++) {
BRect tabFrame = TabFrame(i);
TabAt(i)->DrawTab(this, tabFrame,
i == fSelection ? B_TAB_FRONT : (i == 0) ? B_TAB_FIRST
: B_TAB_ANY,
i + 1 != fSelection);
- left = tabFrame.right;
+ right = tabFrame.right;
}
- BRect frame(Bounds());
- if (fBorderStyle == B_PLAIN_BORDER)
- frame.right += 1;
- else if (fBorderStyle == B_NO_BORDER)
- frame.right += 2;
- if (left < frame.right) {
- frame.left = left;
- frame.bottom = fTabHeight;
- rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
- uint32 borders = BControlLook::B_TOP_BORDER
- | BControlLook::B_BOTTOM_BORDER |
BControlLook::B_RIGHT_BORDER;
- if (left == 0)
- borders |= BControlLook::B_LEFT_BORDER;
- be_control_look->DrawInactiveTab(this, frame, frame, base, 0,
- borders);
- }
- if (fBorderStyle == B_NO_BORDER) {
- // Draw a small inactive area before first tab.
+ if (tabCount > 1 && right < frame.right) {
+ // draw a 1px right border on the last tab
frame = Bounds();
- frame.right = 0.0f;
- // one pixel wide
+ frame.left = frame.right = right;
frame.bottom = fTabHeight;
- rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
- uint32 borders = BControlLook::B_TOP_BORDER
- | BControlLook::B_BOTTOM_BORDER;
be_control_look->DrawInactiveTab(this, frame, frame, base, 0,
- borders);
+ BControlLook::B_TOP_BORDER |
BControlLook::B_BOTTOM_BORDER);
}
- if (fSelection < CountTabs())
- return TabFrame(fSelection);
-
- return BRect();
+ return fSelection < CountTabs() ? TabFrame(fSelection) : BRect();
}
@@ -875,6 +867,8 @@ BTabView::TabFrame(int32 index) const
float width = 100.0f;
float height = fTabHeight;
float borderOffset = 0.0f;
+ float offset = BControlLook::ComposeSpacing(B_USE_WINDOW_SPACING);
+
// Do not use 2.0f for B_NO_BORDER, that will look yet different
// again (handled in DrawTabs()).
if (fBorderStyle == B_PLAIN_BORDER)
@@ -888,8 +882,8 @@ BTabView::TabFrame(int32 index) const
x += StringWidth(TabAt(i)->Label()) + 20.0f;
}
- return BRect(x - borderOffset, 0.0f,
- x + StringWidth(TabAt(index)->Label()) + 20.0f
+ return BRect(offset + x - borderOffset, 0.0f,
+ offset + x + StringWidth(TabAt(index)->Label())
+ 20.0f
- borderOffset,
height);
}
@@ -905,8 +899,8 @@ BTabView::TabFrame(int32 index) const
case B_WIDTH_AS_USUAL:
default:
- return BRect(index * width - borderOffset, 0.0f,
- index * width + width - borderOffset, height);
+ return BRect(offset + index * width - borderOffset,
0.0f,
+ offset + index * width + width - borderOffset,
height);
}
// TODO: fix to remove "offset" in DrawTab and DrawLabel ...