Jamba C++ API  4.1.0
DebugParamDisplayView.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 #include <pongasoft/VST/Timer.h>
22 
24 
36 class DebugParamDisplayView : public ParamDisplayView, public ITimerCallback
37 {
38 public:
39  // Constructor
40  explicit DebugParamDisplayView(const CRect &iSize) : ParamDisplayView(iSize) {}
41 
42  // afterApplyAttributes - simply store the back color and font color (to be able to swap/revert)
43  void afterApplyAttributes() override
44  {
45  fBackColor = getBackColor();
46  fFontColor = getFontColor();
48  }
49 
53  void onTimer(Timer *timer) override
54  {
55  setBackColor(fBackColor);
56  setFontColor(fFontColor);
57  fTimer = nullptr;
58  markDirty();
59  }
60 
64  void onParameterChange(ParamID iParamID) override
65  {
66  setBackColor(fFontColor);
67  setFontColor(fBackColor);
68 
69  // this is safe to call even if there is already a timer pending because the previous one
70  // will be released automatically (due to the behavior of AutoReleaseTimer)
72 
74  }
75 
77  uint32 getHighlightDurationMs() const { return fHighlightDurationMs; }
78  void setHighlightDurationMs(uint32 iValue) { fHighlightDurationMs = iValue; }
79 
80 private:
81  CColor fBackColor{};
82  CColor fFontColor{};
83 
84  uint32 fHighlightDurationMs{1000};
85 
86  std::unique_ptr<AutoReleaseTimer> fTimer{};
87 
88 public:
89  class Creator : public CustomViewCreator<DebugParamDisplayView, ParamDisplayView>
90  {
91  public:
92  explicit Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
93  CustomViewCreator(iViewName, iDisplayName)
94  {
95  registerIntegerAttribute<uint32>("highlight-duration-ms", &DebugParamDisplayView::getHighlightDurationMs, &DebugParamDisplayView::setHighlightDurationMs);
96  }
97  };
98 };
99 
100 }
Inherit from this class to provide the factory for a custom view.
Definition: CustomViewCreator.h:1311
void afterApplyAttributes() override
Handles the lifecycle behavior getting triggered once all the attributes have been set (which usually...
Definition: CustomView.h:387
uint32 fHighlightDurationMs
Definition: DebugParamDisplayView.h:84
This parameter simply extends ParamDisplayView to "highlight" the parameter for highlight-duration-ms...
Definition: DebugParamDisplayView.h:36
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 onParameterChange(ParamID iParamID) override
Callback when a parameter changes.
Definition: CustomView.h:384
DebugParamDisplayView(const CRect &iSize)
Definition: DebugParamDisplayView.h:40
std::unique_ptr< AutoReleaseTimer > fTimer
Definition: DebugParamDisplayView.h:86
CColor fBackColor
Definition: DebugParamDisplayView.h:81
void afterApplyAttributes() override
Called after the attributes have been applied by the framework.
Definition: DebugParamDisplayView.h:43
uint32 getHighlightDurationMs() const
Duration (in ms) to highlight the parameter for when it changes.
Definition: DebugParamDisplayView.h:77
CColor fFontColor
Definition: DebugParamDisplayView.h:82
Definition: CustomController.h:24
static std::unique_ptr< AutoReleaseTimer > create(Steinberg::ITimerCallback *iCallback, Steinberg::uint32 iIntervalMilliseconds)
Creates and return an auto release timer.
Definition: Timer.h:54
void setHighlightDurationMs(uint32 iValue)
Definition: DebugParamDisplayView.h:78
void onParameterChange(ParamID iParamID) override
Swap back and font colors and starts a timer to revert them back.
Definition: DebugParamDisplayView.h:64
Creator(char const *iViewName=nullptr, char const *iDisplayName=nullptr)
Definition: DebugParamDisplayView.h:92
void onTimer(Timer *timer) override
Executed when the timer expires: revert the colors to their original state.
Definition: DebugParamDisplayView.h:53