From 8359b407ffcb4094c508f5b2dd0ad27e0af322a1 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 13 Mar 2015 19:47:59 -0400 Subject: [PATCH] CheckBox: Center the check mark again See 46b39e83 Changed rounding behavior for StrokeLine. This effectively undoes the change in rounding behavior from that commit. --- src/kits/interface/ControlLook.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index 3e6c4ccb15..9f329a4c84 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -486,10 +486,22 @@ BControlLook::DrawCheckBox(BView* view, BRect& rect, const BRect& updateRect, if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) { view->SetHighColor(markColor); - rect.InsetBy(2, 2); - view->SetPenSize(std::max(1.0f, ceilf(rect.Width() / 3.5))); - view->SetDrawingMode(B_OP_OVER); + BFont font; + view->GetFont(&font); + float inset = std::max(2.0f, roundf(font.Size() / 6)); + rect.InsetBy(inset, inset); + float penSize = std::max(1.0f, ceilf(rect.Width() / 3.5f)); + if (penSize > 1.0f && fmodf(penSize, 2.0f) == 0.0f) { + // Tweak ends to "include" the pixel at the index, + // we need to do this in order to produce results like R5, + // where coordinates were inclusive + rect.right++; + rect.bottom++; + } + + view->SetPenSize(penSize); + view->SetDrawingMode(B_OP_OVER); view->StrokeLine(rect.LeftTop(), rect.RightBottom()); view->StrokeLine(rect.LeftBottom(), rect.RightTop()); }