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

Method DrawModule

Source/Transport.cpp:208–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208void Transport::DrawModule()
209{
210 if (Minimized() || IsVisible() == false)
211 return;
212
213 double measurePos = GetMeasurePos(gTime);
214
215 int count = int(fmod(mMeasureTime, 1) * mTimeSigTop) + 1;
216 std::string display;
217 display += ofToString(measurePos, 2) + " " + ofToString(GetMeasure(gTime)) + "\n";
218 display += ofToString(count);
219 DrawTextNormal(display, 5, 52);
220
221 ofPushStyle();
222 float w, h;
223 GetDimensions(w, h);
224 ofFill();
225 ofSetColor(255, 255, 255, 50);
226 float beatWidth = w / mTimeSigTop;
227 ofRect((count - 1) * beatWidth, 0, beatWidth, h, 0);
228 if (count % 2)
229 ofSetColor(255, 0, 255);
230 else
231 ofSetColor(0, 255, 255);
232 ofLine(w * measurePos, 0, w * measurePos, h);
233 ofRect(0, 95, w * ((measurePos + (GetMeasure(gTime) % 4)) / 4), 5);
234 ofPopStyle();
235
236 mSwingSlider->Draw();
237 mResetButton->Draw();
238 if (TheSynth->IsAudioPaused())
239 mPlayPauseButton->SetDisplayStyle(ButtonDisplayStyle::kPlay);
240 else
241 mPlayPauseButton->SetDisplayStyle(ButtonDisplayStyle::kPause);
242 mPlayPauseButton->Draw();
243 mTimeSigTopDropdown->Draw();
244 mTimeSigBottomDropdown->Draw();
245 mSwingIntervalDropdown->Draw();
246 mNudgeBackButton->Draw();
247 mNudgeForwardButton->Draw();
248 mIncreaseTempoButton->Draw();
249 mDecreaseTempoButton->Draw();
250 mTempoSlider->Draw();
251
252 ofBeginShape();
253 for (int i = 0; i < w - 1; ++i)
254 {
255 float pos = i / float(w - 1);
256 float swung = Swing(pos);
257 ofVertex(i + 1, h - 1 - swung * (h - 1));
258 }
259 ofEndShape();
260 ofRect(0, h - Swing(measurePos) * h, 4, 1);
261
262 float nudgeMinX = mNudgeBackButton->GetRect(true).getMinX();
263 float nudgeMaxX = mNudgeForwardButton->GetRect(true).getMaxX();
264 float nudgeX = ofLerp(nudgeMinX, nudgeMaxX, (mNudgeFactor / 15) + .5f);
265 ofLine(nudgeX, mNudgeBackButton->GetRect(true).getMinY(), nudgeX, mNudgeBackButton->GetRect(true).getMaxY());

Callers

nothing calls this directly

Calls 15

ofToStringFunction · 0.85
DrawTextNormalFunction · 0.85
ofPushStyleFunction · 0.85
ofFillFunction · 0.85
ofSetColorFunction · 0.85
ofRectFunction · 0.85
ofLineFunction · 0.85
ofPopStyleFunction · 0.85
ofBeginShapeFunction · 0.85
ofVertexFunction · 0.85
ofEndShapeFunction · 0.85
ofLerpFunction · 0.85

Tested by

no test coverage detected