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

Method SetModuleGridLights

Source/Push2Control.cpp:731–828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729}
730
731void Push2Control::SetModuleGridLights()
732{
733 float minX = 0;
734 float minY = 0;
735 float maxX = ofGetWidth();
736 float maxY = ofGetHeight();
737 for (int i = 0; i < mModules.size(); ++i)
738 {
739 ofVec2f pos = mModules[i]->GetPosition();
740 if (pos.x > maxX)
741 maxX = pos.x;
742 if (pos.y > maxY)
743 maxY = pos.y;
744 if (pos.x < minX)
745 minX = pos.x;
746 if (pos.y < minY)
747 minY = pos.y;
748 }
749 maxX += 1;
750 maxY += 1;
751 mModuleGridRect.set(minX, minY, maxX - minX, maxY - minY);
752
753 if (mModuleGridLayoutStyle == ModuleGridLayoutStyle::Automatic || mScreenDisplayMode == ScreenDisplayMode::kAddModule)
754 {
755 for (int i = 0; i < (int)mModuleGrid.size(); ++i)
756 mModuleGrid[i] = nullptr;
757
758 for (int i = 0; i < mModules.size(); ++i)
759 {
760 ofVec2f pos = mModules[i]->GetPosition();
761 int gridX = (pos.x - minX) / (maxX - minX) * 8;
762 int gridY = (pos.y - minY) / (maxY - minY) * 8;
763 while (gridX < 8 && gridY < 8)
764 {
765 int index = gridX + gridY * 8;
766 if (mModuleGrid[index] == nullptr)
767 {
768 mModuleGrid[index] = mModules[i];
769 break;
770 }
771 else
772 {
773 //IDrawableModule* otherModule = mModuleGrid[index];
774 int peekGridIndex;
775 if (GetGridIndex(gridX + 1, gridY, peekGridIndex) && mModuleGrid[peekGridIndex] == nullptr)
776 ++gridX;
777 else if (GetGridIndex(gridX, gridY + 1, peekGridIndex) && mModuleGrid[peekGridIndex] == nullptr)
778 ++gridY;
779 else
780 ++gridX;
781 }
782 }
783 }
784 }
785 else if (mModuleGridLayoutStyle == ModuleGridLayoutStyle::Manual)
786 {
787 for (int i = 0; i < (int)mModuleGrid.size(); ++i)
788 mModuleGrid[i] = static_cast<IDrawableModule*>(mModuleGridManualCables[i]->GetTarget());

Callers

nothing calls this directly

Calls 12

ofGetWidthFunction · 0.85
ofGetHeightFunction · 0.85
sizeMethod · 0.80
GetListMethod · 0.80
GetPositionMethod · 0.45
setMethod · 0.45
GetTargetMethod · 0.45
GetNumValuesMethod · 0.45
UpdatePush2LedsMethod · 0.45
GetModuleCategoryMethod · 0.45
IsEnabledMethod · 0.45
SendSysExMethod · 0.45

Tested by

no test coverage detected