| 528 | } |
| 529 | |
| 530 | void CFileBrowser::RenderFilePreview(CUIRect Preview) |
| 531 | { |
| 532 | if(m_FileType == CFileBrowser::EFileType::IMAGE) |
| 533 | { |
| 534 | if(m_PreviewState == EPreviewState::LOADED) |
| 535 | { |
| 536 | CUIRect PreviewLabel, PreviewImage; |
| 537 | Preview.HSplitTop(20.0f, &PreviewLabel, &PreviewImage); |
| 538 | |
| 539 | char aSizeLabel[64]; |
| 540 | str_format(aSizeLabel, sizeof(aSizeLabel), "Size: %d × %d", m_PreviewImageWidth, m_PreviewImageHeight); |
| 541 | Ui()->DoLabel(&PreviewLabel, aSizeLabel, 12.0f, TEXTALIGN_ML); |
| 542 | |
| 543 | int Width = m_PreviewImageWidth; |
| 544 | int Height = m_PreviewImageHeight; |
| 545 | if(m_PreviewImageWidth > PreviewImage.w) |
| 546 | { |
| 547 | Height = m_PreviewImageHeight * PreviewImage.w / m_PreviewImageWidth; |
| 548 | Width = PreviewImage.w; |
| 549 | } |
| 550 | if(Height > PreviewImage.h) |
| 551 | { |
| 552 | Width = Width * PreviewImage.h / Height; |
| 553 | Height = PreviewImage.h; |
| 554 | } |
| 555 | |
| 556 | Graphics()->TextureSet(m_PreviewImage); |
| 557 | Graphics()->BlendNormal(); |
| 558 | Graphics()->QuadsBegin(); |
| 559 | IGraphics::CQuadItem QuadItem(PreviewImage.x, PreviewImage.y, Width, Height); |
| 560 | Graphics()->QuadsDrawTL(&QuadItem, 1); |
| 561 | Graphics()->QuadsEnd(); |
| 562 | } |
| 563 | else if(m_PreviewState == EPreviewState::ERROR) |
| 564 | { |
| 565 | Ui()->DoLabel(&Preview, "Failed to load the image (check the local console for details).", 12.0f, TEXTALIGN_TL, {.m_MaxWidth = Preview.w}); |
| 566 | } |
| 567 | } |
| 568 | else if(m_FileType == CFileBrowser::EFileType::SOUND) |
| 569 | { |
| 570 | if(m_PreviewState == EPreviewState::LOADED) |
| 571 | { |
| 572 | Preview.HSplitTop(20.0f, &Preview, nullptr); |
| 573 | Preview.VSplitLeft(Preview.h / 4.0f, nullptr, &Preview); |
| 574 | Editor()->DoAudioPreview(Preview, &m_ButtonPlayPauseId, &m_ButtonStopId, &m_SeekBarId, m_PreviewSound); |
| 575 | } |
| 576 | else if(m_PreviewState == EPreviewState::ERROR) |
| 577 | { |
| 578 | Ui()->DoLabel(&Preview, "Failed to load the sound (check the local console for details). Make sure you enabled sounds in the settings.", 12.0f, TEXTALIGN_TL, {.m_MaxWidth = Preview.w}); |
| 579 | } |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | const char *CFileBrowser::DetermineFileFontIcon(const CFilelistItem *pItem) const |
| 584 | { |
nothing calls this directly
no test coverage detected