Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
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 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
22#include <pongasoft/VST/Timer.h>
23
25
37class DebugParamDisplayView : public ParamDisplayView, public ITimerCallback
38{
39public:
40 // Constructor
41 explicit DebugParamDisplayView(const CRect &iSize) : ParamDisplayView(iSize) {}
42
43 // afterApplyAttributes - simply store the back color and font color (to be able to swap/revert)
44 void afterApplyAttributes() override
45 {
46 fBackColor = getBackColor();
47 fFontColor = getFontColor();
49 }
50
54 void onTimer(Timer *timer) override
55 {
56 setBackColor(fBackColor);
57 setFontColor(fFontColor);
58 fTimer = nullptr;
59 markDirty();
60 }
61
65 void onParameterChange(ParamID iParamID) override
66 {
67 setBackColor(fFontColor);
68 setFontColor(fBackColor);
69
70 // this is safe to call even if there is already a timer pending because the previous one
71 // will be released automatically (due to the behavior of AutoReleaseTimer)
73
75 }
76
79 void setHighlightDurationMs(uint32 iValue) { fHighlightDurationMs = iValue; }
80
81private:
82 CColor fBackColor{};
83 CColor fFontColor{};
84
86
87 std::unique_ptr<AutoReleaseTimer> fTimer{};
88
89public:
90 class Creator : public CustomViewCreator<DebugParamDisplayView, ParamDisplayView>
91 {
92 public:
93 explicit Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
94 CustomViewCreator(iViewName, iDisplayName)
95 {
97 }
98 };
99};
100
101}
static std::unique_ptr< AutoReleaseTimer > create(Steinberg::ITimerCallback *iCallback, Steinberg::uint32 iIntervalMilliseconds)
Creates and return an auto release timer.
Definition Timer.h:55
void onParameterChange(ParamID iParamID) override
Callback when a parameter changes.
Definition CustomView.h:385
void afterApplyAttributes() override
Definition CustomView.h:388
CustomViewCreator(char const *iViewName=nullptr, char const *iDisplayName=nullptr, char const *iBaseViewName=VSTGUI::UIViewCreator::kCView)
Definition CustomViewCreator.h:1318
Creator(char const *iViewName=nullptr, char const *iDisplayName=nullptr)
Definition DebugParamDisplayView.h:93
void onParameterChange(ParamID iParamID) override
Swap back and font colors and starts a timer to revert them back.
Definition DebugParamDisplayView.h:65
void onTimer(Timer *timer) override
Executed when the timer expires: revert the colors to their original state.
Definition DebugParamDisplayView.h:54
uint32 fHighlightDurationMs
Definition DebugParamDisplayView.h:85
void afterApplyAttributes() override
Handles the lifecycle behavior getting triggered once all the attributes have been set (which usually...
Definition DebugParamDisplayView.h:44
uint32 getHighlightDurationMs() const
Duration (in ms) to highlight the parameter for when it changes.
Definition DebugParamDisplayView.h:78
CColor fBackColor
Definition DebugParamDisplayView.h:82
std::unique_ptr< AutoReleaseTimer > fTimer
Definition DebugParamDisplayView.h:87
CColor fFontColor
Definition DebugParamDisplayView.h:83
DebugParamDisplayView(const CRect &iSize)
Definition DebugParamDisplayView.h:41
void setHighlightDurationMs(uint32 iValue)
Definition DebugParamDisplayView.h:79
ParamDisplayView(const CRect &iSize)
Definition ParamDisplayView.h:44
void registerIntegerAttribute(std::string const &iName, typename IntegerAttribute< TInt >::Getter iGetter, typename IntegerAttribute< TInt >::Setter iSetter)
Definition CustomViewCreator.h:1060
Definition CustomController.h:25