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

Method DrawModule

Source/GridModule.cpp:131–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131void GridModule::DrawModule()
132{
133 if (Minimized() || IsVisible() == false)
134 return;
135
136 mMomentaryCheckbox->Draw();
137
138 ofSetColor(150, 150, 150, 255);
139 mGrid->Draw();
140 mGridControlTarget->Draw();
141
142 ofPushStyle();
143 ofSetColor(128, 128, 128, gModuleDrawAlpha * .8f);
144 for (int i = 0; i < mGrid->GetRows() && i < (int)mLabels.size(); ++i)
145 {
146 ofVec2f pos = mGrid->GetCellPosition(0, i) + mGrid->GetPosition(true);
147 float scale = MIN(mGrid->IClickable::GetDimensions().y / mGrid->GetRows() - 2, 10);
148 DrawTextNormal(mLabels[i], 2, pos.y - (scale / 8), scale);
149 }
150 ofPopStyle();
151
152 ofPushStyle();
153 ofFill();
154 for (int i = 0; i < (int)mGridOverlay.size(); ++i)
155 {
156 if (mGridOverlay[i] > 0)
157 {
158 Vec2i cell(i % kGridOverlayMaxDim, i / kGridOverlayMaxDim);
159 if (cell.x < GetCols() && cell.y < GetRows())
160 {
161 ofVec2f pos = mGrid->GetCellPosition(cell.x, cell.y) + mGrid->GetPosition(true);
162 float xsize = float(mGrid->GetWidth()) / mGrid->GetCols();
163 float ysize = float(mGrid->GetHeight()) / mGrid->GetRows();
164 ofSetColor(GetColor(mGridOverlay[i]));
165 ofRect(pos.x + 3, pos.y + 3, xsize - 6, ysize - 6);
166 }
167 }
168 }
169 ofPopStyle();
170
171 ofPushStyle();
172 ofSetLineWidth(3);
173 for (size_t i = 0; i < mHighlightCells.size(); ++i)
174 {
175 if (mHighlightCells[i].time != -1)
176 {
177 if (gTime - mHighlightCells[i].time < mHighlightCells[i].duration)
178 {
179 if (gTime - mHighlightCells[i].time > 0)
180 {
181 ofVec2f pos = mGrid->GetCellPosition(mHighlightCells[i].position.x, mHighlightCells[i].position.y) + mGrid->GetPosition(true);
182 float xsize = float(mGrid->GetWidth()) / mGrid->GetCols();
183 float ysize = float(mGrid->GetHeight()) / mGrid->GetRows();
184 ofSetColor(mHighlightCells[i].color, (1 - (gTime - mHighlightCells[i].time) / mHighlightCells[i].duration) * 255);
185 ofRect(pos.x, pos.y, xsize, ysize);
186 }
187 }
188 else

Callers

nothing calls this directly

Calls 15

ofSetColorFunction · 0.85
ofPushStyleFunction · 0.85
DrawTextNormalFunction · 0.85
ofPopStyleFunction · 0.85
ofFillFunction · 0.85
ofRectFunction · 0.85
ofSetLineWidthFunction · 0.85
sizeMethod · 0.80
DrawMethod · 0.45
GetRowsMethod · 0.45
GetCellPositionMethod · 0.45
GetPositionMethod · 0.45

Tested by

no test coverage detected