| 4280 | } |
| 4281 | |
| 4282 | void IGFD::FileDialog::m_DrawFileListView(ImVec2 vSize) { |
| 4283 | auto& fdi = m_FileDialogInternal.fileManager; |
| 4284 | |
| 4285 | ImGui::PushID(this); |
| 4286 | |
| 4287 | static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable | ImGuiTableFlags_ScrollY | ImGuiTableFlags_NoHostExtendY |
| 4288 | #ifndef USE_CUSTOM_SORTING_ICON |
| 4289 | | ImGuiTableFlags_Sortable |
| 4290 | #endif // USE_CUSTOM_SORTING_ICON |
| 4291 | ; |
| 4292 | const auto listViewID = ImGui::GetID("FileTable"); |
| 4293 | if (ImGui::BeginTableEx("FileTable", listViewID, 4, flags, vSize, 0.0f)) { |
| 4294 | ImGui::TableSetupScrollFreeze(0, 1); // Make header always visible |
| 4295 | ImGui::TableSetupColumn(fdi.headerFileName.c_str(), ImGuiTableColumnFlags_WidthStretch | (defaultSortOrderFilename ? ImGuiTableColumnFlags_PreferSortAscending : ImGuiTableColumnFlags_PreferSortDescending), -1, 0); |
| 4296 | ImGui::TableSetupColumn(fdi.headerFileType.c_str(), |
| 4297 | ImGuiTableColumnFlags_WidthFixed | (defaultSortOrderType ? ImGuiTableColumnFlags_PreferSortAscending : ImGuiTableColumnFlags_PreferSortDescending) | |
| 4298 | ((m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_HideColumnType) ? ImGuiTableColumnFlags_DefaultHide : 0), |
| 4299 | -1, 1); |
| 4300 | ImGui::TableSetupColumn(fdi.headerFileSize.c_str(), |
| 4301 | ImGuiTableColumnFlags_WidthFixed | (defaultSortOrderSize ? ImGuiTableColumnFlags_PreferSortAscending : ImGuiTableColumnFlags_PreferSortDescending) | |
| 4302 | ((m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_HideColumnSize) ? ImGuiTableColumnFlags_DefaultHide : 0), |
| 4303 | -1, 2); |
| 4304 | ImGui::TableSetupColumn(fdi.headerFileDate.c_str(), |
| 4305 | ImGuiTableColumnFlags_WidthFixed | (defaultSortOrderDate ? ImGuiTableColumnFlags_PreferSortAscending : ImGuiTableColumnFlags_PreferSortDescending) | |
| 4306 | ((m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_HideColumnDate) ? ImGuiTableColumnFlags_DefaultHide : 0), |
| 4307 | -1, 3); |
| 4308 | |
| 4309 | #ifndef USE_CUSTOM_SORTING_ICON |
| 4310 | // Sort our data if sort specs have been changed! |
| 4311 | if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs()) { |
| 4312 | if (sorts_specs->SpecsDirty && !fdi.IsFileListEmpty()) { |
| 4313 | bool direction = sorts_specs->Specs->SortDirection == ImGuiSortDirection_Ascending; |
| 4314 | |
| 4315 | if (sorts_specs->Specs->ColumnUserID == 0) { |
| 4316 | fdi.sortingField = IGFD::FileManager::SortingFieldEnum::FIELD_FILENAME; |
| 4317 | fdi.sortingDirection[0] = direction; |
| 4318 | fdi.SortFields(m_FileDialogInternal); |
| 4319 | } else if (sorts_specs->Specs->ColumnUserID == 1) { |
| 4320 | fdi.sortingField = IGFD::FileManager::SortingFieldEnum::FIELD_TYPE; |
| 4321 | fdi.sortingDirection[1] = direction; |
| 4322 | fdi.SortFields(m_FileDialogInternal); |
| 4323 | } else if (sorts_specs->Specs->ColumnUserID == 2) { |
| 4324 | fdi.sortingField = IGFD::FileManager::SortingFieldEnum::FIELD_SIZE; |
| 4325 | fdi.sortingDirection[2] = direction; |
| 4326 | fdi.SortFields(m_FileDialogInternal); |
| 4327 | } else // if (sorts_specs->Specs->ColumnUserID == 3) => alwayd true for the moment, to uncomment if we |
| 4328 | // add a fourth column |
| 4329 | { |
| 4330 | fdi.sortingField = IGFD::FileManager::SortingFieldEnum::FIELD_DATE; |
| 4331 | fdi.sortingDirection[3] = direction; |
| 4332 | fdi.SortFields(m_FileDialogInternal); |
| 4333 | } |
| 4334 | |
| 4335 | sorts_specs->SpecsDirty = false; |
| 4336 | } |
| 4337 | } |
| 4338 | |
| 4339 | ImGui::TableHeadersRow(); |
nothing calls this directly
no test coverage detected