jmorton06 / imgui-filebrowser

File browser implementation for dear-imgui. C++17 required.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

imgui-filebrowser

imgui-filebrowser is a simple file browser implementation for dear-imgui.

IMG

Getting Started

imgui-filebrowser is header-only and must be included after imgui.h:

#include <imgui.h>
#include <imfilebrowser.h>

Instead of creating a file dialog by a immediate function call, you need to create a ImGui::FileBrowser instance, open it with member function Open(), and call Display() in each frame. Here is a simple example:

#include <imgui.h>
#include <imfilebrowser.h>

int main()
{
    //...initialize rendering window and imgui
    
    // create a file browser instance
    ImGui::FileBrowser fileDialog;
    
    // mainloop
    while(continueRendering)
    {
        //...do other stuff like ImGui::NewFrame();
        
        // open file dialog when user clicks this button
        if(ImGui::Button("open file dialog"))
            fileDialog.Open();
        
        fileDialog.Display();
        
        if(fileDialog.HasSelected())
        {
            std::cout << "Selected filename" << fileDialog.GetSelected().string() << std::endl;
            fileDialog.ClearSelected();
        }
        
        //...do other stuff like ImGui::Render();
    }
    
    //...shutdown
}

About

File browser implementation for dear-imgui. C++17 required.

License:MIT License


Languages

Language:C++ 100.0%