1
- #pragma region PVS STUDIO
2
1
3
2
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
4
3
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
5
4
6
- #pragma endregion
7
-
8
- #pragma region IGFD LICENSE
9
-
10
5
/*
11
6
MIT License
12
7
@@ -31,15 +26,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
26
SOFTWARE.
32
27
*/
33
28
34
- #pragma endregion
35
-
36
29
#include " ImGuiFileDialog.h"
37
30
38
31
#ifdef __cplusplus
39
32
40
- #pragma region Includes
41
-
42
- #include < cfloat>
43
33
#include < cstring> // stricmp / strcasecmp
44
34
#include < cstdarg> // variadic
45
35
#include < sstream>
@@ -106,9 +96,9 @@ SOFTWARE.
106
96
#include < algorithm>
107
97
#include < iostream>
108
98
109
- # pragma endregion
110
-
111
- # pragma region Common defines
99
+ // /////////////////////////////
100
+ // STB IMAGE LIBS
101
+ // /////////////////////////////
112
102
113
103
#ifdef USE_THUMBNAILS
114
104
#ifndef DONT_DEFINE_AGAIN__STB_IMAGE_IMPLEMENTATION
@@ -125,6 +115,10 @@ SOFTWARE.
125
115
#include " stb/stb_image_resize2.h"
126
116
#endif // USE_THUMBNAILS
127
117
118
+ // /////////////////////////////
119
+ // FLOAT MACROS
120
+ // /////////////////////////////
121
+
128
122
// float comparisons
129
123
#ifndef IS_FLOAT_DIFFERENT
130
124
#define IS_FLOAT_DIFFERENT (a, b ) (fabs((a) - (b)) > FLT_EPSILON)
@@ -133,15 +127,10 @@ SOFTWARE.
133
127
#define IS_FLOAT_EQUAL (a, b ) (fabs((a) - (b)) < FLT_EPSILON)
134
128
#endif // IS_FLOAT_EQUAL
135
129
136
- #pragma endregion
137
-
138
- #pragma region IGFD NAMESPACE
139
-
140
- #pragma region CUSTOMIZATION DEFINES
141
-
142
130
// /////////////////////////////
143
131
// COMBOBOX
144
132
// /////////////////////////////
133
+
145
134
#ifndef FILTER_COMBO_AUTO_SIZE
146
135
#define FILTER_COMBO_AUTO_SIZE 1
147
136
#endif // FILTER_COMBO_AUTO_SIZE
@@ -151,9 +140,11 @@ SOFTWARE.
151
140
#ifndef IMGUI_BEGIN_COMBO
152
141
#define IMGUI_BEGIN_COMBO ImGui::BeginCombo
153
142
#endif // IMGUI_BEGIN_COMBO
143
+
154
144
// /////////////////////////////
155
145
// BUTTON
156
146
// /////////////////////////////
147
+
157
148
// for lets you define your button widget
158
149
// if you have like me a special bi-color button
159
150
#ifndef IMGUI_PATH_BUTTON
@@ -162,9 +153,11 @@ SOFTWARE.
162
153
#ifndef IMGUI_BUTTON
163
154
#define IMGUI_BUTTON ImGui::Button
164
155
#endif // IMGUI_BUTTON
156
+
165
157
// /////////////////////////////
166
158
// locales
167
159
// /////////////////////////////
160
+
168
161
#ifndef createDirButtonString
169
162
#define createDirButtonString " +"
170
163
#endif // createDirButtonString
@@ -275,9 +268,11 @@ SOFTWARE.
275
268
// see strftime functionin <ctime> for customize
276
269
#define DateTimeFormat " %Y/%m/%d %H:%M"
277
270
#endif // DateTimeFormat
271
+
278
272
// /////////////////////////////
279
273
// THUMBNAILS
280
274
// /////////////////////////////
275
+
281
276
#ifdef USE_THUMBNAILS
282
277
#ifndef tableHeaderFileThumbnailsString
283
278
#define tableHeaderFileThumbnailsString " Thumbnails"
@@ -323,9 +318,11 @@ inline bool inRadioButton(const char* vLabel, bool vToggled) {
323
318
#define IMGUI_RADIO_BUTTON inRadioButton
324
319
#endif // IMGUI_RADIO_BUTTON
325
320
#endif // USE_THUMBNAILS
321
+
326
322
// /////////////////////////////
327
- // BOOKMARKS
323
+ // PLACES
328
324
// /////////////////////////////
325
+
329
326
#ifdef USE_PLACES_FEATURE
330
327
#ifndef defaultPlacePaneWith
331
328
#define defaultPlacePaneWith 150 .0f
@@ -398,12 +395,6 @@ inline bool inToggleButton(const char* vLabel, bool* vToggled) {
398
395
#endif // IMGUI_TOGGLE_BUTTON
399
396
#endif // USE_PLACES_FEATURE
400
397
401
- #pragma endregion
402
-
403
- #pragma region INTERNAL
404
-
405
- #pragma region EXCEPTION
406
-
407
398
class IGFDException : public std ::exception {
408
399
private:
409
400
char const * m_msg{};
@@ -419,10 +410,6 @@ class IGFDException : public std::exception {
419
410
}
420
411
};
421
412
422
- #pragma endregion
423
-
424
- #pragma region FILE SYSTEM INTERFACE
425
-
426
413
#ifndef CUSTOM_FILESYSTEM_INCLUDE
427
414
#ifdef USE_STD_FILESYSTEM
428
415
@@ -797,10 +784,6 @@ class FileSystemDirent : public IGFD::IFileSystem {
797
784
#include CUSTOM_FILESYSTEM_INCLUDE
798
785
#endif // USE_CUSTOM_FILESYSTEM
799
786
800
- #pragma endregion
801
-
802
- #pragma region Utils
803
-
804
787
// https://github.com/ocornut/imgui/issues/1720
805
788
bool IGFD::Utils::ImSplitter (bool split_vertically, float thickness, float * size1, float * size2, float min_size1, float min_size2, float splitter_long_axis_size) {
806
789
auto * window = ImGui::GetCurrentWindow ();
@@ -1015,10 +998,6 @@ std::string IGFD::Utils::FormatFileSize(size_t vByteSize) {
1015
998
return " 0 " fileSizeBytes;
1016
999
}
1017
1000
1018
- #pragma endregion
1019
-
1020
- #pragma region FileStyle
1021
-
1022
1001
IGFD::FileStyle::FileStyle () : color(0 , 0 , 0 , 0 ) {
1023
1002
}
1024
1003
@@ -1032,10 +1011,6 @@ IGFD::FileStyle::FileStyle(const FileStyle& vStyle) {
1032
1011
IGFD::FileStyle::FileStyle (const ImVec4& vColor, const std::string& vIcon, ImFont* vFont) : color(vColor), icon(vIcon), font(vFont) {
1033
1012
}
1034
1013
1035
- #pragma endregion
1036
-
1037
- #pragma region SearchManager
1038
-
1039
1014
void IGFD::SearchManager::Clear () {
1040
1015
searchTag.clear ();
1041
1016
IGFD::Utils::ResetBuffer (searchBuffer);
@@ -1061,10 +1036,6 @@ void IGFD::SearchManager::DrawSearchBar(FileDialogInternal& vFileDialogInternal)
1061
1036
}
1062
1037
}
1063
1038
1064
- #pragma endregion
1065
-
1066
- #pragma region FilterInfos
1067
-
1068
1039
void IGFD::FilterInfos::setCollectionTitle (const std::string& vTitle) {
1069
1040
title = vTitle;
1070
1041
}
@@ -1127,7 +1098,7 @@ bool IGFD::FilterInfos::exist(const FileInfos& vFileInfos, bool vIsCaseInsensiti
1127
1098
}
1128
1099
1129
1100
bool IGFD::FilterInfos::regexExist (const std::string& vFilter) const {
1130
- for (auto regex : filters_regex) {
1101
+ for (const auto & regex : filters_regex) {
1131
1102
if (std::regex_search (vFilter, regex)) {
1132
1103
return true ;
1133
1104
}
@@ -1153,10 +1124,6 @@ std::string IGFD::FilterInfos::transformAsteriskBasedFilterToRegex(const std::st
1153
1124
return res;
1154
1125
}
1155
1126
1156
- #pragma endregion
1157
-
1158
- #pragma region FilterManager
1159
-
1160
1127
const IGFD::FilterInfos& IGFD::FilterManager::GetSelectedFilter () const {
1161
1128
return m_SelectedFilter;
1162
1129
}
@@ -1580,6 +1547,8 @@ std::string IGFD::FilterManager::ReplaceExtentionWithCurrentFilterIfNeeded(const
1580
1547
}
1581
1548
break ;
1582
1549
}
1550
+ default :
1551
+ break ;
1583
1552
}
1584
1553
1585
1554
Utils::ReplaceString (result, " .." , " ." );
@@ -1595,10 +1564,6 @@ void IGFD::FilterManager::SetDefaultFilterIfNotDefined() {
1595
1564
}
1596
1565
}
1597
1566
1598
- #pragma endregion
1599
-
1600
- #pragma region FileType
1601
-
1602
1567
IGFD::FileType::FileType () = default;
1603
1568
IGFD::FileType::FileType (const ContentType& vContentType, const bool & vIsSymlink) : m_Content(vContentType), m_Symlink(vIsSymlink) {
1604
1569
}
@@ -1637,10 +1602,6 @@ bool IGFD::FileType::operator>(const FileType& rhs) const {
1637
1602
return m_Content > rhs.m_Content ;
1638
1603
}
1639
1604
1640
- #pragma endregion
1641
-
1642
- #pragma region FileInfos
1643
-
1644
1605
std::shared_ptr<IGFD::FileInfos> IGFD::FileInfos::create () {
1645
1606
return std::make_shared<IGFD::FileInfos>();
1646
1607
}
@@ -1725,10 +1686,6 @@ bool IGFD::FileInfos::FinalizeFileTypeParsing(const size_t& vMaxDotToExtract) {
1725
1686
return false ;
1726
1687
}
1727
1688
1728
- #pragma endregion
1729
-
1730
- #pragma region FileManager
1731
-
1732
1689
IGFD::FileManager::FileManager () {
1733
1690
fsRoot = IGFD::Utils::GetPathSeparator ();
1734
1691
#define STR (x ) #x
@@ -2074,23 +2031,23 @@ bool IGFD::FileManager::GetDevices() {
2074
2031
return false ;
2075
2032
}
2076
2033
2077
- bool IGFD::FileManager::IsComposerEmpty () {
2034
+ bool IGFD::FileManager::IsComposerEmpty () const {
2078
2035
return m_CurrentPathDecomposition.empty ();
2079
2036
}
2080
2037
2081
- size_t IGFD::FileManager::GetComposerSize () {
2038
+ size_t IGFD::FileManager::GetComposerSize () const {
2082
2039
return m_CurrentPathDecomposition.size ();
2083
2040
}
2084
2041
2085
- bool IGFD::FileManager::IsFileListEmpty () {
2042
+ bool IGFD::FileManager::IsFileListEmpty () const {
2086
2043
return m_FileList.empty ();
2087
2044
}
2088
2045
2089
- bool IGFD::FileManager::IsPathListEmpty () {
2046
+ bool IGFD::FileManager::IsPathListEmpty () const {
2090
2047
return m_PathList.empty ();
2091
2048
}
2092
2049
2093
- size_t IGFD::FileManager::GetFullFileListSize () {
2050
+ size_t IGFD::FileManager::GetFullFileListSize () const {
2094
2051
return m_FileList.size ();
2095
2052
}
2096
2053
@@ -2099,19 +2056,19 @@ std::shared_ptr<IGFD::FileInfos> IGFD::FileManager::GetFullFileAt(size_t vIdx) {
2099
2056
return nullptr ;
2100
2057
}
2101
2058
2102
- bool IGFD::FileManager::IsFilteredListEmpty () {
2059
+ bool IGFD::FileManager::IsFilteredListEmpty () const {
2103
2060
return m_FilteredFileList.empty ();
2104
2061
}
2105
2062
2106
- bool IGFD::FileManager::IsPathFilteredListEmpty () {
2063
+ bool IGFD::FileManager::IsPathFilteredListEmpty () const {
2107
2064
return m_FilteredPathList.empty ();
2108
2065
}
2109
2066
2110
- size_t IGFD::FileManager::GetFilteredListSize () {
2067
+ size_t IGFD::FileManager::GetFilteredListSize () const {
2111
2068
return m_FilteredFileList.size ();
2112
2069
}
2113
2070
2114
- size_t IGFD::FileManager::GetPathFilteredListSize () {
2071
+ size_t IGFD::FileManager::GetPathFilteredListSize () const {
2115
2072
return m_FilteredPathList.size ();
2116
2073
}
2117
2074
@@ -2125,7 +2082,7 @@ std::shared_ptr<IGFD::FileInfos> IGFD::FileManager::GetFilteredPathAt(size_t vId
2125
2082
return nullptr ;
2126
2083
}
2127
2084
2128
- std::vector<std::string>::iterator IGFD::FileManager::GetCurrentPopupComposedPath () {
2085
+ std::vector<std::string>::iterator IGFD::FileManager::GetCurrentPopupComposedPath () const {
2129
2086
return m_PopupComposedPath;
2130
2087
}
2131
2088
@@ -2661,10 +2618,6 @@ std::map<std::string, std::string> IGFD::FileManager::GetResultingSelection(File
2661
2618
return res;
2662
2619
}
2663
2620
2664
- #pragma endregion
2665
-
2666
- #pragma region FileDialogInternal
2667
-
2668
2621
void IGFD::FileDialogInternal::NewFrame () {
2669
2622
canWeContinue = true ; // reset flag for possibily validate the dialog
2670
2623
isOk = false ; // reset dialog result
@@ -2769,14 +2722,6 @@ IGFD::FileDialogConfig& IGFD::FileDialogInternal::getDialogConfigRef() {
2769
2722
return m_DialogConfig;
2770
2723
}
2771
2724
2772
- #pragma endregion
2773
-
2774
- #pragma endregion
2775
-
2776
- #pragma region Optional Features
2777
-
2778
- #pragma region ThumbnailFeature
2779
-
2780
2725
IGFD::ThumbnailFeature::ThumbnailFeature () {
2781
2726
#ifdef USE_THUMBNAILS
2782
2727
m_DisplayMode = DisplayModeEnum::FILE_LIST;
@@ -3030,10 +2975,6 @@ void IGFD::ThumbnailFeature::ManageGPUThumbnails() {
3030
2975
3031
2976
#endif // USE_THUMBNAILS
3032
2977
3033
- #pragma endregion
3034
-
3035
- #pragma region PlacesFeature
3036
-
3037
2978
IGFD::PlacesFeature::PlacesFeature () {
3038
2979
#ifdef USE_PLACES_FEATURE
3039
2980
m_PlacesPaneWidth = defaultPlacePaneWith;
@@ -3265,10 +3206,6 @@ bool IGFD::PlacesFeature::GroupStruct::RemovePlace(const std::string& vPlaceName
3265
3206
}
3266
3207
#endif // USE_PLACES_FEATURE
3267
3208
3268
- #pragma endregion
3269
-
3270
- #pragma region KeyExplorerFeature
3271
-
3272
3209
IGFD::KeyExplorerFeature::KeyExplorerFeature () = default;
3273
3210
3274
3211
#ifdef USE_EXPLORATION_BY_KEYS
@@ -3642,12 +3579,6 @@ void IGFD::KeyExplorerFeature::SetFlashingAttenuationInSeconds(float vAttenValue
3642
3579
}
3643
3580
#endif // USE_EXPLORATION_BY_KEYS
3644
3581
3645
- #pragma endregion
3646
-
3647
- #pragma endregion
3648
-
3649
- #pragma region FileDialog
3650
-
3651
3582
IGFD::FileDialog::FileDialog () : PlacesFeature(), KeyExplorerFeature(), ThumbnailFeature() {
3652
3583
#ifdef USE_PLACES_FEATURE
3653
3584
m_InitPlaces (m_FileDialogInternal);
@@ -4693,14 +4624,8 @@ bool IGFD::FileDialog::m_Confirm_Or_OpenOverWriteFileDialog_IfNeeded(bool vLastA
4693
4624
return false ;
4694
4625
}
4695
4626
4696
- #pragma endregion
4697
-
4698
- #pragma endregion
4699
-
4700
4627
#endif // __cplusplus
4701
4628
4702
- #pragma region IGFD_C_API
4703
-
4704
4629
// return an initialized IGFD_FileDialog_Config
4705
4630
IGFD_C_API IGFD_FileDialog_Config IGFD_FileDialog_Config_Get () {
4706
4631
IGFD_FileDialog_Config res = {};
0 commit comments