mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
VST3 Host: Fix growing windows due to inaccurate coordinate operations
Prior to this commit we used the integral version of localAreaToGlobal before multiplying its result by the scale factor. This multiplied the rounding error of localAreaToGlobal<int> by the scale factor. Now we only round after all calculations have been carried out.
This commit is contained in:
parent
2c9b15e52c
commit
df024aaf3b
1 changed files with 5 additions and 2 deletions
|
|
@ -1637,14 +1637,17 @@ private:
|
|||
/* Convert from the component's coordinate system to the hosted VST3's coordinate system. */
|
||||
ViewRect componentToVST3Rect (Rectangle<int> r) const
|
||||
{
|
||||
const auto physical = localAreaToGlobal (r) * nativeScaleFactor * getDesktopScaleFactor();
|
||||
const auto combinedScale = nativeScaleFactor * getDesktopScaleFactor();
|
||||
const auto physical = (localAreaToGlobal (r.toFloat()) * combinedScale).toNearestInt();
|
||||
return { 0, 0, physical.getWidth(), physical.getHeight() };
|
||||
}
|
||||
|
||||
/* Convert from the hosted VST3's coordinate system to the component's coordinate system. */
|
||||
Rectangle<int> vst3ToComponentRect (const ViewRect& vr) const
|
||||
{
|
||||
return getLocalArea (nullptr, Rectangle<int> { vr.right, vr.bottom } / (nativeScaleFactor * getDesktopScaleFactor()));
|
||||
const auto combinedScale = nativeScaleFactor * getDesktopScaleFactor();
|
||||
const auto floatRect = Rectangle { (float) vr.right, (float) vr.bottom } / combinedScale;
|
||||
return getLocalArea (nullptr, floatRect).toNearestInt();
|
||||
}
|
||||
|
||||
void componentMovedOrResized (bool, bool wasResized) override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue