Skip to content

Commit 7f76942

Browse files
committed
[RFR] : refactor
1 parent c812707 commit 7f76942

1 file changed

Lines changed: 24 additions & 27 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ namespace IGFD
571571
}
572572

573573
/////////////////////////////////////////////////////////////////////////////////////
574-
/////////////////////////////////////////////////////////////////////////////////////
574+
//// FILE EXTENTIONS INFOS //////////////////////////////////////////////////////////
575575
/////////////////////////////////////////////////////////////////////////////////////
576576

577577
IGFD::FileExtentionInfos::FileExtentionInfos() : color(0, 0, 0, 0)
@@ -586,7 +586,7 @@ namespace IGFD
586586
}
587587

588588
/////////////////////////////////////////////////////////////////////////////////////
589-
/////////////////////////////////////////////////////////////////////////////////////
589+
//// FILE INFOS /////////////////////////////////////////////////////////////////////
590590
/////////////////////////////////////////////////////////////////////////////////////
591591

592592
bool IGFD::FileInfos::IsTagFound(const std::string& vTag)
@@ -603,7 +603,7 @@ namespace IGFD
603603
}
604604

605605
/////////////////////////////////////////////////////////////////////////////////////
606-
/////////////////////////////////////////////////////////////////////////////////////
606+
//// SEARCH MANAGER /////////////////////////////////////////////////////////////////
607607
/////////////////////////////////////////////////////////////////////////////////////
608608

609609
void IGFD::SearchManager::Clear()
@@ -638,12 +638,13 @@ namespace IGFD
638638
}
639639

640640
/////////////////////////////////////////////////////////////////////////////////////
641-
/////////////////////////////////////////////////////////////////////////////////////
641+
//// FILTER INFOS ///////////////////////////////////////////////////////////////////
642642
/////////////////////////////////////////////////////////////////////////////////////
643643

644644
void IGFD::FilterManager::FilterInfosStruct::clear()
645645
{
646-
filter.clear(); collectionfilters.clear();
646+
filter.clear();
647+
collectionfilters.clear();
647648
}
648649

649650
bool IGFD::FilterManager::FilterInfosStruct::empty() const
@@ -653,21 +654,21 @@ namespace IGFD
653654

654655
bool IGFD::FilterManager::FilterInfosStruct::filterExist(const std::string& vFilter) const
655656
{
656-
return filter == vFilter || collectionfilters.find(vFilter) != collectionfilters.end();
657+
return filter == vFilter || (collectionfilters.find(vFilter) != collectionfilters.end());
657658
}
658659

659660
/////////////////////////////////////////////////////////////////////////////////////
660-
/////////////////////////////////////////////////////////////////////////////////////
661+
//// FILTER MANAGER /////////////////////////////////////////////////////////////////
661662
/////////////////////////////////////////////////////////////////////////////////////
662663

663664
void IGFD::FilterManager::ParseFilters(const char* vFilters)
664665
{
665666
prParsedFilters.clear();
666667

667668
if (vFilters)
668-
puDLGFilters = vFilters; // file mode
669+
puDLGFilters = vFilters; // file mode
669670
else
670-
puDLGFilters.clear(); // directtory mode
671+
puDLGFilters.clear(); // directory mode
671672

672673
if (!puDLGFilters.empty())
673674
{
@@ -878,7 +879,7 @@ namespace IGFD
878879
}
879880

880881
/////////////////////////////////////////////////////////////////////////////////////
881-
/////////////////////////////////////////////////////////////////////////////////////
882+
//// FILE MANAGER ///////////////////////////////////////////////////////////////////
882883
/////////////////////////////////////////////////////////////////////////////////////
883884

884885
void IGFD::FileManager::OpenCurrentPath(const FileDialogInternal& vFileDialogInternal)
@@ -1915,7 +1916,7 @@ namespace IGFD
19151916
}
19161917

19171918
/////////////////////////////////////////////////////////////////////////////////////
1918-
/////////////////////////////////////////////////////////////////////////////////////
1919+
//// FILE DIALOG INTERNAL ///////////////////////////////////////////////////////////
19191920
/////////////////////////////////////////////////////////////////////////////////////
19201921

19211922
void IGFD::FileDialogInternal::NewFrame()
@@ -1988,7 +1989,7 @@ namespace IGFD
19881989
}
19891990

19901991
/////////////////////////////////////////////////////////////////////////////////////
1991-
/////////////////////////////////////////////////////////////////////////////////////
1992+
//// THUMBNAIL FEATURE //////////////////////////////////////////////////////////////
19921993
/////////////////////////////////////////////////////////////////////////////////////
19931994

19941995
IGFD::ThumbnailFeature::ThumbnailFeature()
@@ -2329,7 +2330,7 @@ namespace IGFD
23292330
#endif // USE_THUMBNAILS
23302331

23312332
/////////////////////////////////////////////////////////////////////////////////////
2332-
/////////////////////////////////////////////////////////////////////////////////////
2333+
//// BOOKMARK FEATURE ///////////////////////////////////////////////////////////////
23332334
/////////////////////////////////////////////////////////////////////////////////////
23342335

23352336
IGFD::BookMarkFeature::BookMarkFeature()
@@ -2468,7 +2469,7 @@ namespace IGFD
24682469
#endif // USE_BOOKMARK
24692470

24702471
/////////////////////////////////////////////////////////////////////////////////////
2471-
/////////////////////////////////////////////////////////////////////////////////////
2472+
//// KEY EXPLORER FEATURE ///////////////////////////////////////////////////////////
24722473
/////////////////////////////////////////////////////////////////////////////////////
24732474

24742475
KeyExplorerFeature::KeyExplorerFeature()
@@ -2900,14 +2901,14 @@ namespace IGFD
29002901
#endif // USE_EXPLORATION_BY_KEYS
29012902

29022903
/////////////////////////////////////////////////////////////////////////////////////
2903-
/////////////////////////////////////////////////////////////////////////////////////
2904+
//// FILE DIALOG CONSTRUCTOR / DESTRUCTOR ///////////////////////////////////////////
29042905
/////////////////////////////////////////////////////////////////////////////////////
29052906

29062907
IGFD::FileDialog::FileDialog() : BookMarkFeature(), KeyExplorerFeature(), ThumbnailFeature() {}
29072908
IGFD::FileDialog::~FileDialog() = default;
29082909

29092910
//////////////////////////////////////////////////////////////////////////////////////////////////
2910-
///// STANDARD DIALOG ////////////////////////////////////////////////////////////////////////////
2911+
///// FILE DIALOG STANDARD DIALOG ////////////////////////////////////////////////////////////////
29112912
//////////////////////////////////////////////////////////////////////////////////////////////////
29122913

29132914
// path and fileName can be specified
@@ -3102,7 +3103,7 @@ namespace IGFD
31023103
}
31033104

31043105
//////////////////////////////////////////////////////////////////////////////////////////////////
3105-
///// MODAL DIALOG ///////////////////////////////////////////////////////////////////////////////
3106+
///// FILE DIALOG MODAL DIALOG ///////////////////////////////////////////////////////////////////
31063107
//////////////////////////////////////////////////////////////////////////////////////////////////
31073108

31083109
void IGFD::FileDialog::OpenModal(
@@ -3198,20 +3199,20 @@ namespace IGFD
31983199
}
31993200

32003201
//////////////////////////////////////////////////////////////////////////////////////////////////
3201-
///// MAIN FUNCTION //////////////////////////////////////////////////////////////////////////////
3202+
///// FILE DIALOG DISPLAY FUNCTION ///////////////////////////////////////////////////////////////
32023203
//////////////////////////////////////////////////////////////////////////////////////////////////
32033204

32043205
bool IGFD::FileDialog::Display(const std::string& vKey, ImGuiWindowFlags vFlags, ImVec2 vMinSize, ImVec2 vMaxSize)
32053206
{
3206-
auto& fdFile = prFileDialogInternal.puFileManager;
3207-
auto& fdFilter = prFileDialogInternal.puFilterManager;
3208-
3209-
static ImGuiWindowFlags flags;
3210-
32113207
if (prFileDialogInternal.puShowDialog && prFileDialogInternal.puDLGkey == vKey)
32123208
{
32133209
bool res = false;
32143210

3211+
auto& fdFile = prFileDialogInternal.puFileManager;
3212+
auto& fdFilter = prFileDialogInternal.puFilterManager;
3213+
3214+
static ImGuiWindowFlags flags;
3215+
32153216
// to be sure than only one dialog is displayed per frame
32163217
ImGuiContext& g = *GImGui;
32173218
if (g.FrameCount == prFileDialogInternal.puLastImGuiFrameCount) // one instance was displayed this frame before for this key +> quit
@@ -3273,10 +3274,6 @@ namespace IGFD
32733274
prFileDialogInternal.puName = name; //-V820
32743275
puAnyWindowsHovered |= ImGui::IsWindowHovered();
32753276

3276-
//if (fdFilter.puSelectedFilter.empty() && // no filter selected
3277-
// !fdFilter.puParsedFilters.empty()) // filter exist
3278-
// fdFilter.puSelectedFilter = *fdFilter.puParsedFilters.begin(); // we take the first filter
3279-
32803277
if (fdFile.puDLGpath.empty())
32813278
fdFile.puDLGpath = "."; // defaut path is '.'
32823279

0 commit comments

Comments
 (0)