-
Notifications
You must be signed in to change notification settings - Fork 12
/
DigitalRingMod.cpp
197 lines (169 loc) · 7.23 KB
/
DigitalRingMod.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
* SurgeXT for VCV Rack - a Surge Synth Team product
*
* A set of modules expressing Surge XT into the VCV Rack Module Ecosystem
*
* Copyright 2019 - 2024, Various authors, as described in the github
* transaction log.
*
* Surge XT for VCV Rack is released under the GNU General Public License
* 3.0 or later (GPL-3.0-or-later). A copy of the license is in this
* repository in the file "LICENSE" or at:
*
* or at https://www.gnu.org/licenses/gpl-3.0.en.html
*
* All source for Surge XT for VCV Rack is available at
* https://github.com/surge-synthesizer/surge-rack/
*/
#include "DigitalRingMod.h"
#include "SurgeXT.h"
#include "XTModuleWidget.h"
#include "XTWidgets.h"
#include "LayoutEngine.h"
namespace sst::surgext_rack::digitalrm::ui
{
struct DigitalRingModWidget : widgets::XTModuleWidget
{
typedef digitalrm::DigitalRingMod M;
DigitalRingModWidget(M *module);
};
DigitalRingModWidget::DigitalRingModWidget(DigitalRingModWidget::M *module) : XTModuleWidget()
{
setModule(module);
box.size = rack::Vec(rack::app::RACK_GRID_WIDTH * 6, rack::app::RACK_GRID_HEIGHT);
auto bg = new widgets::Background(box.size, "", "other", "blank6hp");
addChild(bg);
auto titleLabel = widgets::Label::createWithBaselineBox(
rack::Vec(0, 0),
rack::Vec(box.size.x, rack::mm2px(layout::LayoutConstants::mainLabelBaseline_MM)), "CXOR",
layout::LayoutConstants::mainLabelSize_PT);
titleLabel->tracking = 0.7;
addChild(titleLabel);
float cols[2]{box.size.x * 0.5f - rack::mm2px(7), box.size.x * 0.5f + rack::mm2px(7)};
for (int inst = 0; inst < 2; ++inst)
{
auto inOff = inst == 0 ? 0 : 4;
auto outOff = inst == 0 ? 0 : 2;
auto yShiftMM = inst == 0 ? -58 : 0;
auto yShift = rack::mm2px(yShiftMM);
int col = 0;
for (auto p : {M::INPUT_0_A_L + inOff, M::INPUT_0_A_R + inOff})
{
auto yp = rack::mm2px(layout::LayoutConstants::modulationRowCenters_MM[0]) + yShift;
auto xp = cols[col];
auto pt = rack::createInputCentered<widgets::Port>(rack::Vec(xp, yp), module, p);
pt->connectAsInputFromMixmaster = true;
if (p == M::INPUT_0_A_L + inOff)
pt->mixMasterStereoCompanion = M::INPUT_0_A_R + inOff;
else
pt->mixMasterStereoCompanion = M::INPUT_0_A_L + inOff;
addInput(pt);
col++;
}
col = 0;
for (auto p : {M::INPUT_0_B_L + inOff, M::INPUT_0_B_R + inOff})
{
auto yp = rack::mm2px(layout::LayoutConstants::modulationRowCenters_MM[1]) + yShift;
auto xp = cols[col];
auto pt = rack::createInputCentered<widgets::Port>(rack::Vec(xp, yp), module, p);
pt->connectAsInputFromMixmaster = true;
if (p == M::INPUT_0_B_L + inOff)
pt->mixMasterStereoCompanion = M::INPUT_0_B_R + inOff;
else
pt->mixMasterStereoCompanion = M::INPUT_0_B_L + inOff;
addInput(pt);
col++;
}
auto wb2 = rack::mm2px(layout::LayoutConstants::columnWidth_MM) * 0.5;
col = 0;
for (const std::string &s : {std::string("B: LEFT"), std::string("B: RIGHT")})
{
auto bl = layout::LayoutConstants::inputLabelBaseline_MM - 15 + yShiftMM;
auto lab = widgets::Label::createWithBaselineBox(
rack::Vec(cols[col] - wb2, rack::mm2px(bl - 5)), rack::Vec(2 * wb2, rack::mm2px(5)),
s);
addChild(lab);
col++;
}
col = 0;
for (const std::string &s : {std::string("A: LEFT"), std::string("A: RIGHT")})
{
auto bl = layout::LayoutConstants::modulationRowCenters_MM[0] - 6 + yShiftMM;
auto lab = widgets::Label::createWithBaselineBox(
rack::Vec(cols[col] - wb2, rack::mm2px(bl - 5)), rack::Vec(2 * wb2, rack::mm2px(5)),
s);
addChild(lab);
col++;
}
{
auto od = new widgets::OutputDecoration;
auto bl = layout::LayoutConstants::inputLabelBaseline_MM + yShiftMM;
auto pd_MM = 0.5;
auto c0 = 0, nc = 2;
od->box.size = rack::Vec(
rack::mm2px((nc - 0.2) * layout::LayoutConstants::columnWidth_MM + 2 * pd_MM), 42);
od->box.pos = rack::Vec(
cols[0] + rack::mm2px((c0 - 0.4) * layout::LayoutConstants::columnWidth_MM - pd_MM),
rack::mm2px(bl - pd_MM) - 7.2 * 96 / 72);
od->setup();
addChild(od);
}
col = 0;
for (auto p : {M::OUTPUT_0_L + outOff, M::OUTPUT_0_R + outOff})
{
auto yp = rack::mm2px(layout::LayoutConstants::inputRowCenter_MM) + yShift;
auto xp = cols[col];
auto pt = rack::createOutputCentered<widgets::Port>(rack::Vec(xp, yp), module, p);
pt->connectAsOutputToMixmaster = true;
pt->connectOutputToNeighbor = true;
pt->connectAsInputFromMixmaster = true;
if (p == M::OUTPUT_0_L + outOff)
pt->mixMasterStereoCompanion = M::OUTPUT_0_R + outOff;
else
pt->mixMasterStereoCompanion = M::OUTPUT_0_L + outOff;
addOutput(pt);
col++;
}
col = 0;
for (const std::string &s : {std::string("LEFT"), std::string("RIGHT")})
{
auto bl = layout::LayoutConstants::inputLabelBaseline_MM + yShiftMM;
auto lab = widgets::Label::createWithBaselineBox(
rack::Vec(cols[col] - wb2, rack::mm2px(bl - 5)), rack::Vec(2 * wb2, rack::mm2px(5)),
s, layout::LayoutConstants::labelSize_pt, style::XTStyle::TEXT_LABEL_OUTPUT);
addChild(lab);
col++;
}
auto ys = rack::mm2px(layout::LayoutConstants::modulationRowCenters_MM[0]) + yShift - 48;
auto pxdiff = 5.0;
auto bglcd = widgets::LCDBackground::createAtYPosition(ys, 17, 6, pxdiff);
addChild(bglcd);
auto xpos = rack::mm2px(widgets::LCDBackground::posx_MM) - pxdiff;
auto wsz = bglcd->box.size;
wsz.y -= rack::mm2px(2 * widgets::LCDBackground::padY_MM);
auto wid =
widgets::PlotAreaMenuItem::create(rack::Vec(xpos, ys), wsz, module, M::TYPE_0 + inst);
wid->upcaseDisplay = false;
wid->centerDisplay = true;
wid->onShowMenu = [wid]() {
wid->destroyTooltip();
wid->createContextMenu();
};
addChild(wid);
if (inst == 1)
{
auto x = box.size.x / 2;
auto y = rack::mm2px(layout::LayoutConstants::modulationRowCenters_MM[0]) + yShift;
auto light = rack::createParamCentered<widgets::ActivateKnobSwitch>(rack::Vec(x, y),
module, M::LINK_01);
addChild(light);
}
}
resetStyleCouplingToModule();
}
} // namespace sst::surgext_rack::digitalrm::ui
// namespace sst::surgext_rack::vcf::ui
rack::Model *modelSurgeDigitalRingMods =
rack::createModel<sst::surgext_rack::digitalrm::ui::DigitalRingModWidget::M,
sst::surgext_rack::digitalrm::ui::DigitalRingModWidget>(
"SurgeXTDigitalRingMod");