| 360 | } |
| 361 | |
| 362 | void DropdownList::OnClicked(float x, float y, bool right) |
| 363 | { |
| 364 | if (right || mDropdownIsOpen) |
| 365 | return; |
| 366 | |
| 367 | mOwner->DropdownClicked(this); |
| 368 | |
| 369 | if (mElements.empty()) |
| 370 | return; |
| 371 | |
| 372 | mModalList.SetUpModal(); |
| 373 | |
| 374 | ofVec2f modalPos = GetModalListPosition(); |
| 375 | mModalList.SetOwningContainer(GetModuleParent()->GetOwningContainer()); |
| 376 | |
| 377 | float screenY = (modalPos.y + GetModuleParent()->GetOwningContainer()->GetDrawOffset().y) * GetModuleParent()->GetOwningContainer()->GetDrawScale(); |
| 378 | float maxX = ofGetWidth() - 5; |
| 379 | float maxY = ofGetHeight() - 5; |
| 380 | |
| 381 | const int kMinPerColumn = 3; |
| 382 | mMaxPerColumn = std::max(kMinPerColumn, int((maxY - screenY) / (kItemSpacing * GetModuleParent()->GetOwningContainer()->GetDrawScale()))) - 1; |
| 383 | mTotalColumns = 1 + ((int)mElements.size() - 1) / mMaxPerColumn; |
| 384 | int maxDisplayColumns = std::max(1, int((ofGetWidth() / GetModuleParent()->GetOwningContainer()->GetDrawScale()) / mMaxItemWidth)); |
| 385 | mDisplayColumns = std::min(mTotalColumns, maxDisplayColumns); |
| 386 | mCurrentPagedColumn = 0; |
| 387 | |
| 388 | bool paged = (mDisplayColumns < mTotalColumns); |
| 389 | |
| 390 | ofVec2f modalDimensions(mMaxItemWidth * mDisplayColumns, kItemSpacing * std::min((int)mElements.size(), mMaxPerColumn + (paged ? 1 : 0))); |
| 391 | modalPos.x = std::max(FromScreenPosX(5.0f, GetModuleParent()), std::min(modalPos.x, FromScreenPosX(maxX - modalDimensions.x * GetModuleParent()->GetOwningContainer()->GetDrawScale(), GetModuleParent()))); |
| 392 | mModalList.SetPosition(modalPos.x, modalPos.y); |
| 393 | mModalList.SetDimensions(modalDimensions.x, modalDimensions.y); |
| 394 | |
| 395 | TheSynth->PushModalFocusItem(&mModalList); |
| 396 | } |
| 397 | |
| 398 | int DropdownList::GetItemIndexAt(int x, int y) |
| 399 | { |
nothing calls this directly
no test coverage detected