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.