@@ -325,10 +325,11 @@ namespace IGFD
325325
326326 }
327327
328- IGFD::FileExtentionInfos::FileExtentionInfos (const ImVec4& vColor, const std::string& vIcon)
328+ IGFD::FileExtentionInfos::FileExtentionInfos (const ImVec4& vColor, const std::string& vIcon, ImFont* f )
329329 {
330330 color = vColor;
331331 icon = vIcon;
332+ font = f;
332333 }
333334
334335 // ///////////////////////////////////////////////////////////////////////////////////
@@ -824,12 +825,12 @@ namespace IGFD
824825 prFileExtentionInfos[vFilter] = vInfos;
825826 }
826827
827- void IGFD::FilterManager::SetExtentionInfos (const std::string& vFilter, const ImVec4& vColor, const std::string& vIcon)
828+ void IGFD::FilterManager::SetExtentionInfos (const std::string& vFilter, const ImVec4& vColor, const std::string& vIcon, ImFont* vFont )
828829 {
829- prFileExtentionInfos[vFilter] = FileExtentionInfos (vColor, vIcon);
830+ prFileExtentionInfos[vFilter] = FileExtentionInfos (vColor, vIcon, vFont );
830831 }
831832
832- bool IGFD::FilterManager::GetExtentionInfos (const std::string& vFilter, ImVec4* vOutColor, std::string* vOutIcon)
833+ bool IGFD::FilterManager::GetExtentionInfos (const std::string& vFilter, ImVec4* vOutColor, std::string* vOutIcon, ImFont **vOutFont )
833834 {
834835 if (vOutColor)
835836 {
@@ -840,6 +841,10 @@ namespace IGFD
840841 {
841842 *vOutIcon = prFileExtentionInfos[vFilter].icon ;
842843 }
844+ if (vOutFont)
845+ {
846+ *vOutFont = prFileExtentionInfos[vFilter].font ;
847+ }
843848 return true ;
844849 }
845850 }
@@ -3757,20 +3762,29 @@ namespace IGFD
37573762
37583763 ImVec4 c;
37593764 std::string icon;
3760- bool showColor = prFileDialogInternal.puFilterManager .GetExtentionInfos (infos->fileExt , &c, &icon);
3765+ ImFont* font = 0 ;
3766+ // Directory and Link infos override the one specified by extension
3767+ bool showColor;
3768+ if (infos->fileType == ' d' )
3769+ showColor = prFileDialogInternal.puFilterManager .GetExtentionInfos (DIR_FILTER_STRING, &c, &icon, &font);
3770+ else if (infos->fileType == ' l' )
3771+ showColor = prFileDialogInternal.puFilterManager .GetExtentionInfos (LINK_FILTER_STRING, &c, &icon, &font);
3772+ else
3773+ showColor = false ;
3774+ if (!showColor)
3775+ showColor = prFileDialogInternal.puFilterManager .GetExtentionInfos (infos->fileExt , &c, &icon, &font);
3776+
37613777 if (showColor)
37623778 ImGui::PushStyleColor (ImGuiCol_Text, c);
3779+ if (font)
3780+ ImGui::PushFont (font);
37633781
37643782 std::string str;// = " " + infos->fileName;
3765- if (infos->fileType == ' d' ) str = dirEntryString;
3783+ if (showColor && !icon.empty ()) str = icon;
3784+ else if (infos->fileType == ' d' ) str = dirEntryString;
37663785 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- }
3786+ else if (infos->fileType == ' f' ) str = fileEntryString;
3787+
37743788 str += " " + infos->fileName ;
37753789
37763790 bool selected = fdi.IsFileNameSelected (infos->fileName ); // found
@@ -3803,6 +3817,8 @@ namespace IGFD
38033817 ImGui::Text (" %s" , infos->fileModifDate .c_str ());
38043818 }
38053819
3820+ if (font)
3821+ ImGui::PopFont ();
38063822 if (showColor)
38073823 ImGui::PopStyleColor ();
38083824
@@ -4123,14 +4139,14 @@ namespace IGFD
41234139 prFileDialogInternal.puFilterManager .SetExtentionInfos (vFilter, vInfos);
41244140 }
41254141
4126- void IGFD::FileDialog::SetExtentionInfos (const std::string& vFilter, const ImVec4& vColor, const std::string& vIcon)
4142+ void IGFD::FileDialog::SetExtentionInfos (const std::string& vFilter, const ImVec4& vColor, const std::string& vIcon, ImFont* vFont )
41274143 {
4128- prFileDialogInternal.puFilterManager .SetExtentionInfos (vFilter, vColor, vIcon);
4144+ prFileDialogInternal.puFilterManager .SetExtentionInfos (vFilter, vColor, vIcon, vFont );
41294145 }
41304146
4131- bool IGFD::FileDialog::GetExtentionInfos (const std::string& vFilter, ImVec4* vOutColor, std::string* vOutIcon)
4147+ bool IGFD::FileDialog::GetExtentionInfos (const std::string& vFilter, ImVec4* vOutColor, std::string* vOutIcon, ImFont **vOutFont )
41324148 {
4133- return prFileDialogInternal.puFilterManager .GetExtentionInfos (vFilter, vOutColor, vOutIcon);
4149+ return prFileDialogInternal.puFilterManager .GetExtentionInfos (vFilter, vOutColor, vOutIcon, vOutFont );
41344150 }
41354151
41364152 void IGFD::FileDialog::ClearExtentionInfos ()
0 commit comments