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

Method GetGridSquareColor

Source/LaunchpadKeyboard.cpp:636–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

634}
635
636GridColor LaunchpadKeyboard::GetGridSquareColor(int x, int y)
637{
638 int pitch = GridToPitch(x, y);
639 bool inScale = TheScale->MakeDiatonic(pitch) == pitch;
640 bool isRoot = pitch % TheScale->GetPitchesPerOctave() == TheScale->ScaleRoot();
641 bool isHeld = GetHeldVelocity(GridToPitch(x, y)) > 0;
642 bool isInPentatonic = pitch >= 0 && TheScale->IsInPentatonic(pitch);
643 bool isChordButton = pitch != INVALID_PITCH && pitch < 0;
644 bool isPressedChordButton = isChordButton && IsChordButtonPressed(pitch);
645 bool isChorderEnabled = mChorder && mChorder->IsEnabled();
646
647 GridColor color;
648 if (pitch == INVALID_PITCH)
649 {
650 color = kGridColorOff;
651 }
652 else if (pitch == CHORD_ENABLE_BUTTON)
653 {
654 if (mChorder && mChorder->IsEnabled())
655 color = kGridColor1Bright;
656 else
657 color = kGridColor1Dim;
658 }
659 else if (pitch == CHORD_LATCH_BUTTON)
660 {
661 if (mLatchChords)
662 color = kGridColor3Bright;
663 else
664 color = kGridColor3Dim;
665 }
666 else if (pitch == KEY_LATCH_BUTTON)
667 {
668 if (mLatch)
669 color = kGridColor1Bright;
670 else
671 color = kGridColor1Dim;
672 }
673 else if (isPressedChordButton && isChorderEnabled)
674 {
675 color = kGridColor2Bright;
676 }
677 else if (isChordButton && !isChorderEnabled)
678 {
679 color = kGridColor1Dim;
680 }
681 else if (isChordButton)
682 {
683 color = kGridColor2Dim;
684 }
685 else if (isHeld)
686 {
687 color = kGridColor1Bright;
688 }
689 else if (mLayout == kDrum || mLayout == kAllPads)
690 {
691 color = kGridColor3Bright;
692 }
693 else if (isRoot)

Callers

nothing calls this directly

Calls 5

MakeDiatonicMethod · 0.80
GetPitchesPerOctaveMethod · 0.80
IsInPentatonicMethod · 0.80
ScaleRootMethod · 0.45
IsEnabledMethod · 0.45

Tested by

no test coverage detected