| 231 | } |
| 232 | |
| 233 | void 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) |
no test coverage detected