| 4345 | } |
| 4346 | |
| 4347 | void IGFD::FileDialog::m_DrawFileListView(ImVec2 vSize) { |
| 4348 | auto& fdi = m_FileDialogInternal.fileManager; |
| 4349 | |
| 4350 | ImGui::PushID(this); |
| 4351 | |
| 4352 | static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable | ImGuiTableFlags_ScrollY | ImGuiTableFlags_NoHostExtendY |
| 4353 | #ifndef USE_CUSTOM_SORTING_ICON |
| 4354 | | ImGuiTableFlags_Sortable |
| 4355 | #endif // USE_CUSTOM_SORTING_ICON |
| 4356 | ; |
| 4357 | const auto listViewID = ImGui::GetID("FileTable"); |
| 4358 | if (ImGui::BeginTableEx("FileTable", listViewID, 4, flags, vSize, 0.0f)) { |
| 4359 | ImGui::TableSetupScrollFreeze(0, 1); // Make header always visible |
| 4360 | ImGui::TableSetupColumn(fdi.headerFileName.c_str(), ImGuiTableColumnFlags_WidthStretch | (defaultSortOrderFilename ? ImGuiTableColumnFlags_PreferSortAscending : ImGuiTableColumnFlags_PreferSortDescending), -1, 0); |
| 4361 | ImGui::TableSetupColumn(fdi.headerFileType.c_str(), |
| 4362 | ImGuiTableColumnFlags_WidthFixed | (defaultSortOrderType ? ImGuiTableColumnFlags_PreferSortAscending : ImGuiTableColumnFlags_PreferSortDescending) | |
| 4363 | ((m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_HideColumnType) ? ImGuiTableColumnFlags_DefaultHide : 0), |
| 4364 | -1, 1); |
| 4365 | ImGui::TableSetupColumn(fdi.headerFileSize.c_str(), |
| 4366 | ImGuiTableColumnFlags_WidthFixed | (defaultSortOrderSize ? ImGuiTableColumnFlags_PreferSortAscending : ImGuiTableColumnFlags_PreferSortDescending) | |
| 4367 | ((m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_HideColumnSize) ? ImGuiTableColumnFlags_DefaultHide : 0), |
| 4368 | -1, 2); |
| 4369 | ImGui::TableSetupColumn(fdi.headerFileDate.c_str(), |
| 4370 | ImGuiTableColumnFlags_WidthFixed | (defaultSortOrderDate ? ImGuiTableColumnFlags_PreferSortAscending : ImGuiTableColumnFlags_PreferSortDescending) | |
| 4371 | ((m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_HideColumnDate) ? ImGuiTableColumnFlags_DefaultHide : 0), |
| 4372 | -1, 3); |
| 4373 | |
| 4374 | #ifndef USE_CUSTOM_SORTING_ICON |
| 4375 | // Sort our data if sort specs have been changed! |
| 4376 | if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs()) { |
| 4377 | if (sorts_specs->SpecsDirty && !fdi.IsFileListEmpty()) { |
| 4378 | bool direction = sorts_specs->Specs->SortDirection == ImGuiSortDirection_Ascending; |
| 4379 | |
| 4380 | if (sorts_specs->Specs->ColumnUserID == 0) { |
| 4381 | fdi.sortingField = IGFD::FileManager::SortingFieldEnum::FIELD_FILENAME; |
| 4382 | fdi.sortingDirection[0] = direction; |
| 4383 | fdi.SortFields(m_FileDialogInternal); |
| 4384 | } else if (sorts_specs->Specs->ColumnUserID == 1) { |
| 4385 | fdi.sortingField = IGFD::FileManager::SortingFieldEnum::FIELD_TYPE; |
| 4386 | fdi.sortingDirection[1] = direction; |
| 4387 | fdi.SortFields(m_FileDialogInternal); |
| 4388 | } else if (sorts_specs->Specs->ColumnUserID == 2) { |
| 4389 | fdi.sortingField = IGFD::FileManager::SortingFieldEnum::FIELD_SIZE; |
| 4390 | fdi.sortingDirection[2] = direction; |
| 4391 | fdi.SortFields(m_FileDialogInternal); |
| 4392 | } else // if (sorts_specs->Specs->ColumnUserID == 3) => alwayd true for the moment, to uncomment if we |
| 4393 | // add a fourth column |
| 4394 | { |
| 4395 | fdi.sortingField = IGFD::FileManager::SortingFieldEnum::FIELD_DATE; |
| 4396 | fdi.sortingDirection[3] = direction; |
| 4397 | fdi.SortFields(m_FileDialogInternal); |
| 4398 | } |
| 4399 | |
| 4400 | sorts_specs->SpecsDirty = false; |
| 4401 | } |
| 4402 | } |
| 4403 | |
| 4404 | ImGui::TableHeadersRow(); |
nothing calls this directly
no test coverage detected