| 661 | |
| 662 | #ifndef HEADLESS |
| 663 | struct AidaModelListWidget : ImGuiWidget { |
| 664 | AidaPluginModule* const module; |
| 665 | |
| 666 | struct ghcFile { |
| 667 | std::string full, base; |
| 668 | bool operator<(const ghcFile& other) const noexcept { return base < other.base; } |
| 669 | }; |
| 670 | std::string currentDirectory; |
| 671 | std::vector<ghcFile> currentFiles; |
| 672 | size_t selectedFile = (size_t)-1; |
| 673 | |
| 674 | AidaModelListWidget(AidaPluginModule* const m) |
| 675 | : ImGuiWidget(), |
| 676 | module(m) |
| 677 | { |
| 678 | if (module != nullptr && module->fileChanged) |
| 679 | reloadDir(); |
| 680 | } |
| 681 | |
| 682 | void drawImGui() override |
| 683 | { |
| 684 | const float scaleFactor = getScaleFactor(); |
| 685 | |
| 686 | // transparent background |
| 687 | { |
| 688 | ImGuiStyle& style(ImGui::GetStyle()); |
| 689 | style.WindowRounding = 12 * scaleFactor; |
| 690 | style.WindowBorderSize = style.FrameBorderSize = 0.f; |
| 691 | style.ScrollbarSize = 12 * scaleFactor; |
| 692 | |
| 693 | ImVec4* const colors = style.Colors; |
| 694 | colors[ImGuiCol_Text] = ImVec4(0.f, 0.f, 0.f, 1.f); |
| 695 | colors[ImGuiCol_WindowBg] = ImVec4(0.f, 0.f, 0.f, 0.f); |
| 696 | colors[ImGuiCol_FrameBg] = ImVec4(0.f, 0.f, 0.f, 0.f); |
| 697 | colors[ImGuiCol_FrameBgHovered] = ImVec4(0.f, 0.f, 0.f, 0.f); |
| 698 | colors[ImGuiCol_FrameBgActive] = ImVec4(0.f, 0.f, 0.f, 0.f); |
| 699 | colors[ImGuiCol_Header] = ImVec4(0.f, 0.f, 0.f, 0.4f); |
| 700 | colors[ImGuiCol_HeaderHovered] = ImVec4(0.f, 0.f, 0.f, 0.35f); |
| 701 | colors[ImGuiCol_HeaderActive] = ImVec4(0.f, 0.f, 0.f, 0.5f); |
| 702 | } |
| 703 | |
| 704 | const int flags = ImGuiWindowFlags_NoBackground |
| 705 | | ImGuiWindowFlags_NoSavedSettings |
| 706 | | ImGuiWindowFlags_NoTitleBar |
| 707 | | ImGuiWindowFlags_NoResize |
| 708 | | ImGuiWindowFlags_NoCollapse |
| 709 | | ImGuiWindowFlags_NoScrollbar |
| 710 | | ImGuiWindowFlags_NoScrollWithMouse; |
| 711 | |
| 712 | ImGui::SetNextWindowPos(ImVec2(0, 0)); |
| 713 | ImGui::SetNextWindowSize(ImVec2(box.size.x * scaleFactor, box.size.y * scaleFactor)); |
| 714 | |
| 715 | if (ImGui::Begin("Model File List", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize)) |
| 716 | { |
| 717 | if (ImGui::BeginTable("modellist", 1, ImGuiTableFlags_NoSavedSettings)) |
| 718 | { |
| 719 | for (size_t i=0, count=currentFiles.size(); i < count; ++i) |
| 720 | { |
nothing calls this directly
no outgoing calls
no test coverage detected