Mercurial > hg > pub > prymula > com
comparison DPF-Prymula-audioplugins/plugins/CloneChannel/DistrhoUICloneChannel.cpp @ 3:84e66ea83026
DPF-Prymula-audioplugins-0.231015-2
author | prymula <prymula76@outlook.com> |
---|---|
date | Mon, 16 Oct 2023 21:53:34 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:cf2cb71d31dd | 3:84e66ea83026 |
---|---|
1 /* | |
2 * DISTRHO CloneChannel - Copyright (C) 2023 Przemysław R. Pietraszczyk | |
3 * Based on DPF'ied SoulForce. | |
4 * Copyright (C) 2006 Niall Moody | |
5 * Copyright (C) 2015-2021 Filipe Coelho <falktx@falktx.com> | |
6 * | |
7 * Permission is hereby granted, free of charge, to any person obtaining a | |
8 * copy of this software and associated documentation files (the "Software"), | |
9 * to deal in the Software without restriction, including without limitation | |
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
11 * and/or sell copies of the Software, and to permit persons to whom the | |
12 * Software is furnished to do so, subject to the following conditions: | |
13 * | |
14 * The above copyright notice and this permission notice shall be included in | |
15 * all copies or substantial portions of the Software. | |
16 * | |
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
23 * DEALINGS IN THE SOFTWARE. | |
24 */ | |
25 | |
26 #include "DistrhoUICloneChannel.hpp" | |
27 #include "DistrhoPluginCloneChannel.hpp" | |
28 | |
29 START_NAMESPACE_DISTRHO | |
30 | |
31 namespace Art = DistrhoArtworkCloneChannel; | |
32 | |
33 // ----------------------------------------------------------------------- | |
34 DistrhoUICloneChannel::DistrhoUICloneChannel() | |
35 : UI(Art::backgroundWidth, Art::backgroundHeight, true), | |
36 fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, kImageFormatBGR) | |
37 { | |
38 // switches | |
39 fSwitchSource = new ImageSwitch(this, | |
40 Image(Art::switch_leftData, Art::switch_leftWidth, Art::switch_leftHeight, kImageFormatBGR), | |
41 Image(Art::switch_rightData, Art::switch_rightWidth, Art::switch_rightHeight, kImageFormatBGR)); | |
42 fSwitchSource->setId(DistrhoPluginCloneChannel::kParameterSource); | |
43 fSwitchSource->setAbsolutePos(116, 191); | |
44 fSwitchSource->setCallback(this); | |
45 | |
46 fSwitchSource2 = new ImageSwitch(this, | |
47 Image(Art::switch_leftData, Art::switch_leftWidth, Art::switch_leftHeight, kImageFormatBGR), | |
48 Image(Art::switch_rightData, Art::switch_rightWidth, Art::switch_rightHeight, kImageFormatBGR)); | |
49 fSwitchSource2->setId(DistrhoPluginCloneChannel::kParameterSource2); | |
50 fSwitchSource2->setAbsolutePos(116, 251); | |
51 fSwitchSource2->setCallback(this); | |
52 | |
53 // set initial values | |
54 programLoaded(0); | |
55 } | |
56 | |
57 // ----------------------------------------------------------------------- | |
58 // DSP Callbacks | |
59 | |
60 void DistrhoUICloneChannel::parameterChanged(uint32_t index, float value) | |
61 { | |
62 switch (index) | |
63 { | |
64 case DistrhoPluginCloneChannel::kParameterSource: | |
65 fSwitchSource->setDown(value > 0.5f); | |
66 break; | |
67 case DistrhoPluginCloneChannel::kParameterSource2: | |
68 fSwitchSource2->setDown(value > 0.5f); | |
69 break; | |
70 } | |
71 } | |
72 | |
73 void DistrhoUICloneChannel::programLoaded(uint32_t index) | |
74 { | |
75 switch(index) | |
76 { | |
77 case DistrhoPluginCloneChannel::kProgramDefault: | |
78 fSwitchSource->setDown(false); | |
79 fSwitchSource2->setDown(false); | |
80 break; | |
81 case DistrhoPluginCloneChannel::kProgramStayDown: | |
82 fSwitchSource->setDown(false); | |
83 fSwitchSource2->setDown(false); | |
84 break; | |
85 case DistrhoPluginCloneChannel::kProgramLookingForTheWorld: | |
86 fSwitchSource->setDown(false); | |
87 fSwitchSource2->setDown(false); | |
88 break; | |
89 case DistrhoPluginCloneChannel::kProgramGuerillaLove: | |
90 fSwitchSource->setDown(false); | |
91 fSwitchSource2->setDown(false); | |
92 break; | |
93 case DistrhoPluginCloneChannel::kProgramTumbleToThePower: | |
94 fSwitchSource->setDown(false); | |
95 fSwitchSource2->setDown(false); | |
96 break; | |
97 case DistrhoPluginCloneChannel::kProgramDoYourselfFavour: | |
98 fSwitchSource->setDown(true); | |
99 fSwitchSource2->setDown(true); | |
100 break; | |
101 case DistrhoPluginCloneChannel::kProgramPastIsPast: | |
102 fSwitchSource->setDown(true); | |
103 fSwitchSource2->setDown(true); | |
104 break; | |
105 case DistrhoPluginCloneChannel::kProgramYouAndOnlyYou: | |
106 fSwitchSource->setDown(false); | |
107 fSwitchSource2->setDown(false); | |
108 break; | |
109 case DistrhoPluginCloneChannel::kProgramCloneChannel: | |
110 fSwitchSource->setDown(true); | |
111 fSwitchSource2->setDown(true); | |
112 break; | |
113 } | |
114 } | |
115 | |
116 // ----------------------------------------------------------------------- | |
117 // Widget Callbacks | |
118 void DistrhoUICloneChannel::imageSwitchClicked(ImageSwitch* imageSwitch, bool down) | |
119 { | |
120 const uint buttonId(imageSwitch->getId()); | |
121 | |
122 editParameter(buttonId, true); | |
123 setParameterValue(buttonId, down ? 1.0f : 0.0f); | |
124 editParameter(buttonId, false); | |
125 } | |
126 | |
127 void DistrhoUICloneChannel::onDisplay() | |
128 { | |
129 const GraphicsContext& context(getGraphicsContext()); | |
130 | |
131 fImgBackground.draw(context); | |
132 } | |
133 | |
134 // ----------------------------------------------------------------------- | |
135 | |
136 UI* createUI() | |
137 { | |
138 return new DistrhoUICloneChannel(); | |
139 } | |
140 | |
141 // ----------------------------------------------------------------------- | |
142 | |
143 END_NAMESPACE_DISTRHO |