2.7 KiB
Single-header file picker Windows library for ImGui.
How to use
int renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0) {
Call int fp::renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0); within the render loop providing a pre-allocated C-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 states
- fp::ExitFlags::EXIT_CONTINUE : Window will render next frame.
- fp::ExitFlags::EXIT_SELECTED : A path has been successfully returned, window will close.
- fp::ExitFlags::EXIT_CLOSED : User has closed the window. No path is returned.
- fp::ExitFlags::EXIT_ERROR : An unexpected error has ocurred. No path is returned.
Valid window flags
- fp::WindowFlags::FP_FULLSCREEN`: Render window in full screen, without decorations.
Library dependencies
- C++ STL: This library uses
vectorandw\string.
Build considerations
Define DEBUG 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. - Compiled with
clangusing llvm-mingw 20220906.
How to compile
Download GLFW and pick your libraries according to your toolchain(mingw-w64 in this example).
Then, call your compiler directly (clang is demonstrated here) 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/si.exe -DDEBUG -L C:\capybara\libclang\x86_64-w64-mingw32\bin -L C:\capybara\libclang\x86_64-w64-mingw32\lib -I C:\capybara\libclang\include -std=c++17 -lglfw3 -l opengl32 -l gdi32 -l user32 -l kernel32 -l imm32 -static-libstdc++ --verbose
Add -DDEBUG to print filepicker's debug information, if you so desire.
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.