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

Method DrawModule

Source/UserPrefsEditor.cpp:269–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267}
268
269void UserPrefsEditor::DrawModule()
270{
271 auto& deviceManager = TheSynth->GetAudioDeviceManager();
272 auto* selectedDeviceType = UserPrefs.devicetype.GetIndex() != -1 ? deviceManager.getAvailableDeviceTypes()[UserPrefs.devicetype.GetIndex()] : deviceManager.getCurrentDeviceTypeObject();
273
274 mCategorySelector->Draw();
275
276 int controlX = 175;
277 int controlY = 50;
278 bool hasPrefThatRequiresRestart = false;
279 for (auto* pref : UserPrefs.mUserPrefs)
280 {
281 bool onPage = pref->mCategory == mCategory;
282 bool hide = false;
283 if (pref == &UserPrefs.audio_input_device)
284 hide = !selectedDeviceType->hasSeparateInputsAndOutputs();
285 if (pref == &UserPrefs.position_x || pref == &UserPrefs.position_y)
286 hide = !UserPrefs.set_manual_window_position.Get();
287
288 pref->GetControl()->SetShowing(onPage && !hide);
289
290 if (pref->GetControl()->IsShowing())
291 {
292 pref->GetControl()->SetPosition(controlX, controlY);
293 DrawTextNormal(pref->mName, 3, pref->GetControl()->GetPosition(K(local)).y + 12);
294 pref->GetControl()->Draw();
295
296 if (PrefRequiresRestart(pref) && pref->DiffersFromSavedValue())
297 {
298 DrawRightLabel(pref->GetControl(), "*", ofColor::magenta, 4);
299 hasPrefThatRequiresRestart = true;
300 }
301 }
302
303 if (onPage)
304 controlY += 17;
305 }
306 controlY += 17;
307 mSaveButton->SetPosition(controlX, controlY);
308 mSaveButton->Draw();
309 mCancelButton->SetPosition(mSaveButton->GetRect(K(local)).getMaxX() + 10, controlY);
310 mCancelButton->Draw();
311 mWidth = 1150;
312 mHeight = controlY + 20;
313
314 if (UserPrefs.devicetype.GetDropdown()->GetLabel(UserPrefs.devicetype.GetIndex()) == "DirectSound")
315 DrawRightLabel(UserPrefs.devicetype.GetControl(), "warning: DirectSound can cause crackle and strange behavior for some sample rates and buffer sizes", ofColor::yellow);
316
317 if (!selectedDeviceType->hasSeparateInputsAndOutputs() && mCategory == UserPrefCategory::General)
318 {
319 ofRectangle rect = UserPrefs.audio_output_device.GetControl()->GetRect(true);
320 ofPushStyle();
321 ofSetColor(ofColor::white);
322 DrawTextNormal("note: " + UserPrefs.devicetype.GetDropdown()->GetLabel(UserPrefs.devicetype.GetIndex()) + " uses the same audio device for output and input", rect.x, rect.getMaxY() + 14, 11);
323 ofPopStyle();
324 }
325
326 if (UserPrefs.samplerate.GetDropdown()->GetNumValues() == 0)

Callers

nothing calls this directly

Calls 15

DrawTextNormalFunction · 0.85
ofPushStyleFunction · 0.85
ofSetColorFunction · 0.85
ofPopStyleFunction · 0.85
ofToStringFunction · 0.85
ofGetWidthFunction · 0.85
ofGetHeightFunction · 0.85
GetMethod · 0.80
GetControlMethod · 0.80
IsShowingMethod · 0.80
DiffersFromSavedValueMethod · 0.80
getMaxXMethod · 0.80

Tested by

no test coverage detected