| 268 | } |
| 269 | |
| 270 | void SampleBrowser::ShowPage(int page) |
| 271 | { |
| 272 | page = ofClamp(page, 0, GetNumPages() - 1); |
| 273 | mCurrentPage = page; |
| 274 | int offset = page * (int)mButtons.size(); |
| 275 | for (int i = 0; i < (int)mButtons.size(); ++i) |
| 276 | { |
| 277 | if (i + offset < (int)mDirectoryListing.size()) |
| 278 | { |
| 279 | mButtons[i]->SetShowing(true); |
| 280 | if (mDirectoryListing[i + offset] == ".." || File(mDirectoryListing[i + offset]).isDirectory()) |
| 281 | { |
| 282 | mButtons[i]->SetDisplayStyle(ButtonDisplayStyle::kFolderIcon); |
| 283 | mPlayButtons[i]->SetShowing(false); |
| 284 | } |
| 285 | else |
| 286 | { |
| 287 | mButtons[i]->SetDisplayStyle(ButtonDisplayStyle::kSampleIcon); |
| 288 | mPlayButtons[i]->SetShowing(true); |
| 289 | } |
| 290 | |
| 291 | if (mDirectoryListing[i + offset] == "..") |
| 292 | mButtons[i]->SetLabel(".."); |
| 293 | else |
| 294 | mButtons[i]->SetLabel(File(mDirectoryListing[i + offset]).getFileName().toStdString().c_str()); |
| 295 | } |
| 296 | else |
| 297 | { |
| 298 | mButtons[i]->SetShowing(false); |
| 299 | mPlayButtons[i]->SetShowing(false); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | mBackButton->SetShowing(GetNumPages() > 1 && mCurrentPage > 0); |
| 304 | mForwardButton->SetShowing(GetNumPages() > 1 && mCurrentPage < GetNumPages() - 1); |
| 305 | } |
| 306 | |
| 307 | int SampleBrowser::GetNumPages() const |
| 308 | { |
nothing calls this directly
no test coverage detected