mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
AudioPluginHost: Added an application-level setting for scaling plug-ins on Windows
This commit is contained in:
parent
b1253bfc74
commit
3a0af69eff
8 changed files with 233 additions and 75 deletions
|
|
@ -29,6 +29,11 @@
|
|||
#include "InternalPlugins.h"
|
||||
#include "../UI/GraphEditorPanel.h"
|
||||
|
||||
static std::unique_ptr<ScopedDPIAwarenessDisabler> makeDPIAwarenessDisablerForPlugin (StringRef identifier)
|
||||
{
|
||||
return shouldAutoScalePlugin (identifier) ? std::make_unique<ScopedDPIAwarenessDisabler>()
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
PluginGraph::PluginGraph (AudioPluginFormatManager& fm)
|
||||
|
|
@ -76,10 +81,12 @@ AudioProcessorGraph::Node::Ptr PluginGraph::getNodeForName (const String& name)
|
|||
|
||||
void PluginGraph::addPlugin (const PluginDescription& desc, Point<double> pos)
|
||||
{
|
||||
std::shared_ptr<ScopedDPIAwarenessDisabler> dpiDisabler = makeDPIAwarenessDisablerForPlugin (desc.fileOrIdentifier);
|
||||
|
||||
formatManager.createPluginInstanceAsync (desc,
|
||||
graph.getSampleRate(),
|
||||
graph.getBlockSize(),
|
||||
[this, pos] (std::unique_ptr<AudioPluginInstance> instance, const String& error)
|
||||
[this, pos, dpiDisabler] (std::unique_ptr<AudioPluginInstance> instance, const String& error)
|
||||
{
|
||||
addPluginCallback (std::move (instance), error, pos);
|
||||
});
|
||||
|
|
@ -156,18 +163,10 @@ PluginWindow* PluginGraph::getOrCreateWindowFor (AudioProcessorGraph::Node* node
|
|||
getCommandManager().invokeDirectly (CommandIDs::showAudioSettings, false);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE
|
||||
if (! node->properties["DPIAware"]
|
||||
&& ! node->getProcessor()->getName().contains ("Kontakt")) // Kontakt doesn't behave correctly in DPI unaware mode...
|
||||
{
|
||||
ScopedDPIAwarenessDisabler disableDPIAwareness;
|
||||
auto localDpiDisabler = makeDPIAwarenessDisablerForPlugin (description.fileOrIdentifier);
|
||||
return activePluginWindows.add (new PluginWindow (node, type, activePluginWindows));
|
||||
}
|
||||
#endif
|
||||
|
||||
return activePluginWindows.add (new PluginWindow (node, type, activePluginWindows));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
@ -332,9 +331,6 @@ static XmlElement* createNodeXml (AudioProcessorGraph::Node* const node) noexcep
|
|||
e->setAttribute ("uid", (int) node->nodeID.uid);
|
||||
e->setAttribute ("x", node->properties ["x"].toString());
|
||||
e->setAttribute ("y", node->properties ["y"].toString());
|
||||
#if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE
|
||||
e->setAttribute ("DPIAware", node->properties["DPIAware"].toString());
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < (int) PluginWindow::Type::numTypes; ++i)
|
||||
{
|
||||
|
|
@ -383,10 +379,16 @@ void PluginGraph::createNodeFromXml (const XmlElement& xml)
|
|||
break;
|
||||
}
|
||||
|
||||
String errorMessage;
|
||||
auto createInstance = [this, pd]
|
||||
{
|
||||
String errorMessage;
|
||||
|
||||
if (auto instance = formatManager.createPluginInstance (pd, graph.getSampleRate(),
|
||||
graph.getBlockSize(), errorMessage))
|
||||
auto localDpiDisabler = makeDPIAwarenessDisablerForPlugin (pd.fileOrIdentifier);
|
||||
return formatManager.createPluginInstance (pd, graph.getSampleRate(),
|
||||
graph.getBlockSize(), errorMessage);
|
||||
};
|
||||
|
||||
if (auto instance = createInstance())
|
||||
{
|
||||
if (auto* layoutEntity = xml.getChildByName ("LAYOUT"))
|
||||
{
|
||||
|
|
@ -408,11 +410,8 @@ void PluginGraph::createNodeFromXml (const XmlElement& xml)
|
|||
node->getProcessor()->setStateInformation (m.getData(), (int) m.getSize());
|
||||
}
|
||||
|
||||
node->properties.set ("x", xml.getDoubleAttribute ("x"));
|
||||
node->properties.set ("y", xml.getDoubleAttribute ("y"));
|
||||
#if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE
|
||||
node->properties.set ("DPIAware", xml.getDoubleAttribute ("DPIAware"));
|
||||
#endif
|
||||
node->properties.set ("x", xml.getDoubleAttribute ("x"));
|
||||
node->properties.set ("y", xml.getDoubleAttribute ("y"));
|
||||
|
||||
for (int i = 0; i < (int) PluginWindow::Type::numTypes; ++i)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue