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

Method DrawControls

Source/Push2Control.cpp:1073–1142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1071}
1072
1073void Push2Control::DrawControls(std::vector<IUIControl*> controls, bool sliders, float yPos)
1074{
1075 for (int i = (int)controls.size() - 1; i >= 0; --i)
1076 {
1077 if (i - mModuleViewOffset < -1 || i - mModuleViewOffset > 8)
1078 continue;
1079
1080 ADSRDisplay* adsr = dynamic_cast<ADSRDisplay*>(controls[i]);
1081
1082 ofRectangle originalRect = controls[i]->GetRect(true);
1083 if (adsr != nullptr)
1084 {
1085 adsr->SetDimensions(80, 30);
1086 controls[i]->SetPosition(kColumnSpacing * i + 3, yPos - 13);
1087 }
1088 else
1089 {
1090 controls[i]->SetPosition(kColumnSpacing * i + 3, yPos);
1091 }
1092 ofPushMatrix();
1093 ofClipWindow(kColumnSpacing * i, yPos - 15, kColumnSpacing, 100, true);
1094
1095 ofPushStyle();
1096 ModuleCategory moduleType = controls[i]->GetModuleParent()->GetModuleCategory();
1097 if (mScreenDisplayMode == ScreenDisplayMode::kAddModule)
1098 moduleType = GetModuleTypeForSpawnList(controls[i]);
1099 if (controls[i]->IsShowing())
1100 ofSetColor(IDrawableModule::GetColor(moduleType));
1101 else
1102 ofSetColor(100, 100, 100);
1103 if (adsr == nullptr)
1104 {
1105 if (mDisplayModule == this)
1106 DrawTextBold(juce::String(controls[i]->Path()).replace("~", "\n").toRawUTF8(), kColumnSpacing * i + 3, yPos - 12, 8);
1107 else
1108 DrawTextBold(controls[i]->Name(), kColumnSpacing * i + 3, yPos - 5, 14);
1109 }
1110 controls[i]->Render();
1111 ofPopStyle();
1112
1113 ofPopMatrix();
1114 controls[i]->SetPosition(originalRect.x, originalRect.y);
1115 if (adsr != nullptr)
1116 adsr->SetDimensions(originalRect.width, originalRect.height);
1117
1118 ofPushStyle();
1119 int pushControlIndex = i - mModuleViewOffset;
1120 if (sliders && pushControlIndex >= 0 && pushControlIndex < 8 && mNoteHeldState[pushControlIndex])
1121 {
1122 DropdownList* dropdown = dynamic_cast<DropdownList*>(mSliderControls[i]);
1123 if (dropdown != nullptr)
1124 {
1125 const float kCentering = 7;
1126 float w = dropdown->GetMaxItemWidth();
1127 float h = dropdown->GetNumValues() * DropdownList::kItemSpacing;
1128 ofPushMatrix();
1129 ofTranslate(kColumnSpacing * i + 3, yPos + kCentering - h * controls[i]->GetMidiValue());
1130 dropdown->DrawDropdown(w, h, true);

Callers

nothing calls this directly

Calls 15

ofPushMatrixFunction · 0.85
ofClipWindowFunction · 0.85
ofPushStyleFunction · 0.85
ofSetColorFunction · 0.85
DrawTextBoldFunction · 0.85
StringClass · 0.85
ofPopStyleFunction · 0.85
ofPopMatrixFunction · 0.85
ofTranslateFunction · 0.85
ofFillFunction · 0.85
ofRectFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected