@@ -549,60 +549,37 @@ namespace IGFD
549549 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
550550 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
551551
552- class FileExtentionInfos
553- {
554- public:
555- ImVec4 color = ImVec4(0 , 0 , 0 , 0 );
556- std::string icon;
557-
558- public:
559- FileExtentionInfos ();
560- FileExtentionInfos (const ImVec4& vColor, const std::string& vIcon = " " );
561- };
552+ class FileDialogInternal ;
562553
563554 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
564555 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
565556 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
566557
567- class FileInfos
558+ class SearchManager
568559 {
569560 public:
570- char fileType = ' ' ; // dirent fileType (f:file, d:directory, l:link)
571- std::string filePath; // path of the file
572- std::string fileName; // filename of the file
573- std::string fileName_optimized; // optimized for search => insensitivecase
574- std::string fileExt; // extention of the file
575- size_t fileSize = 0 ; // for sorting operations
576- std::string formatedFileSize; // file size formated (10 o, 10 ko, 10 mo, 10 go)
577- std::string fileModifDate; // file user defined format of the date (data + time by default)
578- #ifdef USE_THUMBNAILS
579- IGFD_Thumbnail_Info thumbnailInfo; // structre for the display for image file tetxure
580- #endif // USE_THUMBNAILS
561+ std::string puSearchTag;
562+ char puSearchBuffer[MAX_FILE_DIALOG_NAME_BUFFER] = " " ;
563+ bool puSearchInputIsActive = false ;
581564
582565 public:
583- bool IsTagFound (const std::string& vTag);
566+ void Clear (); // clear datas
567+ void DrawSearchBar (FileDialogInternal& vFileDialogInternal); // draw the search bar
584568 };
585569
586570 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
587571 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
588572 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
589573
590- class FileDialogInternal ;
591-
592- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
593- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
594- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
595-
596- class SearchManager
574+ class FileExtentionInfos
597575 {
598576 public:
599- std::string puSearchTag;
600- char puSearchBuffer[MAX_FILE_DIALOG_NAME_BUFFER] = " " ;
601- bool puSearchInputIsActive = false ;
577+ ImVec4 color = ImVec4(0 , 0 , 0 , 0 );
578+ std::string icon;
602579
603580 public:
604- void Clear (); // description => todo
605- void DrawSearchBar (FileDialogInternal& vFileDialogInternal); // description => todo
581+ FileExtentionInfos ();
582+ FileExtentionInfos ( const ImVec4& vColor, const std::string& vIcon = " " );
606583 };
607584
608585 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -619,9 +596,9 @@ namespace IGFD
619596 std::set<std::string> collectionfilters;
620597
621598 public:
622- void clear (); // description => todo
623- bool empty () const ; // description => todo
624- bool filterExist (const std::string& vFilter) const ; // description => todo
599+ void clear (); // clear the datas
600+ bool empty () const ; // is filter empty
601+ bool exist (const std::string& vFilter) const ; // is filter exist
625602 };
626603
627604 private:
@@ -634,16 +611,40 @@ namespace IGFD
634611 std::string puDLGdefaultExt;
635612
636613 public:
637- void ParseFilters (const char * vFilters); // parse filter syntax, detect and parse filter collection
638- void SetSelectedFilterWithExt (const std::string& vFilter); // select filter
639- void SetExtentionInfos (const std::string& vFilter, const FileExtentionInfos& vInfos); // description => todo
640- void SetExtentionInfos (const std::string& vFilter, const ImVec4& vColor, const std::string& vIcon); // description => todo
641- bool GetExtentionInfos (const std::string& vFilter, ImVec4* vOutColor, std::string* vOutIcon); // description => todo
642- void ClearExtentionInfos (); // description => todo
643- bool IsCoveredByFilters (const std::string& vTag) const ; // description => todo
644- bool DrawFilterComboBox (FileDialogInternal& vFileDialogInternal); // description => todo
645- FilterInfosStruct GetSelectedFilter (); // description => todo
646- std::string ReplaceExtenstionWithCurrentFilter (const std::string vFile); // description => todo
614+ void ParseFilters (const char * vFilters); // Parse filter syntax, detect and parse filter collection
615+ void SetSelectedFilterWithExt (const std::string& vFilter); // Select filter
616+ void SetExtentionInfos (const std::string& vFilter, const FileExtentionInfos& vInfos); // link filter to ExtentionInfos
617+ void SetExtentionInfos (const std::string& vFilter, const ImVec4& vColor, const std::string& vIcon); // link filter to Color and Icon
618+ bool GetExtentionInfos (const std::string& vFilter, ImVec4* vOutColor, std::string* vOutIcon); // get Color and Icon for Filter
619+ void ClearExtentionInfos (); // clear prFileExtentionInfos
620+ bool IsCoveredByFilters (const std::string& vTag) const ; // check if current file extention (vTag) is covered by current filter
621+ bool DrawFilterComboBox (FileDialogInternal& vFileDialogInternal); // draw the filter combobox
622+ FilterInfosStruct GetSelectedFilter (); // get the current selected filter
623+ std::string ReplaceExtentionWithCurrentFilter (const std::string vFile); // replace the extention of the current file by the selected filter
624+ void SetDefaultFilterIfNotDefined (); // define the first filter if no filter is selected
625+ };
626+
627+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
628+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
629+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
630+
631+ class FileInfos
632+ {
633+ public:
634+ char fileType = ' ' ; // dirent fileType (f:file, d:directory, l:link)
635+ std::string filePath; // path of the file
636+ std::string fileName; // filename of the file
637+ std::string fileName_optimized; // optimized for search => insensitivecase
638+ std::string fileExt; // extention of the file
639+ size_t fileSize = 0 ; // for sorting operations
640+ std::string formatedFileSize; // file size formated (10 o, 10 ko, 10 mo, 10 go)
641+ std::string fileModifDate; // file user defined format of the date (data + time by default)
642+ #ifdef USE_THUMBNAILS
643+ IGFD_Thumbnail_Info thumbnailInfo; // structre for the display for image file tetxure
644+ #endif // USE_THUMBNAILS
645+
646+ public:
647+ bool IsTagFound (const std::string& vTag);
647648 };
648649
649650 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -688,7 +689,7 @@ namespace IGFD
688689 std::string puHeaderFileDate; // detail view name of column date + time
689690#ifdef USE_THUMBNAILS
690691 std::string puHeaderFileThumbnails; // detail view name of column thumbnails
691- bool puSortingDirection[5 ] = { true , true , true , true , true }; // detail view // true => Descending, false => Ascending
692+ bool puSortingDirection[5 ] = { true , true , true , true , true }; // detail view // true => Descending, false => Ascending
692693#else
693694 bool puSortingDirection[4 ] = { true , true , true , true }; // detail view // true => Descending, false => Ascending
694695#endif
@@ -703,7 +704,7 @@ namespace IGFD
703704 private:
704705 std::string prRoundNumber (double vvalue, int n); // custom rounding number
705706 std::string prFormatFileSize (size_t vByteSize); // format file size field
706- std::string prOptimizeFilenameForSearchOperations (const std::string& vFileName); // turn all text in lower case for search facilitie
707+ std::string prOptimizeFilenameForSearchOperations (const std::string& vFileName); // turn all text in lower case for search facilitie
707708 void prCompleteFileInfos (std::shared_ptr<FileInfos> FileInfos); // set time and date infos of a file (detail view mode)
708709 void prRemoveFileNameInSelection (const std::string& vFileName); // selection : remove a file name
709710 void prAddFileNameInSelection (const std::string& vFileName, bool vSetLastSelectionFileName); // selection : add a file name
@@ -720,23 +721,25 @@ namespace IGFD
720721 bool IsFileNameSelected (const std::string vFileName);
721722 std::string GetBack ();
722723 void ClearComposer ();
723- void ClearFileLists (); // clear file list, will destroy thumbnail textures
724+ void ClearFileLists (); // clear file list, will destroy thumbnail textures
724725 void ClearAll ();
725726 void ApplyFilteringOnFileList (const FileDialogInternal& vFileDialogInternal);
726- void OpenCurrentPath (const FileDialogInternal& vFileDialogInternal); // set the path of the dialog, will launch the directory scan for populate the file listview
727- void ScanDir (const FileDialogInternal& vFileDialogInternal, const std::string& vPath); // scan the directory for retrieve the file list
728- void SortFields (const FileDialogInternal& vFileDialogInternal, const SortingFieldEnum& vSortingField, const bool & vCanChangeOrder); // will sort a column
729- bool GetDrives (); // list drives on windows platform
730- void SetCurrentDir (const std::string& vPath); // define current directory for scan
731- bool CreateDir (const std::string& vPath); // create a directory on the file system
732- void ComposeNewPath (std::vector<std::string>::iterator vIter); // compose a path from the compose path widget
733- bool SetPathOnParentDirectoryIfAny (); // compose paht on parent directory
734- std::string GetCurrentPath (); // get the current path
735- void SetCurrentPath (const std::string& vCurrentPath); // set the current path
727+ void OpenCurrentPath (const FileDialogInternal& vFileDialogInternal); // set the path of the dialog, will launch the directory scan for populate the file listview
728+ void ScanDir (const FileDialogInternal& vFileDialogInternal, const std::string& vPath); // scan the directory for retrieve the file list
729+ void SortFields (const FileDialogInternal& vFileDialogInternal,
730+ const SortingFieldEnum& vSortingField, const bool & vCanChangeOrder); // will sort a column
731+ bool GetDrives (); // list drives on windows platform
732+ void SetCurrentDir (const std::string& vPath); // define current directory for scan
733+ bool CreateDir (const std::string& vPath); // create a directory on the file system
734+ void ComposeNewPath (std::vector<std::string>::iterator vIter); // compose a path from the compose path widget
735+ bool SetPathOnParentDirectoryIfAny (); // compose paht on parent directory
736+ std::string GetCurrentPath (); // get the current path
737+ void SetCurrentPath (const std::string& vCurrentPath); // set the current path
736738 bool IsFileExist (const std::string& vFile);
737739 void SetDefaultFileName (const std::string& vFileName);
738- bool SelectDirectory (std::shared_ptr<FileInfos> vInfos); // enter directory
739- void SelectFileName (const FileDialogInternal& vFileDialogInternal, std::shared_ptr<FileInfos> vInfos); // select filename
740+ bool SelectDirectory (std::shared_ptr<FileInfos> vInfos); // enter directory
741+ void SelectFileName (const FileDialogInternal& vFileDialogInternal,
742+ std::shared_ptr<FileInfos> vInfos); // select filename
740743
741744 public:
742745 std::string GetResultingPath ();
@@ -755,7 +758,7 @@ namespace IGFD
755758
756759#ifdef USE_THUMBNAILS
757760 typedef std::function<void (IGFD_Thumbnail_Info*)> CreateThumbnailFun; // texture 2d creation function binding
758- typedef std::function<void (IGFD_Thumbnail_Info*)> DestroyThumbnailFun;// texture 2d destroy function binding
761+ typedef std::function<void (IGFD_Thumbnail_Info*)> DestroyThumbnailFun; // texture 2d destroy function binding
759762#endif
760763 class ThumbnailFeature
761764 {
@@ -780,11 +783,11 @@ namespace IGFD
780783 uint32_t prCountFiles = 0U ;
781784 bool prIsWorking = false ;
782785 std::shared_ptr<std::thread> prThumbnailGenerationThread = nullptr ;
783- std::list<std::shared_ptr<FileInfos>> prThumbnailFileDatasToGet; // base container
786+ std::list<std::shared_ptr<FileInfos>> prThumbnailFileDatasToGet; // base container
784787 std::mutex prThumbnailFileDatasToGetMutex;
785- std::list<std::shared_ptr<FileInfos>> prThumbnailToCreate; // base container
788+ std::list<std::shared_ptr<FileInfos>> prThumbnailToCreate; // base container
786789 std::mutex prThumbnailToCreateMutex;
787- std::list<IGFD_Thumbnail_Info> prThumbnailToDestroy; // base container
790+ std::list<IGFD_Thumbnail_Info> prThumbnailToDestroy; // base container
788791 std::mutex prThumbnailToDestroyMutex;
789792
790793 CreateThumbnailFun prCreateThumbnailFun = nullptr ;
@@ -895,7 +898,7 @@ namespace IGFD
895898 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
896899
897900 typedef void * UserDatas;
898- typedef std::function<void (const char *, UserDatas, bool *)> PaneFun; // side pane function binding
901+ typedef std::function<void (const char *, UserDatas, bool *)> PaneFun; // side pane function binding
899902 class FileDialogInternal
900903 {
901904 public:
@@ -906,14 +909,14 @@ namespace IGFD
906909 public:
907910 std::string puName;
908911 bool puShowDialog = false ;
909- ImVec2 puDialogCenterPos = ImVec2(0 , 0 ); // center pos for display the confirm overwrite dialog
910- int puLastImGuiFrameCount = 0 ; // to be sure than only one dialog displayed per frame
912+ ImVec2 puDialogCenterPos = ImVec2(0 , 0 ); // center pos for display the confirm overwrite dialog
913+ int puLastImGuiFrameCount = 0 ; // to be sure than only one dialog displayed per frame
911914 float puFooterHeight = 0 .0f ;
912- bool puCanWeContinue = true ; // events
913- bool puOkResultToConfirm = false ; // to confim if ok for OverWrite
915+ bool puCanWeContinue = true ; // events
916+ bool puOkResultToConfirm = false ; // to confim if ok for OverWrite
914917 bool puIsOk = false ;
915- bool puFileInputIsActive = false ; // when input text for file or directory is active
916- bool puFileListViewIsActive = false ; // when list view is active
918+ bool puFileInputIsActive = false ; // when input text for file or directory is active
919+ bool puFileListViewIsActive = false ; // when list view is active
917920 std::string puDLGkey;
918921 std::string puDLGtitle;
919922 ImGuiFileDialogFlags puDLGflags = ImGuiFileDialogFlags_None;
@@ -1095,15 +1098,15 @@ namespace IGFD
10951098 // widgets components
10961099 virtual void prDrawSidePane (float vHeight); // draw side pane
10971100 virtual bool prSelectableItem (int vidx, std::shared_ptr<FileInfos> vInfos, bool vSelected, const char * vFmt, ...);
1098- virtual void prDrawFileListView (ImVec2 vSize); // draw file list view (default mode)
1101+ virtual void prDrawFileListView (ImVec2 vSize); // draw file list view (default mode)
10991102
11001103#ifdef USE_THUMBNAILS
11011104 virtual void prDrawThumbnailsListView (ImVec2 vSize); // draw file list view with small thumbnails on the same line
11021105 virtual void prDrawThumbnailsGridView (ImVec2 vSize); // draw a grid of small thumbnails
11031106#endif
11041107
11051108 // others
1106- bool prConfirm_Or_OpenOverWriteFileDialog_IfNeeded (bool vLastAction, ImGuiWindowFlags vFlags); // treatment of the result, start the confirm to overwrite dialog if needed (if defined with flag)
1109+ bool prConfirm_Or_OpenOverWriteFileDialog_IfNeeded (bool vLastAction, ImGuiWindowFlags vFlags); // treatment of the result, start the confirm to overwrite dialog if needed (if defined with flag)
11071110 };
11081111}
11091112
0 commit comments