@@ -126,7 +126,7 @@ namespace IGFD
126126#define fileNameString " File Name :"
127127#endif // fileNameString
128128#ifndef dirNameString
129- #define dirNameString " Directory Name :"
129+ #define dirNameString " Directory Path :"
130130#endif // dirNameString
131131#ifndef buttonResetSearchString
132132#define buttonResetSearchString " Reset search"
@@ -902,7 +902,7 @@ namespace IGFD
902902 !m_Filters.empty ()) // filter exist
903903 m_SelectedFilter = *m_Filters.begin (); // we take the first filter
904904
905- // init list of files
905+ // init list of files
906906 if (m_FileList.empty () && !m_ShowDrives)
907907 {
908908 replaceString (dlg_defaultFileName, dlg_path, " " ); // local path
@@ -911,6 +911,8 @@ namespace IGFD
911911 SetDefaultFileName (dlg_defaultFileName);
912912 SetSelectedFilterWithExt (dlg_defaultExt);
913913 }
914+ else if (dlg_filters.empty ()) // directory mode
915+ SetDefaultFileName (" ." );
914916 ScanDir (dlg_path);
915917 }
916918
@@ -1397,9 +1399,9 @@ namespace IGFD
13971399 {
13981400 if (vInfos.type == ' d' )
13991401 {
1400- if (ImGui::IsMouseDoubleClicked (0 ))
1402+ if (ImGui::IsMouseDoubleClicked (0 )) // 0 -> left mouse button double click
14011403 {
1402- m_PathClicked = SelectDirectory (vInfos);
1404+ m_PathClicked = SelectDirectory (vInfos);
14031405 }
14041406 else if (dlg_filters.empty ()) // directory chooser
14051407 {
@@ -1475,40 +1477,59 @@ namespace IGFD
14751477
14761478 std::string IGFD::FileDialog::GetFilePathName ()
14771479 {
1478- std::string result = m_CurrentPath ;
1480+ std::string result = GetCurrentPath () ;
14791481
1482+ std::string filename = GetCurrentFileName ();
1483+ if (!filename.empty ())
1484+ {
14801485#ifdef UNIX
1481- if (s_fs_root != result)
1486+ if (s_fs_root != result)
14821487#endif // UNIX
1483- result += PATH_SEP;
1488+ result += PATH_SEP;
14841489
1485- result += GetCurrentFileName ();
1490+ result += filename;
1491+ }
14861492
14871493 return result;
14881494 }
14891495
14901496 std::string IGFD::FileDialog::GetCurrentPath ()
14911497 {
1492- return m_CurrentPath;
1498+ std::string path = m_CurrentPath;
1499+
1500+ if (dlg_filters.empty ()) // if directory mode
1501+ {
1502+ std::string selectedDirectory = FileNameBuffer;
1503+ if (!selectedDirectory.empty () &&
1504+ selectedDirectory != " ." )
1505+ path += PATH_SEP + selectedDirectory;
1506+ }
1507+
1508+ return path;
14931509 }
14941510
14951511 std::string IGFD::FileDialog::GetCurrentFileName ()
14961512 {
1497- std::string result = FileNameBuffer;
1498-
1499- // if not a collection we can replace the filter by thee extention we want
1500- if (m_SelectedFilter.collectionfilters .empty ())
1513+ if (!dlg_filters.empty ()) // if not directory mode
15011514 {
1502- size_t lastPoint = result.find_last_of (' .' );
1503- if (lastPoint != std::string::npos)
1515+ std::string result = FileNameBuffer;
1516+
1517+ // if not a collection we can replace the filter by the extention we want
1518+ if (m_SelectedFilter.collectionfilters .empty ())
15041519 {
1505- result = result.substr (0 , lastPoint);
1520+ size_t lastPoint = result.find_last_of (' .' );
1521+ if (lastPoint != std::string::npos)
1522+ {
1523+ result = result.substr (0 , lastPoint);
1524+ }
1525+
1526+ result += m_SelectedFilter.filter ;
15061527 }
15071528
1508- result += m_SelectedFilter. filter ;
1529+ return result ;
15091530 }
15101531
1511- return result;
1532+ return " " ; // directory mode
15121533 }
15131534
15141535 std::string IGFD::FileDialog::GetCurrentFilter ()
@@ -1532,7 +1553,7 @@ namespace IGFD
15321553
15331554 for (auto & it : m_SelectedFileNames)
15341555 {
1535- std::string result = m_CurrentPath ;
1556+ std::string result = GetCurrentPath () ;
15361557
15371558#ifdef UNIX
15381559 if (s_fs_root != result)
@@ -1774,6 +1795,8 @@ namespace IGFD
17741795 m_CurrentPath = vPath;
17751796 m_FileList.clear ();
17761797 m_CurrentPath_Decomposition.clear ();
1798+ if (dlg_filters.empty ()) // directory mode
1799+ SetDefaultFileName (" ." );
17771800 ScanDir (m_CurrentPath);
17781801 }
17791802
@@ -1805,9 +1828,11 @@ namespace IGFD
18051828 }
18061829 }
18071830
1808- void IGFD::FileDialog::FillInfos (FileInfoStruct* vFileInfoStruct)
1831+ void IGFD::FileDialog::CompleteFileInfos (FileInfoStruct* vFileInfoStruct)
18091832 {
1810- if (vFileInfoStruct && vFileInfoStruct->fileName != " .." )
1833+ if (vFileInfoStruct &&
1834+ vFileInfoStruct->fileName != " ." &&
1835+ vFileInfoStruct->fileName != " .." )
18111836 {
18121837 // _stat struct :
18131838 // dev_t st_dev; /* ID of device containing file */
@@ -2004,7 +2029,8 @@ namespace IGFD
20042029 infos.fileName = ent->d_name ;
20052030 infos.fileName_optimized = OptimizeFilenameForSearchOperations (infos.fileName );
20062031
2007- if ((" ." != infos.fileName ))
2032+ if (infos.fileName != " ."
2033+ || dlg_filters.empty ()) // in directory mode we must display the curent dir "."
20082034 {
20092035 switch (ent->d_type )
20102036 {
@@ -2028,7 +2054,7 @@ namespace IGFD
20282054 if (!dlg_filters.empty ())
20292055 {
20302056 // check if current file extention is covered by current filter
2031- // we do that here, for avoid doing taht during filelist display
2057+ // we do that here, for avoid doing that during filelist display
20322058 // for better fps
20332059 if (!m_SelectedFilter.empty () && // selected filter exist
20342060 (!m_SelectedFilter.filterExist (infos.ext ) && // filter not found
@@ -2039,7 +2065,7 @@ namespace IGFD
20392065 }
20402066 }
20412067
2042- FillInfos (&infos);
2068+ CompleteFileInfos (&infos);
20432069 m_FileList.push_back (infos);
20442070 }
20452071 }
0 commit comments