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

Method DrawModule

Source/DotSequencer.cpp:101–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void DotSequencer::DrawModule()
102{
103 if (Minimized() || IsVisible() == false)
104 return;
105
106 ofPushStyle();
107 ofSetLineWidth(mDotGrid->GetDotSize() * .25f);
108 float ysize = mHeight / mDotGrid->GetRows();
109 for (int i = 0; i < mDotGrid->GetRows(); ++i)
110 {
111 ofVec2f pos = mDotGrid->GetCellPosition(0, i - 1) + mDotGrid->GetPosition(true);
112 ofVec2f lineAcrossStart(pos.x + 5, pos.y - ysize * .5f + 2);
113 ofVec2f lineAcrossEnd(pos.x + mDotGrid->GetWidth() - 10, pos.y - ysize * .5f + 2);
114
115 if (RowToPitch(i) % TheScale->GetPitchesPerOctave() == TheScale->ScaleRoot() % TheScale->GetPitchesPerOctave())
116 {
117 ofSetColor(0, 255, 0, gModuleDrawAlpha * .05f);
118 ofLine(lineAcrossStart, lineAcrossEnd);
119 ofSetColor(0, 255, 0, gModuleDrawAlpha * .8f);
120 }
121 else if (TheScale->GetPitchesPerOctave() == 12 && RowToPitch(i) % TheScale->GetPitchesPerOctave() == (TheScale->ScaleRoot() + 7) % TheScale->GetPitchesPerOctave())
122 {
123 ofSetColor(200, 150, 0, gModuleDrawAlpha * .05f);
124 ofLine(lineAcrossStart, lineAcrossEnd);
125 ofSetColor(200, 150, 0, gModuleDrawAlpha * .8f);
126 }
127 else if (mNoteMode == NoteMode::Chromatic && TheScale->IsInScale(RowToPitch(i)))
128 {
129 ofSetColor(175, 100, 0, gModuleDrawAlpha * .05f);
130 ofLine(lineAcrossStart, lineAcrossEnd);
131 ofSetColor(175, 100, 0, gModuleDrawAlpha * .8f);
132 }
133 else
134 {
135 ofSetColor(128, 128, 128, gModuleDrawAlpha * .8f);
136 }
137
138 float scale = std::min(mDotGrid->IClickable::GetDimensions().y / mDotGrid->GetRows() - 2, 10.0f);
139 DrawTextRightJustify(NoteName(RowToPitch(i), false, true) + "(" + ofToString(RowToPitch(i)) + ")", pos.x - 3, pos.y - ysize * .5f + (scale / 2), scale);
140 }
141 ofPopStyle();
142
143 mIntervalSelector->Draw();
144 mNoteModeSelector->Draw();
145 mClearButton->Draw();
146 mOctaveSlider->Draw();
147 mColsSlider->Draw();
148 mRowsSlider->Draw();
149 mRowOffsetSlider->Draw();
150 mDoubleButton->Draw();
151 mDotGrid->Draw();
152}
153
154void DotSequencer::OnTimeEvent(double time)
155{

Callers

nothing calls this directly

Calls 15

ofPushStyleFunction · 0.85
ofSetLineWidthFunction · 0.85
ofSetColorFunction · 0.85
ofLineFunction · 0.85
DrawTextRightJustifyFunction · 0.85
NoteNameFunction · 0.85
ofToStringFunction · 0.85
ofPopStyleFunction · 0.85
GetDotSizeMethod · 0.80
GetPitchesPerOctaveMethod · 0.80
IsInScaleMethod · 0.80
GetRowsMethod · 0.45

Tested by

no test coverage detected