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

Method DrawDropdown

Source/DropdownList.cpp:233–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233void DropdownList::DrawDropdown(int w, int h, bool isScrolling)
234{
235 ofPushStyle();
236
237 if (isScrolling)
238 mModalList.SetDimensions(mMaxItemWidth, (int)mElements.size() * kItemSpacing);
239
240 int hoverIndex = -1;
241 float dropdownW, dropdownH;
242 mModalList.GetDimensions(dropdownW, dropdownH);
243 if (mModalList.GetMouseX() >= 0 && mModalList.GetMouseY() >= 0 && mModalList.GetMouseX() < dropdownW && mModalList.GetMouseY() < dropdownH)
244 hoverIndex = GetItemIndexAt(mModalList.GetMouseX(), mModalList.GetMouseY());
245
246 int maxPerColumn = mMaxPerColumn;
247 int displayColumns = mDisplayColumns;
248 int totalColumns = mTotalColumns;
249 int currentPagedColumn = mCurrentPagedColumn;
250 if (isScrolling)
251 {
252 maxPerColumn = 9999;
253 displayColumns = 1;
254 totalColumns = 1;
255 mCurrentPagedColumn = 0;
256 }
257
258 bool paged = (displayColumns < totalColumns);
259 float pageHeaderShift = (paged ? kPageBarSpacing : 0);
260 mModalList.SetShowPagingControls(paged);
261
262 ofSetColor(0, 0, 0);
263 ofFill();
264 ofRect(0, 0, w, h);
265 for (int i = 0; i < mElements.size(); ++i)
266 {
267 int col = i / maxPerColumn - currentPagedColumn;
268
269 if (col < 0)
270 continue;
271
272 if (col >= displayColumns)
273 break;
274
275 if (i == hoverIndex)
276 {
277 ofSetColor(100, 100, 100, 100);
278 ofRect(mMaxItemWidth * col, (i % maxPerColumn) * kItemSpacing + pageHeaderShift, mMaxItemWidth, kItemSpacing);
279 }
280
281 if (VectorContains(i, mSeparators))
282 {
283 ofPushStyle();
284 ofSetColor(100, 100, 100, 100);
285 ofSetLineWidth(1);
286 ofLine(mMaxItemWidth * col + 3, (i % maxPerColumn) * kItemSpacing + pageHeaderShift, mMaxItemWidth * (col + 1) - 3, (i % maxPerColumn) * kItemSpacing + pageHeaderShift);
287 ofPopStyle();
288 }
289
290 if (mVar && mElements[i].mValue == *mVar)

Callers 2

DrawControlsMethod · 0.80
DrawModuleMethod · 0.80

Calls 15

ofPushStyleFunction · 0.85
ofSetColorFunction · 0.85
ofFillFunction · 0.85
ofRectFunction · 0.85
VectorContainsFunction · 0.85
ofSetLineWidthFunction · 0.85
ofLineFunction · 0.85
ofPopStyleFunction · 0.85
DrawTextNormalFunction · 0.85
ofToStringFunction · 0.85
ofNoFillFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected