Extending the UI with an Open File dialog
ImGui can be used to create simple UIs like in our animation application, but the code can be also extended to build different kinds of tools. For our application, a dialog to choose a file on the system is helpful to load models at runtime, freeing us of hardcoding the model names in the code or using models as command-line parameters when starting the application.
Various ImGui-based file dialogs exist; a nice and easy-to-integrate file dialog can be found in the GitHub repository of Stephane Cuillerdier at https://github.com/aiekick/ImGuiFileDialog.
For a simple integration of the file dialog, we will use CMake’s FetchContent
to download and build the code.
Integrating the file dialog into CMakeLists.txt
First, we add a new FetchContent
block into the CMakeLists.txt
file, right below the end of the ImGui fetching:
FetchContent_Declare(
filedialog
GIT_REPOSITORY https://github.com/aiekick/ImGuiFileDialog
...