| 1 |
[<img src="https://github.com/aiekick/ImGuiFileDialog/workflows/Win/badge.svg" width="150"/>](https://github.com/aiekick/ImGuiFileDialog/actions?query=workflow%3AWin) |
| 2 |
[<img src="https://github.com/aiekick/ImGuiFileDialog/workflows/Linux/badge.svg" width="165"/>](https://github.com/aiekick/ImGuiFileDialog/actions?query=workflow%3ALinux) |
| 3 |
[<img src="https://github.com/aiekick/ImGuiFileDialog/workflows/Osx/badge.svg" width="150"/>](https://github.com/aiekick/ImGuiFileDialog/actions?query=workflow%3AOsx) |
| 4 |
|
| 5 |
# ImGuiFileDialog |
| 6 |
|
| 7 |
## Purpose |
| 8 |
|
| 9 |
ImGuiFileDialog is a file selection dialog built for (and using only) [Dear ImGui](https://github.com/ocornut/imgui). |
| 10 |
|
| 11 |
My primary goal was to have a custom pane with widgets according to file extension. This was not possible using other |
| 12 |
solutions. |
| 13 |
|
| 14 |
## Structure |
| 15 |
|
| 16 |
* The library is in [Lib_Only branch](https://github.com/aiekick/ImGuiFileDialog/tree/Lib_Only) |
| 17 |
* A demo app can be found the [master branch](https://github.com/aiekick/ImGuiFileDialog/tree/master) |
| 18 |
|
| 19 |
This library is designed to be dropped into your source code rather than compiled separately. |
| 20 |
|
| 21 |
From your project directory: |
| 22 |
|
| 23 |
``` |
| 24 |
mkdir lib <or 3rdparty, or externals, etc.> |
| 25 |
cd lib |
| 26 |
git clone https://github.com/aiekick/ImGuiFileDialog.git |
| 27 |
git checkout Lib_Only |
| 28 |
``` |
| 29 |
|
| 30 |
These commands create a `lib` directory where you can store any third-party dependencies used in your project, downloads |
| 31 |
the ImGuiFileDialog git repository and checks out the Lib_Only branch where the actual library code is located. |
| 32 |
|
| 33 |
Add `lib/ImGuiFileDialog/ImGuiFileDialog.cpp` to your build system and include |
| 34 |
`lib/ImGuiFileDialog/ImGuiFileDialog.h` in your source code. ImGuiFileLib will compile with and be included directly in |
| 35 |
your executable file. |
| 36 |
|
| 37 |
If, for example, your project uses cmake, look for a line like `add_executable(my_project_name main.cpp)` |
| 38 |
and change it to `add_executable(my_project_name lib/ImGuiFileDialog/ImGuiFileDialog.cpp main.cpp)`. This tells the |
| 39 |
compiler where to find the source code declared in `ImGuiFileDialog.h` which you included in your own source code. |
| 40 |
|
| 41 |
## Requirements: |
| 42 |
|
| 43 |
You must also, of course, have added [Dear ImGui](https://github.com/ocornut/imgui) to your project for this to work at |
| 44 |
all. |
| 45 |
|
| 46 |
[dirent v1.23](https://github.com/tronkko/dirent/tree/v1.23) is required to use ImGuiFileDialog under Windows. It is |
| 47 |
included in the Lib_Only branch for your convenience. |
| 48 |
|
| 49 |
## Features |
| 50 |
|
| 51 |
- Separate system for call and display |
| 52 |
- Can have many function calls with different parameters for one display function, for example |
| 53 |
- Can create a custom pane with any widgets via function binding |
| 54 |
- This pane can block the validation of the dialog |
| 55 |
- Can also display different things according to current filter and UserDatas |
| 56 |
- Advanced file style for file/dir/link coloring / icons / font |
| 57 |
- Multi-selection (ctrl/shift + click) : |
| 58 |
- 0 => Infinite |
| 59 |
- 1 => One file (default) |
| 60 |
- n => n files |
| 61 |
- Compatible with MacOs, Linux, Windows |
| 62 |
- Windows version can list drives |
| 63 |
- Supports modal or standard dialog types |
| 64 |
- Select files or directories |
| 65 |
- Filter groups and custom filter names |
| 66 |
- Keyboard navigation (arrows, backspace, enter) |
| 67 |
- Exploring by entering characters (case insensitive) |
| 68 |
- Directory bookmarks |
| 69 |
- Directory manual entry (right click on any path element) |
| 70 |
- Optional 'Confirm to Overwrite" dialog if file exists |
| 71 |
- Thumbnails Display (agnostic way for compatibility with any backend, sucessfully tested with OpenGl and Vulkan) |
| 72 |
- C Api (succesfully tested with CimGui) |
| 73 |
|
| 74 |
## Singleton Pattern vs. Multiple Instances |
| 75 |
|
| 76 |
### Single Dialog : |
| 77 |
|
| 78 |
If you only need to display one file dialog at a time, use ImGuiFileDialog's singleton pattern to avoid explicitly |
| 79 |
declaring an object: |
| 80 |
|
| 81 |
```cpp |
| 82 |
ImGuiFileDialog::Instance()->method_of_your_choice(); |
| 83 |
``` |
| 84 |
|
| 85 |
### Multiple Dialogs : |
| 86 |
|
| 87 |
If you need to have multiple file dialogs open at once, declare each dialog explicity: |
| 88 |
|
| 89 |
```cpp |
| 90 |
ImGuiFileDialog instance_a; |
| 91 |
instance_a.method_of_your_choice(); |
| 92 |
ImGuiFileDialog instance_b; |
| 93 |
instance_b.method_of_your_choice(); |
| 94 |
``` |
| 95 |
|
| 96 |
## Simple Dialog : |
| 97 |
|
| 98 |
```cpp |
| 99 |
void drawGui() |
| 100 |
{ |
| 101 |
// open Dialog Simple |
| 102 |
if (ImGui::Button("Open File Dialog")) |
| 103 |
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".cpp,.h,.hpp", "."); |
| 104 |
|
| 105 |
// display |
| 106 |
if (ImGuiFileDialog::Instance()->Display("ChooseFileDlgKey")) |
| 107 |
{ |
| 108 |
// action if OK |
| 109 |
if (ImGuiFileDialog::Instance()->IsOk()) |
| 110 |
{ |
| 111 |
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName(); |
| 112 |
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath(); |
| 113 |
// action |
| 114 |
} |
| 115 |
|
| 116 |
// close |
| 117 |
ImGuiFileDialog::Instance()->Close(); |
| 118 |
} |
| 119 |
} |
| 120 |
``` |
| 121 |
|
| 122 |
 |
| 123 |
|
| 124 |
## Directory Chooser : |
| 125 |
|
| 126 |
To have a directory chooser, set the file extension filter to nullptr: |
| 127 |
|
| 128 |
```cpp |
| 129 |
ImGuiFileDialog::Instance()->OpenDialog("ChooseDirDlgKey", "Choose a Directory", nullptr, "."); |
| 130 |
``` |
| 131 |
|
| 132 |
In this mode you can select any directory with one click and open a directory with a double-click. |
| 133 |
|
| 134 |
 |
| 135 |
|
| 136 |
## Dialog with Custom Pane : |
| 137 |
|
| 138 |
The signature of the custom pane callback is: |
| 139 |
|
| 140 |
### for C++ : |
| 141 |
|
| 142 |
```cpp |
| 143 |
void(const char *vFilter, IGFDUserDatas vUserDatas, bool *vCantContinue) |
| 144 |
``` |
| 145 |
|
| 146 |
### for C : |
| 147 |
|
| 148 |
```c |
| 149 |
void(const char *vFilter, void* vUserDatas, bool *vCantContinue) |
| 150 |
``` |
| 151 |
|
| 152 |
### Example : |
| 153 |
|
| 154 |
```cpp |
| 155 |
static bool canValidateDialog = false; |
| 156 |
inline void InfosPane(cosnt char *vFilter, IGFDUserDatas vUserDatas, bool *vCantContinue) // if vCantContinue is false, the user cant validate the dialog |
| 157 |
{ |
| 158 |
ImGui::TextColored(ImVec4(0, 1, 1, 1), "Infos Pane"); |
| 159 |
ImGui::Text("Selected Filter : %s", vFilter.c_str()); |
| 160 |
if (vUserDatas) |
| 161 |
ImGui::Text("UserDatas : %s", vUserDatas); |
| 162 |
ImGui::Checkbox("if not checked you cant validate the dialog", &canValidateDialog); |
| 163 |
if (vCantContinue) |
| 164 |
*vCantContinue = canValidateDialog; |
| 165 |
} |
| 166 |
|
| 167 |
void drawGui() |
| 168 |
{ |
| 169 |
// open Dialog with Pane |
| 170 |
if (ImGui::Button("Open File Dialog with a custom pane")) |
| 171 |
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".cpp,.h,.hpp", |
| 172 |
".", "", std::bind(&InfosPane, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), 350, 1, UserDatas("InfosPane")); |
| 173 |
|
| 174 |
// display and action if ok |
| 175 |
if (ImGuiFileDialog::Instance()->Display("ChooseFileDlgKey")) |
| 176 |
{ |
| 177 |
if (ImGuiFileDialog::Instance()->IsOk()) |
| 178 |
{ |
| 179 |
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName(); |
| 180 |
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath(); |
| 181 |
std::string filter = ImGuiFileDialog::Instance()->GetCurrentFilter(); |
| 182 |
// here convert from string because a string was passed as a userDatas, but it can be what you want |
| 183 |
std::string userDatas; |
| 184 |
if (ImGuiFileDialog::Instance()->GetUserDatas()) |
| 185 |
userDatas = std::string((const char*)ImGuiFileDialog::Instance()->GetUserDatas()); |
| 186 |
auto selection = ImGuiFileDialog::Instance()->GetSelection(); // multiselection |
| 187 |
|
| 188 |
// action |
| 189 |
} |
| 190 |
// close |
| 191 |
ImGuiFileDialog::Instance()->Close(); |
| 192 |
} |
| 193 |
} |
| 194 |
``` |
| 195 |
|
| 196 |
 |
| 197 |
|
| 198 |
## File Style : Custom icons and colors by extension |
| 199 |
|
| 200 |
You can define style for files/dirs/links in many ways : |
| 201 |
|
| 202 |
the style can be colors, icons and fonts |
| 203 |
|
| 204 |
the general form is : |
| 205 |
```cpp |
| 206 |
ImGuiFileDialog::Instance()->SetFileStyle(styleType, criteria, color, icon, font); |
| 207 |
|
| 208 |
styleType can be thoses : |
| 209 |
|
| 210 |
IGFD_FileStyleByTypeFile // define style for all files |
| 211 |
IGFD_FileStyleByTypeDir // define style for all dir |
| 212 |
IGFD_FileStyleByTypeLink // define style for all link |
| 213 |
IGFD_FileStyleByExtention // define style by extention, for files or links |
| 214 |
IGFD_FileStyleByFullName // define style for particular file/dir/link full name (filename + extention) |
| 215 |
IGFD_FileStyleByContainedInFullName // define style for file/dir/link when criteria is contained in full name |
| 216 |
``` |
| 217 |
|
| 218 |
ImGuiFileDialog accepts icon font macros as well as text tags for file types. |
| 219 |
|
| 220 |
[ImGuIFontStudio](https://github.com/aiekick/ImGuiFontStudio) is useful here. I wrote it to make it easy to create |
| 221 |
custom icon sets for use with Dear ImGui. |
| 222 |
|
| 223 |
It is inspired by [IconFontCppHeaders](https://github.com/juliettef/IconFontCppHeaders), which can also be used with |
| 224 |
ImGuiFileDialog. |
| 225 |
|
| 226 |
samples : |
| 227 |
|
| 228 |
```cpp |
| 229 |
// define style by file extention and Add an icon for .png files |
| 230 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".png", ImVec4(0.0f, 1.0f, 1.0f, 0.9f), ICON_IGFD_FILE_PIC, font1); |
| 231 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".gif", ImVec4(0.0f, 1.0f, 0.5f, 0.9f), "[GIF]"); |
| 232 |
|
| 233 |
// define style for all directories |
| 234 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeDir, "", ImVec4(0.5f, 1.0f, 0.9f, 0.9f), ICON_IGFD_FOLDER); |
| 235 |
// can be for a specific directory |
| 236 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeDir, ".git", ImVec4(0.5f, 1.0f, 0.9f, 0.9f), ICON_IGFD_FOLDER); |
| 237 |
|
| 238 |
// define style for all files |
| 239 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeFile, "", ImVec4(0.5f, 1.0f, 0.9f, 0.9f), ICON_IGFD_FILE); |
| 240 |
// can be for a specific file |
| 241 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeFile, ".git", ImVec4(0.5f, 1.0f, 0.9f, 0.9f), ICON_IGFD_FILE); |
| 242 |
|
| 243 |
// define style for all links |
| 244 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeLink, "", ImVec4(0.5f, 1.0f, 0.9f, 0.9f)); |
| 245 |
// can be for a specific link |
| 246 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeLink, "Readme.md", ImVec4(0.5f, 1.0f, 0.9f, 0.9f)); |
| 247 |
|
| 248 |
// define style for any files/dirs/links by fullname |
| 249 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByFullName, "doc", ImVec4(0.9f, 0.2f, 0.0f, 0.9f), ICON_IGFD_FILE_PIC); |
| 250 |
|
| 251 |
// define style by file who are containing this string |
| 252 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByContainedInFullName, ".git", ImVec4(0.9f, 0.2f, 0.0f, 0.9f), ICON_IGFD_BOOKMARK); |
| 253 |
|
| 254 |
all of theses can be miwed with IGFD_FileStyleByTypeDir / IGFD_FileStyleByTypeFile / IGFD_FileStyleByTypeLink |
| 255 |
like theses by ex : |
| 256 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeDir | IGFD_FileStyleByContainedInFullName, ".git", ImVec4(0.9f, 0.2f, 0.0f, 0.9f), ICON_IGFD_BOOKMARK); |
| 257 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeFile | IGFD_FileStyleByFullName, "cmake", ImVec4(0.5f, 0.8f, 0.5f, 0.9f), ICON_IGFD_SAVE); |
| 258 |
``` |
| 259 |
|
| 260 |
this sample code of [master/main.cpp](https://github.com/aiekick/ImGuiFileDialog/blob/master/main.cpp) produce the picture above : |
| 261 |
|
| 262 |
```cpp |
| 263 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".cpp", ImVec4(1.0f, 1.0f, 0.0f, 0.9f)); |
| 264 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".h", ImVec4(0.0f, 1.0f, 0.0f, 0.9f)); |
| 265 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".hpp", ImVec4(0.0f, 0.0f, 1.0f, 0.9f)); |
| 266 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".md", ImVec4(1.0f, 0.0f, 1.0f, 0.9f)); |
| 267 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".png", ImVec4(0.0f, 1.0f, 1.0f, 0.9f), ICON_IGFD_FILE_PIC); // add an icon for the filter type |
| 268 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".gif", ImVec4(0.0f, 1.0f, 0.5f, 0.9f), "[GIF]"); // add an text for a filter type |
| 269 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeDir, nullptr, ImVec4(0.5f, 1.0f, 0.9f, 0.9f), ICON_IGFD_FOLDER); // for all dirs |
| 270 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeFile, "CMakeLists.txt", ImVec4(0.1f, 0.5f, 0.5f, 0.9f), ICON_IGFD_ADD); |
| 271 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByFullName, "doc", ImVec4(0.9f, 0.2f, 0.0f, 0.9f), ICON_IGFD_FILE_PIC); |
| 272 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeDir | IGFD_FileStyleByContainedInFullName, ".git", ImVec4(0.9f, 0.2f, 0.0f, 0.9f), ICON_IGFD_BOOKMARK); |
| 273 |
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeFile | IGFD_FileStyleByContainedInFullName, ".git", ImVec4(0.5f, 0.8f, 0.5f, 0.9f), ICON_IGFD_SAVE); |
| 274 |
``` |
| 275 |
|
| 276 |
 |
| 277 |
|
| 278 |
## Filter Collections |
| 279 |
|
| 280 |
You can define a custom filter name that corresponds to a group of filters using this syntax: |
| 281 |
|
| 282 |
```custom_name1{filter1,filter2,filter3},custom_name2{filter1,filter2},filter1``` |
| 283 |
|
| 284 |
When you select custom_name1, filters 1 to 3 will be applied. The characters `{` and `}` are reserved. Don't use them |
| 285 |
for filter names. |
| 286 |
|
| 287 |
this code : |
| 288 |
|
| 289 |
```cpp |
| 290 |
const char *filters = "Source files (*.cpp *.h *.hpp){.cpp,.h,.hpp},Image files (*.png *.gif *.jpg *.jpeg){.png,.gif,.jpg,.jpeg},.md"; |
| 291 |
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", ICON_IMFDLG_FOLDER_OPEN " Choose a File", filters, "."); |
| 292 |
``` |
| 293 |
|
| 294 |
will produce : |
| 295 |
 |
| 296 |
|
| 297 |
## Multi Selection |
| 298 |
|
| 299 |
You can define in OpenDialog/OpenModal call the count file you want to select : |
| 300 |
|
| 301 |
- 0 => infinite |
| 302 |
- 1 => one file only (default) |
| 303 |
- n => n files only |
| 304 |
|
| 305 |
See the define at the end of these funcs after path. |
| 306 |
|
| 307 |
```cpp |
| 308 |
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".*,.cpp,.h,.hpp", "."); |
| 309 |
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose 1 File", ".*,.cpp,.h,.hpp", ".", 1); |
| 310 |
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose 5 File", ".*,.cpp,.h,.hpp", ".", 5); |
| 311 |
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose many File", ".*,.cpp,.h,.hpp", ".", 0); |
| 312 |
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".png,.jpg", |
| 313 |
".", "", std::bind(&InfosPane, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), 350, 1, "SaveFile"); // 1 file |
| 314 |
``` |
| 315 |
|
| 316 |
 |
| 317 |
|
| 318 |
## File Dialog Constraints |
| 319 |
|
| 320 |
You can set the minimum and/or maximum size of the dialog: |
| 321 |
|
| 322 |
```cpp |
| 323 |
ImVec2 maxSize = ImVec2((float)display_w, (float)display_h); // The full display area |
| 324 |
ImVec2 minSize = maxSize * 0.5f; // Half the display area |
| 325 |
ImGuiFileDialog::Instance()->Display("ChooseFileDlgKey", ImGuiWindowFlags_NoCollapse, minSize, maxSize); |
| 326 |
``` |
| 327 |
|
| 328 |
 |
| 329 |
|
| 330 |
## Detail View Mode |
| 331 |
|
| 332 |
Dear ImGui just released an improved table API. If your downloaded version of Dear ImGui includes the beta version of |
| 333 |
table support (included for some time now) you can enable table support by uncommenting `#define USE_IMGUI_TABLES` in |
| 334 |
you custom config file (CustomImGuiFileDialogConfig.h) |
| 335 |
|
| 336 |
If your version of Dear ImGui has finalized tables support, it will be enabled by default. |
| 337 |
 |
| 338 |
|
| 339 |
## Exploring by keys |
| 340 |
|
| 341 |
You can activate this feature by uncommenting `#define USE_EXPLORATION_BY_KEYS` |
| 342 |
in your custom config file (CustomImGuiFileDialogConfig.h) |
| 343 |
|
| 344 |
You can also uncomment the next lines to define navigation keys: |
| 345 |
|
| 346 |
* IGFD_KEY_UP => Up key for explore to the top |
| 347 |
* IGFD_KEY_DOWN => Down key for explore to the bottom |
| 348 |
* IGFD_KEY_ENTER => Enter key for open directory |
| 349 |
* IGFD_KEY_BACKSPACE => BackSpace for comming back to the last directory |
| 350 |
|
| 351 |
You can also jump to a point in the file list by pressing the corresponding key of the first filename character. |
| 352 |
|
| 353 |
 |
| 354 |
|
| 355 |
As you see the current item is flashed by default for 1 second. You can define the flashing lifetime with the function |
| 356 |
|
| 357 |
```cpp |
| 358 |
ImGuiFileDialog::Instance()->SetFlashingAttenuationInSeconds(1.0f); |
| 359 |
``` |
| 360 |
|
| 361 |
## Bookmarks |
| 362 |
|
| 363 |
You can create/edit/call path bookmarks and load/save them. |
| 364 |
|
| 365 |
Activate this feature by uncommenting: `#define USE_BOOKMARK` in your custom config file (CustomImGuiFileDialogConfig.h) |
| 366 |
|
| 367 |
More customization options: |
| 368 |
|
| 369 |
```cpp |
| 370 |
#define bookmarkPaneWith 150.0f => width of the bookmark pane |
| 371 |
#define IMGUI_TOGGLE_BUTTON ToggleButton => customize the Toggled button (button stamp must be : (const char* label, bool *toggle) |
| 372 |
#define bookmarksButtonString "Bookmark" => the text in the toggle button |
| 373 |
#define bookmarksButtonHelpString "Bookmark" => the helper text when mouse over the button |
| 374 |
#define addBookmarkButtonString "+" => the button for add a bookmark |
| 375 |
#define removeBookmarkButtonString "-" => the button for remove the selected bookmark |
| 376 |
``` |
| 377 |
|
| 378 |
* You can select each bookmark to edit the displayed name corresponding to a path |
| 379 |
* Double-click on the label to apply the bookmark |
| 380 |
|
| 381 |
 |
| 382 |
|
| 383 |
You can also serialize/deserialize bookmarks (for example to load/save from/to a file): |
| 384 |
```cpp |
| 385 |
Load => ImGuiFileDialog::Instance()->DeserializeBookmarks(bookmarString); |
| 386 |
Save => std::string bookmarkString = ImGuiFileDialog::Instance()->SerializeBookmarks(); |
| 387 |
``` |
| 388 |
(please see example code for details) |
| 389 |
|
| 390 |
## Path Edition : |
| 391 |
|
| 392 |
Right clicking on any path element button allows the user to manually edit the path from that portion of the tree. |
| 393 |
Pressing the completion key (GLFW uses `enter` by default) validates the new path. Pressing the cancel key (GLFW |
| 394 |
uses`escape` by default) cancels the manual entry and restores the original path. |
| 395 |
|
| 396 |
Here's the manual entry operation in action: |
| 397 |
 |
| 398 |
|
| 399 |
## Confirm Overwrite Dialog : |
| 400 |
|
| 401 |
If you want avoid overwriting files after selection, ImGuiFileDialog can show a dialog to confirm or cancel the |
| 402 |
operation. |
| 403 |
|
| 404 |
To do so, define the flag ImGuiFileDialogFlags_ConfirmOverwrite in your call to OpenDialog/OpenModal. |
| 405 |
|
| 406 |
By default this flag is not set since there is no pre-defined way to define if a dialog will be for Open or Save |
| 407 |
behavior. (by design! :) ) |
| 408 |
|
| 409 |
Example code For Standard Dialog : |
| 410 |
|
| 411 |
```cpp |
| 412 |
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", |
| 413 |
ICON_IGFD_SAVE " Choose a File", filters, |
| 414 |
".", "", 1, nullptr, ImGuiFileDialogFlags_ConfirmOverwrite); |
| 415 |
``` |
| 416 |
|
| 417 |
Example code For Modal Dialog : |
| 418 |
|
| 419 |
```cpp |
| 420 |
ImGuiFileDialog::Instance()->OpenModal("ChooseFileDlgKey", |
| 421 |
ICON_IGFD_SAVE " Choose a File", filters, |
| 422 |
".", "", 1, nullptr, ImGuiFileDialogFlags_ConfirmOverwrite); |
| 423 |
``` |
| 424 |
|
| 425 |
This dialog will only verify the file in the file field, not with `GetSelection()`. |
| 426 |
|
| 427 |
The confirmation dialog will be a non-movable modal (input blocking) dialog displayed in the middle of the current |
| 428 |
ImGuiFileDialog window. |
| 429 |
|
| 430 |
As usual, you can customize the dialog in your custom config file (CustomImGuiFileDialogConfig.h in this example) |
| 431 |
|
| 432 |
Uncomment these line for customization options: |
| 433 |
|
| 434 |
```cpp |
| 435 |
//#define OverWriteDialogTitleString "The file Already Exist !" |
| 436 |
//#define OverWriteDialogMessageString "Would you like to OverWrite it ?" |
| 437 |
//#define OverWriteDialogConfirmButtonString "Confirm" |
| 438 |
//#define OverWriteDialogCancelButtonString "Cancel" |
| 439 |
``` |
| 440 |
|
| 441 |
See the result : |
| 442 |
|
| 443 |
 |
| 444 |
|
| 445 |
## Open / Save dialog Behavior : |
| 446 |
|
| 447 |
ImGuiFileDialog uses the same code internally for Open and Save dialogs. To distinguish between them access the various |
| 448 |
data return functions depending on what the dialog is doing. |
| 449 |
|
| 450 |
When selecting an existing file (for example, a Load or Open dialog), use |
| 451 |
|
| 452 |
```cpp |
| 453 |
std::map<std::string, std::string> GetSelection(); // Returns selection via a map<FileName, FilePathName> |
| 454 |
UserDatas GetUserDatas(); // Get user data provided by the Open dialog |
| 455 |
``` |
| 456 |
|
| 457 |
To selecting a new file (for example, a Save As... dialog), use: |
| 458 |
|
| 459 |
```cpp |
| 460 |
std::string GetFilePathName(); // Returns the content of the selection field with current file extension and current path |
| 461 |
std::string GetCurrentFileName(); // Returns the content of the selection field with current file extension but no path |
| 462 |
std::string GetCurrentPath(); // Returns current path only |
| 463 |
std::string GetCurrentFilter(); // The file extension |
| 464 |
``` |
| 465 |
|
| 466 |
## Thumbnails Display |
| 467 |
|
| 468 |
You can now, display thumbnails of pictures. |
| 469 |
|
| 470 |
 |
| 471 |
|
| 472 |
The file resize use stb/image so the following files extentions are supported : |
| 473 |
* .png (tested sucessfully) |
| 474 |
* .bmp (tested sucessfully) |
| 475 |
* .tga (tested sucessfully) |
| 476 |
* .jpg (tested sucessfully) |
| 477 |
* .jpeg (tested sucessfully) |
| 478 |
* .gif (tested sucessfully_ but not animation just first frame) |
| 479 |
* .psd (not tested) |
| 480 |
* .pic (not tested) |
| 481 |
* .ppm (not tested) |
| 482 |
* .pgm (not tested) |
| 483 |
|
| 484 |
Corresponding to your backend (ex : OpenGl) you need to define two callbacks : |
| 485 |
* the first is a callback who will be called by ImGuiFileDialog for create the backend texture |
| 486 |
* the second is a callback who will be called by ImGuiFileDialog for destroy the backend texture |
| 487 |
|
| 488 |
After that you need to call the function who is responsible to create / destroy the textures. |
| 489 |
this function must be called in your GPU Rendering zone for avoid destroying of used texture. |
| 490 |
if you do that at the same place of your imgui code, some backend can crash your app, by ex with vulkan. |
| 491 |
|
| 492 |
ex, for opengl : |
| 493 |
|
| 494 |
```cpp |
| 495 |
// Create thumbnails texture |
| 496 |
ImGuiFileDialog::Instance()->SetCreateThumbnailCallback([](IGFD_Thumbnail_Info *vThumbnail_Info) -> void |
| 497 |
{ |
| 498 |
if (vThumbnail_Info && |
| 499 |
vThumbnail_Info->isReadyToUpload && |
| 500 |
vThumbnail_Info->textureFileDatas) |
| 501 |
{ |
| 502 |
GLuint textureId = 0; |
| 503 |
glGenTextures(1, &textureId); |
| 504 |
vThumbnail_Info->textureID = (void*)textureId; |
| 505 |
|
| 506 |
glBindTexture(GL_TEXTURE_2D, textureId); |
| 507 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 508 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 509 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 510 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 511 |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, |
| 512 |
(GLsizei)vThumbnail_Info->textureWidth, (GLsizei)vThumbnail_Info->textureHeight, |
| 513 |
0, GL_RGBA, GL_UNSIGNED_BYTE, vThumbnail_Info->textureFileDatas); |
| 514 |
glFinish(); |
| 515 |
glBindTexture(GL_TEXTURE_2D, 0); |
| 516 |
|
| 517 |
delete[] vThumbnail_Info->textureFileDatas; |
| 518 |
vThumbnail_Info->textureFileDatas = nullptr; |
| 519 |
|
| 520 |
vThumbnail_Info->isReadyToUpload = false; |
| 521 |
vThumbnail_Info->isReadyToDisplay = true; |
| 522 |
} |
| 523 |
}); |
| 524 |
``` |
| 525 |
|
| 526 |
```cpp |
| 527 |
// Destroy thumbnails texture |
| 528 |
ImGuiFileDialog::Instance()->SetDestroyThumbnailCallback([](IGFD_Thumbnail_Info* vThumbnail_Info) |
| 529 |
{ |
| 530 |
if (vThumbnail_Info) |
| 531 |
{ |
| 532 |
GLuint texID = (GLuint)vThumbnail_Info->textureID; |
| 533 |
glDeleteTextures(1, &texID); |
| 534 |
glFinish(); |
| 535 |
} |
| 536 |
}); |
| 537 |
``` |
| 538 |
|
| 539 |
```cpp |
| 540 |
// GPU Rendering Zone // To call for Create/ Destroy Textures |
| 541 |
ImGuiFileDialog::Instance()->ManageGPUThumbnails(); |
| 542 |
``` |
| 543 |
|
| 544 |
## How to Integrate ImGuiFileDialog in your project |
| 545 |
|
| 546 |
### Customize ImGuiFileDialog : |
| 547 |
|
| 548 |
You can customize many aspects of ImGuiFileDialog by overriding `ImGuiFileDialogConfig.h`. |
| 549 |
|
| 550 |
To enable your customizations, define the preprocessor directive CUSTOM_IMGUIFILEDIALOG_CONFIG with the path of your |
| 551 |
custom config file. This path must be relative to the directory where you put the ImGuiFileDialog module. |
| 552 |
|
| 553 |
This operation is demonstrated in `CustomImGuiFileDialog.h` in the example project to: |
| 554 |
|
| 555 |
* Have a custom icon font instead of labels for buttons or message titles |
| 556 |
* Customize the button text (the button call signature must be the same, by the way! :) |
| 557 |
|
| 558 |
The custom icon font used in the example code ([CustomFont.cpp](CustomFont.cpp) and [CustomFont.h](CustomFont.h)) was made |
| 559 |
with [ImGuiFontStudio](https://github.com/aiekick/ImGuiFontStudio), which I wrote. :) |
| 560 |
|
| 561 |
ImGuiFontStudio uses ImGuiFileDialog! Check it out. |
| 562 |
|
| 563 |
## Api's C/C++ : |
| 564 |
|
| 565 |
### C++. |
| 566 |
|
| 567 |
this is the base API : |
| 568 |
|
| 569 |
```cpp |
| 570 |
static FileDialog* Instance() // Singleton for easier accces form anywhere but only one dialog at a time |
| 571 |
|
| 572 |
FileDialog(); // ImGuiFileDialog Constructor. can be used for have many dialog at same tiem (not possible with singleton) |
| 573 |
|
| 574 |
// standard dialog |
| 575 |
void OpenDialog( // open simple dialog (path and fileName can be specified) |
| 576 |
const std::string& vKey, // key dialog |
| 577 |
const std::string& vTitle, // title |
| 578 |
const char* vFilters, // filters |
| 579 |
const std::string& vPath, // path |
| 580 |
const std::string& vFileName, // defaut file name |
| 581 |
const int& vCountSelectionMax = 1, // count selection max |
| 582 |
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) |
| 583 |
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags |
| 584 |
|
| 585 |
void OpenDialog( // open simple dialog (path and filename are obtained from filePathName) |
| 586 |
const std::string& vKey, // key dialog |
| 587 |
const std::string& vTitle, // title |
| 588 |
const char* vFilters, // filters |
| 589 |
const std::string& vFilePathName, // file path name (will be decompsoed in path and fileName) |
| 590 |
const int& vCountSelectionMax = 1, // count selection max |
| 591 |
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) |
| 592 |
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags |
| 593 |
|
| 594 |
// with pane |
| 595 |
void OpenDialog( // open dialog with custom right pane (path and fileName can be specified) |
| 596 |
const std::string& vKey, // key dialog |
| 597 |
const std::string& vTitle, // title |
| 598 |
const char* vFilters, // filters |
| 599 |
const std::string& vPath, // path |
| 600 |
const std::string& vFileName, // defaut file name |
| 601 |
const PaneFun& vSidePane, // side pane |
| 602 |
const float& vSidePaneWidth = 250.0f, // side pane width |
| 603 |
const int& vCountSelectionMax = 1, // count selection max |
| 604 |
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) |
| 605 |
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags |
| 606 |
|
| 607 |
void OpenDialog( // open dialog with custom right pane (path and filename are obtained from filePathName) |
| 608 |
const std::string& vKey, // key dialog |
| 609 |
const std::string& vTitle, // title |
| 610 |
const char* vFilters, // filters |
| 611 |
const std::string& vFilePathName, // file path name (will be decompsoed in path and fileName) |
| 612 |
const PaneFun& vSidePane, // side pane |
| 613 |
const float& vSidePaneWidth = 250.0f, // side pane width |
| 614 |
const int& vCountSelectionMax = 1, // count selection max |
| 615 |
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) |
| 616 |
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags |
| 617 |
|
| 618 |
// modal dialog |
| 619 |
void OpenModal( // open simple modal (path and fileName can be specified) |
| 620 |
const std::string& vKey, // key dialog |
| 621 |
const std::string& vTitle, // title |
| 622 |
const char* vFilters, // filters |
| 623 |
const std::string& vPath, // path |
| 624 |
const std::string& vFileName, // defaut file name |
| 625 |
const int& vCountSelectionMax = 1, // count selection max |
| 626 |
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) |
| 627 |
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags |
| 628 |
|
| 629 |
void OpenModal( // open simple modal (path and fielname are obtained from filePathName) |
| 630 |
const std::string& vKey, // key dialog |
| 631 |
const std::string& vTitle, // title |
| 632 |
const char* vFilters, // filters |
| 633 |
const std::string& vFilePathName, // file path name (will be decompsoed in path and fileName) |
| 634 |
const int& vCountSelectionMax = 1, // count selection max |
| 635 |
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) |
| 636 |
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags |
| 637 |
|
| 638 |
// with pane |
| 639 |
void OpenModal( // open modal with custom right pane (path and filename are obtained from filePathName) |
| 640 |
const std::string& vKey, // key dialog |
| 641 |
const std::string& vTitle, // title |
| 642 |
const char* vFilters, // filters |
| 643 |
const std::string& vPath, // path |
| 644 |
const std::string& vFileName, // defaut file name |
| 645 |
const PaneFun& vSidePane, // side pane |
| 646 |
const float& vSidePaneWidth = 250.0f, // side pane width |
| 647 |
const int& vCountSelectionMax = 1, // count selection max |
| 648 |
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) |
| 649 |
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags |
| 650 |
|
| 651 |
void OpenModal( // open modal with custom right pane (path and fielname are obtained from filePathName) |
| 652 |
const std::string& vKey, // key dialog |
| 653 |
const std::string& vTitle, // title |
| 654 |
const char* vFilters, // filters |
| 655 |
const std::string& vFilePathName, // file path name (will be decompsoed in path and fileName) |
| 656 |
const PaneFun& vSidePane, // side pane |
| 657 |
const float& vSidePaneWidth = 250.0f, // side pane width |
| 658 |
const int& vCountSelectionMax = 1, // count selection max |
| 659 |
UserDatas vUserDatas = nullptr, // user datas (can be retrieved in pane) |
| 660 |
ImGuiFileDialogFlags vFlags = 0); // ImGuiFileDialogFlags |
| 661 |
|
| 662 |
// Display / Close dialog form |
| 663 |
bool Display( // Display the dialog. return true if a result was obtained (Ok or not) |
| 664 |
const std::string& vKey, // key dialog to display (if not the same key as defined by OpenDialog/Modal => no opening) |
| 665 |
ImGuiWindowFlags vFlags = ImGuiWindowFlags_NoCollapse, // ImGuiWindowFlags |
| 666 |
ImVec2 vMinSize = ImVec2(0, 0), // mininmal size contraint for the ImGuiWindow |
| 667 |
ImVec2 vMaxSize = ImVec2(FLT_MAX, FLT_MAX)); // maximal size contraint for the ImGuiWindow |
| 668 |
void Close(); // close dialog |
| 669 |
|
| 670 |
// queries |
| 671 |
bool WasOpenedThisFrame(const std::string& vKey); // say if the dialog key was already opened this frame |
| 672 |
bool WasOpenedThisFrame(); // say if the dialog was already opened this frame |
| 673 |
bool IsOpened(const std::string& vKey); // say if the key is opened |
| 674 |
bool IsOpened(); // say if the dialog is opened somewhere |
| 675 |
std::string GetOpenedKey(); // return the dialog key who is opened, return nothing if not opened |
| 676 |
|
| 677 |
// get result |
| 678 |
bool IsOk(); // true => Dialog Closed with Ok result / false : Dialog closed with cancel result |
| 679 |
std::map<std::string, std::string> GetSelection(); // Open File behavior : will return selection via a map<FileName, FilePathName> |
| 680 |
std::string GetFilePathName(); // Save File behavior : will always return the content of the field with current filter extention and current path |
| 681 |
std::string GetCurrentFileName(); // Save File behavior : will always return the content of the field with current filter extention |
| 682 |
std::string GetCurrentPath(); // will return current path |
| 683 |
std::string GetCurrentFilter(); // will return selected filter |
| 684 |
UserDatas GetUserDatas(); // will return user datas send with Open Dialog/Modal |
| 685 |
|
| 686 |
// extentions displaying |
| 687 |
void SetExtentionInfos( // SetExtention datas for have custom display of particular file type |
| 688 |
const std::string& vFilter, // extention filter to tune |
| 689 |
const FileExtentionInfosStruct& vInfos); // Filter Extention Struct who contain Color and Icon/Text for the display of the file with extention filter |
| 690 |
void SetExtentionInfos( // SetExtention datas for have custom display of particular file type |
| 691 |
const std::string& vFilter, // extention filter to tune |
| 692 |
const ImVec4& vColor, // wanted color for the display of the file with extention filter |
| 693 |
const std::string& vIcon = ""); // wanted text or icon of the file with extention filter |
| 694 |
bool GetExtentionInfos( // GetExtention datas. return true is extention exist |
| 695 |
const std::string& vFilter, // extention filter (same as used in SetExtentionInfos) |
| 696 |
ImVec4 *vOutColor, // color to retrieve |
| 697 |
std::string* vOutIcon = 0); // icon or text to retrieve |
| 698 |
void ClearExtentionInfos(); // clear extentions setttings |
| 699 |
|
| 700 |
feature : USE_EXPLORATION_BY_KEYS |
| 701 |
void SetFlashingAttenuationInSeconds( // set the flashing time of the line in file list when use exploration keys |
| 702 |
float vAttenValue); // set the attenuation (from flashed to not flashed) in seconds |
| 703 |
|
| 704 |
feature : USE_BOOKMARK |
| 705 |
std::string SerializeBookmarks(); // serialize bookmarks : return bookmark buffer to save in a file |
| 706 |
void DeserializeBookmarks( // deserialize bookmarks : load bookmar buffer to load in the dialog (saved from previous use with SerializeBookmarks()) |
| 707 |
const std::string& vBookmarks); // bookmark buffer to load |
| 708 |
|
| 709 |
feature : USE_THUMBNAILS |
| 710 |
void SetCreateThumbnailCallback(const CreateThumbnailFun vCreateThumbnailFun); // define the texture creation callback |
| 711 |
void SetDestroyThumbnailCallback(const DestroyThumbnailFun vCreateThumbnailFun); // define the texture destroy callback |
| 712 |
void ManageGPUThumbnails(); // in gpu rendering zone, whill create or destroy textures |
| 713 |
``` |
| 714 |
|
| 715 |
### C Api |
| 716 |
|
| 717 |
this api was sucessfully tested with CImGui |
| 718 |
|
| 719 |
```cpp |
| 720 |
struct IGFD_Selection_Pair |
| 721 |
{ |
| 722 |
char* fileName; |
| 723 |
char* filePathName; |
| 724 |
}; |
| 725 |
|
| 726 |
IMGUIFILEDIALOG_API IGFD_Selection_Pair IGFD_Selection_Pair_Get(); // return an initialized IGFD_Selection_Pair |
| 727 |
IMGUIFILEDIALOG_API void IGFD_Selection_Pair_DestroyContent( |
| 728 |
IGFD_Selection_Pair *vSelection_Pair); // destroy the content of a IGFD_Selection_Pair |
| 729 |
|
| 730 |
struct IGFD_Selection |
| 731 |
{ |
| 732 |
IGFD_Selection_Pair* table; |
| 733 |
size_t count; |
| 734 |
}; |
| 735 |
|
| 736 |
IMGUIFILEDIALOG_API IGFD_Selection IGFD_Selection_Get(); // return an initialized IGFD_Selection |
| 737 |
IMGUIFILEDIALOG_API void IGFD_Selection_DestroyContent( |
| 738 |
IGFD_Selection* vSelection); // destroy the content of a IGFD_Selection |
| 739 |
|
| 740 |
// constructor / destructor |
| 741 |
IMGUIFILEDIALOG_API ImGuiFileDialog* IGFD_Create(void); // create the filedialog context |
| 742 |
IMGUIFILEDIALOG_API void IGFD_Destroy(ImGuiFileDialog *vContext); // destroy the filedialog context |
| 743 |
|
| 744 |
typedef void (*IGFD_PaneFun)(const char*, void*, bool*); // callback fucntion for display the pane |
| 745 |
|
| 746 |
IMGUIFILEDIALOG_API void IGFD_OpenDialog( // open a standard dialog |
| 747 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 748 |
const char* vKey, // key dialog |
| 749 |
const char* vTitle, // title |
| 750 |
const char* vFilters, // filters/filter collections. set it to null for directory mode |
| 751 |
const char* vPath, // path |
| 752 |
const char* vFileName, // defaut file name |
| 753 |
const int vCountSelectionMax, // count selection max |
| 754 |
void* vUserDatas, // user datas (can be retrieved in pane) |
| 755 |
ImGuiFileDialogFlags vFlags); // ImGuiFileDialogFlags |
| 756 |
|
| 757 |
IMGUIFILEDIALOG_API void IGFD_OpenDialog2( // open a standard dialog |
| 758 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 759 |
const char* vKey, // key dialog |
| 760 |
const char* vTitle, // title |
| 761 |
const char* vFilters, // filters/filter collections. set it to null for directory mode |
| 762 |
const char* vFilePathName, // defaut file path name (path and filename witl be extracted from it) |
| 763 |
const int vCountSelectionMax, // count selection max |
| 764 |
void* vUserDatas, // user datas (can be retrieved in pane) |
| 765 |
ImGuiFileDialogFlags vFlags); // ImGuiFileDialogFlags |
| 766 |
|
| 767 |
IMGUIFILEDIALOG_API void IGFD_OpenPaneDialog( // open a standard dialog with pane |
| 768 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 769 |
const char* vKey, // key dialog |
| 770 |
const char* vTitle, // title |
| 771 |
const char* vFilters, // filters/filter collections. set it to null for directory mode |
| 772 |
const char* vPath, // path |
| 773 |
const char* vFileName, // defaut file name |
| 774 |
const IGFD_PaneFun vSidePane, // side pane |
| 775 |
const float vSidePaneWidth, // side pane base width |
| 776 |
const int vCountSelectionMax, // count selection max |
| 777 |
void* vUserDatas, // user datas (can be retrieved in pane) |
| 778 |
ImGuiFileDialogFlags vFlags); // ImGuiFileDialogFlags |
| 779 |
|
| 780 |
IMGUIFILEDIALOG_API void IGFD_OpenPaneDialog2( // open a standard dialog with pane |
| 781 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 782 |
const char* vKey, // key dialog |
| 783 |
const char* vTitle, // title |
| 784 |
const char* vFilters, // filters/filter collections. set it to null for directory mode |
| 785 |
const char* vFilePathName, // defaut file name (path and filename witl be extracted from it) |
| 786 |
const IGFD_PaneFun vSidePane, // side pane |
| 787 |
const float vSidePaneWidth, // side pane base width |
| 788 |
const int vCountSelectionMax, // count selection max |
| 789 |
void* vUserDatas, // user datas (can be retrieved in pane) |
| 790 |
ImGuiFileDialogFlags vFlags); // ImGuiFileDialogFlags |
| 791 |
|
| 792 |
IMGUIFILEDIALOG_API void IGFD_OpenModal( // open a modal dialog |
| 793 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 794 |
const char* vKey, // key dialog |
| 795 |
const char* vTitle, // title |
| 796 |
const char* vFilters, // filters/filter collections. set it to null for directory mode |
| 797 |
const char* vPath, // path |
| 798 |
const char* vFileName, // defaut file name |
| 799 |
const int vCountSelectionMax, // count selection max |
| 800 |
void* vUserDatas, // user datas (can be retrieved in pane) |
| 801 |
ImGuiFileDialogFlags vFlags); // ImGuiFileDialogFlags |
| 802 |
|
| 803 |
IMGUIFILEDIALOG_API void IGFD_OpenModal2( // open a modal dialog |
| 804 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 805 |
const char* vKey, // key dialog |
| 806 |
const char* vTitle, // title |
| 807 |
const char* vFilters, // filters/filter collections. set it to null for directory mode |
| 808 |
const char* vFilePathName, // defaut file name (path and filename witl be extracted from it) |
| 809 |
const int vCountSelectionMax, // count selection max |
| 810 |
void* vUserDatas, // user datas (can be retrieved in pane) |
| 811 |
ImGuiFileDialogFlags vFlags); // ImGuiFileDialogFlags |
| 812 |
|
| 813 |
IMGUIFILEDIALOG_API void IGFD_OpenPaneModal( // open a modal dialog with pane |
| 814 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 815 |
const char* vKey, // key dialog |
| 816 |
const char* vTitle, // title |
| 817 |
const char* vFilters, // filters/filter collections. set it to null for directory mode |
| 818 |
const char* vPath, // path |
| 819 |
const char* vFileName, // defaut file name |
| 820 |
const IGFD_PaneFun vSidePane, // side pane |
| 821 |
const float vSidePaneWidth, // side pane base width |
| 822 |
const int vCountSelectionMax, // count selection max |
| 823 |
void* vUserDatas, // user datas (can be retrieved in pane) |
| 824 |
ImGuiFileDialogFlags vFlags); // ImGuiFileDialogFlags |
| 825 |
|
| 826 |
IMGUIFILEDIALOG_API void IGFD_OpenPaneModal2( // open a modal dialog with pane |
| 827 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 828 |
const char* vKey, // key dialog |
| 829 |
const char* vTitle, // title |
| 830 |
const char* vFilters, // filters/filter collections. set it to null for directory mode |
| 831 |
const char* vFilePathName, // defaut file name (path and filename witl be extracted from it) |
| 832 |
const IGFD_PaneFun vSidePane, // side pane |
| 833 |
const float vSidePaneWidth, // side pane base width |
| 834 |
const int vCountSelectionMax, // count selection max |
| 835 |
void* vUserDatas, // user datas (can be retrieved in pane) |
| 836 |
ImGuiFileDialogFlags vFlags); // ImGuiFileDialogFlags |
| 837 |
|
| 838 |
IMGUIFILEDIALOG_API bool IGFD_DisplayDialog( // Display the dialog |
| 839 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 840 |
const char* vKey, // key dialog to display (if not the same key as defined by OpenDialog/Modal => no opening) |
| 841 |
ImGuiWindowFlags vFlags, // ImGuiWindowFlags |
| 842 |
ImVec2 vMinSize, // mininmal size contraint for the ImGuiWindow |
| 843 |
ImVec2 vMaxSize); // maximal size contraint for the ImGuiWindow |
| 844 |
|
| 845 |
IMGUIFILEDIALOG_API void IGFD_CloseDialog( // Close the dialog |
| 846 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 847 |
|
| 848 |
IMGUIFILEDIALOG_API bool IGFD_IsOk( // true => Dialog Closed with Ok result / false : Dialog closed with cancel result |
| 849 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 850 |
|
| 851 |
IMGUIFILEDIALOG_API bool IGFD_WasKeyOpenedThisFrame( // say if the dialog key was already opened this frame |
| 852 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 853 |
const char* vKey); |
| 854 |
|
| 855 |
IMGUIFILEDIALOG_API bool IGFD_WasOpenedThisFrame( // say if the dialog was already opened this frame |
| 856 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 857 |
|
| 858 |
IMGUIFILEDIALOG_API bool IGFD_IsKeyOpened( // say if the dialog key is opened |
| 859 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 860 |
const char* vCurrentOpenedKey); // the dialog key |
| 861 |
|
| 862 |
IMGUIFILEDIALOG_API bool IGFD_IsOpened( // say if the dialog is opened somewhere |
| 863 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 864 |
|
| 865 |
IMGUIFILEDIALOG_API IGFD_Selection IGFD_GetSelection( // Open File behavior : will return selection via a map<FileName, FilePathName> |
| 866 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 867 |
|
| 868 |
IMGUIFILEDIALOG_API char* IGFD_GetFilePathName( // Save File behavior : will always return the content of the field with current filter extention and current path |
| 869 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 870 |
|
| 871 |
IMGUIFILEDIALOG_API char* IGFD_GetCurrentFileName( // Save File behavior : will always return the content of the field with current filter extention |
| 872 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 873 |
|
| 874 |
IMGUIFILEDIALOG_API char* IGFD_GetCurrentPath( // will return current path |
| 875 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 876 |
|
| 877 |
IMGUIFILEDIALOG_API char* IGFD_GetCurrentFilter( // will return selected filter |
| 878 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 879 |
|
| 880 |
IMGUIFILEDIALOG_API void* IGFD_GetUserDatas( // will return user datas send with Open Dialog/Modal |
| 881 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 882 |
|
| 883 |
IMGUIFILEDIALOG_API void IGFD_SetExtentionInfos( // SetExtention datas for have custom display of particular file type |
| 884 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 885 |
const char* vFilter, // extention filter to tune |
| 886 |
ImVec4 vColor, // wanted color for the display of the file with extention filter |
| 887 |
const char* vIconText); // wanted text or icon of the file with extention filter (can be sued with font icon) |
| 888 |
|
| 889 |
IMGUIFILEDIALOG_API void IGFD_SetExtentionInfos2( // SetExtention datas for have custom display of particular file type |
| 890 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 891 |
const char* vFilter, // extention filter to tune |
| 892 |
float vR, float vG, float vB, float vA, // wanted color channels RGBA for the display of the file with extention filter |
| 893 |
const char* vIconText); // wanted text or icon of the file with extention filter (can be sued with font icon) |
| 894 |
|
| 895 |
IMGUIFILEDIALOG_API bool IGFD_GetExtentionInfos( |
| 896 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 897 |
const char* vFilter, // extention filter (same as used in SetExtentionInfos) |
| 898 |
ImVec4* vOutColor, // color to retrieve |
| 899 |
char** vOutIconText); // icon or text to retrieve |
| 900 |
|
| 901 |
IMGUIFILEDIALOG_API void IGFD_ClearExtentionInfos( // clear extentions setttings |
| 902 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 903 |
|
| 904 |
feature : USE_EXPLORATION_BY_KEYS |
| 905 |
IMGUIFILEDIALOG_API void IGFD_SetFlashingAttenuationInSeconds( // set the flashing time of the line in file list when use exploration keys |
| 906 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 907 |
float vAttenValue); // set the attenuation (from flashed to not flashed) in seconds |
| 908 |
|
| 909 |
feature : USE_BOOKMARK |
| 910 |
IMGUIFILEDIALOG_API char* IGFD_SerializeBookmarks( // serialize bookmarks : return bookmark buffer to save in a file |
| 911 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 912 |
|
| 913 |
IMGUIFILEDIALOG_API void IGFD_DeserializeBookmarks( // deserialize bookmarks : load bookmar buffer to load in the dialog (saved from previous use with SerializeBookmarks()) |
| 914 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 915 |
const char* vBookmarks); // bookmark buffer to load |
| 916 |
|
| 917 |
feature : USE_THUMBNAILS |
| 918 |
IMGUIFILEDIALOG_API void SetCreateThumbnailCallback( // define the callback for create the thumbnails texture |
| 919 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 920 |
const IGFD_CreateThumbnailFun vCreateThumbnailFun); // the callback for create the thumbnails texture |
| 921 |
|
| 922 |
IMGUIFILEDIALOG_API void SetDestroyThumbnailCallback( // define the callback for destroy the thumbnails texture |
| 923 |
ImGuiFileDialog* vContext, // ImGuiFileDialog context |
| 924 |
const IGFD_DestroyThumbnailFun vDestroyThumbnailFun); // the callback for destroy the thumbnails texture |
| 925 |
|
| 926 |
IMGUIFILEDIALOG_API void ManageGPUThumbnails( // must be call in gpu zone, possibly a thread, will call the callback for create / destroy the textures |
| 927 |
ImGuiFileDialog* vContext); // ImGuiFileDialog context |
| 928 |
``` |