Ticket #7330: ControlLook_patch.diff
File ControlLook_patch.diff, 9.6 KB (added by , 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, 1355 1355 1356 1356 void 1357 1357 BControlLook::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) 1359 1359 { 1360 1360 if (!rect.IsValid() || !rect.Intersects(updateRect)) 1361 1361 return; … … BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect, 1405 1405 1406 1406 static const float kRoundCornerRadius = 4.0f; 1407 1407 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 } 1431 1505 1432 1506 // clip out the corners 1433 1507 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 } 1434 1519 1435 1520 // draw the rest of frame and fill 1436 1521 _DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor, 1437 1522 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 } 1443 1535 1444 1536 _DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor, 1445 frameShadowColor, B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);1537 frameShadowColor, bordersToDraw); 1446 1538 1447 1539 _DrawFrame(view, rect, bevelLightColor, bevelLightColor, bevelShadowColor, 1448 1540 bevelShadowColor); … … BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect, 1456 1548 1457 1549 void 1458 1550 BControlLook::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) 1460 1552 { 1461 1553 if (!rect.IsValid() || !rect.Intersects(updateRect)) 1462 1554 return; … … BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect, 1491 1583 fillGradient.AddColor(tint_color(base, 1.08), 255); 1492 1584 } 1493 1585 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 1494 1601 // active tabs stand out at the top, but this is an inactive tab 1495 1602 view->SetHighColor(base); 1496 view->FillRect(BRect(rect.left, rect.top, rect.right, rect.top + 4)); 1497 rect.top += 4; 1603 view->FillRect(rect); 1498 1604 1499 1605 // frame and fill 1500 1606 _DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor, 1501 1607 edgeLightColor, 1502 borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));1608 borders & bordersToDraw); 1503 1609 1504 1610 _DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor, 1505 1611 frameShadowColor, 1506 borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));1612 borders & bordersToDraw); 1507 1613 1508 1614 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 } 1511 1622 } 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 } 1514 1630 } 1515 1631 1516 1632 view->FillRect(rect, fillGradient); … … BControlLook::_DrawRoundCornerFrameRightBottom(BView* view, BRect& cornerRect, 3164 3280 // frame 3165 3281 ellipseRect.InsetBy(1, 1); 3166 3282 cornerRect.right--; 3167 cornerRect.bottom ++;3283 cornerRect.bottom--; 3168 3284 view->SetHighColor(frameColor); 3169 3285 view->FillEllipse(ellipseRect); 3170 3286 3171 3287 // prepare for bevel 3172 cornerRect. left++;3288 cornerRect.right--; 3173 3289 cornerRect.bottom--; 3174 3290 } 3175 3291