Ticket #13673: 0001-BTabView-cleanup-draw-function.patch

File 0001-BTabView-cleanup-draw-function.patch, 5.2 KB (added by KapiX, 7 years ago)
  • src/kits/interface/ControlLook.cpp

    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,  
    15701570    }
    15711571
    15721572    BRect background = rect;
    1573     uint32 bordersToDraw = 0;
    15741573    switch (side) {
    15751574        case B_TOP_BORDER:
    1576             bordersToDraw = (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
    15771575            rect.top += 4;
    15781576            background.bottom = rect.top;
    15791577            break;
    15801578        case B_BOTTOM_BORDER:
    1581             bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER);
    15821579            rect.bottom -= 4;
    15831580            background.top = rect.bottom;
    15841581            break;
    15851582        case B_LEFT_BORDER:
    1586             bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER);
    15871583            rect.left += 4;
    15881584            background.right = rect.left;
    15891585            break;
    15901586        case B_RIGHT_BORDER:
    1591             bordersToDraw = (B_RIGHT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER);
    15921587            rect.right -= 4;
    15931588            background.left = rect.right;
    15941589        break;
    BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,  
    16001595
    16011596    // frame and fill
    16021597    _DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
    1603         edgeLightColor, borders & bordersToDraw);
     1598        edgeLightColor, borders);
    16041599
    16051600    _DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
    1606         frameShadowColor, borders & bordersToDraw);
     1601        frameShadowColor, borders);
    16071602
    16081603    if (rect.IsValid()) {
    16091604        if (side == B_TOP_BORDER || side == B_BOTTOM_BORDER) {
  • src/kits/interface/TabView.cpp

    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)  
    274274        borders |= BControlLook::B_RIGHT_BORDER;
    275275
    276276    if (position == B_TAB_FRONT) {
    277         frame.bottom += 1.0f;
     277        frame.bottom -= 1.0f;
    278278        be_control_look->DrawActiveTab(owner, frame, frame, no_tint, 0,
    279279            borders);
    280280    } else {
    BTabView::FocusTab() const  
    789789void
    790790BTabView::Draw(BRect updateRect)
    791791{
    792     DrawBox(TabFrame(fSelection));
    793792    DrawTabs();
     793    DrawBox(TabFrame(fSelection));
    794794
    795795    if (IsFocus() && fFocus != -1)
    796796        TabAt(fFocus)->DrawFocusMark(this, TabFrame(fFocus));
    BTabView::Draw(BRect updateRect)  
    800800BRect
    801801BTabView::DrawTabs()
    802802{
    803     // TODO: Rewrite this method
    804 
    805803    // draw an inactive tab frame behind all tabs
    806804    BRect bounds(Bounds());
    807805    bounds.bottom = fTabHeight;
    BTabView::DrawTabs()  
    813811    } else
    814812        borders |= BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER;
    815813
    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
    817816    if (fBorderStyle == B_PLAIN_BORDER) {
    818817        bounds.left -= 1;
    819818        bounds.right += 1;
    820819    }
    821820
    822     // TODO: Doesn't draw bottom border, why?
    823821    be_control_look->DrawInactiveTab(this, bounds, bounds, base, 0, borders);
    824822
    825823    // draw the tabs on top of the inactive tab bounds
    BTabView::DrawTabs()  
    847845            BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER);
    848846    }
    849847
    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 
    872848    return fSelection < CountTabs() ? TabFrame(fSelection) : BRect();
    873849}
    874850
    BTabView::DrawBox(BRect selectedTabRect)  
    880856    rect.top = fTabHeight;
    881857
    882858    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) {
    886863        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);
    888865    } else
    889866        ; // B_NO_BORDER draws no box
    890867}