Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
CustomControlView.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2019 pongasoft
3 *
4 * Licensed under the Apache License, Version 2.0 or the MIT license,
5 * at your option. You may not use this file except in compliance with
6 * one of these licenses. You may obtain copies of the licenses at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 * https://opensource.org/licenses/MIT
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 *
17 * @author Yan Pujante
18 */
19#pragma once
20
21#include "CustomView.h"
22
24
43{
44public:
45 explicit CustomControlView(const CRect &iSize) : CustomView(iSize) {}
46
48 virtual void setControlTag (ParamID iTag) { fControlTag = iTag; };
49
59 ParamID getControlTag () const { return fControlTag; }
60
61public:
62 CLASS_METHODS_NOCOPY(CustomControlView, CustomView)
63
64protected:
66
67public:
68 class Creator : public CustomViewCreator<CustomControlView, CustomView>
69 {
70 public:
71 explicit Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
72 CustomViewCreator(iViewName, iDisplayName)
73 {
75 }
76 };
77};
78
88template<typename T>
90{
91public:
92 // TCustomControlView
93 explicit TCustomControlView(const CRect &iSize) : CustomControlView(iSize) {}
94
95public:
96 CLASS_METHODS_NOCOPY(TCustomControlView, CustomControlView)
97
98
101
104 virtual void setControlValue(T const &iControlValue);
105
108 void registerParameters() override;
109
110protected:
111 // the gui parameter tied to the control (handle vst/jmb or simple value)
113
114public:
116};
117
125
154{
155public:
156 // CustomDiscreteControlView
157 explicit CustomDiscreteControlView(const CRect &iSize) : TCustomControlView<int32>(iSize) {}
158
166 int32 getStepCount() const { return fStepCount; }
167
169 void setStepCount(int32 iStepCount) { fStepCount = iStepCount; }
170
171public:
173
174
175 void registerParameters() override;
176
177protected:
178 int32 fStepCount{-1};
179
180public:
181 class Creator : public CustomViewCreator<CustomDiscreteControlView, TCustomControlView<int32>>
182 {
183 public:
184 explicit Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
185 CustomViewCreator(iViewName, iDisplayName)
186 {
188 }
189 };
190};
191
192//------------------------------------------------------------------------
193// TCustomControlView<T>::getControlValue
194//------------------------------------------------------------------------
195template<typename T>
197{
198 return fControlParameter.getValue();
199}
200
201//------------------------------------------------------------------------
202// TCustomControlView<T>::setControlValue
203//------------------------------------------------------------------------
204template<typename T>
205void TCustomControlView<T>::setControlValue(T const &iControlValue)
206{
207 fControlParameter.update(iControlValue);
208}
209
210//------------------------------------------------------------------------
211// TCustomControlView<T>::registerParameters
212//------------------------------------------------------------------------
213template<typename T>
219
220}
Represents an optional parameter (Jmb, Vst or no param at all).
Definition GUIOptionalParam.h:50
virtual void registerParameters()
Subclasses should override this method to register each parameter.
Definition ParamAware.h:498
GUIOptionalParam< T > registerOptionalParam(ParamID iParamID, bool iSubscribeToChanges=true)
Registers an optional parameter which handles Vst, Jmb or no parameter at all.
Definition ParamAware.hpp:31
Creator(char const *iViewName=nullptr, char const *iDisplayName=nullptr)
Definition CustomControlView.h:71
Base class for custom views which are tied to one parameter only (similar to CControl).
Definition CustomControlView.h:43
virtual void setControlTag(ParamID iTag)
Definition CustomControlView.h:48
ParamID getControlTag() const
Id of the parameter that this view manages.
Definition CustomControlView.h:59
ParamID fControlTag
Definition CustomControlView.h:65
CustomControlView(const CRect &iSize)
Definition CustomControlView.h:45
Creator(char const *iViewName=nullptr, char const *iDisplayName=nullptr)
Definition CustomControlView.h:184
Specialization of TCustomControlView for discrete values.
Definition CustomControlView.h:154
void setStepCount(int32 iStepCount)
Definition CustomControlView.h:169
void registerParameters() override
Registers the optional parameter using getControlTag() as its id.
Definition CustomControlView.cpp:27
int32 getStepCount() const
The number of steps of the managed discrete parameter as specified by this view.
Definition CustomControlView.h:166
CustomDiscreteControlView(const CRect &iSize)
Definition CustomControlView.h:157
int32 fStepCount
Definition CustomControlView.h:178
Inherit from this class to provide the factory for a custom view.
Definition CustomViewCreator.h:1316
CustomViewCreator(char const *iViewName=nullptr, char const *iDisplayName=nullptr, char const *iBaseViewName=VSTGUI::UIViewCreator::kCView)
Definition CustomViewCreator.h:1318
Class you should inherit from if you want to write a custom view.
Definition CustomView.h:62
CustomView(const CRect &iSize)
Definition CustomView.cpp:30
Base class which extends CustomControlView to provide the type (T) of the underlying parameter this v...
Definition CustomControlView.h:90
TCustomControlView(const CRect &iSize)
Definition CustomControlView.h:93
GUIOptionalParam< ParamValue > fControlParameter
Definition CustomControlView.h:112
virtual void setControlValue(ParamValue const &iControlValue)
CustomViewCreator< TCustomControlView< T >, CustomControlView > Creator
Definition CustomControlView.h:115
void registerIntegerAttribute(std::string const &iName, typename IntegerAttribute< TInt >::Getter iGetter, typename IntegerAttribute< TInt >::Setter iSetter)
Definition CustomViewCreator.h:1060
void registerTagAttribute(std::string const &iName, typename TagAttribute::Getter iGetter, typename TagAttribute::Setter iSetter)
Definition CustomViewCreator.h:1049
Definition CustomController.h:25
TCustomControlView< ParamValue > RawCustomControlView
Specialization for raw parameter (ParamValue / no conversion).
Definition CustomControlView.h:124
constexpr ParamID UNDEFINED_PARAM_ID
Constant used throughout the code to test whether the ParamID represents a valid id or an undefined o...
Definition Types.h:48