A simple and lightweight file dialog for Dear ImGui, based on L2DFileDialog.
- Multiple dialog types:
- 📂 Open File
- 💾 Save File
- 📁 Select Folder
- File sorting options:
- 📝 By Name
- 📏 By Size
- 🔠 By Type
- 🕒 By Last Modified Date
- 🔍 Customizable file filters (e.g., support for specific file types like .json).
⚠️ Error handling (e.g., alert when a file already exists during a "Save File" operation).
- Download
imgui_filedialog.h
andimgui_filedialog.cpp
- Add downloaded files to your C++ project.
- Include the header file where you want to use ImGuiFileDialogs.
// Declare variables outside of the draw loop
bool m_fileDialogOpen;
ImFileDialogInfo m_fileDialogInfo;
// Trigger file dialog on button click
if (ImGui::Button("Save File"))
{
m_fileDialogOpen = true;
m_fileDialogInfo.type = ImGuiFileDialogType_SaveFile;
m_fileDialogInfo.title = "Save File";
m_fileDialogInfo.fileName = "test.json";
m_fileDialogInfo.directoryPath = std::filesystem::current_path();
// Optional: Define file filters
m_fileDialogInfo.filters =
{
"All Files (*.*)|.*",
"JSON (*.json)|.json"
};
}
// Show file dialog in the render loop
if (ImGui::FileDialog(&m_fileDialogOpen, &m_fileDialogInfo))
{
// Handle result path: m_fileDialogInfo.resultPath
}
- 📁 Added SelectFolder dialog type.
- 🔧 Changed the file filtering system.
- ⬇️ Introduced a filter dropdown for easier selection.
- 📑 Updated the
ImFileDialogInfo
structure. - 🔄 Refactored the method to refresh paths:
void RefreshInfo(ImFileDialogInfo* dialogInfo)
(replacingImFileDialogInfo::refreshPaths()
). ⚠️ Added Error Text during "Open File" operation.- 🛑 Introduced a popup that appears if a file already exists when attempting to save.
- 📚 Updated the README.
📝 This project is licensed under the Apache License 2.0.
📖 Apache License 2.0 Overview:
- ✅ Free to use, modify, and distribute.
- ✅ Can be used in commercial and non-commercial projects.
- ✅ Provides an express grant of patent rights from contributors.
- ❗ Must include original license, copyright, and NOTICE file.
See the LICENSE file for more details.