MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / AudioFileListWidget

Class AudioFileListWidget

plugins/Cardinal/src/AudioFile.cpp:380–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378
379#ifndef HEADLESS
380struct AudioFileListWidget : ImGuiWidget {
381 CarlaInternalPluginModule* const module;
382
383 bool showError = false;
384 String errorMessage;
385
386 struct ghcFile {
387 std::string full, base;
388 bool operator<(const ghcFile& other) const noexcept { return base < other.base; }
389 };
390 std::string currentDirectory;
391 std::vector<ghcFile> currentFiles;
392 size_t selectedFile = (size_t)-1;
393
394 AudioFileListWidget(CarlaInternalPluginModule* const m)
395 : ImGuiWidget(),
396 module(m)
397 {
398 if (module->fileChanged)
399 reloadDir();
400 }
401
402 void drawImGui() override
403 {
404 const float scaleFactor = getScaleFactor();
405
406 const int flags = ImGuiWindowFlags_NoSavedSettings
407 | ImGuiWindowFlags_NoTitleBar
408 | ImGuiWindowFlags_NoResize
409 | ImGuiWindowFlags_NoCollapse
410 | ImGuiWindowFlags_NoScrollbar
411 | ImGuiWindowFlags_NoScrollWithMouse;
412
413 ImGui::SetNextWindowPos(ImVec2(0, 0));
414 ImGui::SetNextWindowSize(ImVec2(box.size.x * scaleFactor, box.size.y * scaleFactor));
415
416 if (ImGui::Begin("Plugin List", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize))
417 {
418 if (showError)
419 {
420 showError = false;
421 ImGui::OpenPopup("Audio File Error");
422 }
423
424 if (ImGui::BeginPopupModal("Audio File Error", nullptr, flags))
425 {
426 ImGui::TextWrapped("Failed to load audio file, error was:\n%s", errorMessage.buffer());
427
428 ImGui::Separator();
429
430 if (ImGui::Button("Ok"))
431 ImGui::CloseCurrentPopup();
432
433 ImGui::EndPopup();
434 }
435 else if (ImGui::BeginTable("pluginlist", 1, ImGuiTableFlags_NoSavedSettings))
436 {
437 for (size_t i=0, count=currentFiles.size(); i < count; ++i)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected