MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / UpdateDropdowns

Method UpdateDropdowns

Source/UserPrefsEditor.cpp:129–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129void UserPrefsEditor::UpdateDropdowns(std::vector<DropdownList*> toUpdate)
130{
131 auto& deviceManager = TheSynth->GetAudioDeviceManager();
132
133 int i;
134
135 if (toUpdate.empty() || VectorContains(UserPrefs.devicetype.GetDropdown(), toUpdate))
136 {
137 UserPrefs.devicetype.GetIndex() = -1;
138 UserPrefs.devicetype.GetDropdown()->Clear();
139 UserPrefs.devicetype.GetDropdown()->AddLabel("auto", -1);
140 i = 0;
141 for (auto* deviceType : deviceManager.getAvailableDeviceTypes())
142 {
143 UserPrefs.devicetype.GetDropdown()->AddLabel(deviceType->getTypeName().toStdString(), i);
144 if (deviceType == deviceManager.getCurrentDeviceTypeObject() &&
145 UserPrefs.devicetype.Get() != "auto")
146 UserPrefs.devicetype.GetIndex() = i;
147 ++i;
148 }
149 }
150
151 auto* selectedDeviceType = UserPrefs.devicetype.GetIndex() != -1 ? deviceManager.getAvailableDeviceTypes()[UserPrefs.devicetype.GetIndex()] : deviceManager.getCurrentDeviceTypeObject();
152 selectedDeviceType->scanForDevices();
153
154 if (toUpdate.empty() || VectorContains(UserPrefs.audio_output_device.GetDropdown(), toUpdate))
155 {
156 UserPrefs.audio_output_device.GetIndex() = -1;
157 UserPrefs.audio_output_device.GetDropdown()->Clear();
158 UserPrefs.audio_output_device.GetDropdown()->AddLabel("none", -2);
159 UserPrefs.audio_output_device.GetDropdown()->AddLabel("auto", -1);
160 i = 0;
161 for (auto outputDevice : selectedDeviceType->getDeviceNames())
162 {
163 UserPrefs.audio_output_device.GetDropdown()->AddLabel(outputDevice.toStdString(), i);
164 if (deviceManager.getCurrentAudioDevice() != nullptr &&
165 i == selectedDeviceType->getIndexOfDevice(deviceManager.getCurrentAudioDevice(), false) &&
166 UserPrefs.audio_output_device.Get() != "auto")
167 UserPrefs.audio_output_device.GetIndex() = i;
168 ++i;
169 }
170
171 if (UserPrefs.audio_output_device.GetIndex() == -1) //update dropdown to match requested value, in case audio system failed to start
172 {
173 for (int j = -2; j < i; ++j)
174 {
175 if (UserPrefs.audio_output_device.GetDropdown()->GetLabel(j) == UserPrefs.audio_output_device.Get())
176 UserPrefs.audio_output_device.GetIndex() = j;
177 }
178 }
179 }
180
181 if (toUpdate.empty() || VectorContains(UserPrefs.audio_input_device.GetDropdown(), toUpdate))
182 {
183 UserPrefs.audio_input_device.GetIndex() = -1;
184 if (UserPrefs.audio_input_device.Get() == "none")
185 UserPrefs.audio_input_device.GetIndex() = -2;
186 UserPrefs.audio_input_device.GetDropdown()->Clear();

Callers

nothing calls this directly

Calls 8

VectorContainsFunction · 0.85
ofToStringFunction · 0.85
emptyMethod · 0.80
GetMethod · 0.80
GetDropdownMethod · 0.45
ClearMethod · 0.45
AddLabelMethod · 0.45
GetLabelMethod · 0.45

Tested by

no test coverage detected