адаптация s13bby/osc под vst и gui. (вайбкод)
вайбкод потому что мне в моменте стало понятно. что проще было сразу писать на фреймворке JUCE, чем адаптировать консольное приложение на MiniAudio. обновляться данный репозиторий не будет. СmakeLists адаптирован онли под linux.
This commit is contained in:
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
// The following checks should cause a compile error if you've forgotten to
|
||||
// define all your plugin settings properly.
|
||||
|
||||
#if ! (JucePlugin_Build_VST || JucePlugin_Build_VST3 \
|
||||
|| JucePlugin_Build_AU || JucePlugin_Build_AUv3 \
|
||||
|| JucePlugin_Build_AAX || JucePlugin_Build_Standalone \
|
||||
|| JucePlugin_Build_LV2 || JucePlugin_Build_Unity)
|
||||
#error "You need to enable at least one plugin format!"
|
||||
#endif
|
||||
|
||||
#ifdef JUCE_CHECKSETTINGMACROS_H
|
||||
#error "This header should never be included twice! Otherwise something is wrong."
|
||||
#endif
|
||||
#define JUCE_CHECKSETTINGMACROS_H
|
||||
|
||||
#ifndef JucePlugin_IsSynth
|
||||
#error "You need to define the JucePlugin_IsSynth value!"
|
||||
#endif
|
||||
|
||||
#ifndef JucePlugin_ManufacturerCode
|
||||
#error "You need to define the JucePlugin_ManufacturerCode value!"
|
||||
#endif
|
||||
|
||||
#ifndef JucePlugin_PluginCode
|
||||
#error "You need to define the JucePlugin_PluginCode value!"
|
||||
#endif
|
||||
|
||||
#ifndef JucePlugin_ProducesMidiOutput
|
||||
#error "You need to define the JucePlugin_ProducesMidiOutput value!"
|
||||
#endif
|
||||
|
||||
#ifndef JucePlugin_WantsMidiInput
|
||||
#error "You need to define the JucePlugin_WantsMidiInput value!"
|
||||
#endif
|
||||
|
||||
#ifdef JucePlugin_Latency
|
||||
#error "JucePlugin_Latency is now deprecated - instead, call the AudioProcessor::setLatencySamples() method if your plugin has a non-zero delay"
|
||||
#endif
|
||||
|
||||
#ifndef JucePlugin_EditorRequiresKeyboardFocus
|
||||
#error "You need to define the JucePlugin_EditorRequiresKeyboardFocus value!"
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if JucePlugin_Build_AAX && ! defined (JucePlugin_AAXIdentifier)
|
||||
#error "You need to define the JucePlugin_AAXIdentifier value!"
|
||||
#endif
|
||||
|
||||
#if defined (__ppc__)
|
||||
#undef JucePlugin_Build_AAX
|
||||
#define JucePlugin_Build_AAX 0
|
||||
#endif
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
inline std::unique_ptr<AudioProcessor> createPluginFilterOfType (AudioProcessor::WrapperType type)
|
||||
{
|
||||
PluginHostType::jucePlugInClientCurrentWrapperType = type;
|
||||
AudioProcessor::setTypeOfNextNewPlugin (type);
|
||||
auto pluginInstance = rawToUniquePtr (::createPluginFilter());
|
||||
AudioProcessor::setTypeOfNextNewPlugin (AudioProcessor::wrapperType_Undefined);
|
||||
|
||||
// your createPluginFilter() method must return an object!
|
||||
jassert (pluginInstance != nullptr && pluginInstance->wrapperType == type);
|
||||
|
||||
#if JucePlugin_Enable_ARA
|
||||
jassert (pluginInstance->getARAClientExtensions() != nullptr);
|
||||
#endif
|
||||
|
||||
return pluginInstance;
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <juce_audio_plugin_client/juce_audio_plugin_client.h>
|
||||
#include <juce_audio_processors/juce_audio_processors.h>
|
||||
|
||||
#define Component juce::Component
|
||||
|
||||
#if JUCE_MAC
|
||||
#define Point juce::Point
|
||||
#endif
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT _WIN32_WINNT_WIN10
|
||||
#undef STRICT
|
||||
#define STRICT 1
|
||||
#include <windows.h>
|
||||
#include <float.h>
|
||||
#if JUCE_MSVC
|
||||
#pragma warning (disable : 4312 4355)
|
||||
#endif
|
||||
#ifdef __INTEL_COMPILER
|
||||
#pragma warning (disable : 1899)
|
||||
#endif
|
||||
#elif JUCE_LINUX || JUCE_BSD
|
||||
#include <float.h>
|
||||
#include <sys/time.h>
|
||||
#include <arpa/inet.h>
|
||||
#elif JUCE_MAC || JUCE_IOS
|
||||
#ifdef __OBJC__
|
||||
#if JUCE_MAC
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#elif JUCE_IOS
|
||||
#include <UIKit/UIKit.h>
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <objc/runtime.h>
|
||||
#include <objc/objc.h>
|
||||
#include <objc/message.h>
|
||||
#endif
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#if JUCE_LINUX || JUCE_BSD
|
||||
|
||||
namespace juce::detail
|
||||
{
|
||||
|
||||
// Implemented in juce_Messaging_linux.cpp
|
||||
bool dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages);
|
||||
|
||||
class MessageThread : public Thread
|
||||
{
|
||||
public:
|
||||
MessageThread() : Thread (SystemStats::getJUCEVersion() + ": Plugin Message Thread")
|
||||
{
|
||||
start();
|
||||
}
|
||||
|
||||
~MessageThread() override
|
||||
{
|
||||
MessageManager::getInstance()->stopDispatchLoop();
|
||||
stop();
|
||||
}
|
||||
|
||||
void start()
|
||||
{
|
||||
startThread (Priority::high);
|
||||
|
||||
// Wait for setCurrentThreadAsMessageThread() and getInstance to be executed
|
||||
// before leaving this method
|
||||
threadInitialised.wait (10000);
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
signalThreadShouldExit();
|
||||
stopThread (-1);
|
||||
}
|
||||
|
||||
bool isRunning() const noexcept { return isThreadRunning(); }
|
||||
|
||||
void run() override
|
||||
{
|
||||
MessageManager::getInstance()->setCurrentThreadAsMessageThread();
|
||||
XWindowSystem::getInstance();
|
||||
|
||||
threadInitialised.signal();
|
||||
|
||||
while (! threadShouldExit())
|
||||
{
|
||||
if (! dispatchNextMessageOnSystemQueue (true))
|
||||
Thread::sleep (1);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
WaitableEvent threadInitialised;
|
||||
JUCE_DECLARE_NON_MOVEABLE (MessageThread)
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MessageThread)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class HostDrivenEventLoop
|
||||
{
|
||||
public:
|
||||
HostDrivenEventLoop()
|
||||
{
|
||||
messageThread->stop();
|
||||
MessageManager::getInstance()->setCurrentThreadAsMessageThread();
|
||||
}
|
||||
|
||||
void processPendingEvents()
|
||||
{
|
||||
MessageManager::getInstance()->setCurrentThreadAsMessageThread();
|
||||
|
||||
for (;;)
|
||||
if (! dispatchNextMessageOnSystemQueue (true))
|
||||
return;
|
||||
}
|
||||
|
||||
~HostDrivenEventLoop()
|
||||
{
|
||||
messageThread->start();
|
||||
}
|
||||
|
||||
private:
|
||||
SharedResourcePointer<MessageThread> messageThread;
|
||||
};
|
||||
|
||||
} // namespace juce::detail
|
||||
|
||||
#endif
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace juce::detail
|
||||
{
|
||||
|
||||
/** Keeps track of scale factors specified by the host and/or queried by the
|
||||
the plugin.
|
||||
*/
|
||||
class StoredScaleFactor
|
||||
{
|
||||
public:
|
||||
/** Sets a scale factor that originated from the host.
|
||||
This scale will take precedence over other scale factors.
|
||||
*/
|
||||
StoredScaleFactor withHost (float x) const { return withMember (*this, &StoredScaleFactor::host, x); }
|
||||
|
||||
/** Sets a scale factor that originated from the plugin.
|
||||
This scale will only be used if there's no host-provided scale.
|
||||
Defaults to 1.0f.
|
||||
*/
|
||||
StoredScaleFactor withInternal (float x) const { return withMember (*this, &StoredScaleFactor::internal, x); }
|
||||
|
||||
/** Returns the host-provided scale, if any, or the internal scale otherwise. */
|
||||
float get() const { return host.value_or (internal); }
|
||||
|
||||
/** Returns true if this object holds a host-originated scale, or false otherwise. */
|
||||
bool isHostScale() const { return host.has_value(); }
|
||||
|
||||
private:
|
||||
std::optional<float> host;
|
||||
float internal = 1.0f;
|
||||
};
|
||||
|
||||
class PluginScaleFactorManagerListener
|
||||
{
|
||||
public:
|
||||
virtual ~PluginScaleFactorManagerListener() = default;
|
||||
virtual void peerBoundsDidUpdate() = 0;
|
||||
};
|
||||
|
||||
class PluginScaleFactorManager : private Timer,
|
||||
private ComponentListener
|
||||
{
|
||||
public:
|
||||
~PluginScaleFactorManager() override
|
||||
{
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
void startObserving (Component& comp)
|
||||
{
|
||||
observed = ∁
|
||||
observed->addComponentListener (this);
|
||||
applyScaleFactor (scale);
|
||||
|
||||
#if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE
|
||||
if (! scale.isHostScale())
|
||||
startTimer (500);
|
||||
#endif
|
||||
}
|
||||
|
||||
void stopObserving ([[maybe_unused]] Component& comp)
|
||||
{
|
||||
stopTimer();
|
||||
jassert (&comp == observed.getComponent());
|
||||
observed->removeComponentListener (this);
|
||||
observed = nullptr;
|
||||
}
|
||||
|
||||
void addListener (PluginScaleFactorManagerListener& l)
|
||||
{
|
||||
listeners.add (&l);
|
||||
}
|
||||
|
||||
void removeListener (PluginScaleFactorManagerListener& l)
|
||||
{
|
||||
listeners.remove (&l);
|
||||
}
|
||||
|
||||
void setHostScale (float x)
|
||||
{
|
||||
stopTimer();
|
||||
applyScaleFactor (scale.withHost (x));
|
||||
}
|
||||
|
||||
std::optional<float> getHostScale() const
|
||||
{
|
||||
return scale.isHostScale() ? std::optional (scale.get()) : std::nullopt;
|
||||
}
|
||||
|
||||
Rectangle<int> convertToHostBounds (Rectangle<float> pluginRect) const
|
||||
{
|
||||
jassert (observed != nullptr);
|
||||
return (observed->localAreaToGlobal (pluginRect) * getPlatformAndDesktopScale()).withZeroOrigin().toNearestIntEdges();
|
||||
}
|
||||
|
||||
Rectangle<float> convertFromHostBounds (Rectangle<int> hostViewRect) const
|
||||
{
|
||||
jassert (observed != nullptr);
|
||||
return observed->getLocalArea (nullptr, hostViewRect.toFloat() / getPlatformAndDesktopScale()).withZeroOrigin();
|
||||
}
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
static double getScaleFactorForWindow (HWND h)
|
||||
{
|
||||
return (double) GetDpiForWindow (h) / USER_DEFAULT_SCREEN_DPI;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
void componentParentHierarchyChanged (Component&) override
|
||||
{
|
||||
if (auto* peer = observed->getPeer())
|
||||
peer->setCustomPlatformScaleFactor (getHostScale());
|
||||
}
|
||||
|
||||
float getScaleFactorForWindow() const
|
||||
{
|
||||
if (auto* comp = observed.getComponent())
|
||||
if (auto* peer = comp->getPeer())
|
||||
return (float) peer->getPlatformScaleFactor();
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
void timerCallback() override
|
||||
{
|
||||
if (const auto estimatedScale = getScaleFactorForWindow(); estimatedScale > 0.0f)
|
||||
applyScaleFactor (scale.withInternal (estimatedScale));
|
||||
}
|
||||
|
||||
void applyScaleFactor (StoredScaleFactor newFactor)
|
||||
{
|
||||
const auto previous = std::exchange (scale, newFactor).get();
|
||||
const auto current = scale.get();
|
||||
const auto scalesEqual = approximatelyEqual (current, previous);
|
||||
|
||||
if (observed == nullptr)
|
||||
return;
|
||||
|
||||
if (scale.isHostScale())
|
||||
if (auto* peer = observed->getPeer())
|
||||
peer->setCustomPlatformScaleFactor (current);
|
||||
|
||||
if (scalesEqual)
|
||||
return;
|
||||
|
||||
#if JUCE_LINUX || JUCE_BSD
|
||||
const MessageManagerLock mmLock;
|
||||
#endif
|
||||
|
||||
if (auto* peer = observed->getPeer())
|
||||
{
|
||||
peer->updateBounds();
|
||||
listeners.call ([] (auto& l) { l.peerBoundsDidUpdate(); });
|
||||
}
|
||||
}
|
||||
|
||||
float getPlatformAndDesktopScale() const
|
||||
{
|
||||
jassert (observed != nullptr);
|
||||
return (observed->getDesktopScaleFactor() * std::invoke ([&]
|
||||
{
|
||||
if (auto* peer = observed->getPeer())
|
||||
return (float) peer->getPlatformScaleFactor();
|
||||
|
||||
return scale.get();
|
||||
}));
|
||||
}
|
||||
|
||||
ListenerList<PluginScaleFactorManagerListener> listeners;
|
||||
Component::SafePointer<Component> observed;
|
||||
StoredScaleFactor scale;
|
||||
};
|
||||
|
||||
} // namespace juce::detail
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <juce_audio_plugin_client/detail/juce_IncludeModuleHeaders.h>
|
||||
#include <juce_audio_plugin_client/detail/juce_CreatePluginFilter.h>
|
||||
|
||||
namespace juce::detail
|
||||
{
|
||||
|
||||
struct PluginUtilities
|
||||
{
|
||||
PluginUtilities() = delete;
|
||||
|
||||
struct FlagsAndWindowsMultiTouch
|
||||
{
|
||||
FlagsAndWindowsMultiTouch (int d, bool w)
|
||||
: desktopFlags (d),
|
||||
windowsUsesMultiTouch (w)
|
||||
{
|
||||
}
|
||||
|
||||
int desktopFlags{};
|
||||
bool windowsUsesMultiTouch{};
|
||||
};
|
||||
|
||||
static FlagsAndWindowsMultiTouch getDesktopFlagsAndWindowsMultiTouchMode (const AudioProcessorEditor& editor)
|
||||
{
|
||||
auto flags = editor.wantsLayerBackedView()
|
||||
? 0
|
||||
: ComponentPeer::windowRequiresSynchronousCoreGraphicsRendering;
|
||||
|
||||
return { flags, editor.usesWindowsMultiTouch() };
|
||||
}
|
||||
|
||||
static FlagsAndWindowsMultiTouch getDesktopFlagsAndWindowsMultiTouchMode (const AudioProcessorEditor* editor)
|
||||
{
|
||||
return editor != nullptr ? getDesktopFlagsAndWindowsMultiTouchMode (*editor)
|
||||
: FlagsAndWindowsMultiTouch { 0, false };
|
||||
}
|
||||
|
||||
static void addToDesktop (AudioProcessorEditor& editor, void* parent)
|
||||
{
|
||||
const auto [flags, usesWindowsMultiTouch] = getDesktopFlagsAndWindowsMultiTouchMode (editor);
|
||||
editor.addToDesktop (flags, parent);
|
||||
|
||||
if (auto* peer = editor.getPeer())
|
||||
peer->setWindowsCanUseMultiTouch (usesWindowsMultiTouch);
|
||||
}
|
||||
|
||||
static const PluginHostType& getHostType()
|
||||
{
|
||||
static PluginHostType hostType;
|
||||
return hostType;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace juce::detail
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if JUCE_MAC
|
||||
|
||||
#include <juce_audio_plugin_client/detail/juce_IncludeModuleHeaders.h>
|
||||
|
||||
namespace juce::detail
|
||||
{
|
||||
|
||||
struct VSTWindowUtilities
|
||||
{
|
||||
VSTWindowUtilities() = delete;
|
||||
|
||||
static void* attachComponentToWindowRefVST (Component* comp,
|
||||
int desktopFlags,
|
||||
void* parentWindowOrView)
|
||||
{
|
||||
JUCE_AUTORELEASEPOOL
|
||||
{
|
||||
NSView* parentView = [(NSView*) parentWindowOrView retain];
|
||||
|
||||
const auto defaultFlags = JucePlugin_EditorRequiresKeyboardFocus
|
||||
? 0
|
||||
: ComponentPeer::windowIgnoresKeyPresses;
|
||||
comp->addToDesktop (desktopFlags | defaultFlags, parentView);
|
||||
|
||||
// this workaround is because Wavelab provides a zero-size parent view
|
||||
if (approximatelyEqual ([parentView frame].size.height, 0.0))
|
||||
[((NSView*) comp->getWindowHandle()) setFrameOrigin: NSZeroPoint];
|
||||
|
||||
comp->setVisible (true);
|
||||
comp->toFront (false);
|
||||
|
||||
[[parentView window] setAcceptsMouseMovedEvents: YES];
|
||||
return parentView;
|
||||
}
|
||||
}
|
||||
|
||||
static void detachComponentFromWindowRefVST (Component* comp,
|
||||
void* window)
|
||||
{
|
||||
JUCE_AUTORELEASEPOOL
|
||||
{
|
||||
comp->removeFromDesktop();
|
||||
[(id) window release];
|
||||
}
|
||||
}
|
||||
|
||||
static void setNativeHostWindowSizeVST (void* window,
|
||||
Component* component,
|
||||
int newWidth,
|
||||
int newHeight)
|
||||
{
|
||||
JUCE_AUTORELEASEPOOL
|
||||
{
|
||||
if (NSView* hostView = (NSView*) window)
|
||||
{
|
||||
const int dx = newWidth - component->getWidth();
|
||||
const int dy = newHeight - component->getHeight();
|
||||
|
||||
NSRect r = [hostView frame];
|
||||
r.size.width += dx;
|
||||
r.size.height += dy;
|
||||
r.origin.y -= dy;
|
||||
[hostView setFrame: r];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace juce::detail
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user