Skip to content

Commit 8356f11

Browse files
committed
[UPD] : update ReadMe
1 parent 86ef275 commit 8356f11

1 file changed

Lines changed: 93 additions & 32 deletions

File tree

README.md

Lines changed: 93 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[<img src="https://github.com/aiekick/ImGuiFileDialog/workflows/Win/badge.svg"/>](https://github.com/aiekick/ImGuiFileDialog/actions?query=workflow%3AWin)
22
[<img src="https://github.com/aiekick/ImGuiFileDialog/workflows/Linux/badge.svg"/>](https://github.com/aiekick/ImGuiFileDialog/actions?query=workflow%3ALinux)
33
[<img src="https://github.com/aiekick/ImGuiFileDialog/workflows/Osx/badge.svg"/>](https://github.com/aiekick/ImGuiFileDialog/actions?query=workflow%3AOsx)
4-
[![Wrapped Dear ImGui Version](https://img.shields.io/badge/Dear%20ImGui%20Version-1.88-blue.svg)](https://github.com/ocornut/imgui)
4+
[![Wrapped Dear ImGui Version](https://img.shields.io/badge/Dear%20ImGui%20Version-1.89.5-blue.svg)](https://github.com/ocornut/imgui)
55

66
# ImGuiFileDialog
77

@@ -14,7 +14,7 @@ solutions.
1414

1515
## ImGui Supported Version
1616

17-
ImGuiFileDialog follow the master and docking branch of ImGui . currently ImGui 1.88
17+
ImGuiFileDialog follow the master and docking branch of ImGui . currently ImGui 1.89.5
1818

1919
## Structure
2020

@@ -55,18 +55,20 @@ Android Requirements : Api 21 mini
5555

5656
## Features
5757

58+
- C Api (succesfully tested with CimGui)
5859
- Separate system for call and display
59-
- Can have many function calls with different parameters for one display function, for example
60+
- Can have many function calls with different parameters for one display function, for example
6061
- Can create a custom pane with any widgets via function binding
61-
- This pane can block the validation of the dialog
62-
- Can also display different things according to current filter and UserDatas
62+
- This pane can block the validation of the dialog
63+
- Can also display different things according to current filter and UserDatas
6364
- Advanced file style for file/dir/link coloring / icons / font
65+
- predefined form or user custom form by lambda function (the lambda mode is not available for the C API)
6466
- Multi-selection (ctrl/shift + click) :
65-
- 0 => Infinite
66-
- 1 => One file (default)
67-
- n => n files
67+
- 0 => Infinite
68+
- 1 => One file (default)
69+
- n => n files
6870
- Compatible with MacOs, Linux, Windows
69-
- Windows version can list drives
71+
- Windows version can list drives
7072
- Supports modal or standard dialog types
7173
- Select files or directories
7274
- Filter groups and custom filter names
@@ -76,18 +78,30 @@ Android Requirements : Api 21 mini
7678
- Directory bookmarks
7779
- Directory manual entry (right click on any path element)
7880
- Optional 'Confirm to Overwrite" dialog if file exists
79-
- C Api (succesfully tested with CimGui)
8081
- Thumbnails Display (agnostic way for compatibility with any backend, sucessfully tested with OpenGl and Vulkan)
8182
- The dialog can be embedded in another user frame than the standard or modal dialog
82-
- Can tune validation buttons (placements, widths, inversion)
83+
- Can tune validation buttons (placements, widths, inversion)
8384
- Can quick select a parrallel directory of a path, in the path composer (when you clikc on a / you have a popup)
84-
- regex support for filters, collection of fitler and filestyle (the regex is recognized when between ( and ) in a filter
85+
- regex support for filters, collection of filters and filestyle (the regex is recognized when between (( and )) in a filter)
8586

8687
### WARNINGS :
8788
- the nav system keyboard behavior is not working as expected, so maybe full of bug for ImGuiFileDialog
8889

8990
<details open><summary><h2>Singleton Pattern vs. Multiple Instances :</h2></summary><blockquote>
9091

92+
### Filter format
93+
94+
A filter is recognized only if it respects theses rules :
95+
96+
0) a filter must have 2 chars mini and the first must be a .
97+
1) a regex must be in (( and ))
98+
2) a , will separate filters except if between a ( and )
99+
3) name{filter1, filter2} is a special form for collection filters
100+
3.1) the name can be composed of what you want except { and }
101+
3.2) a filter can be a regex
102+
4) the filters cannot integrate these chars '(' ')' '{' '}' ' ' except for a regex with respect to rule 1)
103+
5) the filters cannot integrate a ','
104+
91105
### Single Dialog :
92106

93107
If you only need to display one file dialog at a time, use ImGuiFileDialog's singleton pattern to avoid explicitly
@@ -245,9 +259,13 @@ the style can be colors, icons and fonts
245259
the general form is :
246260
```cpp
247261
ImGuiFileDialog::Instance()->SetFileStyle(styleType, criteria, color, icon, font);
262+
```
263+
264+
### Predefined Form :
248265

249266
styleType can be thoses :
250267

268+
```cpp
251269
IGFD_FileStyleByTypeFile // define style for all files
252270
IGFD_FileStyleByTypeDir // define style for all dir
253271
IGFD_FileStyleByTypeLink // define style for all link
@@ -256,20 +274,45 @@ IGFD_FileStyleByFullName // define style for particular file/dir/link full na
256274
IGFD_FileStyleByContainedInFullName // define style for file/dir/link when criteria is contained in full name
257275
```
258276

277+
### Lambda Function Form :
278+
279+
You can define easily your own style include your own detection by using lambda function :
280+
281+
** To note, this mode is not available with the C API **
282+
283+
this lamba will treat a file and return a shared pointer of your files style
284+
285+
see in action a styling of all files and dir starting by a dot
286+
287+
this lambda input a FileInfos and output a FileStyle
288+
return true if a FileStyle was defined
289+
290+
```cpp
291+
ImGuiFileDialog::Instance()->SetFileStyle([](const IGFD::FileInfos& vFile, IGFD::FileStyle &vOutStyle) -> bool {
292+
if (!vFile.fileNameExt.empty() && vFile.fileNameExt[0] == '.') {
293+
vOutStyle = IGFD::FileStyle(ImVec4(0.0f, 0.9f, 0.9f, 1.0f), ICON_IGFD_REMOVE);
294+
return true;
295+
}
296+
return false;
297+
});
298+
```
299+
300+
see sample app for the code in action
301+
302+
### Samples :
303+
259304
ImGuiFileDialog accepts icon font macros as well as text tags for file types.
260305
261-
[ImGuIFontStudio](https://github.com/aiekick/ImGuiFontStudio) is useful here. I wrote it to make it easy to create
262-
custom icon sets for use with Dear ImGui.
306+
[ImGuIFontStudio](https://github.com/aiekick/ImGuiFontStudio) is useful here. I wrote it to make it easy to create
307+
custom icon sets for use with Dear ImGui.
263308
264-
It is inspired by [IconFontCppHeaders](https://github.com/juliettef/IconFontCppHeaders), which can also be used with
309+
It is inspired by [IconFontCppHeaders](https://github.com/juliettef/IconFontCppHeaders), which can also be used with
265310
ImGuiFileDialog.
266311
267-
you can also use a regex for the filtering. the regex must be betwwen the ( and ) for be recognized as a regex
268-
269312
samples :
270313
271314
```cpp
272-
// define style by file extention and Add an icon for .png files
315+
// define style by file extention and Add an icon for .png files
273316
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".png", ImVec4(0.0f, 1.0f, 1.0f, 0.9f), ICON_IGFD_FILE_PIC, font1);
274317
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".gif", ImVec4(0.0f, 1.0f, 0.5f, 0.9f), "[GIF]");
275318
@@ -301,13 +344,23 @@ ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeFile | IGFD_FileSt
301344
302345
// for all these,s you can use a regex
303346
// ex for color files like Custom*.h
304-
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByFullName, "(Custom.+[.]h)", ImVec4(0.0f, 1.0f, 1.0f, 0.9f), ICON_IGFD_FILE_PIC, font1);
347+
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByFullName, "((Custom.+[.]h))", ImVec4(0.0f, 1.0f, 1.0f, 0.9f), ICON_IGFD_FILE_PIC, font1);
348+
349+
// lambda function
350+
// set file style with a lambda function
351+
// return true is a file style was defined
352+
ImGuiFileDialog::Instance()->SetFileStyle([](const IGFD::FileInfos& vFile, IGFD::FileStyle &vOutStyle) -> bool {
353+
if (!vFile.fileNameExt.empty() && vFile.fileNameExt[0] == '.') {
354+
vOutStyle = IGFD::FileStyle(ImVec4(0.0f, 0.9f, 0.9f, 1.0f), ICON_IGFD_REMOVE);
355+
return true;
356+
}
357+
return false;
358+
});
305359
```
306360

307361
this sample code of [master/main.cpp](https://github.com/aiekick/ImGuiFileDialog/blob/master/main.cpp) produce the picture above :
308362

309363
```cpp
310-
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByFullName, "(Custom.+[.]h)", ImVec4(1.0f, 1.0f, 0.0f, 0.9f));
311364
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".cpp", ImVec4(1.0f, 1.0f, 0.0f, 0.9f));
312365
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".h", ImVec4(0.0f, 1.0f, 0.0f, 0.9f));
313366
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtention, ".hpp", ImVec4(0.0f, 0.0f, 1.0f, 0.9f));
@@ -704,6 +757,14 @@ with [ImGuiFontStudio](https://github.com/aiekick/ImGuiFontStudio), which I wrot
704757

705758
ImGuiFontStudio uses ImGuiFileDialog! Check it out.
706759

760+
### Overriding ImGuiFileDialog :
761+
762+
You can also override it to draw differently or to add/remove widgets.
763+
764+
Take a look at the example application where I show how to use it to display a read-only checkbox.
765+
766+
see the 'CustomDrawReadOnlyCheckBoxFileDialog' class.
767+
707768
</blockquote></details>
708769

709770
<details open><summary><h2>Tune the validations button group :</h2></summary><blockquote>
@@ -744,39 +805,39 @@ ok and cancel buttons inverted (cancel on the left and ok on the right)
744805

745806
<details open><summary><h2>Filtering by a regex :</h2></summary><blockquote>
746807

747-
you can use a regex for filtering and file coloring
808+
you can use a regex for filtering and file Styling
748809

749-
for have a filter recognized as a regex, you must have it between a ( and a )
810+
for have a filter recognized as a regex, you must have it between a (( and a ))
750811

751-
this one will filter files who start by the word "Common" and finish by ".h"
812+
this one will filter files who start by the word "Common" and finish by ".h"
752813
```cpp
753-
ex : "(Custom.+[.]h)"
814+
ex : "((Custom.+[.]h))"
754815
```
755816

756817
use cases :
757818

758-
* Simple filter :
819+
* Simple filter :
759820
```cpp
760-
OpenDialog("toto", "Choose File", "(Custom.+[.]h)");
821+
OpenDialog("toto", "Choose File", "((Custom.+[.]h))");
761822
```
762823
763-
* Collections filter :
824+
* Collections filter :
764825
for this one the filter is between "{" and "}", so you can use the "(" and ")" outside
765826
766827
```cpp
767-
OpenDialog("toto", "Choose File", "Source files (*.cpp *.h *.hpp){(Custom.+[.]h),.h,.hpp},);
828+
OpenDialog("toto", "Choose File", "Source files (*.cpp *.h *.hpp){((Custom.+[.]h)),.h,.hpp}");
768829
```
769830

770831
* file coloring :
771-
this one will colorized all files who start by the word "Common" and finish by ".h"
832+
this one will colorized all files who start by the word "Common" and finish by ".h"
772833
```cpp
773-
SetFileStyle(IGFD_FileStyleByFullName, "(Custom.+[.]h)", ImVec4(1.0f, 1.0f, 0.0f, 0.9f));
834+
SetFileStyle(IGFD_FileStyleByFullName, "((Custom.+[.]h))", ImVec4(1.0f, 1.0f, 0.0f, 0.9f));
774835
```
775836
776837
* with this feature you can by ex filter and colorize render frame pictures who have ext like .000, .001, .002, etc..
777838
```cpp
778-
OpenDialog("toto", "Choose File", "([.][0-9]{3})");
779-
SetFileStyle(IGFD_FileStyleByFullName, "([.][0-9]{3})", ImVec4(1.0f, 1.0f, 0.0f, 0.9f));
839+
OpenDialog("toto", "Choose File", "(([.][0-9]{3}))");
840+
SetFileStyle(IGFD_FileStyleByFullName, "(([.][0-9]{3}))", ImVec4(1.0f, 1.0f, 0.0f, 0.9f));
780841
```
781842

782843
</blockquote></details>

0 commit comments

Comments
 (0)