Skip to content

Commit 6fa1a7b

Browse files
committed
[ADD] : add a flag for disable the thumbnail view mode (by ex if we want to select a file who is not a picture)
1 parent 454de08 commit 6fa1a7b

2 files changed

Lines changed: 38 additions & 22 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3453,10 +3453,13 @@ namespace IGFD
34533453
prFileDialogInternal.puFileManager.DrawPathComposer(prFileDialogInternal);
34543454

34553455
#ifdef USE_THUMBNAILS
3456-
prDrawDisplayModeToolBar();
3457-
ImGui::SameLine();
3458-
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
3459-
ImGui::SameLine();
3456+
if (!(prFileDialogInternal.puDLGflags & ImGuiFileDialogFlags_DisableThumbnailMode))
3457+
{
3458+
prDrawDisplayModeToolBar();
3459+
ImGui::SameLine();
3460+
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
3461+
ImGui::SameLine();
3462+
}
34603463
#endif // USE_THUMBNAILS
34613464

34623465
prFileDialogInternal.puSearchManager.DrawSearchBar(prFileDialogInternal);
@@ -3492,16 +3495,23 @@ namespace IGFD
34923495
}
34933496

34943497
#ifdef USE_THUMBNAILS
3495-
switch (prDisplayMode)
3498+
if (prFileDialogInternal.puDLGflags & ImGuiFileDialogFlags_DisableThumbnailMode)
34963499
{
3497-
case DisplayModeEnum::FILE_LIST:
34983500
prDrawFileListView(size);
3499-
break;
3500-
case DisplayModeEnum::THUMBNAILS_LIST:
3501-
prDrawThumbnailsListView(size);
3502-
break;
3503-
case DisplayModeEnum::THUMBNAILS_GRID:
3504-
prDrawThumbnailsGridView(size);
3501+
}
3502+
else
3503+
{
3504+
switch (prDisplayMode)
3505+
{
3506+
case DisplayModeEnum::FILE_LIST:
3507+
prDrawFileListView(size);
3508+
break;
3509+
case DisplayModeEnum::THUMBNAILS_LIST:
3510+
prDrawThumbnailsListView(size);
3511+
break;
3512+
case DisplayModeEnum::THUMBNAILS_GRID:
3513+
prDrawThumbnailsGridView(size);
3514+
}
35053515
}
35063516
#else
35073517
prDrawFileListView(size);

ImGuiFileDialog.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ enum ImGuiFileDialogFlags_
572572
ImGuiFileDialogFlags_HideColumnType = (1 << 3), // hide column file type
573573
ImGuiFileDialogFlags_HideColumnSize = (1 << 4), // hide column file size
574574
ImGuiFileDialogFlags_HideColumnDate = (1 << 5), // hide column file date
575+
#ifdef USE_THUMBNAILS
576+
ImGuiFileDialogFlags_DisableThumbnailMode = (1 << 6), // disable the thumbnail mode
577+
#endif
575578
ImGuiFileDialogFlags_Default = ImGuiFileDialogFlags_ConfirmOverwrite
576579
};
577580

@@ -1177,20 +1180,20 @@ namespace IGFD
11771180
void Close(); // close dialog
11781181

11791182
// queries
1180-
bool WasOpenedThisFrame(const std::string& vKey) const; // say if the dialog key was already opened this frame
1181-
bool WasOpenedThisFrame() const; // say if the dialog was already opened this frame
1182-
bool IsOpened(const std::string& vKey) const; // say if the key is opened
1183-
bool IsOpened() const; // say if the dialog is opened somewhere
1184-
std::string GetOpenedKey() const; // return the dialog key who is opened, return nothing if not opened
1183+
bool WasOpenedThisFrame(const std::string& vKey) const; // say if the dialog key was already opened this frame
1184+
bool WasOpenedThisFrame() const; // say if the dialog was already opened this frame
1185+
bool IsOpened(const std::string& vKey) const; // say if the key is opened
1186+
bool IsOpened() const; // say if the dialog is opened somewhere
1187+
std::string GetOpenedKey() const; // return the dialog key who is opened, return nothing if not opened
11851188

11861189
// get result
1187-
bool IsOk() const; // true => Dialog Closed with Ok result / false : Dialog closed with cancel result
1190+
bool IsOk() const; // true => Dialog Closed with Ok result / false : Dialog closed with cancel result
11881191
std::map<std::string, std::string> GetSelection(); // Open File behavior : will return selection via a map<FileName, FilePathName>
11891192
std::string GetFilePathName(); // Save File behavior : will always return the content of the field with current filter extention and current path
11901193
std::string GetCurrentFileName(); // Save File behavior : will always return the content of the field with current filter extention
11911194
std::string GetCurrentPath(); // will return current path
11921195
std::string GetCurrentFilter(); // will return selected filter
1193-
UserDatas GetUserDatas() const; // will return user datas send with Open Dialog/Modal
1196+
UserDatas GetUserDatas() const; // will return user datas send with Open Dialog/Modal
11941197

11951198
// extentions displaying
11961199
void SetExtentionInfos( // SetExtention datas for have custom display of particular file type
@@ -1207,7 +1210,7 @@ namespace IGFD
12071210
void ClearExtentionInfos(); // clear extentions setttings
12081211

12091212
void SetLocales( // set locales to use before and after the dialog display
1210-
const int& vLocaleCategory, // set local category
1213+
const int& vLocaleCategory, // set local category
12111214
const std::string& vLocaleBegin, // locale to use at begining of the dialog display
12121215
const std::string& vLocaleEnd); // locale to use at the end of the dialog display
12131216

@@ -1217,7 +1220,8 @@ namespace IGFD
12171220
void QuitFrame(); // quit frame when qui quit the dialog
12181221

12191222
// others
1220-
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)
1223+
bool prConfirm_Or_OpenOverWriteFileDialog_IfNeeded(
1224+
bool vLastAction, ImGuiWindowFlags vFlags); // treatment of the result, start the confirm to overwrite dialog if needed (if defined with flag)
12211225

12221226
public:
12231227
// dialog parts
@@ -1227,7 +1231,9 @@ namespace IGFD
12271231

12281232
// widgets components
12291233
virtual void prDrawSidePane(float vHeight); // draw side pane
1230-
virtual bool prSelectableItem(int vidx, std::shared_ptr<FileInfos> vInfos, bool vSelected, const char* vFmt, ...);
1234+
virtual bool prSelectableItem(int vidx,
1235+
std::shared_ptr<FileInfos> vInfos,
1236+
bool vSelected, const char* vFmt, ...); // draw a custom selectable behavior item
12311237
virtual void prDrawFileListView(ImVec2 vSize); // draw file list view (default mode)
12321238

12331239
#ifdef USE_THUMBNAILS

0 commit comments

Comments
 (0)