@@ -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
@@ -1302,64 +1302,36 @@ namespace IGFD
13021302 else
13031303 str = fileEntryString + str;
13041304 }
1305- bool selected = false ;
1306- if (m_SelectedFileNames.find (infos.fileName ) != m_SelectedFileNames.end ()) // found
1307- selected = true ;
1305+ bool selected = (m_SelectedFileNames.find (infos.fileName ) != m_SelectedFileNames.end ()); // found
13081306 ImGui::TableNextRow ();
1309- if (ImGui::TableSetColumnIndex (0 )) // first column
1310- {
1311- ImGuiSelectableFlags selectableFlags = ImGuiSelectableFlags_AllowDoubleClick;
1312- selectableFlags |=
1313- ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_SpanAvailWidth;
13141307
1315- bool _selectablePressed = false ;
1316- #ifdef USE_EXPLORATION_BY_KEYS
1317- bool flashed = BeginFlashItem (i);
1318- _selectablePressed = FlashableSelectable (str.c_str (), selected, selectableFlags,
1319- flashed);
1320- if (flashed)
1321- EndFlashItem ();
1322- #else // USE_EXPLORATION_BY_KEYS
1323- _selectablePressed = ImGui::Selectable (str.c_str (), selected, selectableFlags);
1324- #endif // USE_EXPLORATION_BY_KEYS
1325- if (_selectablePressed)
1326- {
1327- if (infos.type == ' d' )
1328- {
1329- if (!dlg_filters.empty () || ImGui::IsMouseDoubleClicked (0 ))
1330- {
1331- m_PathClicked = SelectDirectory (infos);
1332- }
1333- else // directory chooser
1334- {
1335- SelectFileName (infos);
1336- }
1337-
1338- if (showColor)
1339- ImGui::PopStyleColor ();
1308+ bool needToBreakTheloop = false ;
13401309
1341- break ;
1342- }
1343- else
1344- {
1345- SelectFileName (infos);
1346- }
1347- }
1310+ if (ImGui::TableSetColumnIndex (0 )) // first column
1311+ {
1312+ needToBreakTheloop = SelectableItem (i, infos, selected, str.c_str ());
13481313 }
13491314 if (ImGui::TableSetColumnIndex (1 )) // second column
13501315 {
13511316 if (infos.type != ' d' )
13521317 {
1353- ImGui::Text (" %s " , infos.formatedFileSize .c_str ()); // -V111
1318+ needToBreakTheloop = SelectableItem (i, infos, selected, " %s " , infos.formatedFileSize .c_str ());
1319+ }
1320+ else
1321+ {
1322+ needToBreakTheloop = SelectableItem (i, infos, selected, " " );
13541323 }
13551324 }
13561325 if (ImGui::TableSetColumnIndex (2 )) // third column
13571326 {
1358- ImGui::Text ( " %s" , infos.fileModifDate .c_str ()); // -V111
1327+ needToBreakTheloop = SelectableItem (i, infos, selected, " %s" , infos.fileModifDate .c_str ());
13591328 }
1329+
13601330 if (showColor)
13611331 ImGui::PopStyleColor ();
13621332
1333+ if (needToBreakTheloop)
1334+ break ;
13631335 }
13641336 }
13651337 m_FileListClipper.End ();
@@ -1401,6 +1373,50 @@ namespace IGFD
14011373 ImGui::EndChild ();
14021374 }
14031375
1376+ bool IGFD::FileDialog::SelectableItem (int vidx, const FileInfoStruct& vInfos, bool vSelected, const char * vFmt, ...)
1377+ {
1378+ static ImGuiSelectableFlags selectableFlags = ImGuiSelectableFlags_AllowDoubleClick |
1379+ ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_SpanAvailWidth;
1380+
1381+ va_list args;
1382+ va_start (args, vFmt);
1383+ vsnprintf (VariadicBuffer, MAX_FILE_DIALOG_NAME_BUFFER, vFmt, args);
1384+ va_end (args);
1385+
1386+ #ifdef USE_EXPLORATION_BY_KEYS
1387+ bool flashed = BeginFlashItem (vidx);
1388+ bool res = FlashableSelectable (VariadicBuffer, vSelected, selectableFlags,
1389+ flashed);
1390+ if (flashed)
1391+ EndFlashItem ();
1392+ #else // USE_EXPLORATION_BY_KEYS
1393+ (void )vidx; // remove a warnings ofr unused var
1394+ bool res = ImGui::Selectable (VariadicBuffer, vSelected, selectableFlags);
1395+ #endif // USE_EXPLORATION_BY_KEYS
1396+ if (res)
1397+ {
1398+ if (vInfos.type == ' d' )
1399+ {
1400+ if (ImGui::IsMouseDoubleClicked (0 ))
1401+ {
1402+ m_PathClicked = SelectDirectory (vInfos);
1403+ }
1404+ else if (dlg_filters.empty ()) // directory chooser
1405+ {
1406+ SelectFileName (vInfos);
1407+ }
1408+
1409+ return true ; // needToBreakTheloop
1410+ }
1411+ else
1412+ {
1413+ SelectFileName (vInfos);
1414+ }
1415+ }
1416+
1417+ return false ;
1418+ }
1419+
14041420 void IGFD::FileDialog::DrawSidePane (float vHeight)
14051421 {
14061422 ImGui::SameLine ();
0 commit comments