From a78d43c2208811cd10bf6a129156220ff0cecdb8 Mon Sep 17 00:00:00 2001
From: Kacper Kasper <kacperkasper@gmail.com>
Date: Thu, 17 Aug 2017 06:08:09 +0200
Subject: [PATCH 1/3] BTabView: cleanup draw function.
* Slightly changes how tabs look.
---
src/kits/interface/ControlLook.cpp | 9 ++-------
src/kits/interface/TabView.cpp | 41 +++++++++-----------------------------
2 files changed, 11 insertions(+), 39 deletions(-)
diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp
index fbaadad..60ab9ae 100644
a
|
b
|
BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
1570 | 1570 | } |
1571 | 1571 | |
1572 | 1572 | BRect background = rect; |
1573 | | uint32 bordersToDraw = 0; |
1574 | 1573 | switch (side) { |
1575 | 1574 | case B_TOP_BORDER: |
1576 | | bordersToDraw = (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER); |
1577 | 1575 | rect.top += 4; |
1578 | 1576 | background.bottom = rect.top; |
1579 | 1577 | break; |
1580 | 1578 | case B_BOTTOM_BORDER: |
1581 | | bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER); |
1582 | 1579 | rect.bottom -= 4; |
1583 | 1580 | background.top = rect.bottom; |
1584 | 1581 | break; |
1585 | 1582 | case B_LEFT_BORDER: |
1586 | | bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER); |
1587 | 1583 | rect.left += 4; |
1588 | 1584 | background.right = rect.left; |
1589 | 1585 | break; |
1590 | 1586 | case B_RIGHT_BORDER: |
1591 | | bordersToDraw = (B_RIGHT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER); |
1592 | 1587 | rect.right -= 4; |
1593 | 1588 | background.left = rect.right; |
1594 | 1589 | break; |
… |
… |
BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
1600 | 1595 | |
1601 | 1596 | // frame and fill |
1602 | 1597 | _DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor, |
1603 | | edgeLightColor, borders & bordersToDraw); |
| 1598 | edgeLightColor, borders); |
1604 | 1599 | |
1605 | 1600 | _DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor, |
1606 | | frameShadowColor, borders & bordersToDraw); |
| 1601 | frameShadowColor, borders); |
1607 | 1602 | |
1608 | 1603 | if (rect.IsValid()) { |
1609 | 1604 | if (side == B_TOP_BORDER || side == B_BOTTOM_BORDER) { |
diff --git a/src/kits/interface/TabView.cpp b/src/kits/interface/TabView.cpp
index 590b4b9..030649d 100644
a
|
b
|
BTab::DrawTab(BView* owner, BRect frame, tab_position position, bool full)
|
274 | 274 | borders |= BControlLook::B_RIGHT_BORDER; |
275 | 275 | |
276 | 276 | if (position == B_TAB_FRONT) { |
277 | | frame.bottom += 1.0f; |
| 277 | frame.bottom -= 1.0f; |
278 | 278 | be_control_look->DrawActiveTab(owner, frame, frame, no_tint, 0, |
279 | 279 | borders); |
280 | 280 | } else { |
… |
… |
BTabView::FocusTab() const
|
789 | 789 | void |
790 | 790 | BTabView::Draw(BRect updateRect) |
791 | 791 | { |
792 | | DrawBox(TabFrame(fSelection)); |
793 | 792 | DrawTabs(); |
| 793 | DrawBox(TabFrame(fSelection)); |
794 | 794 | |
795 | 795 | if (IsFocus() && fFocus != -1) |
796 | 796 | TabAt(fFocus)->DrawFocusMark(this, TabFrame(fFocus)); |
… |
… |
BTabView::Draw(BRect updateRect)
|
800 | 800 | BRect |
801 | 801 | BTabView::DrawTabs() |
802 | 802 | { |
803 | | // TODO: Rewrite this method |
804 | | |
805 | 803 | // draw an inactive tab frame behind all tabs |
806 | 804 | BRect bounds(Bounds()); |
807 | 805 | bounds.bottom = fTabHeight; |
… |
… |
BTabView::DrawTabs()
|
813 | 811 | } else |
814 | 812 | borders |= BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER; |
815 | 813 | |
816 | | // TODO: Why do we have to do this? |
| 814 | // DrawInactiveTab draws 2px border |
| 815 | // draw a little wider tab frame to align B_PLAIN_BORDER with it |
817 | 816 | if (fBorderStyle == B_PLAIN_BORDER) { |
818 | 817 | bounds.left -= 1; |
819 | 818 | bounds.right += 1; |
820 | 819 | } |
821 | 820 | |
822 | | // TODO: Doesn't draw bottom border, why? |
823 | 821 | be_control_look->DrawInactiveTab(this, bounds, bounds, base, 0, borders); |
824 | 822 | |
825 | 823 | // draw the tabs on top of the inactive tab bounds |
… |
… |
BTabView::DrawTabs()
|
847 | 845 | BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER); |
848 | 846 | } |
849 | 847 | |
850 | | // TODO: Why do we have to do this? |
851 | | // TODO: Why don't we have to do this for B_FANCY_BORDER? |
852 | | // TODO: Why does this draw the wrong color (152 instead of 151) |
853 | | if (fBorderStyle != B_FANCY_BORDER) { |
854 | | // draw the bottom border of the tabs |
855 | | rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); |
856 | | |
857 | | // draw the bottom border left of the active tab |
858 | | bounds = Bounds(); |
859 | | bounds.top = bounds.bottom = fTabHeight; |
860 | | bounds.right = activeTabFrame.left; |
861 | | be_control_look->DrawBorder(this, bounds, bounds, base, B_PLAIN_BORDER, |
862 | | 0, BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER); |
863 | | |
864 | | // draw the bottom border right of the active tab |
865 | | bounds = Bounds(); |
866 | | bounds.top = bounds.bottom = fTabHeight; |
867 | | bounds.left = activeTabFrame.right; |
868 | | be_control_look->DrawBorder(this, bounds, bounds, base, B_PLAIN_BORDER, |
869 | | 0, BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER); |
870 | | } |
871 | | |
872 | 848 | return fSelection < CountTabs() ? TabFrame(fSelection) : BRect(); |
873 | 849 | } |
874 | 850 | |
… |
… |
BTabView::DrawBox(BRect selectedTabRect)
|
880 | 856 | rect.top = fTabHeight; |
881 | 857 | |
882 | 858 | rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); |
883 | | if (fBorderStyle == B_FANCY_BORDER) |
884 | | be_control_look->DrawGroupFrame(this, rect, rect, base); |
885 | | else if (fBorderStyle == B_PLAIN_BORDER) { |
| 859 | if (fBorderStyle == B_FANCY_BORDER) { |
| 860 | be_control_look->DrawGroupFrame(this, rect, rect, base, |
| 861 | BControlLook::B_ALL_BORDERS & ~BControlLook::B_TOP_BORDER); |
| 862 | } else if (fBorderStyle == B_PLAIN_BORDER) { |
886 | 863 | be_control_look->DrawBorder(this, rect, rect, base, B_PLAIN_BORDER, |
887 | | 0, BControlLook::B_ALL_BORDERS); |
| 864 | 0, BControlLook::B_ALL_BORDERS & ~BControlLook::B_TOP_BORDER); |
888 | 865 | } else |
889 | 866 | ; // B_NO_BORDER draws no box |
890 | 867 | } |