GUI glitches with fractional zoom-factors

reproducible in:

VST SDK 3.7 with VSTGUI 4.9:
VST SDK 3.6.9 with VSTGUI 4.6:

setZoomFactor:

When a fractional factor like 1.5 or 1.75 is used wrong pixels can appear around the borders of a CAnimKnob

I am not the only one who experienced this. This hack of the VSTGUI did fix it for me

https://gitmemory.com/issue/steinbergmedia/vstgui/133/648696050

diff --git a/vstgui/lib/cframe.cpp b/vstgui/lib/cframe.cpp
index 1448f527…faf8d37a 100644
— a/vstgui/lib/cframe.cpp
+++ b/vstgui/lib/cframe.cpp
@@ -1410,7 +1410,7 @@ void CFrame::invalidRect (const CRect& rect)

CRect _rect (rect);
getTransform ().transform (_rect);

  •   _rect.makeIntegral ();
    
  •   _rect.makeIntegralOnlyExpanding ();
    

if (pImpl->collectInvalidRects)
pImpl->collectInvalidRects->addRect (_rect);
else
diff --git a/vstgui/lib/crect.h b/vstgui/lib/crect.h
index 333751eb…33568aee 100644
— a/vstgui/lib/crect.h
+++ b/vstgui/lib/crect.h
@@ -68,6 +68,7 @@ struct CRect
/** moves this rect to the center of r */
inline CRect& centerInside (const CRect& r);
inline CRect& makeIntegral ();

  • inline CRect& makeIntegralOnlyExpanding ();

CCoord left {0.};
CCoord top {0.};
@@ -272,6 +273,17 @@ inline CRect& CRect::makeIntegral ()
return *this;
}

+// this will give you a rectangle which is integral, but also is outside the given input
+inline CRect& CRect::makeIntegralOnlyExpanding()
+{

  •   left = std::floor (left);
    
  •   right = std::ceil (right);
    
  •   top = std::floor (top);
    
  •   bottom = std::ceil (bottom);
    
  •   return *this;
    

+}
+
+

and already fixed on the develop branch of vstgui:
https://github.com/steinbergmedia/vstgui/commit/094bab1a11962a9230331f410ef5c429cc16256c

Thank you Arne. I assumed that the VST SDK 3.7 (August 2020) would have already included the fixes from the older VSTGUI 4.9 (December 2019).

Editing crect.h in your way did fix the problem.

inline CRect& CRect::makeIntegral ()
{
left = std::floor (left);
right = std::ceil (right);
top = std::floor (top);
bottom = std::ceil (bottom);
return *this;
}