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

Method OnClicked

Source/ADSRDisplay.cpp:400–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398}
399
400void ADSRDisplay::OnClicked(float x, float y, bool right)
401{
402 if (mASlider != nullptr && mASlider->IsShowing())
403 {
404 if (gHoveredUIControl == mASlider)
405 mASlider->TestClick(x + mX, y + mY, right, false);
406 if (gHoveredUIControl == mDSlider)
407 mDSlider->TestClick(x + mX, y + mY, right, false);
408 if (gHoveredUIControl == mSSlider)
409 mSSlider->TestClick(x + mX, y + mY, right, false);
410 if (gHoveredUIControl == mRSlider)
411 mRSlider->TestClick(x + mX, y + mY, right, false);
412 return;
413 }
414
415 if (!mShowing)
416 return;
417
418 if (right)
419 {
420 //randomize
421 for (int i = 0; i < mAdsr->GetNumStages(); ++i)
422 {
423 if (i == 0)
424 mAdsr->GetStageData(i).target = 1;
425 else if (i == mAdsr->GetNumStages() - 1)
426 mAdsr->GetStageData(i).target = 0;
427 else
428 mAdsr->GetStageData(i).target = ofRandom(0, 1);
429
430 mAdsr->GetStageData(i).time = ofMap(pow(ofRandom(1), 2), 0, 1, 1, 200);
431 }
432 return;
433 }
434
435 if (mAdjustMode == kAdjustEnvelopeEditor)
436 {
437 TheSynth->ScheduleEnvelopeEditorSpawn(this);
438 }
439 else if (mAdsr->IsStandardADSR() || mAdsr->GetNumStages() == 2)
440 {
441 mClick = true;
442 mClickStart.set(x, y);
443 mClickAdsr.Set(*mAdsr);
444 mClickLength = mMaxTime;
445 }
446}
447
448void ADSRDisplay::MouseReleased()
449{

Callers

nothing calls this directly

Calls 9

ofRandomFunction · 0.85
ofMapFunction · 0.85
IsShowingMethod · 0.80
GetNumStagesMethod · 0.80
IsStandardADSRMethod · 0.80
TestClickMethod · 0.45
setMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected