Ticket #7330: ControlLook_patch.diff

File ControlLook_patch.diff, 9.6 KB (added by KapiX, 7 years ago)
  • src/kits/interface/ControlLook.cpp

    diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp
    index 642d300..e99e2d5 100644
    a b BControlLook::DrawSliderHashMarks(BView* view, BRect& rect,  
    13551355
    13561356void
    13571357BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
    1358     const rgb_color& base, uint32 flags, uint32 borders)
     1358    const rgb_color& base, uint32 flags, uint32 borders, uint32 orientation)
    13591359{
    13601360    if (!rect.IsValid() || !rect.Intersects(updateRect))
    13611361        return;
    BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,  
    14051405
    14061406    static const float kRoundCornerRadius = 4.0f;
    14071407
    1408     // left top corner dimensions
    1409     BRect leftTopCorner(rect);
    1410     leftTopCorner.right = floorf(leftTopCorner.left + kRoundCornerRadius);
    1411     leftTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
    1412     clipping.Exclude(leftTopCorner);
    1413 
    1414     // draw the left top corner
    1415     _DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
    1416         edgeShadowColor, frameLightColor, bevelLightColor,
    1417         fillGradient);
    1418 
    1419     // right top corner dimensions
    1420     BRect rightTopCorner(rect);
    1421     rightTopCorner.right = floorf(rect.right);
    1422     rightTopCorner.left = floorf(rightTopCorner.right - kRoundCornerRadius);
    1423     rightTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
    1424     clipping.Exclude(rightTopCorner);
    1425 
    1426     // draw the right top corner
    1427     _DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
    1428         edgeShadowColor, edgeLightColor, frameLightColor,
    1429         frameShadowColor, bevelLightColor, bevelShadowColor,
    1430         fillGradient);
     1408    if(orientation == 0) {
     1409        // left top corner dimensions
     1410        BRect leftTopCorner(rect);
     1411        leftTopCorner.right = floorf(leftTopCorner.left + kRoundCornerRadius);
     1412        leftTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
     1413        clipping.Exclude(leftTopCorner);
     1414
     1415        // draw the left top corner
     1416        _DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
     1417            edgeShadowColor, frameLightColor, bevelLightColor,
     1418            fillGradient);
     1419
     1420        // right top corner dimensions
     1421        BRect rightTopCorner(rect);
     1422        rightTopCorner.right = floorf(rect.right);
     1423        rightTopCorner.left = floorf(rightTopCorner.right - kRoundCornerRadius);
     1424        rightTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
     1425        clipping.Exclude(rightTopCorner);
     1426
     1427        // draw the right top corner
     1428        _DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
     1429            edgeShadowColor, edgeLightColor, frameLightColor,
     1430            frameShadowColor, bevelLightColor, bevelShadowColor,
     1431            fillGradient);
     1432    } else if(orientation == 1) {
     1433        // left bottom corner dimensions
     1434        BRect leftBottomCorner(rect);
     1435        leftBottomCorner.right = floorf(leftBottomCorner.left + kRoundCornerRadius);
     1436        leftBottomCorner.top = floorf(rect.bottom - kRoundCornerRadius);
     1437        clipping.Exclude(leftBottomCorner);
     1438
     1439        // draw the left top corner
     1440        _DrawRoundCornerLeftBottom(view, leftBottomCorner, updateRect, base,
     1441            edgeShadowColor, edgeLightColor, frameLightColor,
     1442            frameShadowColor, bevelLightColor, bevelShadowColor,
     1443            fillGradient);
     1444
     1445        // right top corner dimensions
     1446        BRect rightBottomCorner(rect);
     1447        rightBottomCorner.right = floorf(rect.right);
     1448        rightBottomCorner.left = floorf(rightBottomCorner.right - kRoundCornerRadius);
     1449        rightBottomCorner.top = floorf(rect.bottom - kRoundCornerRadius);
     1450        clipping.Exclude(rightBottomCorner);
     1451
     1452        // draw the right top corner
     1453        _DrawRoundCornerRightBottom(view, rightBottomCorner, updateRect, base,
     1454            edgeLightColor, frameShadowColor, bevelShadowColor,
     1455            fillGradient);
     1456    } else if(orientation == 2) {
     1457        // left top corner dimensions
     1458        BRect leftTopCorner(rect);
     1459        leftTopCorner.right = floorf(leftTopCorner.left + kRoundCornerRadius);
     1460        leftTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
     1461        clipping.Exclude(leftTopCorner);
     1462
     1463        // draw the left top corner
     1464        _DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
     1465            edgeShadowColor, frameLightColor, bevelLightColor,
     1466            fillGradient);
     1467
     1468        // left bottom corner dimensions
     1469        BRect leftBottomCorner(rect);
     1470        leftBottomCorner.right = floorf(leftBottomCorner.left + kRoundCornerRadius);
     1471        leftBottomCorner.top = floorf(rect.bottom - kRoundCornerRadius);
     1472        clipping.Exclude(leftBottomCorner);
     1473
     1474        // draw the left top corner
     1475        _DrawRoundCornerLeftBottom(view, leftBottomCorner, updateRect, base,
     1476            edgeShadowColor, edgeLightColor, frameLightColor,
     1477            frameShadowColor, bevelLightColor, bevelShadowColor,
     1478            fillGradient);
     1479    } else if(orientation == 3) {
     1480        // right top corner dimensions
     1481        BRect rightTopCorner(rect);
     1482        rightTopCorner.right = floorf(rect.right);
     1483        rightTopCorner.left = floorf(rightTopCorner.right - kRoundCornerRadius);
     1484        rightTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
     1485        clipping.Exclude(rightTopCorner);
     1486
     1487        // draw the right top corner
     1488        _DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
     1489            edgeShadowColor, edgeLightColor, frameLightColor,
     1490            frameShadowColor, bevelLightColor, bevelShadowColor,
     1491            fillGradient);
     1492
     1493        // right top corner dimensions
     1494        BRect rightBottomCorner(rect);
     1495        rightBottomCorner.right = floorf(rect.right);
     1496        rightBottomCorner.left = floorf(rightBottomCorner.right - kRoundCornerRadius);
     1497        rightBottomCorner.top = floorf(rect.bottom - kRoundCornerRadius);
     1498        clipping.Exclude(rightBottomCorner);
     1499
     1500        // draw the right top corner
     1501        _DrawRoundCornerRightBottom(view, rightBottomCorner, updateRect, base,
     1502            edgeLightColor, frameShadowColor, bevelShadowColor,
     1503            fillGradient);
     1504    }
    14311505
    14321506    // clip out the corners
    14331507    view->ConstrainClippingRegion(&clipping);
     1508   
     1509    uint32 bordersToDraw = 0;
     1510    if(orientation == 0) {
     1511        bordersToDraw = (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
     1512    } else if(orientation == 1) {
     1513        bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER);
     1514    } else if(orientation == 2) { // left
     1515        bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER);
     1516    } else if(orientation == 3) { // right
     1517        bordersToDraw = (B_RIGHT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER);
     1518    }
    14341519
    14351520    // draw the rest of frame and fill
    14361521    _DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
    14371522        edgeLightColor,
    1438         borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
    1439     if ((borders & B_LEFT_BORDER) == 0)
    1440         rect.left++;
    1441     if ((borders & B_RIGHT_BORDER) == 0)
    1442         rect.right--;
     1523        borders & bordersToDraw);
     1524    if(orientation == 0 || orientation == 1) {
     1525        if ((borders & B_LEFT_BORDER) == 0)
     1526            rect.left++;
     1527        if ((borders & B_RIGHT_BORDER) == 0)
     1528            rect.right--;
     1529    } else {
     1530        if ((borders & B_TOP_BORDER) == 0)
     1531            rect.top++;
     1532        if ((borders & B_BOTTOM_BORDER) == 0)
     1533            rect.bottom--;
     1534    }
    14431535
    14441536    _DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
    1445         frameShadowColor, B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
     1537        frameShadowColor, bordersToDraw);
    14461538
    14471539    _DrawFrame(view, rect, bevelLightColor, bevelLightColor, bevelShadowColor,
    14481540        bevelShadowColor);
    BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,  
    14561548
    14571549void
    14581550BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
    1459     const rgb_color& base, uint32 flags, uint32 borders)
     1551    const rgb_color& base, uint32 flags, uint32 borders, uint32 orientation)
    14601552{
    14611553    if (!rect.IsValid() || !rect.Intersects(updateRect))
    14621554        return;
    BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,  
    14911583        fillGradient.AddColor(tint_color(base, 1.08), 255);
    14921584    }
    14931585
     1586    uint32 bordersToDraw = 0;
     1587    if(orientation == 0) {
     1588        bordersToDraw = (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
     1589        rect.top += 4;
     1590    } else if(orientation == 1) {
     1591        bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER);
     1592        rect.bottom -= 4;
     1593    } else if(orientation == 2) { // left
     1594        bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER);
     1595        rect.left += 4;
     1596    } else if(orientation == 3) { // right
     1597        bordersToDraw = (B_RIGHT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER);
     1598        rect.right -= 4;
     1599    }
     1600   
    14941601    // active tabs stand out at the top, but this is an inactive tab
    14951602    view->SetHighColor(base);
    1496     view->FillRect(BRect(rect.left, rect.top, rect.right, rect.top + 4));
    1497     rect.top += 4;
     1603    view->FillRect(rect);
    14981604
    14991605    // frame and fill
    15001606    _DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
    15011607        edgeLightColor,
    1502         borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
     1608        borders & bordersToDraw);
    15031609
    15041610    _DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
    15051611        frameShadowColor,
    1506         borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
     1612        borders & bordersToDraw);
    15071613
    15081614    if (rect.IsValid()) {
    1509         _DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
    1510             bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
     1615        if(orientation == 0 || orientation == 1) {
     1616            _DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
     1617                bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
     1618        } else {
     1619            _DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
     1620                bevelLightColor, bevelLightColor, B_TOP_BORDER & ~borders);
     1621        }
    15111622    } else {
    1512         if ((B_LEFT_BORDER & ~borders) != 0)
    1513             rect.left++;
     1623        if(orientation == 0 || orientation == 1) {
     1624            if ((B_LEFT_BORDER & ~borders) != 0)
     1625                rect.left++;
     1626        } else {
     1627            if ((B_TOP_BORDER & ~borders) != 0)
     1628                rect.top++;
     1629        }
    15141630    }
    15151631
    15161632    view->FillRect(rect, fillGradient);
    BControlLook::_DrawRoundCornerFrameRightBottom(BView* view, BRect& cornerRect,  
    31643280    // frame
    31653281    ellipseRect.InsetBy(1, 1);
    31663282    cornerRect.right--;
    3167     cornerRect.bottom++;
     3283    cornerRect.bottom--;
    31683284    view->SetHighColor(frameColor);
    31693285    view->FillEllipse(ellipseRect);
    31703286
    31713287    // prepare for bevel
    3172     cornerRect.left++;
     3288    cornerRect.right--;
    31733289    cornerRect.bottom--;
    31743290}
    31753291