Skip to content

Commit 50c487b

Browse files
committed
[IMP] : change default DateTime Format for just date + hour/min. seconds are removed. can always be customized by the used in custom config file
[RFR] : removes some unused vars [IMP] : improvement, now opening a directory need a double click like on all systems. a simple click on a directory outside of 'directory chooser mode', will not select the directory [FIX] : fix possible buffer overflow in a variadic item
1 parent ea65805 commit 50c487b

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ namespace IGFD
169169
#endif // OverWriteDialogCancelButtonString
170170
// see strftime functionin <ctime> for customize
171171
#ifndef DateTimeFormat
172-
#define DateTimeFormat "%Y/%m/%d %H:%M:%S"
172+
#define DateTimeFormat "%Y/%m/%d %H:%M"
173173
#endif // DateTimeFormat
174174

175175
#ifdef USE_BOOKMARK
@@ -1375,16 +1375,13 @@ namespace IGFD
13751375

13761376
bool IGFD::FileDialog::SelectableItem(int vidx, const FileInfoStruct& vInfos, bool vSelected, const char* vFmt, ...)
13771377
{
1378-
bool needToBreakTheloop = false;
13791378
static ImGuiSelectableFlags selectableFlags = ImGuiSelectableFlags_AllowDoubleClick |
13801379
ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_SpanAvailWidth;
13811380

13821381
va_list args;
13831382
va_start(args, vFmt);
1384-
int w = vsnprintf(VariadicBuffer, MAX_FILE_DIALOG_NAME_BUFFER - 1, vFmt, args);
1383+
vsnprintf(VariadicBuffer, MAX_FILE_DIALOG_NAME_BUFFER, vFmt, args);
13851384
va_end(args);
1386-
if (w)
1387-
VariadicBuffer[w] = '\0';
13881385

13891386
#ifdef USE_EXPLORATION_BY_KEYS
13901387
bool flashed = BeginFlashItem(vidx);
@@ -1393,17 +1390,17 @@ namespace IGFD
13931390
if (flashed)
13941391
EndFlashItem();
13951392
#else // USE_EXPLORATION_BY_KEYS
1396-
res = ImGui::Selectable(VariadicBuffer, selected, selectableFlags);
1393+
bool res = ImGui::Selectable(VariadicBuffer, vSelected, selectableFlags);
13971394
#endif // USE_EXPLORATION_BY_KEYS
13981395
if (res)
13991396
{
14001397
if (vInfos.type == 'd')
14011398
{
1402-
if (!dlg_filters.empty() || ImGui::IsMouseDoubleClicked(0))
1399+
if (ImGui::IsMouseDoubleClicked(0))
14031400
{
14041401
m_PathClicked = SelectDirectory(vInfos);
14051402
}
1406-
else // directory chooser
1403+
else if (dlg_filters.empty()) // directory chooser
14071404
{
14081405
SelectFileName(vInfos);
14091406
}

ImGuiFileDialogConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
// DateTimeFormat
4949
// see strftime functionin <ctime> for customize
50-
// "%Y/%m/%d %H:%M:%S" give 2021:01:22 11:47:10
50+
// "%Y/%m/%d %H:%M" give 2021:01:22 11:47
5151
// "%Y/%m/%d %i:%M%p" give 2021:01:22 11:45PM
5252
//#define DateTimeFormat "%Y/%m/%d %i:%M%p"
5353

0 commit comments

Comments
 (0)