29 #include "customcontrols.h" 32 #include "vstgui/vstgui.h" 33 #include "vstgui/uidescription/uiviewswitchcontainer.h" 34 #include "vstgui/vstgui_uidescription.h" 35 #include "vstgui/lib/crect.h" 37 #if VSTGUI_LIVE_EDITING 38 #include "vstgui/uidescription/editing/uieditcontroller.h" 39 #include "vstgui/uidescription/editing/uieditmenucontroller.h" 43 #import <CoreFoundation/CoreFoundation.h> 44 #import <AudioUnit/AudioUnit.h> 45 #import <AudioToolbox/AudioToolbox.h> 49 #include "AAX_IEffectParameters.h" 50 #include "AAXtoVSTGUIButtonState.h" 54 #include "pluginparameter.h" 65 const uint32_t kHostChoice = 3;
103 CControl* ctrl = *it;
132 control->setDefaultValue(normalizedValue);
143 CControl* ctrl = *it;
161 CControl* ctrl = *it;
162 if(ctrl && ctrl->isEditing())
228 CControl* guiCtrl = *it;
229 if(guiCtrl && control != guiCtrl)
232 CTextLabel* label =
dynamic_cast<CTextLabel*
>(guiCtrl);
233 COptionMenu* oMenu =
dynamic_cast<COptionMenu*
>(guiCtrl);
235 CVuMeter* meter =
dynamic_cast<CVuMeter*
>(guiCtrl);
253 oMenu->removeAllEntry();
266 xyPad->calculateXY(xyPad->getValue(), x, y);
269 int32_t tagX = xyPad->getTagX();
270 int32_t tagY = xyPad->getTagY();
277 if(tagX >= 0 && tagY >= 0 && !guiCtrl->isEditing())
278 xyPad->
setValue(xyPad->calculateValue(x, y));
280 else if(!guiCtrl->isEditing())
305 if(!ctrl)
return false;
307 bool stickyVisible = ctrl->isVisible();
313 CView* parent = ctrl->getParentView();
316 stickyVisible = parent->isVisible();
320 parent = parent->getParentView();
322 return stickyVisible;
332 CPoint mousePoint = where;
336 CControl* ctrl = *it;
339 CPoint point = ctrl->frameToLocal(mousePoint);
340 CRect rect = ctrl->getViewSize();
341 if(rect.pointInside(point))
343 int tag = ctrl->getTag();
361 CPoint mousePoint = where;
365 CControl* ctrl = *it;
368 CPoint point = ctrl->frameToLocal(mousePoint);
369 CRect rect = ctrl->getViewSize();
370 if(rect.pointInside(point))
411 public IViewAddedRemovedObserver,
412 public IMouseObserver,
413 public IKeyboardHook,
414 public VSTGUIEditorInterface,
416 public ICommandMenuItemTarget,
428 bool open(UTF8StringPtr _viewName,
430 const std::vector<PluginParameter*>* pluginParameterPtr,
431 const PlatformType& platformType = kDefaultNative,
433 void* data =
nullptr);
442 void getSize(
float& width,
float& height);
461 void save(
bool saveAs =
false);
469 for(std::vector<PluginParameter*>::iterator it = pluginParameters.begin(); it != pluginParameters.end(); ++it) {
472 pluginParameters.clear();
484 for(std::vector<PluginParameter*>::iterator it = pluginParameters.begin(); it != pluginParameters.end(); ++it) {
529 CMouseEventResult
sendAAXMouseDown(
int controlID,
const CButtonState& buttons);
532 CMouseEventResult
sendAAXMouseMoved(
int controlID,
const CButtonState& buttons,
const CPoint& where);
535 CMouseEventResult
sendAUMouseDown(CControl* control,
const CButtonState& buttons);
538 CMouseEventResult
sendAUMouseMoved(CControl* control,
const CButtonState& buttons,
const CPoint& where) {
return kMouseEventNotImplemented; }
554 setAUEventFromGUIControl(control, tag, actualValue);
558 setAAXParameterFromGUIControl(control, tag, actualValue, normalizedValue);
562 setVSTParameterFromGUIControl(control, tag, actualValue, normalizedValue);
566 setRAFXParameterFromGUIControl(control, tag, actualValue, normalizedValue);
579 void setAAXViewContainer(AAX_IViewContainer* _aaxViewContainer){ aaxViewContainer = _aaxViewContainer;}
582 void setAAXParameterFromGUIControl(CControl* control,
int tag,
float actualValue,
float normalizedValue);
585 void updateGUIControlAAX(
int tag,
float actualPluginValue,
float normalizedValue = 0.f,
bool useNormalized =
false);
592 AUEventListenerRef AUEventListener;
596 void dispatchAUControlChange(
int tag,
float actualPluginValue,
int message = -1,
bool fromEventListener =
false);
601 void setAU(AudioUnit inAU){m_AU = inAU;}
605 void setAUEventFromGUIControl(CControl* control,
int tag,
float normalizedValue);
610 void setVSTParameterFromGUIControl(CControl* control,
int tag,
float actualValue,
float normalizedValue);
613 void updateGUIControlVST(
int tag,
float normalizedValue);
618 void setRAFXParameterFromGUIControl(CControl* control,
int tag,
float actualValue,
float normalizedValue);
621 void updateGUIControlRAFX(
int tag,
float normalizedValue);
627 CMessageResult
notify(CBaseObject* sender, IdStringPtr message)
override;
630 virtual void valueChanged(VSTGUI::CControl* pControl)
override;
652 CView*
createUserCustomView(std::string viewname,
const CRect rect, IControlListener* listener, int32_t tag);
676 CMouseEventResult
onMouseDown(CFrame* frame,
const CPoint& where,
const CButtonState& buttons)
override;
679 CMouseEventResult
onMouseMoved(CFrame* frame,
const CPoint& where,
const CButtonState& buttons)
override;
682 int32_t
onKeyDown(
const VstKeyCode& code, CFrame* frame)
override {
return -1; }
685 int32_t
onKeyUp(
const VstKeyCode& code, CFrame* frame)
override {
return -1; }
710 inline static bool parseSize (
const std::string& str, CPoint& point)
712 size_t sep = str.find (
',', 0);
713 if (sep != std::string::npos)
715 point.x = strtol (str.c_str (), 0, 10);
716 point.y = strtol (str.c_str () + sep+1, 0, 10);
732 return std::find (writeableControls.begin (), writeableControls.end (), control) != writeableControls.end ();
751 writeableControls.push_back(control);
765 for(std::vector<CControl*>::iterator it = writeableControls.begin(); it != writeableControls.end(); ++it)
767 CControl* ctrl = *it;
771 writeableControls.erase(it);
783 for (ControlUpdateReceiverMap::const_iterator it = controlUpdateReceivers.begin(), end = controlUpdateReceivers.end(); it != end; ++it)
787 controlUpdateReceivers.clear();
795 for (std::vector<CControl*>::iterator it = writeableControls.begin(); it != writeableControls.end(); ++it)
797 CControl* ctrl = *it;
800 writeableControls.clear();
834 typedef std::map<int32_t, ControlUpdateReceiver*> ControlUpdateReceiverMap;
835 ControlUpdateReceiverMap controlUpdateReceivers;
836 std::vector<CControl*> writeableControls;
837 std::vector<PluginParameter*> pluginParameters;
840 AAX_IViewContainer* aaxViewContainer =
nullptr;
IGUIWindowFrame * guiWindowFrame
interface to allow plugin shell to resize our window
Definition: plugingui.h:515
double getControlValue()
the main function to access the underlying atomic double value
Definition: pluginparameter.h:167
CView * createView(const UIAttributes &attributes, const IUIDescription *description) override
virtual void controlTagWillChange(VSTGUI::CControl *pControl) override
void checkAddWriteableControl(PluginParameter *piParam, CControl *control)
check to see if we already store this meter control and add it if we don't
Definition: plugingui.h:741
bool hasICustomView(IController *subController)
simple helper function to test sub-controller for ICustomView
Definition: plugingui.h:825
CControl * getControl_WithMouseCoords(const CPoint &where)
Definition: plugingui.h:359
virtual void setValue(float val) override
Definition: customcontrols.cpp:979
const PluginParameter getGuiControl()
Definition: plugingui.h:292
The PluginGUI object that maintains the entire GUI operation and has #defines to use with AAX...
Definition: plugingui.h:410
void save(bool saveAs=false)
void updateControlsWithControl(CControl *control)
Definition: plugingui.h:189
~ControlUpdateReceiver()
Definition: plugingui.h:99
uint32_t numUIControls
control counter
Definition: plugingui.h:498
virtual void controlBeginEdit(VSTGUI::CControl *pControl) override
void getSize(float &width, float &height)
std::string getGUIDesignerSize()
float getActualValueWithNormalizedValue(float normalizedValue)
Definition: plugingui.h:172
CMessageResult notify(CBaseObject *sender, IdStringPtr message) override
double getControlValueNormalized()
get control value as normalied value
Definition: pluginparameter.h:279
void removeControl(CControl *control)
Definition: plugingui.h:139
virtual void valueChanged(VSTGUI::CControl *pControl) override
bool getIsWritable()
query writable control (meter)
Definition: pluginparameter.h:152
IGUIPluginConnector * guiPluginConnector
the plugin shell interface that arrives with the open( ) function; OK if NULL for standalone GUIs ...
Definition: plugingui.h:493
CMouseEventResult sendAAXMouseMoved(int controlID, const CButtonState &buttons, const CPoint &where)
bool open(UTF8StringPtr _viewName, void *parent, const std::vector< PluginParameter *> *pluginParameterPtr, const PlatformType &platformType=kDefaultNative, IGUIPluginConnector *_guiPluginConnector=nullptr, void *data=nullptr)
uint32_t getControlID()
get ID value
Definition: pluginparameter.h:81
std::string getControlValueAsString()
the main function to access the underlying atomic double value as a string
Definition: pluginparameter.cpp:227
double getGUIMin()
Definition: pluginparameter.h:345
void deleteGUIControlList()
Definition: plugingui.h:467
IController * createSubController(UTF8StringPtr name, const IUIDescription *description) override
bool showGUIEditor
show the GUI designer
Definition: plugingui.h:507
double guiDesignerWidth
GUI Designer's frame size.
Definition: plugingui.h:510
std::vector< CControl * > guiControls
list of controls that share the control tag with this one
Definition: plugingui.h:379
double zoomFactor
scaling factor for built-in scaling
Definition: plugingui.h:499
CView * createUserCustomView(std::string viewname, const CRect rect, IControlListener *listener, int32_t tag)
void addControl(CControl *control)
Definition: plugingui.h:120
bool hasWriteableControl(CControl *control)
check to see if we already store this meter control
Definition: plugingui.h:730
PluginGUI(UTF8StringPtr _xmlFile)
bool controlAndContainerVisible(CControl *ctrl)
Definition: plugingui.h:303
CRect nonEditRect
non-edit area for GUI designer
Definition: plugingui.h:504
void updateControlsWithNormalizedValue(float normalizedValue, CControl *control=nullptr)
Definition: plugingui.h:198
virtual void controlTagDidChange(VSTGUI::CControl *pControl) override
virtual void controlEndEdit(VSTGUI::CControl *pControl) override
CVSTGUITimer * timer
timer object (this is platform dependent)
Definition: plugingui.h:500
bool controlInRxGroupIsEditing()
Definition: plugingui.h:157
std::string getStringByIndex(uint32_t index)
get string-list string by index
Definition: pluginparameter.cpp:281
float getNormalizedValueWithActualValue(float actualValue)
Definition: plugingui.h:181
CMouseEventResult sendAUMouseMoved(CControl *control, const CButtonState &buttons, const CPoint &where)
Definition: plugingui.h:538
float guiWidth
embedded GUI size
Definition: plugingui.h:512
int32_t onKeyDown(const VstKeyCode &code, CFrame *frame) override
Definition: plugingui.h:682
CPoint minSize
the min size of the GUI window
Definition: plugingui.h:502
Custom interface so that GUI can pass information to plugin shell in a thread-safe manner...
Definition: pluginstructures.h:1473
float guiHeight
embedded GUI size
Definition: plugingui.h:513
double getControlValueWithNormalizedValue(double normalizedValue, bool applyTaper=true)
get the new control value as if it were set with a normalized value
Definition: pluginparameter.h:305
Custom View interface to allow plugin core to create safe communication channels with GUI custom view...
Definition: pluginstructures.h:1395
bool hasRefGuiControl
internal flag
Definition: plugingui.h:380
void onViewRemoved(CFrame *frame, CView *view) override
bool isReservedTag(int tag)
check to see if a tag is reserved: ASPiK defines several reserved control ID values.
Definition: guiconstants.h:49
virtual bool validateCommandMenuItem(CCommandMenuItem *item)
validates menu item selections to prevent crashing
Definition: plugingui.cpp:738
Definition: customcontrols.cpp:20
std::string viewName
name
Definition: plugingui.h:495
size_t getStringCount()
get the number of individual strings in a string-list control
Definition: pluginparameter.h:227
void setControlValue(double actualParamValue, bool ignoreSmoothing=false)
the main function to set the underlying atomic double value
Definition: pluginparameter.h:175
void syncGUIControl(uint32_t controlID)
int getControlID_WithMouseCoords(const CPoint &where)
Definition: plugingui.h:330
uint32_t knobAction
knob mode
Definition: plugingui.h:517
CMouseEventResult onMouseMoved(CFrame *frame, const CPoint &where, const CButtonState &buttons) override
double getDefaultValueNormalized()
get default value as normalied value
Definition: pluginparameter.h:253
void onMouseEntered(CView *view, CFrame *frame) override
Definition: plugingui.h:670
void onMouseExited(CView *view, CFrame *frame) override
Definition: plugingui.h:673
ControlUpdateReceiver(CControl *control, PluginParameter *pluginParameterPtr, bool _isControlListener)
Definition: plugingui.h:87
The ControlUpdateReceiver object is the connection mechanism between PluginParameter objects and thei...
Definition: plugingui.h:83
bool hasICustomView(CView *view)
simple helper function to test view for ICustomView
Definition: plugingui.h:810
int32_t onKeyUp(const VstKeyCode &code, CFrame *frame) override
Definition: plugingui.h:685
bool hasControl(CControl *control)
Definition: plugingui.h:112
ControlUpdateReceiver * getControlUpdateReceiver(int32_t tag) const
virtual bool onCommandMenuItemSelected(CCommandMenuItem *item)
message handler for GUI Designer menu
Definition: plugingui.cpp:785
void scaleGUISize(uint32_t controlValue)
The PluginParameter object stores all of the data needed for any type of plugin parameter. It is a large object, but it is not complex as it really just stores LOTS of information about plugin parameters.
Definition: pluginparameter.h:51
CMouseEventResult sendAAXMouseDown(int controlID, const CButtonState &buttons)
CMouseEventResult onMouseDown(CFrame *frame, const CPoint &where, const CButtonState &buttons) override
virtual void setGUIWindowFrame(IGUIWindowFrame *frame) override
set the interface pointer for resizing from the GUI
Definition: plugingui.h:699
Custom interface to allow resizing of GUI window; this is mainly used for the GUI designer...
Definition: pluginstructures.h:1454
void initControl(CControl *control)
Definition: plugingui.h:206
bool createNewView
show the normal GUI
Definition: plugingui.h:508
Custom interface to allow resizing of GUI window; this is mainly used for the GUI designer...
Definition: pluginstructures.h:1430
double guiDesignerHeight
GUI Designer's frame size.
Definition: plugingui.h:511
The CXYPadEx object extends the CXYPad CVuMeter object with extra functionality. It is used in the Pl...
Definition: customcontrols.h:539
CFrame * guiEditorFrame
pointer to our frame
Definition: plugingui.h:516
void onViewAdded(CFrame *frame, CView *view) override
Definition: plugingui.h:664
static bool parseSize(const std::string &str, CPoint &point)
simple helper function to get size from string
Definition: plugingui.h:710
PluginParameter * getGuiControlWithTag(int tag)
find the local PluginParameter that is connected to the same control ID
Definition: plugingui.h:482
double getNormalizedControlValueWithActualValue(double actualValue)
get the new normalized control value as if it were set with an actual value
Definition: pluginparameter.h:342
void deleteControlUpdateReceivers()
delete all reciever objects
Definition: plugingui.h:781
UIDescription * description
the description version of the XML file
Definition: plugingui.h:494
virtual int32_t getKnobMode() const override
CMouseEventResult sendAUMouseDown(CControl *control, const CButtonState &buttons)
void checkRemoveWriteableControl(CControl *control)
check to see if we already store this meter control and remove it if we do
Definition: plugingui.h:761
CControl * getControl_WithMouseCoords(const CPoint &where)
PluginParameter refGuiControl
single parameter with this control tag
Definition: plugingui.h:378
int getControlID_WithMouseCoords(const CPoint &where)
void setPluginParameterFromGUIControl(CControl *control, int tag, float actualValue, float normalizedValue)
safely set a plugin shell parameter with a GUI control
Definition: plugingui.h:551
bool isControlListener
internal flag
Definition: plugingui.h:381
void forgetWriteableControls()
forget all writeable (neter) controls
Definition: plugingui.h:793
int32_t getControlID()
Definition: plugingui.h:297
bool createGUI(bool bShowGUIEditor)
CPoint maxSize
the max size of the GUI window
Definition: plugingui.h:503
std::string xmlFile
the XML file name
Definition: plugingui.h:496
void updateControlsWithActualValue(float actualValue, CControl *control=nullptr)
Definition: plugingui.h:216
virtual int32_t controlModifierClicked(VSTGUI::CControl *pControl, VSTGUI::CButtonState button) override
return 1 if you want the control to not handle it, otherwise 0
Definition: plugingui.h:633