-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
540c282
commit aa5c6aa
Showing
13 changed files
with
21,039 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
#pragma once | ||
|
||
// uncomment and modify defines under for customize ImGuiFileDialog | ||
|
||
// uncomment if you need to use your FileSystem Interface | ||
// if commented, you have two defualt interface, std::filesystem or dirent | ||
// #define USE_CUSTOM_FILESYSTEM | ||
|
||
// this options need c++17 | ||
// #define USE_STD_FILESYSTEM | ||
|
||
// #define MAX_FILE_DIALOG_NAME_BUFFER 1024 | ||
// #define MAX_PATH_BUFFER_SIZE 1024 | ||
|
||
// the slash's buttons in path cna be used for quick select parallles directories | ||
// #define USE_QUICK_PATH_SELECT | ||
|
||
// the spacing between button path's can be customized. | ||
// if disabled the spacing is defined by the imgui theme | ||
// define the space between path buttons | ||
// #define CUSTOM_PATH_SPACING 2 | ||
|
||
// #define USE_THUMBNAILS | ||
// the thumbnail generation use the stb_image and stb_resize lib who need to define the implementation | ||
// btw if you already use them in your app, you can have compiler error due to "implemntation found in double" | ||
// so uncomment these line for prevent the creation of implementation of these libs again | ||
// #define DONT_DEFINE_AGAIN__STB_IMAGE_IMPLEMENTATION | ||
// #define DONT_DEFINE_AGAIN__STB_IMAGE_RESIZE_IMPLEMENTATION | ||
// #define IMGUI_RADIO_BUTTON RadioButton | ||
// #define DisplayMode_ThumbailsList_ImageHeight 32.0f | ||
// #define tableHeaderFileThumbnailsString "Thumbnails" | ||
// #define DisplayMode_FilesList_ButtonString "FL" | ||
// #define DisplayMode_FilesList_ButtonHelp "File List" | ||
// #define DisplayMode_ThumbailsList_ButtonString "TL" | ||
// #define DisplayMode_ThumbailsList_ButtonHelp "Thumbnails List" | ||
// todo | ||
// #define DisplayMode_ThumbailsGrid_ButtonString "TG" | ||
// #define DisplayMode_ThumbailsGrid_ButtonHelp "Thumbnails Grid" | ||
|
||
// #define USE_EXPLORATION_BY_KEYS | ||
// this mapping by default is for GLFW but you can use another | ||
// #include <GLFW/glfw3.h> | ||
// Up key for explore to the top | ||
// #define IGFD_KEY_UP ImGuiKey_UpArrow | ||
// Down key for explore to the bottom | ||
// #define IGFD_KEY_DOWN ImGuiKey_DownArrow | ||
// Enter key for open directory | ||
// #define IGFD_KEY_ENTER ImGuiKey_Enter | ||
// BackSpace for comming back to the last directory | ||
// #define IGFD_KEY_BACKSPACE ImGuiKey_Backspace | ||
|
||
// by ex you can quit the dialog by pressing the key excape | ||
// #define USE_DIALOG_EXIT_WITH_KEY | ||
// #define IGFD_EXIT_KEY ImGuiKey_Escape | ||
|
||
// widget | ||
// begin combo widget | ||
// #define IMGUI_BEGIN_COMBO ImGui::BeginCombo | ||
// when auto resized, FILTER_COMBO_MIN_WIDTH will be considered has minimum width | ||
// FILTER_COMBO_AUTO_SIZE is enabled by default now to 1 | ||
// uncomment if you want disable | ||
// #define FILTER_COMBO_AUTO_SIZE 0 | ||
// filter combobox width | ||
// #define FILTER_COMBO_MIN_WIDTH 120.0f | ||
// button widget use for compose path | ||
// #define IMGUI_PATH_BUTTON ImGui::Button | ||
// standard button | ||
// #define IMGUI_BUTTON ImGui::Button | ||
|
||
// locales string | ||
// #define createDirButtonString "+" | ||
// #define resetButtonString "R" | ||
// #define drivesButtonString "Drives" | ||
// #define editPathButtonString "E" | ||
// #define searchString "Search" | ||
// #define dirEntryString "[DIR] " | ||
// #define linkEntryString "[LINK] " | ||
// #define fileEntryString "[FILE] " | ||
// #define fileNameString "File Name : " | ||
// #define dirNameString "Directory Path :" | ||
// #define buttonResetSearchString "Reset search" | ||
// #define buttonDriveString "Drives" | ||
// #define buttonEditPathString "Edit path\nYou can also right click on path buttons" | ||
// #define buttonResetPathString "Reset to current directory" | ||
// #define buttonCreateDirString "Create Directory" | ||
// #define OverWriteDialogTitleString "The file Already Exist !" | ||
// #define OverWriteDialogMessageString "Would you like to OverWrite it ?" | ||
// #define OverWriteDialogConfirmButtonString "Confirm" | ||
// #define OverWriteDialogCancelButtonString "Cancel" | ||
|
||
// Validation buttons | ||
// #define okButtonString " OK" | ||
// #define okButtonWidth 0.0f | ||
// #define cancelButtonString " Cancel" | ||
// #define cancelButtonWidth 0.0f | ||
// alignement [0:1], 0.0 is left, 0.5 middle, 1.0 right, and other ratios | ||
// #define okCancelButtonAlignement 0.0f | ||
// #define invertOkAndCancelButtons 0 | ||
|
||
// DateTimeFormat | ||
// see strftime functionin <ctime> for customize | ||
// "%Y/%m/%d %H:%M" give 2021:01:22 11:47 | ||
// "%Y/%m/%d %i:%M%p" give 2021:01:22 11:45PM | ||
// #define DateTimeFormat "%Y/%m/%d %i:%M%p" | ||
|
||
// theses icons will appear in table headers | ||
// #define USE_CUSTOM_SORTING_ICON | ||
// #define tableHeaderAscendingIcon "A|" | ||
// #define tableHeaderDescendingIcon "D|" | ||
// #define tableHeaderFileNameString " File name" | ||
// #define tableHeaderFileTypeString " Type" | ||
// #define tableHeaderFileSizeString " Size" | ||
// #define tableHeaderFileDateTimeString " Date" | ||
// #define fileSizeBytes "o" | ||
// #define fileSizeKiloBytes "Ko" | ||
// #define fileSizeMegaBytes "Mo" | ||
// #define fileSizeGigaBytes "Go" | ||
|
||
// default table sort field (must be FIELD_FILENAME, FIELD_TYPE, FIELD_SIZE, FIELD_DATE or FIELD_THUMBNAILS) | ||
// #define defaultSortField FIELD_FILENAME | ||
|
||
// default table sort order for each field (true => Descending, false => Ascending) | ||
// #define defaultSortOrderFilename true | ||
// #define defaultSortOrderType true | ||
// #define defaultSortOrderSize true | ||
// #define defaultSortOrderDate true | ||
// #define defaultSortOrderThumbnails true | ||
|
||
// #define USE_PLACES_FEATURE | ||
// #define PLACES_PANE_DEFAULT_SHOWN false | ||
// #define placesPaneWith 150.0f | ||
// #define IMGUI_TOGGLE_BUTTON ToggleButton | ||
// #define placesButtonString "Place" | ||
// #define placesButtonHelpString "Places" | ||
// #define addPlaceButtonString "+" | ||
// #define removePlaceButtonString "-" | ||
// #define validatePlaceButtonString "ok" | ||
// #define editPlaceButtonString "E" | ||
|
||
// a group for bookmarks will be added by default, but you can also create it yourself and many more | ||
// #define USE_PLACES_BOOKMARKS | ||
// #define PLACES_BOOKMARK_DEFAULT_OPEPEND true | ||
// #define placesBookmarksGroupName "Bookmarks" | ||
// #define placesBookmarksDisplayOrder 0 // to the first | ||
|
||
// a group for system devices (returned by IFileSystem), but you can also add yours | ||
// by ex if you would like to display a specific icon for some devices | ||
// #define USE_PLACES_DEVICES | ||
// #define PLACES_DEVICES_DEFAULT_OPEPEND true | ||
// #define placesDevicesGroupName "Devices" | ||
// #define placesDevicesDisplayOrder 10 // to the end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018-2024 Stephane Cuillerdier (aka Aiekick) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
# ImGuiFileDialog | ||
|
||
## Build Matrix | ||
|
||
| | Win | Linux | MacOs | | ||
| :---: | :---: | :---: | :---: | | ||
| Msvc | [![Win Msvc](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Win_Msvc.yml/badge.svg)](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Win_Msvc.yml) | | | | ||
| Gcc | | [![Linux Gcc](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Linux_Gcc.yml/badge.svg)](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Linux_Gcc.yml) | [![Osx Gcc](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Osx_Gcc.yml/badge.svg)](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Osx_Gcc.yml) | | ||
| Clang | | [![Linux Clang](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Linux_Clang.yml/badge.svg)](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Linux_Clang.yml) | [![Osx Clang](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Osx_Clang.yml/badge.svg)](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Osx_Clang.yml) | | ||
| Leak Sanitizer | | [![Leak Sanitizer](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Leak.yml/badge.svg)](https://github.com/aiekick/ImGuiFileDialog/actions/workflows/Leak.yml) | | | ||
|
||
## Purpose | ||
|
||
ImGuiFileDialog is a file selection dialog built for (and using only) [Dear ImGui](https://github.com/ocornut/imgui). | ||
|
||
My primary goal was to have a custom pane with widgets according to file extension. This was not possible using other | ||
solutions. | ||
|
||
## Possible Dialog Customization | ||
|
||
![alt text](https://github.com/aiekick/ImGuiFileDialog/blob/DemoApp/doc/demo_dialog.png) | ||
|
||
## ImGui Supported Version | ||
|
||
> [!NOTE] | ||
> ImGuiFileDialog follow the master and docking branch of ImGui. | ||
> Currently : [![Wrapped Dear ImGui Version](https://img.shields.io/badge/Dear%20ImGui%20Version-1.90.4-blue.svg)](https://github.com/ocornut/imgui) | ||
## Structure | ||
|
||
* The library is in [Master branch](https://github.com/aiekick/ImGuiFileDialog/tree/master) | ||
* A demo app can be found in the [DemoApp branch](https://github.com/aiekick/ImGuiFileDialog/tree/DemoApp) | ||
|
||
This library is designed to be dropped into your source code rather than compiled separately. | ||
|
||
From your project directory: | ||
|
||
``` | ||
mkdir lib <or 3rdparty, or externals, etc.> | ||
cd lib | ||
git clone https://github.com/aiekick/ImGuiFileDialog.git | ||
git checkout master | ||
``` | ||
|
||
These commands create a `lib` directory where you can store any third-party dependencies used in your project, downloads | ||
the ImGuiFileDialog git repository and checks out the Lib_Only branch where the actual library code is located. | ||
|
||
Add `lib/ImGuiFileDialog/ImGuiFileDialog.cpp` to your build system and include | ||
`lib/ImGuiFileDialog/ImGuiFileDialog.h` in your source code. ImGuiFileLib will compile with and be included directly in | ||
your executable file. | ||
|
||
If, for example, your project uses cmake, look for a line like `add_executable(my_project_name main.cpp)` | ||
and change it to `add_executable(my_project_name lib/ImGuiFileDialog/ImGuiFileDialog.cpp main.cpp)`. This tells the | ||
compiler where to find the source code declared in `ImGuiFileDialog.h` which you included in your own source code. | ||
|
||
## Requirements: | ||
|
||
You must also, of course, have added [Dear ImGui](https://github.com/ocornut/imgui) to your project for this to work at | ||
all. | ||
|
||
[dirent v1.23](https://github.com/tronkko/dirent/tree/v1.23) is required to use ImGuiFileDialog under Windows. It is | ||
included in the Lib_Only branch for your convenience. | ||
|
||
Android Requirements : Api 21 mini | ||
|
||
## Features | ||
|
||
- C Api (succesfully tested with CimGui) | ||
- Separate system for call and display | ||
- Can have many function calls with different parameters for one display function, for example | ||
- Can create a custom pane with any widgets via function binding | ||
- This pane can block the validation of the dialog | ||
- Can also display different things according to current filter and UserDatas | ||
- Advanced file style for file/dir/link coloring / icons / font | ||
- predefined form or user custom form by lambda function (the lambda mode is not available for the C API) | ||
- Multi-selection (ctrl/shift + click) : | ||
- 0 => Infinite | ||
- 1 => One file (default) | ||
- n => n files | ||
- Compatible with MacOs, Linux, Windows, Emscripten, Android | ||
- Supports modal or standard dialog types | ||
- Select files or directories | ||
- Filter groups and custom filter names | ||
- can ignore filter Case for file searching | ||
- Keyboard navigation (arrows, backspace, enter) | ||
- Exploring by entering characters (case insensitive) | ||
- Custom places (bookmarks, system devices, whatever you want) | ||
- Directory manual entry (right click on any path element) | ||
- Optional 'Confirm to Overwrite" dialog if file exists | ||
- Thumbnails Display (agnostic way for compatibility with any backend, sucessfully tested with OpenGl and Vulkan) | ||
- The dialog can be embedded in another user frame than the standard or modal dialog | ||
- Can tune validation buttons (placements, widths, inversion) | ||
- Can quick select a parrallel directory of a path, in the path composer (when you clikc on a / you have a popup) | ||
- regex support for filters, collection of filters and filestyle (the regex is recognized when between (( and )) in a filter) | ||
- multi layer extentions like : .a.b.c .json.cpp .vcxproj.filters etc.. | ||
- advanced behavior regarding asterisk based filter. like : .* .*.* .vcx.* .*.filters .vcs*.filt.* etc.. (internally regex is used) | ||
- result modes GetFilePathName, GetFileName and GetSelection (overwrite file ext, keep file, add ext if no user ext exist) | ||
- you can use your own FileSystem Api | ||
- by default Api Dirent and std::filesystem are defined | ||
- you can override GetDrieveList for specify by ex on android other fs, like local and SDCards | ||
|
||
### WARNINGS : | ||
- the nav system keyboard behavior is not working as expected, so maybe full of bug for ImGuiFileDialog | ||
|
||
### Simple Usage : | ||
|
||
```cpp | ||
void drawGui() { | ||
// open Dialog Simple | ||
if (ImGui::Button("Open File Dialog")) { | ||
IGFD::FileDialogConfig config; | ||
config.path = "."; | ||
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".cpp,.h,.hpp", config); | ||
} | ||
// display | ||
if (ImGuiFileDialog::Instance()->Display("ChooseFileDlgKey")) { | ||
if (ImGuiFileDialog::Instance()->IsOk()) { // action if OK | ||
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName(); | ||
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath(); | ||
// action | ||
} | ||
|
||
// close | ||
ImGuiFileDialog::Instance()->Close(); | ||
} | ||
} | ||
``` | ||
|
||
![alt text](https://github.com/aiekick/ImGuiFileDialog/blob/DemoApp/doc/dlg_simple.gif) | ||
|
||
### Documentation : | ||
|
||
for a complete explantion and howto about ImGuiFileDialog Api, | ||
you can check the Documentation [HERE](https://github.com/aiekick/ImGuiFileDialog/blob/master/Documentation.md) | ||
|
||
### How to build the sample app | ||
|
||
The sample app is [here in master branch]((https://github.com/aiekick/ImGuiFileDialog/tree/master) | ||
|
||
You need to use cMake. For the 3 Os (Win, Linux, MacOs), the cMake usage is exactly the same, | ||
|
||
Choose a build directory. (called here my_build_directory for instance) and | ||
Choose a Build Mode : "Release" / "MinSizeRel" / "RelWithDebInfo" / "Debug" (called here BuildMode for instance) | ||
Run cMake in console : (the first for generate cmake build files, the second for build the binary) | ||
|
||
cmake -B my_build_directory -DCMAKE_BUILD_TYPE=BuildMode | ||
cmake --build my_build_directory --config BuildMode | ||
|
||
Some cMake version need Build mode define via the directive CMAKE_BUILD_TYPE or via --Config when we launch the build. This is why i put the boths possibilities | ||
|
||
By the way you need before, to make sure, you have needed dependencies. | ||
|
||
### On Windows : | ||
|
||
You need to have the opengl library installed | ||
|
||
### On Linux : | ||
|
||
You need many lib : (X11, xrandr, xinerama, xcursor, mesa) | ||
|
||
If you are on debian you can run : | ||
|
||
sudo apt-get update | ||
sudo apt-get install libgl1-mesa-dev libx11-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev | ||
|
||
### On MacOs : | ||
|
||
you need many lib : opengl and cocoa framework | ||
|
||
</blockquote></details> | ||
|
||
## Thats all folks :-) | ||
|
||
You can check by example in this repo with the file CustomImGuiFileDialogConfig.h : | ||
- this trick was used for have custom icon font instead of labels for buttons or messages titles | ||
- you can also use your custom imgui button, the button call stamp must be same by the way :) | ||
|
||
The Custom Icon Font (in CustomFont.cpp and CustomFont.h) was made with ImGuiFontStudio (https://github.com/aiekick/ImGuiFontStudio) i wrote for that :) | ||
ImGuiFontStudio is using also ImGuiFileDialog.$ | ||
|
||
![Alt](https://repobeats.axiom.co/api/embed/22a6eef207d0bce7c03519d94f55100973b451ca.svg "Repobeats analytics image") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 1998-2019 Toni Ronkko | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.