From 6f20778781492b124de90e5e0e5937ce6ab949e1 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 10 Dec 2014 13:50:19 +0100 Subject: [PATCH] ControlLook: fix DrawActiveTab with subpixel rectangle Fixes #4078. When font hinting is disabled, the width of a string may not be an integer number of pixels. This results in the tab position also being non-integer, and the drawing code doesn't handle this, resulting in part of the tab being shifted 1px to the right. Snap the rectangle to the pixel grid so the runding error doesn't happen. --- src/kits/interface/ControlLook.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index 52fb87dcdf..48e0e8342f 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -1344,6 +1344,12 @@ BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect, if (!rect.IsValid() || !rect.Intersects(updateRect)) return; + // Snap the rectangle to pixels to avoid rounding errors. + rect.left = floorf(rect.left); + rect.right = floorf(rect.right); + rect.top = floorf(rect.top); + rect.bottom = floorf(rect.bottom); + // save the clipping constraints of the view view->PushState();