MCPcopy Create free account
hub / github.com/aiekick/ImGuiFileDialog / Display

Method Display

ImGuiFileDialog.cpp:3792–3909  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3790//////////////////////////////////////////////////////////////////////////////////////////////////
3791
3792bool IGFD::FileDialog::Display(const std::string& vKey, ImGuiWindowFlags vFlags, ImVec2 vMinSize, ImVec2 vMaxSize) {
3793 bool res = false;
3794
3795 if (m_FileDialogInternal.showDialog && m_FileDialogInternal.dLGkey == vKey) {
3796 if (m_FileDialogInternal.puUseCustomLocale) setlocale(m_FileDialogInternal.localeCategory, m_FileDialogInternal.localeBegin.c_str());
3797
3798 auto& fdFile = m_FileDialogInternal.fileManager;
3799 auto& fdFilter = m_FileDialogInternal.filterManager;
3800
3801 // to be sure than only one dialog is displayed per frame
3802 ImGuiContext& g = *GImGui;
3803 if (g.FrameCount == m_FileDialogInternal.lastImGuiFrameCount) { // one instance was displayed this frame before
3804 return res; // for this key +> quit
3805 }
3806 m_FileDialogInternal.lastImGuiFrameCount = g.FrameCount; // mark this instance as used this frame
3807
3808 m_CurrentDisplayedFlags = vFlags;
3809 std::string name = m_FileDialogInternal.dLGtitle + "##" + m_FileDialogInternal.dLGkey;
3810 if (m_FileDialogInternal.name != name) {
3811 fdFile.ClearComposer();
3812 fdFile.ClearFileLists();
3813 }
3814
3815 m_NewFrame();
3816
3817#ifdef IMGUI_HAS_VIEWPORT
3818 if (!ImGui::GetIO().ConfigViewportsNoDecoration) {
3819 // https://github.com/ocornut/imgui/issues/4534
3820 ImGuiWindowClass window_class;
3821 window_class.ViewportFlagsOverrideClear = ImGuiViewportFlags_NoDecoration;
3822 ImGui::SetNextWindowClass(&window_class);
3823 }
3824#endif // IMGUI_HAS_VIEWPORT
3825
3826 bool beg = false;
3827 ImVec2 frameSize = ImVec2(0, 0);
3828 if (m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_NoDialog) { // disable our own dialog system (standard or modal)
3829 frameSize = vMinSize;
3830 beg = true;
3831 } else {
3832 ImGui::SetNextWindowSizeConstraints(vMinSize, vMaxSize);
3833 if (m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_Modal && // disable modal because the confirm dialog for overwrite is
3834 !m_FileDialogInternal.okResultToConfirm) { // a new modal
3835 ImGui::OpenPopup(name.c_str());
3836 beg = ImGui::BeginPopupModal(name.c_str(), (bool*)nullptr, m_CurrentDisplayedFlags | ImGuiWindowFlags_NoScrollbar);
3837 } else {
3838 beg = ImGui::Begin(name.c_str(), (bool*)nullptr, m_CurrentDisplayedFlags | ImGuiWindowFlags_NoScrollbar);
3839 }
3840 }
3841 if (beg) {
3842#ifdef IMGUI_HAS_VIEWPORT
3843 // if decoration is enabled we disable the resizing feature of imgui for avoid crash with SDL2 and GLFW3
3844 if (ImGui::GetIO().ConfigViewportsNoDecoration) {
3845 m_CurrentDisplayedFlags = vFlags;
3846 } else {
3847 auto win = ImGui::GetCurrentWindowRead();
3848 if (win->Viewport->Idx != 0)
3849 m_CurrentDisplayedFlags |= ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar;

Callers 1

IGFD_DisplayDialogFunction · 0.80

Calls 7

ClearComposerMethod · 0.80
ClearFileListsMethod · 0.80
emptyMethod · 0.80
IsFileListEmptyMethod · 0.80
SetDefaultFileNameMethod · 0.80
ScanDirMethod · 0.80

Tested by

no test coverage detected