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

Method DrawModule

Source/NoteCanvas.cpp:323–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323void NoteCanvas::DrawModule()
324{
325 if (Minimized() || IsVisible() == false)
326 return;
327
328 ofPushStyle();
329 ofFill();
330 for (int i = 0; i < 128; ++i)
331 {
332 int pitch = 127 - i;
333 if (pitch % TheScale->GetPitchesPerOctave() == TheScale->ScaleRoot() % TheScale->GetPitchesPerOctave())
334 mCanvas->SetRowColor(i, ofColor(0, 255, 0, 80));
335 else if (pitch % TheScale->GetPitchesPerOctave() == (TheScale->ScaleRoot() + 7) % TheScale->GetPitchesPerOctave())
336 mCanvas->SetRowColor(i, ofColor(200, 150, 0, 80));
337 else if (TheScale->IsInScale(pitch))
338 mCanvas->SetRowColor(i, ofColor(100, 75, 0, 80));
339 else
340 mCanvas->SetRowColor(i, ofColor(100, 100, 100, 30));
341 }
342 ofPopStyle();
343
344 mCanvas->SetCursorPos(GetCurPos(gTime));
345
346 mCanvas->Draw();
347 mCanvasTimeline->Draw();
348 mCanvasScrollbarHorizontal->Draw();
349 mCanvasScrollbarVertical->Draw();
350
351 ofPushStyle();
352 ofSetColor(128, 128, 128, gModuleDrawAlpha * .8f);
353 for (int i = 0; i < mCanvas->GetNumVisibleRows(); ++i)
354 {
355 int pitch = 127 - mCanvas->GetRowOffset() - i;
356 float boxHeight = (float(mCanvas->GetHeight()) / mCanvas->GetNumVisibleRows());
357 float y = mCanvas->GetPosition(true).y + i * boxHeight;
358 float scale = MIN(boxHeight - 2, 18);
359 DrawTextNormal(NoteName(pitch, false, true) + "(" + ofToString(pitch) + ")", mCanvas->GetPosition(true).x + 2, y - (scale / 8) + boxHeight, scale);
360 }
361 ofPopStyle();
362
363 if (mShowIntervals)
364 {
365 ofPushMatrix();
366 ofTranslate(mCanvas->GetPosition(true).x, mCanvas->GetPosition(true).y);
367 ofPushStyle();
368 ofSetLineWidth(3);
369 auto elements = mCanvas->GetElements();
370 for (auto e1 : elements)
371 {
372 for (auto e2 : elements)
373 {
374 if (e1 != e2)
375 {
376 if (abs(e1->GetStart() - e2->GetStart()) < (1.0 / 32) / mNumMeasures)
377 {
378 int interval = abs(e1->mRow - e2->mRow);
379 if (interval >= 3 && interval <= 7)
380 {

Callers

nothing calls this directly

Calls 15

ofPushStyleFunction · 0.85
ofFillFunction · 0.85
ofColorClass · 0.85
ofPopStyleFunction · 0.85
ofSetColorFunction · 0.85
DrawTextNormalFunction · 0.85
NoteNameFunction · 0.85
ofToStringFunction · 0.85
ofPushMatrixFunction · 0.85
ofTranslateFunction · 0.85
ofSetLineWidthFunction · 0.85
ofLineFunction · 0.85

Tested by

no test coverage detected