Initial release

This commit is contained in:
civ
2026-08-16 18:24:52 +07:00
commit 876886a39a
13244 changed files with 2353959 additions and 0 deletions
@@ -0,0 +1,160 @@
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
#ifndef __aeffguieditor__
#include "aeffguieditor.h"
#endif
#ifndef __audioeffectx__
#include "public.sdk/source/vst2.x/audioeffectx.h"
#endif
#include "../lib/platform/iplatformframe.h"
#if WINDOWS
#include <windows.h>
#include "../lib/platform/win32/win32support.h"
#endif
namespace VSTGUI {
//-----------------------------------------------------------------------------
// AEffGUIEditor Implementation
//-----------------------------------------------------------------------------
AEffGUIEditor::AEffGUIEditor (void* pEffect)
: AEffEditor ((AudioEffect*)pEffect)
{
((AudioEffect*)pEffect)->setEditor (this);
systemWindow = 0;
#if WINDOWS
OleInitialize (nullptr);
#endif
}
//-----------------------------------------------------------------------------
AEffGUIEditor::~AEffGUIEditor ()
{
#if WINDOWS
OleUninitialize ();
#endif
}
//-----------------------------------------------------------------------------
#if VST_2_1_EXTENSIONS
bool AEffGUIEditor::onKeyDown (VstKeyCode& keyCode)
{
return false;
}
//-----------------------------------------------------------------------------
bool AEffGUIEditor::onKeyUp (VstKeyCode& keyCode)
{
return false;
}
#endif
//-----------------------------------------------------------------------------
bool AEffGUIEditor::open (void* ptr)
{
return AEffEditor::open (ptr);
}
//-----------------------------------------------------------------------------
void AEffGUIEditor::idle ()
{
AEffEditor::idle ();
if (frame)
frame->idle ();
}
//-----------------------------------------------------------------------------
int32_t AEffGUIEditor::knobMode = kCircularMode;
//-----------------------------------------------------------------------------
bool AEffGUIEditor::setKnobMode (int32_t val)
{
AEffGUIEditor::knobMode = val;
return true;
}
//-----------------------------------------------------------------------------
bool AEffGUIEditor::onWheel (float distance)
{
return false;
}
//-----------------------------------------------------------------------------
void AEffGUIEditor::doIdleStuff ()
{
vstgui_assert (false, "unexpected call");
}
//-----------------------------------------------------------------------------
bool AEffGUIEditor::getRect (ERect **ppErect)
{
*ppErect = &rect;
return true;
}
// -----------------------------------------------------------------------------
bool AEffGUIEditor::beforeSizeChange (const CRect& newSize, const CRect& oldSize)
{
AudioEffectX* eX = (AudioEffectX*)effect;
if (eX && eX->canHostDo ((char*)"sizeWindow"))
{
if (eX->sizeWindow ((VstInt32)newSize.getWidth (), (VstInt32)newSize.getHeight ()))
{
return true;
}
return false;
}
#if WINDOWS
// old hack to size the window of the host. Very ugly stuff ...
if (getFrame () == 0)
return true;
RECT rctTempWnd, rctParentWnd;
HWND hTempWnd;
long iFrame = (2 * GetSystemMetrics (SM_CYFIXEDFRAME));
long diffWidth = 0;
long diffHeight = 0;
hTempWnd = (HWND)getFrame ()->getPlatformFrame ()->getPlatformRepresentation ();
while ((diffWidth != iFrame) && (hTempWnd != nullptr)) // look for FrameWindow
{
HWND hTempParentWnd = GetParent (hTempWnd);
TCHAR buffer[1024];
GetClassName (hTempParentWnd, buffer, 1024);
if (!hTempParentWnd || !VSTGUI_STRCMP (buffer, TEXT("MDIClient")))
break;
GetWindowRect (hTempWnd, &rctTempWnd);
GetWindowRect (hTempParentWnd, &rctParentWnd);
SetWindowPos (hTempWnd, HWND_TOP, 0, 0, (int)newSize.getWidth () + diffWidth, (int)newSize.getHeight () + diffHeight, SWP_NOMOVE);
diffWidth += (rctParentWnd.right - rctParentWnd.left) - (rctTempWnd.right - rctTempWnd.left);
diffHeight += (rctParentWnd.bottom - rctParentWnd.top) - (rctTempWnd.bottom - rctTempWnd.top);
if ((diffWidth > 80) || (diffHeight > 80)) // parent belongs to host
return true;
if (diffWidth < 0)
diffWidth = 0;
if (diffHeight < 0)
diffHeight = 0;
hTempWnd = hTempParentWnd;
}
if (hTempWnd)
SetWindowPos (hTempWnd, HWND_TOP, 0, 0, (int)newSize.getWidth () + diffWidth, (int)newSize.getHeight () + diffHeight, SWP_NOMOVE);
#endif
return true;
}
} // VSTGUI
@@ -0,0 +1,73 @@
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
#ifndef __aeffguieditor__
#define __aeffguieditor__
#ifndef __aeffeditor__
#include "public.sdk/source/vst2.x/aeffeditor.h"
#endif
#ifndef __audioeffectx__
#include "public.sdk/source/vst2.x/audioeffectx.h"
#endif
#include "../vstgui.h"
namespace VSTGUI {
//-----------------------------------------------------------------------------
// AEffGUIEditor Declaration
//-----------------------------------------------------------------------------
class AEffGUIEditor : public AEffEditor, public VSTGUIEditorInterface
{
public :
AEffGUIEditor (void* pEffect);
virtual ~AEffGUIEditor ();
virtual void setParameter (VstInt32 index, float value) {}
virtual bool getRect (ERect** ppRect);
virtual bool open (void* ptr);
virtual void idle ();
#if VST_2_1_EXTENSIONS
virtual bool onKeyDown (VstKeyCode& keyCode);
virtual bool onKeyUp (VstKeyCode& keyCode);
#endif
// feedback to appli.
virtual void doIdleStuff ();
// get the effect attached to this editor
AudioEffect* getEffect () { return effect; }
// get version of this VSTGUI
int32_t getVstGuiVersion () { return (VSTGUI_VERSION_MAJOR << 16) + VSTGUI_VERSION_MINOR; }
// set/get the knob mode
virtual bool setKnobMode (int32_t val);
virtual int32_t getKnobMode () const { return knobMode; }
virtual bool beforeSizeChange (const CRect& newSize, const CRect& oldSize);
virtual bool onWheel (float distance);
#if VST_2_1_EXTENSIONS
virtual void beginEdit (int32_t index) { ((AudioEffectX*)effect)->beginEdit (index); }
virtual void endEdit (int32_t index) { ((AudioEffectX*)effect)->endEdit (index); }
#endif
//---------------------------------------
protected:
ERect rect;
private:
static int32_t knobMode;
};
} // VSTGUI
#endif
@@ -0,0 +1,54 @@
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
#ifndef __getpluginbundle__
#define __getpluginbundle__
//-----------------------------------------------------------------------------
/// @cond ignore
//-----------------------------------------------------------------------------
#if MAC
#include <dlfcn.h>
#include <CoreFoundation/CFBundle.h>
#include <string>
//-----------------------------------------------------------------------------
static CFBundleRef GetPluginBundle ()
{
CFBundleRef pluginBundle = 0;
Dl_info info;
if (dladdr ((const void*)GetPluginBundle, &info))
{
if (info.dli_fname)
{
std::string name;
name.assign (info.dli_fname);
for (int i = 0; i < 3; i++)
{
size_t delPos = name.find_last_of ('/');
if (delPos == std::string::npos)
{
fprintf (stdout, "Could not determine bundle location.\n");
return 0; // unexpected
}
name.erase (delPos, name.length () - delPos);
}
CFURLRef bundleUrl = CFURLCreateFromFileSystemRepresentation (0, (const UInt8*)name.c_str (), name.length (), true);
if (bundleUrl)
{
pluginBundle = CFBundleCreate (0, bundleUrl);
CFRelease (bundleUrl);
}
}
}
return pluginBundle;
}
#endif
//-----------------------------------------------------------------------------
/// @endcond
//-----------------------------------------------------------------------------
#endif // __getpluginbundle__
@@ -0,0 +1,78 @@
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
#ifndef __plugguieditor__
#include "plugguieditor.h"
#endif
#if WINDOWS
#include <windows.h>
#include <ole2.h>
#endif
namespace VSTGUI {
//-----------------------------------------------------------------------------
// PluginGUIEditor Implementation
//-----------------------------------------------------------------------------
/*! @class PluginGUIEditor
This is the same as the AEffGUIEditor class except that this one allows
the VSTGUI lib to build without VST dependencies.
*/
PluginGUIEditor::PluginGUIEditor (void *pEffect)
: effect (pEffect)
{
systemWindow = nullptr;
#if WINDOWS
OleInitialize (nullptr);
#endif
}
//-----------------------------------------------------------------------------
PluginGUIEditor::~PluginGUIEditor ()
{
#if WINDOWS
OleUninitialize ();
#endif
}
//-----------------------------------------------------------------------------
bool PluginGUIEditor::open (void *ptr)
{
systemWindow = ptr;
return true;
}
//-----------------------------------------------------------------------------
void PluginGUIEditor::idle ()
{
if (frame)
frame->idle ();
}
//-----------------------------------------------------------------------------
int32_t PluginGUIEditor::knobMode = kCircularMode;
//-----------------------------------------------------------------------------
int32_t PluginGUIEditor::setKnobMode (int32_t val)
{
PluginGUIEditor::knobMode = val;
return 1;
}
//-----------------------------------------------------------------------------
void PluginGUIEditor::doIdleStuff ()
{
vstgui_assert (false, "unexpected call");
}
//-----------------------------------------------------------------------------
bool PluginGUIEditor::getRect (ERect **ppErect)
{
*ppErect = &rect;
return true;
}
} // VSTGUI
@@ -0,0 +1,67 @@
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
#ifndef __plugguieditor__
#define __plugguieditor__
#include "../vstgui.h"
namespace VSTGUI {
//----------------------------------------------------------------------
struct ERect
{
int16_t top;
int16_t left;
int16_t bottom;
int16_t right;
};
//-----------------------------------------------------------------------------
// AEffGUIEditor Declaration
//-----------------------------------------------------------------------------
class [[deprecated ("Please use your own VSTGUIEditorInterface subclass")]] PluginGUIEditor
: public VSTGUIEditorInterface
{
public :
PluginGUIEditor (void *pEffect);
~PluginGUIEditor () override;
virtual void setParameter (int32_t index, float value) {}
virtual bool getRect (ERect **ppRect);
virtual bool open (void *ptr);
virtual void close () { systemWindow = nullptr; }
virtual void idle ();
// feedback to appli.
void doIdleStuff () override;
// get the effect attached to this editor
void *getEffect () { return effect; }
// get version of this VSTGUI
int32_t getVstGuiVersion () { return (VSTGUI_VERSION_MAJOR << 16) + VSTGUI_VERSION_MINOR; }
// set/get the knob mode
virtual int32_t setKnobMode (int32_t val);
int32_t getKnobMode () const override { return knobMode; }
void beginEdit (int32_t index) override {}
void endEdit (int32_t index) override {}
//---------------------------------------
protected:
ERect rect;
void* effect;
void* systemWindow;
private:
static int32_t knobMode;
};
} // VSTGUI
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,257 @@
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
#pragma once
#include "public.sdk/source/vst/vstguieditor.h"
#include "pluginterfaces/vst/ivstplugview.h"
#include "../uidescription/uidescription.h"
#include "../uidescription/icontroller.h"
#include "../lib/controls/icommandmenuitemtarget.h"
#include "../lib/optional.h"
#include <string>
#include <vector>
#include <map>
#if VST_VERSION >= 0x030607
#include "pluginterfaces/gui/iplugviewcontentscalesupport.h"
#define VST3_CONTENT_SCALE_SUPPORT
#endif
namespace VSTGUI {
class ParameterChangeListener;
class VST3Editor;
//-----------------------------------------------------------------------------
//! @brief delegate interface for a VST3Editor.
//!
//! You either extend Steinberg::Vst::EditController with this interface and pass the editor
//! controller to the constructor of the VST3Editor class, or you create a delegate without
//! extending Steinberg::Vst::EditController and explicitly set the delegate of the VST3Editor.
//!
//! @ingroup new_in_4_0
//-----------------------------------------------------------------------------
class IVST3EditorDelegate
{
public:
virtual ~IVST3EditorDelegate () = default;
/** create a custom view */
virtual CView* createCustomView (UTF8StringPtr name, const UIAttributes& attributes,
const IUIDescription* description, VST3Editor* editor) = 0;
/** verify a view after it was created */
virtual CView* verifyView (CView* view, const UIAttributes& attributes,
const IUIDescription* description, VST3Editor* editor) = 0;
/** find a parameter */
virtual bool findParameter (const CPoint& pos, Steinberg::Vst::ParamID& paramID,
VST3Editor* editor) = 0;
/** check if parameter ID is private and should not be exposed to the host */
virtual bool isPrivateParameter (const Steinberg::Vst::ParamID paramID) = 0;
/** called after the editor was opened */
virtual void didOpen (VST3Editor* editor) = 0;
/** called before the editor will close */
virtual void willClose (VST3Editor* editor) = 0;
/** create the context menu for the editor, will be added to the host menu */
virtual COptionMenu* createContextMenu (const CPoint& pos, VST3Editor* editor) = 0;
/** called when a sub controller should be created.
The controller is now owned by the editor, which will call forget() if it is a CBaseObject,
release() if it is a Steinberg::FObject or it will be simply deleted if the frame gets
closed. */
virtual IController* createSubController (UTF8StringPtr name, const IUIDescription* description,
VST3Editor* editor) = 0;
/** called when the user zoom factor of the editor was changed */
virtual void onZoomChanged (VST3Editor* editor, double newZoom) = 0;
};
//------------------------------------------------------------------------
/** Default adapter implementation for IVST3EditorDelegate */
class VST3EditorDelegate : public IVST3EditorDelegate
{
public:
CView* createCustomView (UTF8StringPtr name, const UIAttributes& attributes,
const IUIDescription* description, VST3Editor* editor) override
{
return nullptr;
}
CView* verifyView (CView* view, const UIAttributes& attributes,
const IUIDescription* description, VST3Editor* editor) override
{
return view;
}
bool findParameter (const CPoint& pos, Steinberg::Vst::ParamID& paramID,
VST3Editor* editor) override
{
return false;
}
bool isPrivateParameter (const Steinberg::Vst::ParamID paramID) override { return false; }
void didOpen (VST3Editor* editor) override {}
void willClose (VST3Editor* editor) override {}
COptionMenu* createContextMenu (const CPoint& pos, VST3Editor* editor) override
{
return nullptr;
}
IController* createSubController (UTF8StringPtr name, const IUIDescription* description,
VST3Editor* editor) override
{
return nullptr;
}
void onZoomChanged (VST3Editor* editor, double newZoom) override {}
};
//-----------------------------------------------------------------------------
//! @brief VST3 Editor with automatic parameter binding
//! @ingroup new_in_4_0
//-----------------------------------------------------------------------------
class VST3Editor : public Steinberg::Vst::VSTGUIEditor,
public Steinberg::Vst::IParameterFinder,
public IController,
public IViewAddedRemovedObserver,
public IMouseObserver,
public CommandMenuItemTargetAdapter
#ifdef VST3_CONTENT_SCALE_SUPPORT
, public Steinberg::IPlugViewContentScaleSupport
#endif
{
public:
VST3Editor (Steinberg::Vst::EditController* controller, UTF8StringPtr templateName, UTF8StringPtr xmlFile);
VST3Editor (UIDescription* desc, Steinberg::Vst::EditController* controller, UTF8StringPtr templateName, UTF8StringPtr xmlFile = nullptr);
bool exchangeView (UTF8StringPtr templateName);
void enableTooltips (bool state);
bool setEditorSizeConstrains (const CPoint& newMinimumSize, const CPoint& newMaximumSize);
void getEditorSizeConstrains (CPoint& minimumSize, CPoint& maximumSize) const;
bool requestResize (const CPoint& newSize);
void setZoomFactor (double factor);
double getZoomFactor () const;
void setAllowedZoomFactors (std::vector<double> zoomFactors) { allowedZoomFactors = zoomFactors; }
/** set the delegate of the editor. no reference counting is happening here. */
void setDelegate (IVST3EditorDelegate* delegate);
IVST3EditorDelegate* getDelegate () const;
UIDescription* getUIDescription () const;
bool inEditMode () const;
const std::string& getCurrentTemplateName () const { return viewName; }
//-----------------------------------------------------------------------------
DELEGATE_REFCOUNT(Steinberg::Vst::VSTGUIEditor)
Steinberg::tresult PLUGIN_API queryInterface (const ::Steinberg::TUID iid, void** obj) override;
protected:
~VST3Editor () override;
void init ();
double getAbsScaleFactor () const;
double getContentScaleFactor () const;
ParameterChangeListener* getParameterChangeListener (int32_t tag) const;
void recreateView ();
void requestRecreateView ();
void syncParameterTags ();
void save (bool saveAs = false);
bool enableEditing (bool state);
void saveScreenshot ();
bool enableShowEditButton () const;
void enableShowEditButton (bool state);
void showEditButton (bool state);
bool PLUGIN_API open (void* parent, const PlatformType& type) override;
void PLUGIN_API close () override;
void beginEdit (int32_t index) override;
void endEdit (int32_t index) override;
CView* createView (const UIAttributes& attributes, const IUIDescription* description) override;
CView* verifyView (CView* view, const UIAttributes& attributes, const IUIDescription* description) override;
IController* createSubController (UTF8StringPtr name, const IUIDescription* description) override;
bool beforeSizeChange (const CRect& newSize, const CRect& oldSize) override;
Steinberg::tresult PLUGIN_API onSize (Steinberg::ViewRect* newSize) override;
Steinberg::tresult PLUGIN_API canResize () override;
Steinberg::tresult PLUGIN_API checkSizeConstraint (Steinberg::ViewRect* rect) override;
// IParameterFinder
Steinberg::tresult PLUGIN_API findParameter (Steinberg::int32 xPos, Steinberg::int32 yPos, Steinberg::Vst::ParamID& resultTag) override;
// IControlListener
virtual void valueChanged (CControl* pControl) override;
virtual void controlBeginEdit (CControl* pControl) override;
virtual void controlEndEdit (CControl* pControl) override;
virtual void controlTagWillChange (CControl* pControl) override;
virtual void controlTagDidChange (CControl* pControl) override;
// IViewAddedRemovedObserver
void onViewAdded (CFrame* frame, CView* view) override;
void onViewRemoved (CFrame* frame, CView* view) override;
// IMouseObserver
void onMouseEntered (CView* view, CFrame* frame) override {}
void onMouseExited (CView* view, CFrame* frame) override {}
void onMouseEvent (MouseEvent& event, CFrame* frame) override;
// CommandMenuItemTargetAdapter
bool validateCommandMenuItem (CCommandMenuItem* item) override;
bool onCommandMenuItemSelected (CCommandMenuItem* item) override;
#ifdef VST3_CONTENT_SCALE_SUPPORT
Steinberg::tresult PLUGIN_API setContentScaleFactor (ScaleFactor factor) override;
#endif
struct KeyboardHook;
KeyboardHook* keyboardHook {nullptr};
UIDescription* description {nullptr};
IVST3EditorDelegate* delegate {nullptr};
IController* originalController {nullptr};
IControlListener* openUIEditorController {nullptr};
using ParameterChangeListenerMap = std::map<int32_t, ParameterChangeListener*>;
ParameterChangeListenerMap paramChangeListeners;
std::string viewName;
std::string xmlFile;
bool tooltipsEnabled {true};
bool doCreateView {false};
bool editingEnabled {false};
double contentScaleFactor {1.};
double zoomFactor {1.};
std::vector<double> allowedZoomFactors;
CPoint minSize;
CPoint maxSize;
CRect nonEditRect;
Optional<CPoint> sizeRequest;
};
//-----------------------------------------------------------------------------
//! @brief An extended VST3 Editor which scales its contents when resized
//! @ingroup new_in_4_14
//-----------------------------------------------------------------------------
class AspectRatioVST3Editor : public VST3Editor
{
public:
using VST3Editor::VST3Editor;
void setMinZoomFactor (double factor);
double getMinZoomFactor () const;
protected:
bool canCalculateAspectRatio () const;
bool PLUGIN_API open (void* parent, const PlatformType& type) override;
Steinberg::tresult PLUGIN_API onSize (Steinberg::ViewRect* newSize) override;
Steinberg::tresult PLUGIN_API checkSizeConstraint (Steinberg::ViewRect* rect) override;
#ifdef VST3_CONTENT_SCALE_SUPPORT
Steinberg::tresult PLUGIN_API setContentScaleFactor (ScaleFactor factor) override;
#endif
private:
CPoint initialSize {};
double minZoomFactor {1.};
double calcZoomFactor {1.};
};
//------------------------------------------------------------------------
} // VSTGUI
@@ -0,0 +1,85 @@
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
#include "vst3groupcontroller.h"
#include <cassert>
namespace VSTGUI {
//------------------------------------------------------------------------
GroupController::GroupController (Steinberg::Vst::Parameter* parameter, Steinberg::Vst::EditController* editController)
: parameter (parameter)
, editController (editController)
{
parameter->addDependent (this);
vstgui_assert (parameter->getInfo ().stepCount > 0);
}
//------------------------------------------------------------------------
GroupController::~GroupController ()
{
parameter->removeDependent (this);
}
//------------------------------------------------------------------------
CView* GroupController::verifyView (CView* view, const UIAttributes& attributes, const IUIDescription* description)
{
auto* control = dynamic_cast<CControl*>(view);
if (control)
{
controls.push_back (control);
control->setListener (this);
parameter->deferUpdate ();
}
return view;
}
//------------------------------------------------------------------------
void GroupController::valueChanged (CControl* pControl)
{
Steinberg::Vst::ParamValue normValue = parameter->toNormalized (pControl->getTag ());
editController->performEdit (parameter->getInfo().id, normValue);
parameter->setNormalized (normValue);
}
//------------------------------------------------------------------------
void GroupController::controlBeginEdit (CControl* pControl)
{
for (const auto& c : controls)
c->setMouseEnabled (c == pControl);
editController->beginEdit (parameter->getInfo ().id);
}
//------------------------------------------------------------------------
void GroupController::controlEndEdit (CControl* pControl)
{
editController->endEdit (parameter->getInfo ().id);
update (parameter, kChanged);
}
//------------------------------------------------------------------------
void PLUGIN_API GroupController::update (Steinberg::FUnknown* changedUnknown, Steinberg::int32 message)
{
auto* p = Steinberg::FCast<Steinberg::Vst::Parameter> (changedUnknown);
if (p && p == parameter)
{
Steinberg::Vst::ParamValue plainValue = parameter->toPlain (parameter->getNormalized ());
for (const auto& c : controls)
{
if (c->getTag () == plainValue)
{
c->setValue (1);
c->setMouseEnabled (false);
}
else
{
c->setValue (0);
c->setMouseEnabled (true);
}
c->invalid ();
}
}
}
} // namespace
@@ -0,0 +1,42 @@
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
#pragma once
#include "../lib/controls/ccontrol.h"
#include "../uidescription/uidescriptionfwd.h"
#include "../uidescription/icontroller.h"
#include "base/source/fobject.h"
#include "public.sdk/source/vst/vstparameters.h"
#include "public.sdk/source/vst/vsteditcontroller.h"
#include <vector>
namespace VSTGUI {
//-----------------------------------------------------------------------------
class GroupController : public Steinberg::FObject, public IController
{
public:
GroupController (Steinberg::Vst::Parameter* parameter, Steinberg::Vst::EditController* editController);
~GroupController ();
CView* verifyView (CView* view, const UIAttributes& attributes, const IUIDescription* description) override;
void valueChanged (CControl* pControl) override;
void controlBeginEdit (CControl* pControl) override;
void controlEndEdit (CControl* pControl) override;
//-----------------------------------------------------------------------------
OBJ_METHODS(GroupController, FObject)
protected:
void PLUGIN_API update (Steinberg::FUnknown* changedUnknown, Steinberg::int32 message) override;
Steinberg::Vst::Parameter* parameter;
Steinberg::Vst::EditController* editController;
using ControlList = std::vector<CControl*>;
ControlList controls;
};
} // namespace
@@ -0,0 +1,129 @@
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
#include "vst3padcontroller.h"
namespace VSTGUI {
//------------------------------------------------------------------------
PadController::PadController (IController* baseController,
Steinberg::Vst::EditController* editController,
Steinberg::Vst::Parameter* xParam, Steinberg::Vst::Parameter* yParam)
: DelegationController (baseController)
, editController (editController)
, xParam (xParam)
, yParam (yParam)
, padControl (nullptr)
{
if (xParam)
xParam->addDependent (this);
if (yParam)
yParam->addDependent (this);
}
//------------------------------------------------------------------------
PadController::~PadController ()
{
if (xParam)
xParam->removeDependent (this);
if (yParam)
yParam->removeDependent (this);
}
//------------------------------------------------------------------------
CView* PadController::verifyView (CView* view, const UIAttributes& attributes,
const IUIDescription* description)
{
auto* pad = dynamic_cast<CXYPad*> (view);
if (pad)
{
padControl = pad;
padControl->setListener (this);
update (xParam, kChanged);
}
return view;
}
//------------------------------------------------------------------------
void PadController::valueChanged (CControl* pControl)
{
if (pControl == padControl && xParam && yParam)
{
float x, y;
CXYPad::calculateXY (pControl->getValue (), x, y);
auto xId = xParam->getInfo ().id;
if (editController->setParamNormalized (xId, x) == Steinberg::kResultTrue)
editController->performEdit (xId, editController->getParamNormalized (xId));
auto yId = yParam->getInfo ().id;
if (editController->setParamNormalized (yId, y) == Steinberg::kResultTrue)
editController->performEdit (yId, editController->getParamNormalized (yId));
}
else
{
DelegationController::valueChanged (pControl);
}
}
//------------------------------------------------------------------------
void PadController::controlBeginEdit (CControl* pControl)
{
if (pControl == padControl && xParam && yParam)
{
editController->startGroupEdit ();
editController->beginEdit (xParam->getInfo ().id);
editController->beginEdit (yParam->getInfo ().id);
}
else
{
DelegationController::controlBeginEdit (pControl);
}
}
//------------------------------------------------------------------------
void PadController::controlEndEdit (CControl* pControl)
{
if (pControl == padControl && xParam && yParam)
{
editController->endEdit (xParam->getInfo ().id);
editController->endEdit (yParam->getInfo ().id);
editController->finishGroupEdit ();
}
else
{
DelegationController::controlEndEdit (pControl);
}
}
//------------------------------------------------------------------------
void PLUGIN_API PadController::update (Steinberg::FUnknown* changedUnknown,
Steinberg::int32 message)
{
if (padControl)
{
auto* p = Steinberg::FCast<Steinberg::Vst::Parameter> (changedUnknown);
if (p && (p == xParam || p == yParam))
{
if (message == kChanged)
{
float value =
CXYPad::calculateValue (xParam->getNormalized (), yParam->getNormalized ());
padControl->setValue (value);
padControl->invalid ();
}
else if (message == kWillDestroy)
{
if (xParam)
xParam->removeDependent (this);
if (yParam)
yParam->removeDependent (this);
xParam = nullptr;
yParam = nullptr;
}
}
}
}
} // namespace
@@ -0,0 +1,43 @@
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
#pragma once
#include "../lib/controls/cxypad.h"
#include "../uidescription/delegationcontroller.h"
#include "../uidescription/uidescription.h"
#include "public.sdk/source/vst/vsteditcontroller.h"
#include "public.sdk/source/vst/vstparameters.h"
#include "base/source/fobject.h"
namespace VSTGUI {
//------------------------------------------------------------------------
class PadController : public Steinberg::FObject, public DelegationController
{
public:
PadController (IController* baseController, Steinberg::Vst::EditController* editController,
Steinberg::Vst::Parameter* xParam, Steinberg::Vst::Parameter* yParam);
~PadController () override;
CView* verifyView (CView* view, const UIAttributes& attributes,
const IUIDescription* description) override;
void valueChanged (CControl* pControl) override;
void controlBeginEdit (CControl* pControl) override;
void controlEndEdit (CControl* pControl) override;
//-----------------------------------------------------------------------------
OBJ_METHODS (PadController, FObject)
protected:
void PLUGIN_API update (Steinberg::FUnknown* changedUnknown, Steinberg::int32 message) override;
Steinberg::Vst::EditController* editController;
Steinberg::Vst::Parameter* xParam;
Steinberg::Vst::Parameter* yParam;
CXYPad* padControl;
SharedPointer<UIDescription> uiDescription;
};
} // namespace