2.8 KiB
Single-header file picker library for ImGui.
Currently, this library is Windows-only. Support for Linux is planned.
How to use
This library exposes two functions:
##int renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0);
Call this function within the render loop providing a pre-allocated C-wide string buffer of MAX_PATH characters in userPath. windowOpen must be initially set to true, and will set itself to false when execution is done. If succesful, your buffer will contain a valid path. You can check the file picker state each frame by parsing this function's return value. You can provide windowFlags to customize its appearance.
Window customization flags
fp::WindowFlags::FULLSCREEN : Render window in full screen, without decorations.
Return values
fp::ExitFlags::CONTINUE : Window will render next frame.
fp::ExitFlags::SELECTED : A path has been successfully returned, window will close.
fp::ExitFlags::CLOSED : User has closed the window. No path is returned.
##void setDebugInfo(int debugVerbosity);
When FPDEBUG is enabled, this allows you to configure debug granularity.
Debug flags
fp::DebugVerbosity::DIRECTORY
fp::DebugVerbosity::VOLUME
fp::DebugVerbosity::EXTENSION
Library dependencies
- C++ STL: This library uses
vectorandw\string.
Enable debug information
Define FPDEBUG to print relevant information to the console.
Demo build instructions
Build requirements
- GLFW v3: used as rendering backend. Executable in releases is compiled with version
3.3.8. - Developed and tested with
clangusing llvm-mingw 20220906. AnyMinGW-backedclangcompiler should work, but your mileage may vary.
How to compile
Download GLFW and pick your libraries according to your toolchain. Then, call your compiler directly specifying both libs needed and your paths to the necessary header and lib files:
clang++ demo/main.cpp -o demo/demo.exe -L C:/pathtollvmmingw/x86_64-w64-mingw32/bin -I C:\pathtollvmmingw\include -L C:/pathtoglfw/lib-mingw-w64 -I C:\pathtoglfw\include -lglfw3 -l libc++
If you want to statically link:
clang++ demo/main.cpp -o demo/demo.exe -L C:/pathtoglfw/lib-mingw-w64 -L C:/pathtollvmmingw/x86_64-w64-mingw32/lib -I C:\pathtollvmmingw\include -I C:\pathtoglfw\include -std=c++17 -stdlib=libc++ -rtlib=compiler-rt -static -l glfw3 -l gdi32 -l opengl32 -l user32 -l kernel32 -static-libstdc++
To-Dos
- Implement a file watcher to check for changes on the current directory.
- Add Linux support.
- Allow users to provide their own memory allocations as an option.