| 3852 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3853 | |
| 3854 | bool IGFD::FileDialog::Display(const std::string& vKey, ImGuiWindowFlags vFlags, ImVec2 vMinSize, ImVec2 vMaxSize) { |
| 3855 | bool res = false; |
| 3856 | |
| 3857 | if (m_FileDialogInternal.showDialog && m_FileDialogInternal.dLGkey == vKey) { |
| 3858 | if (m_FileDialogInternal.puUseCustomLocale) setlocale(m_FileDialogInternal.localeCategory, m_FileDialogInternal.localeBegin.c_str()); |
| 3859 | |
| 3860 | auto& fdFile = m_FileDialogInternal.fileManager; |
| 3861 | auto& fdFilter = m_FileDialogInternal.filterManager; |
| 3862 | |
| 3863 | // to be sure than only one dialog is displayed per frame |
| 3864 | ImGuiContext& g = *GImGui; |
| 3865 | if (g.FrameCount == m_FileDialogInternal.lastImGuiFrameCount) { // one instance was displayed this frame before |
| 3866 | return res; // for this key +> quit |
| 3867 | } |
| 3868 | m_FileDialogInternal.lastImGuiFrameCount = g.FrameCount; // mark this instance as used this frame |
| 3869 | |
| 3870 | m_CurrentDisplayedFlags = vFlags; |
| 3871 | std::string name = m_FileDialogInternal.dLGtitle + "##" + m_FileDialogInternal.dLGkey; |
| 3872 | if (m_FileDialogInternal.name != name) { |
| 3873 | fdFile.ClearComposer(); |
| 3874 | fdFile.ClearFileLists(); |
| 3875 | } |
| 3876 | |
| 3877 | m_NewFrame(); |
| 3878 | |
| 3879 | #ifdef IMGUI_HAS_VIEWPORT |
| 3880 | if (!ImGui::GetIO().ConfigViewportsNoDecoration) { |
| 3881 | // https://github.com/ocornut/imgui/issues/4534 |
| 3882 | ImGuiWindowClass window_class; |
| 3883 | window_class.ViewportFlagsOverrideClear = ImGuiViewportFlags_NoDecoration; |
| 3884 | ImGui::SetNextWindowClass(&window_class); |
| 3885 | } |
| 3886 | #endif // IMGUI_HAS_VIEWPORT |
| 3887 | |
| 3888 | bool beg = false; |
| 3889 | ImVec2 frameSize = ImVec2(0, 0); |
| 3890 | if (m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_NoDialog) { // disable our own dialog system (standard or modal) |
| 3891 | frameSize = vMinSize; |
| 3892 | beg = true; |
| 3893 | } else { |
| 3894 | ImGui::SetNextWindowSizeConstraints(vMinSize, vMaxSize); |
| 3895 | if (m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_Modal && // disable modal because the confirm dialog for overwrite is |
| 3896 | !m_FileDialogInternal.okResultToConfirm) { // a new modal |
| 3897 | ImGui::OpenPopup(name.c_str()); |
| 3898 | beg = ImGui::BeginPopupModal(name.c_str(), (bool*)nullptr, m_CurrentDisplayedFlags | ImGuiWindowFlags_NoScrollbar); |
| 3899 | } else { |
| 3900 | beg = ImGui::Begin(name.c_str(), (bool*)nullptr, m_CurrentDisplayedFlags | ImGuiWindowFlags_NoScrollbar); |
| 3901 | } |
| 3902 | } |
| 3903 | if (beg) { |
| 3904 | #ifdef IMGUI_HAS_VIEWPORT |
| 3905 | // if decoration is enabled we disable the resizing feature of imgui for avoid crash with SDL2 and GLFW3 |
| 3906 | if (ImGui::GetIO().ConfigViewportsNoDecoration) { |
| 3907 | m_CurrentDisplayedFlags = vFlags; |
| 3908 | } else { |
| 3909 | auto win = ImGui::GetCurrentWindowRead(); |
| 3910 | if (win && win->Viewport->Idx != 0) |
| 3911 | m_CurrentDisplayedFlags |= ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar; |
no test coverage detected