Skip to content

Muppetsg2/ImGuiFileDialog

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

License

File Dialog for Dear ImGui πŸ–₯️

A simple and lightweight file dialog for Dear ImGui, based on L2DFileDialog.

File Dialog Without Filter

πŸ“‹ Table of Contents

✨ Features

  • 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).

βš™οΈ Adding to your project

  1. Download imgui_filedialog.h and imgui_filedialog.cpp
  2. Add downloaded files to your C++ project.
  3. Include the header file where you want to use ImGuiFileDialogs.

πŸ’‘ Example Usage

// 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
}

πŸ”„ Changes

  • πŸ“ 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) (replacing ImFileDialogInfo::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.

πŸ“œ License

πŸ“ 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.

About

A simple and lightweight file dialog for Dear ImGui, based on L2DFileDialog.

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • C++ 100.0%