Skip to content

Commit c66527e

Browse files
committed
[RFR] : Remvoved documentation section. quite unmaintainable, and the doc is in the Documentation.md file
[RFR] : Remvoed teh #Pragma region. helping nothing finally [RFR] : Removed unused static function from the stf files, no more warnings [RFR] : Renamed IMGUIFILEDIALOG_VERSION to IGFD_VERSION
1 parent 00d324c commit c66527e

File tree

3 files changed

+91
-1522
lines changed

3 files changed

+91
-1522
lines changed

ImGuiFileDialog.cpp

+30-105
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
#pragma region PVS STUDIO
21

32
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
43
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
54

6-
#pragma endregion
7-
8-
#pragma region IGFD LICENSE
9-
105
/*
116
MIT License
127
@@ -31,15 +26,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3126
SOFTWARE.
3227
*/
3328

34-
#pragma endregion
35-
3629
#include "ImGuiFileDialog.h"
3730

3831
#ifdef __cplusplus
3932

40-
#pragma region Includes
41-
42-
#include <cfloat>
4333
#include <cstring> // stricmp / strcasecmp
4434
#include <cstdarg> // variadic
4535
#include <sstream>
@@ -106,9 +96,9 @@ SOFTWARE.
10696
#include <algorithm>
10797
#include <iostream>
10898

109-
#pragma endregion
110-
111-
#pragma region Common defines
99+
///////////////////////////////
100+
// STB IMAGE LIBS
101+
///////////////////////////////
112102

113103
#ifdef USE_THUMBNAILS
114104
#ifndef DONT_DEFINE_AGAIN__STB_IMAGE_IMPLEMENTATION
@@ -125,6 +115,10 @@ SOFTWARE.
125115
#include "stb/stb_image_resize2.h"
126116
#endif // USE_THUMBNAILS
127117

118+
///////////////////////////////
119+
// FLOAT MACROS
120+
///////////////////////////////
121+
128122
// float comparisons
129123
#ifndef IS_FLOAT_DIFFERENT
130124
#define IS_FLOAT_DIFFERENT(a, b) (fabs((a) - (b)) > FLT_EPSILON)
@@ -133,15 +127,10 @@ SOFTWARE.
133127
#define IS_FLOAT_EQUAL(a, b) (fabs((a) - (b)) < FLT_EPSILON)
134128
#endif // IS_FLOAT_EQUAL
135129

136-
#pragma endregion
137-
138-
#pragma region IGFD NAMESPACE
139-
140-
#pragma region CUSTOMIZATION DEFINES
141-
142130
///////////////////////////////
143131
// COMBOBOX
144132
///////////////////////////////
133+
145134
#ifndef FILTER_COMBO_AUTO_SIZE
146135
#define FILTER_COMBO_AUTO_SIZE 1
147136
#endif // FILTER_COMBO_AUTO_SIZE
@@ -151,9 +140,11 @@ SOFTWARE.
151140
#ifndef IMGUI_BEGIN_COMBO
152141
#define IMGUI_BEGIN_COMBO ImGui::BeginCombo
153142
#endif // IMGUI_BEGIN_COMBO
143+
154144
///////////////////////////////
155145
// BUTTON
156146
///////////////////////////////
147+
157148
// for lets you define your button widget
158149
// if you have like me a special bi-color button
159150
#ifndef IMGUI_PATH_BUTTON
@@ -162,9 +153,11 @@ SOFTWARE.
162153
#ifndef IMGUI_BUTTON
163154
#define IMGUI_BUTTON ImGui::Button
164155
#endif // IMGUI_BUTTON
156+
165157
///////////////////////////////
166158
// locales
167159
///////////////////////////////
160+
168161
#ifndef createDirButtonString
169162
#define createDirButtonString "+"
170163
#endif // createDirButtonString
@@ -275,9 +268,11 @@ SOFTWARE.
275268
// see strftime functionin <ctime> for customize
276269
#define DateTimeFormat "%Y/%m/%d %H:%M"
277270
#endif // DateTimeFormat
271+
278272
///////////////////////////////
279273
// THUMBNAILS
280274
///////////////////////////////
275+
281276
#ifdef USE_THUMBNAILS
282277
#ifndef tableHeaderFileThumbnailsString
283278
#define tableHeaderFileThumbnailsString "Thumbnails"
@@ -323,9 +318,11 @@ inline bool inRadioButton(const char* vLabel, bool vToggled) {
323318
#define IMGUI_RADIO_BUTTON inRadioButton
324319
#endif // IMGUI_RADIO_BUTTON
325320
#endif // USE_THUMBNAILS
321+
326322
///////////////////////////////
327-
// BOOKMARKS
323+
// PLACES
328324
///////////////////////////////
325+
329326
#ifdef USE_PLACES_FEATURE
330327
#ifndef defaultPlacePaneWith
331328
#define defaultPlacePaneWith 150.0f
@@ -398,12 +395,6 @@ inline bool inToggleButton(const char* vLabel, bool* vToggled) {
398395
#endif // IMGUI_TOGGLE_BUTTON
399396
#endif // USE_PLACES_FEATURE
400397

401-
#pragma endregion
402-
403-
#pragma region INTERNAL
404-
405-
#pragma region EXCEPTION
406-
407398
class IGFDException : public std::exception {
408399
private:
409400
char const* m_msg{};
@@ -419,10 +410,6 @@ class IGFDException : public std::exception {
419410
}
420411
};
421412

422-
#pragma endregion
423-
424-
#pragma region FILE SYSTEM INTERFACE
425-
426413
#ifndef CUSTOM_FILESYSTEM_INCLUDE
427414
#ifdef USE_STD_FILESYSTEM
428415

@@ -797,10 +784,6 @@ class FileSystemDirent : public IGFD::IFileSystem {
797784
#include CUSTOM_FILESYSTEM_INCLUDE
798785
#endif // USE_CUSTOM_FILESYSTEM
799786

800-
#pragma endregion
801-
802-
#pragma region Utils
803-
804787
// https://github.com/ocornut/imgui/issues/1720
805788
bool IGFD::Utils::ImSplitter(bool split_vertically, float thickness, float* size1, float* size2, float min_size1, float min_size2, float splitter_long_axis_size) {
806789
auto* window = ImGui::GetCurrentWindow();
@@ -1015,10 +998,6 @@ std::string IGFD::Utils::FormatFileSize(size_t vByteSize) {
1015998
return "0 " fileSizeBytes;
1016999
}
10171000

1018-
#pragma endregion
1019-
1020-
#pragma region FileStyle
1021-
10221001
IGFD::FileStyle::FileStyle() : color(0, 0, 0, 0) {
10231002
}
10241003

@@ -1032,10 +1011,6 @@ IGFD::FileStyle::FileStyle(const FileStyle& vStyle) {
10321011
IGFD::FileStyle::FileStyle(const ImVec4& vColor, const std::string& vIcon, ImFont* vFont) : color(vColor), icon(vIcon), font(vFont) {
10331012
}
10341013

1035-
#pragma endregion
1036-
1037-
#pragma region SearchManager
1038-
10391014
void IGFD::SearchManager::Clear() {
10401015
searchTag.clear();
10411016
IGFD::Utils::ResetBuffer(searchBuffer);
@@ -1061,10 +1036,6 @@ void IGFD::SearchManager::DrawSearchBar(FileDialogInternal& vFileDialogInternal)
10611036
}
10621037
}
10631038

1064-
#pragma endregion
1065-
1066-
#pragma region FilterInfos
1067-
10681039
void IGFD::FilterInfos::setCollectionTitle(const std::string& vTitle) {
10691040
title = vTitle;
10701041
}
@@ -1127,7 +1098,7 @@ bool IGFD::FilterInfos::exist(const FileInfos& vFileInfos, bool vIsCaseInsensiti
11271098
}
11281099

11291100
bool IGFD::FilterInfos::regexExist(const std::string& vFilter) const {
1130-
for (auto regex : filters_regex) {
1101+
for (const auto& regex : filters_regex) {
11311102
if (std::regex_search(vFilter, regex)) {
11321103
return true;
11331104
}
@@ -1153,10 +1124,6 @@ std::string IGFD::FilterInfos::transformAsteriskBasedFilterToRegex(const std::st
11531124
return res;
11541125
}
11551126

1156-
#pragma endregion
1157-
1158-
#pragma region FilterManager
1159-
11601127
const IGFD::FilterInfos& IGFD::FilterManager::GetSelectedFilter() const {
11611128
return m_SelectedFilter;
11621129
}
@@ -1580,6 +1547,8 @@ std::string IGFD::FilterManager::ReplaceExtentionWithCurrentFilterIfNeeded(const
15801547
}
15811548
break;
15821549
}
1550+
default:
1551+
break;
15831552
}
15841553

15851554
Utils::ReplaceString(result, "..", ".");
@@ -1595,10 +1564,6 @@ void IGFD::FilterManager::SetDefaultFilterIfNotDefined() {
15951564
}
15961565
}
15971566

1598-
#pragma endregion
1599-
1600-
#pragma region FileType
1601-
16021567
IGFD::FileType::FileType() = default;
16031568
IGFD::FileType::FileType(const ContentType& vContentType, const bool& vIsSymlink) : m_Content(vContentType), m_Symlink(vIsSymlink) {
16041569
}
@@ -1637,10 +1602,6 @@ bool IGFD::FileType::operator>(const FileType& rhs) const {
16371602
return m_Content > rhs.m_Content;
16381603
}
16391604

1640-
#pragma endregion
1641-
1642-
#pragma region FileInfos
1643-
16441605
std::shared_ptr<IGFD::FileInfos> IGFD::FileInfos::create() {
16451606
return std::make_shared<IGFD::FileInfos>();
16461607
}
@@ -1725,10 +1686,6 @@ bool IGFD::FileInfos::FinalizeFileTypeParsing(const size_t& vMaxDotToExtract) {
17251686
return false;
17261687
}
17271688

1728-
#pragma endregion
1729-
1730-
#pragma region FileManager
1731-
17321689
IGFD::FileManager::FileManager() {
17331690
fsRoot = IGFD::Utils::GetPathSeparator();
17341691
#define STR(x) #x
@@ -2074,23 +2031,23 @@ bool IGFD::FileManager::GetDevices() {
20742031
return false;
20752032
}
20762033

2077-
bool IGFD::FileManager::IsComposerEmpty() {
2034+
bool IGFD::FileManager::IsComposerEmpty() const {
20782035
return m_CurrentPathDecomposition.empty();
20792036
}
20802037

2081-
size_t IGFD::FileManager::GetComposerSize() {
2038+
size_t IGFD::FileManager::GetComposerSize() const {
20822039
return m_CurrentPathDecomposition.size();
20832040
}
20842041

2085-
bool IGFD::FileManager::IsFileListEmpty() {
2042+
bool IGFD::FileManager::IsFileListEmpty() const {
20862043
return m_FileList.empty();
20872044
}
20882045

2089-
bool IGFD::FileManager::IsPathListEmpty() {
2046+
bool IGFD::FileManager::IsPathListEmpty() const{
20902047
return m_PathList.empty();
20912048
}
20922049

2093-
size_t IGFD::FileManager::GetFullFileListSize() {
2050+
size_t IGFD::FileManager::GetFullFileListSize() const {
20942051
return m_FileList.size();
20952052
}
20962053

@@ -2099,19 +2056,19 @@ std::shared_ptr<IGFD::FileInfos> IGFD::FileManager::GetFullFileAt(size_t vIdx) {
20992056
return nullptr;
21002057
}
21012058

2102-
bool IGFD::FileManager::IsFilteredListEmpty() {
2059+
bool IGFD::FileManager::IsFilteredListEmpty() const {
21032060
return m_FilteredFileList.empty();
21042061
}
21052062

2106-
bool IGFD::FileManager::IsPathFilteredListEmpty() {
2063+
bool IGFD::FileManager::IsPathFilteredListEmpty() const {
21072064
return m_FilteredPathList.empty();
21082065
}
21092066

2110-
size_t IGFD::FileManager::GetFilteredListSize() {
2067+
size_t IGFD::FileManager::GetFilteredListSize() const {
21112068
return m_FilteredFileList.size();
21122069
}
21132070

2114-
size_t IGFD::FileManager::GetPathFilteredListSize() {
2071+
size_t IGFD::FileManager::GetPathFilteredListSize() const {
21152072
return m_FilteredPathList.size();
21162073
}
21172074

@@ -2125,7 +2082,7 @@ std::shared_ptr<IGFD::FileInfos> IGFD::FileManager::GetFilteredPathAt(size_t vId
21252082
return nullptr;
21262083
}
21272084

2128-
std::vector<std::string>::iterator IGFD::FileManager::GetCurrentPopupComposedPath() {
2085+
std::vector<std::string>::iterator IGFD::FileManager::GetCurrentPopupComposedPath() const {
21292086
return m_PopupComposedPath;
21302087
}
21312088

@@ -2661,10 +2618,6 @@ std::map<std::string, std::string> IGFD::FileManager::GetResultingSelection(File
26612618
return res;
26622619
}
26632620

2664-
#pragma endregion
2665-
2666-
#pragma region FileDialogInternal
2667-
26682621
void IGFD::FileDialogInternal::NewFrame() {
26692622
canWeContinue = true; // reset flag for possibily validate the dialog
26702623
isOk = false; // reset dialog result
@@ -2769,14 +2722,6 @@ IGFD::FileDialogConfig& IGFD::FileDialogInternal::getDialogConfigRef() {
27692722
return m_DialogConfig;
27702723
}
27712724

2772-
#pragma endregion
2773-
2774-
#pragma endregion
2775-
2776-
#pragma region Optional Features
2777-
2778-
#pragma region ThumbnailFeature
2779-
27802725
IGFD::ThumbnailFeature::ThumbnailFeature() {
27812726
#ifdef USE_THUMBNAILS
27822727
m_DisplayMode = DisplayModeEnum::FILE_LIST;
@@ -3030,10 +2975,6 @@ void IGFD::ThumbnailFeature::ManageGPUThumbnails() {
30302975

30312976
#endif // USE_THUMBNAILS
30322977

3033-
#pragma endregion
3034-
3035-
#pragma region PlacesFeature
3036-
30372978
IGFD::PlacesFeature::PlacesFeature() {
30382979
#ifdef USE_PLACES_FEATURE
30392980
m_PlacesPaneWidth = defaultPlacePaneWith;
@@ -3265,10 +3206,6 @@ bool IGFD::PlacesFeature::GroupStruct::RemovePlace(const std::string& vPlaceName
32653206
}
32663207
#endif // USE_PLACES_FEATURE
32673208

3268-
#pragma endregion
3269-
3270-
#pragma region KeyExplorerFeature
3271-
32723209
IGFD::KeyExplorerFeature::KeyExplorerFeature() = default;
32733210

32743211
#ifdef USE_EXPLORATION_BY_KEYS
@@ -3642,12 +3579,6 @@ void IGFD::KeyExplorerFeature::SetFlashingAttenuationInSeconds(float vAttenValue
36423579
}
36433580
#endif // USE_EXPLORATION_BY_KEYS
36443581

3645-
#pragma endregion
3646-
3647-
#pragma endregion
3648-
3649-
#pragma region FileDialog
3650-
36513582
IGFD::FileDialog::FileDialog() : PlacesFeature(), KeyExplorerFeature(), ThumbnailFeature() {
36523583
#ifdef USE_PLACES_FEATURE
36533584
m_InitPlaces(m_FileDialogInternal);
@@ -4693,14 +4624,8 @@ bool IGFD::FileDialog::m_Confirm_Or_OpenOverWriteFileDialog_IfNeeded(bool vLastA
46934624
return false;
46944625
}
46954626

4696-
#pragma endregion
4697-
4698-
#pragma endregion
4699-
47004627
#endif // __cplusplus
47014628

4702-
#pragma region IGFD_C_API
4703-
47044629
// return an initialized IGFD_FileDialog_Config
47054630
IGFD_C_API IGFD_FileDialog_Config IGFD_FileDialog_Config_Get() {
47064631
IGFD_FileDialog_Config res = {};

0 commit comments

Comments
 (0)