Jamba  3.2.0
SwitchViewContainer.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 
21 
22 namespace pongasoft {
23 namespace VST {
24 namespace GUI {
25 namespace Views {
26 
41 class SwitchViewContainer : public CustomViewAdapter<CViewContainer>, IViewContainerListenerAdapter
42 {
43 public:
44  // Lifecycle
45  explicit SwitchViewContainer(const CRect &iSize);
46  ~SwitchViewContainer() override;
47 
48  // get/setSwitchControlTag
49  virtual void setSwitchControlTag (int32_t iTag) { fSwitchControlTag = iTag; };
50  int32_t getSwitchControlTag () const { return fSwitchControlTag; }
51 
52  // get/setTemplateNames
53  const std::vector<std::string> &getTemplateNames() const { return fTemplateNames; }
54  void setTemplateNames(const std::vector<std::string> &iNames) { fTemplateNames = iNames; switchCurrentView(); }
55 
56  // registerParameters
57  void registerParameters() override;
58 
59  // afterCreate
60  virtual void afterCreate(IUIDescription const *iDescription, IController *iController);
61 
62  // onParameterChange
63  void onParameterChange(ParamID iParamID) override;
64 
65 protected:
71  void viewContainerViewAdded(CViewContainer *container, CView *view) override;
72 
75  virtual void switchCurrentView();
76 
81  virtual void setCurrentView(CView *iCurrentView);
82 
86  virtual std::string computeTemplateName(int iIndex);
87 
88 protected:
89  IUIDescription const *fUIDescription{};
90  IController *fUIController{};
91 
92  int32_t fSwitchControlTag{-1};
94 
95  std::vector<std::string> fTemplateNames;
96 
97  CView *fCurrentView{};
98  std::string fCurrentTemplateName{};
99 
100 public:
101  class Creator : public CustomViewCreator<SwitchViewContainer, CustomViewAdapter<CViewContainer>>
102  {
103  public:
104  explicit Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
105  CustomViewCreator(iViewName, iDisplayName)
106  {
109  }
110  };
111 };
112 
117 template<>
119  const UIAttributes &iAttributes,
120  const IUIDescription *iDescription);
121 
122 }
123 }
124 }
125 }
Definition: CustomViewCreator.h:1049
virtual void afterCreate(IUIDescription const *iDescription, IController *iController)
Definition: SwitchViewContainer.cpp:46
int32_t getSwitchControlTag() const
Definition: SwitchViewContainer.h:50
virtual void setSwitchControlTag(int32_t iTag)
Definition: SwitchViewContainer.h:49
Definition: GUIRawVstParameter.h:216
void registerTagAttribute(std::string const &iName, typename TagAttribute::Getter iGetter, typename TagAttribute::Setter iSetter)
Definition: CustomViewCreator.h:874
const std::vector< std::string > & getTemplateNames() const
Definition: SwitchViewContainer.h:53
Definition: Clock.h:22
Definition: SwitchViewContainer.h:41
~SwitchViewContainer() override
Definition: SwitchViewContainer.cpp:37
virtual void switchCurrentView()
Definition: SwitchViewContainer.cpp:74
CView * fCurrentView
Definition: SwitchViewContainer.h:97
std::vector< std::string > fTemplateNames
Definition: SwitchViewContainer.h:95
virtual void setCurrentView(CView *iCurrentView)
Definition: SwitchViewContainer.cpp:109
std::string fCurrentTemplateName
Definition: SwitchViewContainer.h:98
void viewContainerViewAdded(CViewContainer *container, CView *view) override
Definition: SwitchViewContainer.cpp:126
void registerParameters() override
Definition: SwitchViewContainer.cpp:55
SwitchViewContainer * createCustomView< SwitchViewContainer >(CRect const &iSize, const UIAttributes &iAttributes, const IUIDescription *iDescription)
Definition: SwitchViewContainer.cpp:150
void setTemplateNames(const std::vector< std::string > &iNames)
Definition: SwitchViewContainer.h:54
virtual std::string computeTemplateName(int iIndex)
Definition: SwitchViewContainer.cpp:138
IUIDescription const * fUIDescription
Definition: SwitchViewContainer.h:89
void registerVectorStringAttribute(std::string const &iName, typename VectorStringAttribute::Getter iGetter, typename VectorStringAttribute::Setter iSetter, char iDelimiter=',', bool iSkipEmptyEntries=false)
Definition: CustomViewCreator.h:862
Creator(char const *iViewName=nullptr, char const *iDisplayName=nullptr)
Definition: SwitchViewContainer.h:104
int32_t fSwitchControlTag
Definition: SwitchViewContainer.h:92
IController * fUIController
Definition: SwitchViewContainer.h:90
void onParameterChange(ParamID iParamID) override
Definition: SwitchViewContainer.cpp:99
GUIRawVstParam fControlSwitch
Definition: SwitchViewContainer.h:93
SwitchViewContainer(const CRect &iSize)
Definition: SwitchViewContainer.cpp:29