ASPiK SDK
vst3editor.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __vst3editor__
6 #define __vst3editor__
7 
8 #include "public.sdk/source/vst/vstguieditor.h"
9 #include "pluginterfaces/vst/ivstplugview.h"
10 #include "../uidescription/uidescription.h"
11 #include "../uidescription/icontroller.h"
12 #include <string>
13 #include <vector>
14 #include <map>
15 
16 #if VST_VERSION >= 0x030607
17 #include "pluginterfaces/gui/iplugviewcontentscalesupport.h"
18 #define VST3_CONTENT_SCALE_SUPPORT
19 #endif
20 
21 namespace VSTGUI {
22 class ParameterChangeListener;
23 class VST3Editor;
24 
25 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
30 {
31 public:
32  virtual ~VST3EditorDelegate () {}
33 
34  virtual CView* createCustomView (UTF8StringPtr name, const UIAttributes& attributes, const IUIDescription* description, VST3Editor* editor) { return 0; }
35  virtual CView* verifyView (CView* view, const UIAttributes& attributes, const IUIDescription* description, VST3Editor* editor) { return view; }
36  virtual bool findParameter (const CPoint& pos, Steinberg::Vst::ParamID& paramID, VST3Editor* editor) { return false; }
37  virtual bool isPrivateParameter (const Steinberg::Vst::ParamID paramID) { return false; }
38  virtual void didOpen (VST3Editor* editor) {}
39  virtual void willClose (VST3Editor* editor) {}
40  virtual COptionMenu* createContextMenu (const CPoint& pos, VST3Editor* editor) { return 0; }
41 
44  virtual IController* createSubController (UTF8StringPtr name, const IUIDescription* description, VST3Editor* editor) { return 0; }
45 };
46 
47 //-----------------------------------------------------------------------------
50 //-----------------------------------------------------------------------------
51 class VST3Editor : public Steinberg::Vst::VSTGUIEditor,
52  public Steinberg::Vst::IParameterFinder,
53  public IController,
55  public IMouseObserver
56 #ifdef VST3_CONTENT_SCALE_SUPPORT
57  , public Steinberg::IPlugViewContentScaleSupport
58 #endif
59 {
60 public:
61  VST3Editor (Steinberg::Vst::EditController* controller, UTF8StringPtr templateName, UTF8StringPtr xmlFile);
62  VST3Editor (UIDescription* desc, Steinberg::Vst::EditController* controller, UTF8StringPtr templateName, UTF8StringPtr xmlFile = 0);
63 
64  bool exchangeView (UTF8StringPtr templateName);
65  void enableTooltips (bool state);
66 
67  bool setEditorSizeConstrains (const CPoint& newMinimumSize, const CPoint& newMaximumSize);
68  void getEditorSizeConstrains (CPoint& minimumSize, CPoint& maximumSize) const;
69  bool requestResize (const CPoint& newSize);
70 
71  void setZoomFactor (double factor);
72  double getZoomFactor () const { return zoomFactor; }
73 
74  void setAllowedZoomFactors (std::vector<double> zoomFactors) { allowedZoomFactors = zoomFactors; }
75 
76 //-----------------------------------------------------------------------------
77  DELEGATE_REFCOUNT(Steinberg::Vst::VSTGUIEditor)
78  Steinberg::tresult PLUGIN_API queryInterface (const ::Steinberg::TUID iid, void** obj) override;
79 protected:
80  ~VST3Editor ();
81  void init ();
82  double getAbsScaleFactor () const;
83  ParameterChangeListener* getParameterChangeListener (int32_t tag) const;
84  void recreateView ();
85 
86  void syncParameterTags ();
87  void save (bool saveAs = false);
88  bool enableEditing (bool state);
89 
90  bool PLUGIN_API open (void* parent, const PlatformType& type) override;
91  void PLUGIN_API close () override;
92 
93  void beginEdit (int32_t index) override;
94  void endEdit (int32_t index) override;
95 
96  CView* createView (const UIAttributes& attributes, const IUIDescription* description) override;
97  CView* verifyView (CView* view, const UIAttributes& attributes, const IUIDescription* description) override;
98  IController* createSubController (UTF8StringPtr name, const IUIDescription* description) override;
99 
100  CMessageResult notify (CBaseObject* sender, IdStringPtr message) override;
101 
102  bool beforeSizeChange (const CRect& newSize, const CRect& oldSize) override;
103 
104  Steinberg::tresult PLUGIN_API onSize (Steinberg::ViewRect* newSize) override;
105  Steinberg::tresult PLUGIN_API canResize () override;
106  Steinberg::tresult PLUGIN_API checkSizeConstraint (Steinberg::ViewRect* rect) override;
107 
108  // IParameterFinder
109  Steinberg::tresult PLUGIN_API findParameter (Steinberg::int32 xPos, Steinberg::int32 yPos, Steinberg::Vst::ParamID& resultTag) override;
110 
111  // IControlListener
112  virtual void valueChanged (CControl* pControl) override;
113  virtual void controlBeginEdit (CControl* pControl) override;
114  virtual void controlEndEdit (CControl* pControl) override;
115  virtual void controlTagWillChange (CControl* pControl) override;
116  virtual void controlTagDidChange (CControl* pControl) override;
117 
118  // IViewAddedRemovedObserver
119  void onViewAdded (CFrame* frame, CView* view) override;
120  void onViewRemoved (CFrame* frame, CView* view) override;
121 
122  // IMouseObserver
123  void onMouseEntered (CView* view, CFrame* frame) override {}
124  void onMouseExited (CView* view, CFrame* frame) override {}
125  CMouseEventResult onMouseMoved (CFrame* frame, const CPoint& where, const CButtonState& buttons) override { return kMouseEventNotHandled; }
126  CMouseEventResult onMouseDown (CFrame* frame, const CPoint& where, const CButtonState& buttons) override;
127 
128 #ifdef VST3_CONTENT_SCALE_SUPPORT
129  Steinberg::tresult PLUGIN_API setContentScaleFactor (ScaleFactor factor) override;
130 #endif
131 
132  struct KeyboardHook;
133  KeyboardHook* keyboardHook {nullptr};
134  UIDescription* description {nullptr};
135  VST3EditorDelegate* delegate {nullptr};
136  IController* originalController {nullptr};
137  typedef std::map<int32_t, ParameterChangeListener*> ParameterChangeListenerMap;
138  ParameterChangeListenerMap paramChangeListeners;
139  std::string viewName;
140  std::string xmlFile;
141  bool tooltipsEnabled {true};
142  bool doCreateView {false};
143  bool editingEnabled {false};
144  bool requestResizeGuard {false};
145 
146  double contentScaleFactor {1.};
147  double zoomFactor {1.};
148  std::vector<double> allowedZoomFactors;
149 
150  CPoint minSize;
151  CPoint maxSize;
152  CRect nonEditRect;
153 };
154 
155 } // namespace
156 
157 #endif
virtual COptionMenu * createContextMenu(const CPoint &pos, VST3Editor *editor)
create the context menu for the editor, will be added to the host menu
Definition: vst3editor.h:40
VST3 Editor with automatic parameter binding.
Definition: vst3editor.h:51
a popup menu control
Definition: coptionmenu.h:137
Rect structure.
Definition: crect.h:17
CMouseEventResult onMouseMoved(CFrame *frame, const CPoint &where, const CButtonState &buttons) override
a mouse move event happend on the frame at position where. If the observer handles this...
Definition: vst3editor.h:125
Definition: iuidescription.h:19
virtual CView * verifyView(CView *view, const UIAttributes &attributes, const IUIDescription *description, VST3Editor *editor)
verify a view after it was created
Definition: vst3editor.h:35
Definition: xmlparse.c:181
view added removed observer interface for CFrame
Definition: cframe.h:281
Base Object with reference counter.
Definition: vstguibase.h:276
XML description parser and view creator.
Definition: uidescription.h:24
Definition: vst3editor.cpp:95
virtual void didOpen(VST3Editor *editor)
called after the editor was opened
Definition: vst3editor.h:38
delegate extension to Steinberg::Vst::EditController for a VST3 Editor
Definition: vst3editor.h:29
virtual IController * createSubController(UTF8StringPtr name, const IUIDescription *description, VST3Editor *editor)
create a sub controller
Definition: vst3editor.h:44
Definition: customcontrols.cpp:8
base class of all VSTGUI controls
Definition: ccontrol.h:76
virtual CView * createCustomView(UTF8StringPtr name, const UIAttributes &attributes, const IUIDescription *description, VST3Editor *editor)
create a custom view
Definition: vst3editor.h:34
Definition: uiattributes.h:21
Button and Modifier state.
Definition: cbuttonstate.h:34
extension to IControlListener used by UIDescription
Definition: icontroller.h:20
Base Class of all view objects.
Definition: cview.h:44
CMouseEventResult onMouseDown(CFrame *frame, const CPoint &where, const CButtonState &buttons) override
a mouse down event happend on the frame at position where. If the observer handles this...
Definition: vst3editor.cpp:793
virtual bool findParameter(const CPoint &pos, Steinberg::Vst::ParamID &paramID, VST3Editor *editor)
find a parameter
Definition: vst3editor.h:36
virtual void willClose(VST3Editor *editor)
called before the editor will close
Definition: vst3editor.h:39
Point structure.
Definition: cpoint.h:17
The CFrame is the parent container of all views.
Definition: cframe.h:32
virtual bool isPrivateParameter(const Steinberg::Vst::ParamID paramID)
check if parameter ID is private and should not be exposed to the host
Definition: vst3editor.h:37
generic mouse observer interface for CFrame
Definition: cframe.h:252