1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

AAX: Resize host window correctly when global scale != 1

This commit is contained in:
ed 2020-05-29 09:46:10 +01:00
parent 889f3baa70
commit 351c5142e5

View file

@ -497,8 +497,9 @@ namespace AAXClasses
{
if (component != nullptr)
{
viewSize->horz = (float) component->getWidth();
viewSize->vert = (float) component->getHeight();
*viewSize = convertToHostBounds ({ (float) component->getHeight(),
(float) component->getWidth() });
return AAX_SUCCESS;
}
@ -553,6 +554,18 @@ namespace AAXClasses
int getParamIndexFromID (AAX_CParamID paramID) const noexcept;
AAX_CParamID getAAXParamIDFromJuceIndex (int index) const noexcept;
//==============================================================================
static AAX_Point convertToHostBounds (AAX_Point pluginSize)
{
auto desktopScale = Desktop::getInstance().getGlobalScaleFactor();
if (approximatelyEqual (desktopScale, 1.0f))
return pluginSize;
return { pluginSize.vert * desktopScale,
pluginSize.horz * desktopScale };
}
//==============================================================================
struct ContentWrapperComponent : public Component
{
@ -611,26 +624,39 @@ namespace AAXClasses
void mouseUp (const MouseEvent& e) override { callMouseMethod (e, &AAX_IViewContainer::HandleParameterMouseUp); }
void mouseDrag (const MouseEvent& e) override { callMouseMethod (e, &AAX_IViewContainer::HandleParameterMouseDrag); }
void parentSizeChanged() override
{
resizeHostWindow();
if (pluginEditor != nullptr)
pluginEditor->repaint();
}
void childBoundsChanged (Component*) override
{
if (resizeHostWindow())
{
setSize (pluginEditor->getWidth(), pluginEditor->getHeight());
lastValidSize = getBounds();
}
else
{
pluginEditor->setBoundsConstrained (pluginEditor->getBounds().withSize (lastValidSize.getWidth(),
lastValidSize.getHeight()));
}
}
bool resizeHostWindow()
{
if (pluginEditor != nullptr)
{
auto w = pluginEditor->getWidth();
auto h = pluginEditor->getHeight();
auto newSize = convertToHostBounds ({ (float) pluginEditor->getHeight(),
(float) pluginEditor->getWidth() });
AAX_Point newSize ((float) h, (float) w);
if (owner.GetViewContainer()->SetViewSize (newSize) == AAX_SUCCESS)
{
setSize (w, h);
lastValidSize = getBounds();
}
else
{
auto validSize = pluginEditor->getBounds().withSize (lastValidSize.getWidth(), lastValidSize.getHeight());
pluginEditor->setBoundsConstrained (validSize);
}
return owner.GetViewContainer()->SetViewSize (newSize) == AAX_SUCCESS;
}
return false;
}
std::unique_ptr<AudioProcessorEditor> pluginEditor;