| 516 | } |
| 517 | |
| 518 | void ModelView::BuildControlDialog() |
| 519 | { |
| 520 | ImGuiIO const& io = ImGui::GetIO(); |
| 521 | float const fontSize = ImGui::GetFontSize(); |
| 522 | |
| 523 | auto viewExtent = m_view.GetViewExtent(); |
| 524 | ImGui::SetNextWindowPos(ImVec2( |
| 525 | float(viewExtent.minX + viewExtent.maxX) * 0.5f, |
| 526 | float(viewExtent.maxY) - fontSize * 0.6f), |
| 527 | ImGuiCond_Always, ImVec2(0.5f, 1.0f)); |
| 528 | |
| 529 | ImGui::Begin("Model View", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | |
| 530 | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize); |
| 531 | |
| 532 | // Mip level slider |
| 533 | if (m_textureMips > 1) |
| 534 | { |
| 535 | ImGui::PushItemWidth(120.f); |
| 536 | ImGui::SliderFloat("##MipLevel", &m_showMipLevel, 0.f, float(m_textureMips) - 1.f, "Mip %.1f"); |
| 537 | ImGui::PopItemWidth(); |
| 538 | } |
| 539 | else |
| 540 | { |
| 541 | ImGui::AlignTextToFramePadding(); |
| 542 | ImGui::TextUnformatted("(No Mips)"); |
| 543 | } |
| 544 | |
| 545 | // Display mode selection |
| 546 | ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(6.f, 3.f)); |
| 547 | ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.4f, 0.4f, 0.4f, 1.f)); |
| 548 | |
| 549 | if (!m_decompressedImagesAvailable) |
| 550 | m_displayMode = DisplayMode::LeftTexture; |
| 551 | |
| 552 | std::tuple<DisplayMode, const char*> modes[] = { |
| 553 | { DisplayMode::LeftTexture, m_leftImageName.c_str() }, |
| 554 | { DisplayMode::RightTexture, m_rightImageName.c_str() }, |
| 555 | { DisplayMode::SplitScreen, "Split-Screen" } |
| 556 | }; |
| 557 | |
| 558 | bool first = true; |
| 559 | for (const auto& [mode, label] : modes) |
| 560 | { |
| 561 | ImGui::SameLine(first ? fontSize * 8.5f : 0.f); |
| 562 | first = false; |
| 563 | |
| 564 | // Use an ID string with ### to make ImGui element ID independent from the button label which is volatile |
| 565 | const std::string id = std::string(label) + "###" + std::to_string(int(mode)); |
| 566 | |
| 567 | bool active = m_displayMode == mode; |
| 568 | ImGui::BeginDisabled(!m_decompressedImagesAvailable); |
| 569 | ImGui::ToggleButton(id.c_str(), &active, ImVec2(fontSize * 6.5f, 0)); |
| 570 | ImGui::EndDisabled(); |
| 571 | if (active) m_displayMode = mode; |
| 572 | |
| 573 | if ((mode == DisplayMode::LeftTexture || mode == DisplayMode::RightTexture) && ImGui::BeginDragDropTarget()) |
| 574 | { |
| 575 | if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("CompressionRun")) |