mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
VST3 Host: Avoid inadvertent window growth for scaled views
This commit is contained in:
parent
7e87d3e7a6
commit
0e6a358c45
1 changed files with 27 additions and 7 deletions
|
|
@ -1606,8 +1606,12 @@ private:
|
|||
bool) override
|
||||
{
|
||||
auto rect = componentToVST3Rect (bounds);
|
||||
view->checkSizeConstraint (&rect);
|
||||
bounds = vst3ToComponentRect (rect);
|
||||
auto constrainedRect = rect;
|
||||
view->checkSizeConstraint (&constrainedRect);
|
||||
|
||||
// Prevent inadvertent window growth while dragging; see componentMovedOrResized below
|
||||
if (constrainedRect.getWidth() != rect.getWidth() || constrainedRect.getHeight() != rect.getHeight())
|
||||
bounds = vst3ToComponentRect (constrainedRect);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -1633,19 +1637,29 @@ private:
|
|||
|
||||
if (view->canResize() == kResultTrue)
|
||||
{
|
||||
auto rect = componentToVST3Rect (getLocalBounds());
|
||||
view->checkSizeConstraint (&rect);
|
||||
// componentToVST3Rect will apply DPI scaling and round to the nearest integer; vst3ToComponentRect
|
||||
// will invert the DPI scaling, but the logical size returned by vst3ToComponentRect may be
|
||||
// different from the original size due to floating point rounding if the scale factor is > 100%.
|
||||
// This can cause the window to unexpectedly grow while it's moving.
|
||||
auto scaledRect = componentToVST3Rect (getLocalBounds());
|
||||
|
||||
auto constrainedRect = scaledRect;
|
||||
view->checkSizeConstraint (&constrainedRect);
|
||||
|
||||
const auto tieRect = [] (const auto& x) { return std::tuple (x.getWidth(), x.getHeight()); };
|
||||
|
||||
// Only update the size if the constrained size is actually different
|
||||
if (tieRect (constrainedRect) != tieRect (scaledRect))
|
||||
{
|
||||
const ScopedValueSetter<bool> recursiveResizeSetter (recursiveResize, true);
|
||||
const ScopedValueSetter recursiveResizeSetter (recursiveResize, true);
|
||||
|
||||
const auto logicalSize = vst3ToComponentRect (rect);
|
||||
const auto logicalSize = vst3ToComponentRect (constrainedRect);
|
||||
setSize (logicalSize.getWidth(), logicalSize.getHeight());
|
||||
}
|
||||
|
||||
embeddedComponent.setBounds (getLocalBounds());
|
||||
|
||||
view->onSize (&rect);
|
||||
view->onSize (&constrainedRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1752,6 +1766,12 @@ private:
|
|||
attachedCalled = true;
|
||||
|
||||
updatePluginScale();
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
// Make sure the embedded component window is the right size
|
||||
// and invalidate the embedded HWND and any child windows
|
||||
embeddedComponent.updateHWNDBounds();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue