Debug verbosity, modified README

This commit is contained in:
Hane 2024-01-15 21:27:42 +01:00
commit 19f09f208f
3 changed files with 136 additions and 92 deletions

View file

@ -1,45 +1,58 @@
Single-header file picker Windows library for ImGui.
Single-header file picker library for ImGui.
Currently, this library is Windows-only. Support for Linux is planned.
# How to use
int renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0) {
This library exposes two functions:
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.
##int renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0);
## Window states
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::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.
fp::WindowFlags::FULLSCREEN : Render window in full screen, without decorations.
```
## Valid window flags
### Return values
```
- fp::WindowFlags::FP_FULLSCREEN`: Render window in full screen, without decorations.
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 `vector` and `w\string`.
## Build considerations
## Enable debug information
Define `DEBUG` to print relevant information to the console.
Define `FPDEBUG` to print relevant information to the console.
# Demo build instructions
## Build requirements
- [**GLFW v3**](https://github.com/glfw/glfw/releases): used as rendering backend. Executable in releases is compiled with version [`3.3.8`](https://github.com/glfw/glfw/releases/tag/3.3.8).
- Compiled with `clang` using [**llvm-mingw 20220906**](https://github.com/mstorsjo/llvm-mingw/releases/tag/20220906).
- Developed and tested with `clang` using [**llvm-mingw 20220906**](https://github.com/mstorsjo/llvm-mingw/releases/tag/20220906). Any `MinGW`-backed `clang` compiler should work, but your mileage may vary.
## 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:
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++
@ -48,10 +61,8 @@ int renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0) {
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
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++
```
Add `-DDEBUG` to print filepicker's debug information, if you so desire.
# To-Dos