Skip to content

Commit 13c07da

Browse files
author
Zoltán Turányi
committed
Allow separate visual settings for dirs & links
Allow the use to specify color and icon for directories and links by using the special DIR_FILTER_STRING and LINK_FILTER_STRING filter names. When displaying directory and link lines, any filter specified by these names will take precedence over filters matching based on externsion. The behaviour is completely backwards compatible - if the special filter names are not used, no changes to existing behaviour.
1 parent 7cfed54 commit 13c07da

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3757,20 +3757,26 @@ namespace IGFD
37573757

37583758
ImVec4 c;
37593759
std::string icon;
3760-
bool showColor = prFileDialogInternal.puFilterManager.GetExtentionInfos(infos->fileExt, &c, &icon);
3760+
//Directory and Link infos override the one specified by extension
3761+
bool showColor;
3762+
if (infos->fileType == 'd')
3763+
showColor = prFileDialogInternal.puFilterManager.GetExtentionInfos(DIR_FILTER_STRING, &c, &icon);
3764+
else if (infos->fileType == 'l')
3765+
showColor = prFileDialogInternal.puFilterManager.GetExtentionInfos(LINK_FILTER_STRING, &c, &icon);
3766+
else
3767+
showColor = false;
3768+
if (!showColor)
3769+
showColor = prFileDialogInternal.puFilterManager.GetExtentionInfos(infos->fileExt, &c, &icon);
3770+
37613771
if (showColor)
37623772
ImGui::PushStyleColor(ImGuiCol_Text, c);
37633773

37643774
std::string str;// = " " + infos->fileName;
3765-
if (infos->fileType == 'd') str = dirEntryString;
3775+
if (showColor && !icon.empty()) str = icon;
3776+
else if (infos->fileType == 'd') str = dirEntryString;
37663777
else if (infos->fileType == 'l') str = linkEntryString;
3767-
else if (infos->fileType == 'f')
3768-
{
3769-
if (showColor && !icon.empty())
3770-
str = icon;
3771-
else
3772-
str = fileEntryString;
3773-
}
3778+
else if (infos->fileType == 'f') str = fileEntryString;
3779+
37743780
str += " " + infos->fileName;
37753781

37763782
bool selected = fdi.IsFileNameSelected(infos->fileName); // found

ImGuiFileDialog.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ namespace IGFD
625625
#define MAX_PATH_BUFFER_SIZE 1024
626626
#endif // MAX_PATH_BUFFER_SIZE
627627

628+
#define DIR_FILTER_STRING "\0d"
629+
#define LINK_FILTER_STRING "\0l"
630+
628631
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
629632
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
630633
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)