/
DynamicParameterList.h
202 lines (144 loc) · 4.43 KB
/
DynamicParameterList.h
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
198
199
200
201
202
/* ===========================================================================
*
* This file is part of HISE.
* Copyright 2016 Christoph Hart
*
* HISE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HISE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HISE. If not, see <http://www.gnu.org/licenses/>.
*
* Commercial licenses for using HISE in an closed source project are
* available on request. Please visit the project's website to get more
* information about commercial licensing:
*
* http://www.hise.audio/
*
* HISE is based on the JUCE library,
* which must be separately licensed for closed source applications:
*
* http://www.juce.com
*
* ===========================================================================
*/
#pragma once
namespace scriptnode {
using namespace juce;
using namespace hise;
namespace parameter
{
struct dynamic_list
{
dynamic_list() :
numParameters(PropertyIds::NumParameters, 0)
{};
struct MultiOutputConnection : public ConnectionBase
{
valuetree::ChildListener connectionListener;
valuetree::RecursivePropertyListener connectionPropertyListener;
MultiOutputConnection(NodeBase* n, ValueTree switchTarget);
void updateConnectionProperty(ValueTree, Identifier);
bool rebuildConnections(bool tryAgainIfFail);
void updateConnections(ValueTree v, bool wasAdded);
bool matchesTarget(NodeBase::Parameter* np);
bool ok = false;
ValueTree connectionTree;
NodeBase::Ptr parentNode;
parameter::dynamic_base_holder p;
};
valuetree::ChildListener connectionUpdater;
NodePropertyT<int> numParameters;
void initialise(NodeBase* n);
void rebuildMultiOutputConnections();
int getNumParameters() const;
void updateConnections(ValueTree v, bool wasAdded);
void updateParameterAmount(Identifier id, var newValue);
template <int P> dynamic_base_holder& getParameter()
{
jassert(isPositiveAndBelow(P, getNumParameters()));
return targets[P]->p;
}
template <int P> void call(double v)
{
jassert(isPositiveAndBelow(P, getNumParameters()));
targets[P]->p.call(v);
}
bool deferUpdate = false;
ValueTree switchTree;
NodeBase* parentNode;
String missingNodes;
ReferenceCountedArray<MultiOutputConnection> targets;
JUCE_DECLARE_WEAK_REFERENCEABLE(dynamic_list);
};
namespace ui
{
struct UIConstants
{
static constexpr int GraphHeight = 70;
static constexpr int ButtonHeight = 22;
static constexpr int DragHeight = 48;
};
struct Factory : public PathFactory
{
String getId() const override { return {}; }
Path createPath(const String& url) const override;
};
struct dynamic_list_editor : public ScriptnodeExtraComponent<parameter::dynamic_list>,
public ButtonListener
{
struct MultiConnectionEditor : public Component
{
static constexpr int ViewportWidth = 400 + 16;
struct ConnectionEditor;
struct OutputEditor;
struct WrappedOutputEditor;
MultiConnectionEditor(parameter::dynamic_list* l);
void resized() override;
OwnedArray<WrappedOutputEditor> editors;
};
struct DragComponent : public Component,
public MultiOutputDragSource
{
DragComponent(parameter::dynamic_list* parent, int index_);
NodeBase* getNode() const override {
return n;
}
int getNumOutputs() const override
{
return pdl->getNumParameters();
}
int getOutputIndex() const override
{
return index;
}
bool matchesParameter(NodeBase::Parameter* p) const override;
ModulationSourceNode* n;
void mouseDown(const MouseEvent& e) override;
void mouseDrag(const MouseEvent& e);
void resized() override;
void paint(Graphics& g) override;
const int index;
Path p;
WeakReference<parameter::dynamic_list> pdl;
};
dynamic_list_editor(parameter::dynamic_list* l, PooledUIUpdater* updater);
void timerCallback() override;
void buttonClicked(Button* b) override;
void resized() override;
Factory f;
HiseShapeButton addButton;
HiseShapeButton removeButton;
HiseShapeButton editButton;
OwnedArray<DragComponent> dragSources;
};
}
}
}