Jamba C++ API  5.0.0
ParamDisplayView.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 pongasoft
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  *
16  * @author Yan Pujante
17  */
18 #pragma once
19 
20 #include <vstgui4/vstgui/lib/controls/cparamdisplay.h>
22 
23 #include "CustomView.h"
24 
26 
36 class ParamDisplayView : public CustomViewAdapter<CParamDisplay>
37 {
38 public:
40 
41 public:
42  // Constructor
43  explicit ParamDisplayView(const CRect &iSize) : super_type(iSize)
44  {
45  tag = UNDEFINED_PARAM_ID;
46  }
47 
48  // draw - overridden to handle any parameter
49  void draw(CDrawContext *iContext) override;
50 
58  int32 getPrecisionOverride() const { return fPrecisionOverride; }
59  void setPrecisionOverride(int32 iPrecisionOverride) { fPrecisionOverride = iPrecisionOverride; markDirty(); }
60 
61  // registerParameters
62  void registerParameters() override;
63 
64 protected:
65  int32 fPrecisionOverride{-1};
66 
68 
69 public:
70  class Creator : public CustomViewCreator<ParamDisplayView, super_type>
71  {
72  public:
73  explicit Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
74  CustomViewCreator(iViewName, iDisplayName, VSTGUI::UIViewCreator::kCParamDisplay)
75  {
76  registerIntegerAttribute<int32>("precision-override", &ParamDisplayView::getPrecisionOverride, &ParamDisplayView::setPrecisionOverride);
77  }
78  };
79 };
80 
81 }
82 
Inherit from this class to provide the factory for a custom view.
Definition: CustomViewCreator.h:1314
int32 fPrecisionOverride
Definition: ParamDisplayView.h:65
ParamDisplayView(const CRect &iSize)
Definition: ParamDisplayView.h:43
void setPrecisionOverride(int32 iPrecisionOverride)
Definition: ParamDisplayView.h:59
int32 getPrecisionOverride() const
Allow to override the precision of the parameter.
Definition: ParamDisplayView.h:58
This view extends CParamDisplay to work for both Vst and Jmb parameters.
Definition: ParamDisplayView.h:36
void markDirty()
Marks this view dirty which will (at the appropriate time in the rendering lifecycle) trigger a call ...
Definition: CustomView.h:346
void draw(CDrawContext *iContext) override
Definition: ParamDisplayView.cpp:26
This class can be used to extend VSTGUI classes directly while still benefiting from the extensions a...
Definition: CustomView.h:335
void registerParameters() override
Subclasses should override this method to register each parameter.
Definition: ParamDisplayView.cpp:41
Creator(char const *iViewName=nullptr, char const *iDisplayName=nullptr)
Definition: ParamDisplayView.h:73
Definition: Types.h:29
Definition: CustomController.h:24
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:47
Wrapper instance returned by ParamAware::registerBaseParam() methods.
Definition: IGUIParameter.h:401
IGUIParam fParam
Definition: ParamDisplayView.h:67