| 3445 | } |
| 3446 | |
| 3447 | void IGFD::KeyExplorerFeature::m_ExploreWithkeys(FileDialogInternal& vFileDialogInternal, ImGuiID vListViewID) { |
| 3448 | auto& fdi = vFileDialogInternal.fileManager; |
| 3449 | if (!fdi.IsFilteredListEmpty()) { |
| 3450 | bool canWeExplore = false; |
| 3451 | bool hasNav = (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard); |
| 3452 | |
| 3453 | ImGuiContext& g = *GImGui; |
| 3454 | if (!hasNav && !g.ActiveId) // no nav and no activated inputs |
| 3455 | canWeExplore = true; |
| 3456 | |
| 3457 | if (g.NavId && g.NavId == vListViewID) { |
| 3458 | if (ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_KeypadEnter) || ImGui::IsKeyPressed(ImGuiKey_Space)) { |
| 3459 | ImGui::ActivateItemByID(vListViewID); |
| 3460 | ImGui::SetActiveID(vListViewID, g.CurrentWindow); |
| 3461 | } |
| 3462 | } |
| 3463 | |
| 3464 | if (vListViewID == g.LastActiveId - 1) // if listview id is the last acticated nav id (ImGui::ActivateItemByID(vListViewID);) |
| 3465 | canWeExplore = true; |
| 3466 | |
| 3467 | if (canWeExplore && ImGui::IsWindowFocused()) { |
| 3468 | if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { |
| 3469 | ImGui::ClearActiveID(); |
| 3470 | g.LastActiveId = 0; |
| 3471 | } |
| 3472 | |
| 3473 | auto countFiles = fdi.GetFilteredListSize(); |
| 3474 | |
| 3475 | // explore |
| 3476 | bool exploreByKey = false; |
| 3477 | bool enterInDirectory = false; |
| 3478 | bool exitDirectory = false; |
| 3479 | |
| 3480 | if ((hasNav && ImGui::IsKeyPressed(ImGuiKey_UpArrow)) || (!hasNav && ImGui::IsKeyPressed(ImGuiKey_UpArrow))) { |
| 3481 | exploreByKey = true; |
| 3482 | if (m_LocateFileByInputChar_lastFileIdx > 0) |
| 3483 | m_LocateFileByInputChar_lastFileIdx--; |
| 3484 | else |
| 3485 | m_LocateFileByInputChar_lastFileIdx = countFiles - 1U; |
| 3486 | } else if ((hasNav && ImGui::IsKeyPressed(ImGuiKey_DownArrow)) || (!hasNav && ImGui::IsKeyPressed(ImGuiKey_DownArrow))) { |
| 3487 | exploreByKey = true; |
| 3488 | if (m_LocateFileByInputChar_lastFileIdx < countFiles - 1U) |
| 3489 | m_LocateFileByInputChar_lastFileIdx++; |
| 3490 | else |
| 3491 | m_LocateFileByInputChar_lastFileIdx = 0U; |
| 3492 | } else if (ImGui::IsKeyReleased(ImGuiKey_Enter)) { |
| 3493 | exploreByKey = true; |
| 3494 | enterInDirectory = true; |
| 3495 | } else if (ImGui::IsKeyReleased(ImGuiKey_Backspace)) { |
| 3496 | exploreByKey = true; |
| 3497 | exitDirectory = true; |
| 3498 | } |
| 3499 | |
| 3500 | if (exploreByKey) { |
| 3501 | // float totalHeight = m_FilteredFileList.size() * ImGui::GetTextLineHeightWithSpacing(); |
| 3502 | float p = (float)((double)m_LocateFileByInputChar_lastFileIdx / (double)(countFiles - 1U)) * ImGui::GetScrollMaxY(); // seems not udpated in tables version outside tables |
| 3503 | // float p = ((float)locateFileByInputChar_lastFileIdx) * ImGui::GetTextLineHeightWithSpacing(); |
| 3504 | ImGui::SetScrollY(p); |
nothing calls this directly
no test coverage detected