@@ -96,13 +96,14 @@ included in the Lib_Only branch for your convenience.
9696## Features
9797################################################################
9898
99+ - C Api (succesfully tested with CimGui)
99100- Separate system for call and display
100101 - Can have many function calls with different parameters for one display function, for example
101102- Can create a custom pane with any widgets via function binding
102103 - This pane can block the validation of the dialog
103104 - Can also display different things according to current filter and UserDatas
104105- Advanced file style for file/dir/link coloring / icons / font
105- - predefined form or user custom form by lambda function
106+ - predefined form or user custom form by lambda function (the lambda mode is not available for the C API)
106107- Multi-selection (ctrl/shift + click) :
107108 - 0 => Infinite
108109 - 1 => One file (default)
@@ -118,7 +119,6 @@ included in the Lib_Only branch for your convenience.
118119- Directory bookmarks
119120- Directory manual entry (right click on any path element)
120121- Optional 'Confirm to Overwrite" dialog if file exists
121- - C Api (succesfully tested with CimGui)
122122- Thumbnails Display (agnostic way for compatibility with any backend, sucessfully tested with OpenGl and Vulkan)
123123- The dialog can be embedded in another user frame than the standard or modal dialog
124124- Can tune validation buttons (placements, widths, inversion)
@@ -319,17 +319,23 @@ IGFD_FileStyleByContainedInFullName // define style for file/dir/link when crit
319319
320320You can define easily your own style include your own detection by using lambda function :
321321
322+ ** To note, this mode is not available with the C API **
323+
322324this lamba will treat a file and return a shared pointer of your files style
323325
324326see in action a styling of all files and dir starting by a dot
325327
328+ this lambda input a FileInfos and output a FileStyle
329+ return true if a FileStyle was defined
330+
326331```cpp
327- ImGuiFileDialog::Instance()->SetFileStyle([](const IGFD::FileInfos& vFile) -> std::shared_ptr<IGFD::FileStyle> {
328- if (!vFile.fileNameExt.empty() && vFile.fileNameExt[0] == '.') {
329- return std::make_shared<IGFD::FileStyle>(ImVec4(0.0f, 0.9f, 0.9f, 1.0f), ICON_IGFD_REMOVE);
330- }
331- return nullptr;
332- });
332+ ImGuiFileDialog::Instance()->SetFileStyle([](const IGFD::FileInfos& vFile, IGFD::FileStyle &vOutStyle) -> bool {
333+ if (!vFile.fileNameExt.empty() && vFile.fileNameExt[0] == '.') {
334+ vOutStyle = IGFD::FileStyle(ImVec4(0.0f, 0.9f, 0.9f, 1.0f), ICON_IGFD_REMOVE);
335+ return true;
336+ }
337+ return false;
338+ });
333339```
334340
335341see sample app for the code in action
@@ -380,6 +386,17 @@ ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeFile | IGFD_FileSt
380386// for all these,s you can use a regex
381387// ex for color files like Custom*.h
382388ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByFullName, "((Custom.+[.]h))", ImVec4(0.0f, 1.0f, 1.0f, 0.9f), ICON_IGFD_FILE_PIC, font1);
389+
390+ // lambda function
391+ // set file style with a lambda function
392+ // return true is a file style was defined
393+ ImGuiFileDialog::Instance()->SetFileStyle([](const IGFD::FileInfos& vFile, IGFD::FileStyle &vOutStyle) -> bool {
394+ if (!vFile.fileNameExt.empty() && vFile.fileNameExt[0] == '.') {
395+ vOutStyle = IGFD::FileStyle(ImVec4(0.0f, 0.9f, 0.9f, 1.0f), ICON_IGFD_REMOVE);
396+ return true;
397+ }
398+ return false;
399+ });
383400```
384401
385402this sample code of [master/main.cpp](https://github.com/aiekick/ImGuiFileDialog/blob/master/main.cpp) produce the picture above :
@@ -1109,11 +1126,11 @@ class Utils {
11091126class FileInfos ;
11101127class FileStyle {
11111128public:
1112- typedef std::function<std::shared_ptr<FileStyle> (const FileInfos&)> FileStyleFunctor;
1129+ typedef std::function<bool (const FileInfos&, FileStyle &)> FileStyleFunctor;
11131130
11141131public:
1115- ImVec4 color = ImVec4(0 , 0 , 0 , 0 );
11161132 std::string icon;
1133+ ImVec4 color = ImVec4(0 , 0 , 0 , 0 );
11171134 ImFont* font = nullptr ;
11181135 IGFD_FileStyleFlags flags = 0 ;
11191136
0 commit comments