Jamba C++ API  6.3.0
CustomController.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 (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/uidescription/delegationcontroller.h>
22 #include "StateAware.h"
23 
25 
32 class CustomController : public VSTGUI::DelegationController, public ParamAware
33 {
34 public:
35  // Constructor
36  explicit CustomController(IController *iBaseController) : DelegationController(iBaseController) {}
37 };
38 
39 
49 template<typename TGUIState>
50 class StateAwareCustomController : public CustomController, public StateAware<TGUIState>
51 {
52  // ensures that TGUIState is a subclass of GUIState
53  static_assert(std::is_convertible<TGUIState *, GUIState*>::value, "TGUIState must be a subclass of GUIState");
54 
55 public:
56  // Constructor
57  explicit StateAwareCustomController(IController *iBaseController) : CustomController(iBaseController) {}
58 
79  template<typename TView>
80  inline ParamAwareView<TView> *makeParamAware(TView *iView) {
81  return StateAware<TGUIState>::fState->makeParamAware(iView);
82  }
83 
84 protected:
87  void initState(GUIState *iGUIState) override
88  {
89  CustomController::initState(iGUIState);
91  }
92 };
93 
97 template<typename TGUIState>
98 class [[deprecated("Since 4.0.0 - Use StateAwareCustomController instead")]] PluginCustomController : public StateAwareCustomController<TGUIState>
99 {
100 public:
101  explicit PluginCustomController(IController *iBaseController) :
102  StateAwareCustomController<TGUIState>(iBaseController)
103  {}
104 };
105 }
Override from this class if you need to implement a controller specific to a given plugin.
Definition: CustomController.h:50
This class is inherited by classes who want to be aware of parameters and be notified when they chang...
Definition: ParamAware.h:63
This class is used to get access to the GUI state and parameters of the plugin with their actual type...
Definition: StateAware.h:30
Definition: GUIState.h:41
Base class that a custom controller can inherit from.
Definition: CustomController.h:32
CustomController(IController *iBaseController)
Definition: CustomController.h:36
virtual void initState(GUIState *iGUIState)
Called during initialization.
Definition: ParamAware.cpp:36
StateAwareCustomController(IController *iBaseController)
Definition: CustomController.h:57
ParamAwareView< TView > * makeParamAware(TView *iView)
Allow for registering an arbitrary callback on an arbitrary view without having to inherit from the v...
Definition: CustomController.h:80
virtual void initState(GUIState *iGUIState)
This method is called by Jamba automatically to initialize the state.
Definition: StateAware.h:41
Definition: CustomController.h:24
This subclass allows for registering callbacks to any kind of view without having to inherit from it.
Definition: ParamAware.h:561
void initState(GUIState *iGUIState) override
Overriden to call both ParamAware::initState() and StateAware::initState()
Definition: CustomController.h:87
PluginCustomController(IController *iBaseController)
Definition: CustomController.h:101