MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / m_ExploreWithkeys

Method m_ExploreWithkeys

external/ImGuiFileDialog/ImGuiFileDialog.cpp:3509–3620  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3507}
3508
3509void IGFD::KeyExplorerFeature::m_ExploreWithkeys(FileDialogInternal& vFileDialogInternal, ImGuiID vListViewID) {
3510 auto& fdi = vFileDialogInternal.fileManager;
3511 if (!fdi.IsFilteredListEmpty()) {
3512 bool canWeExplore = false;
3513 bool hasNav = (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard);
3514
3515 ImGuiContext& g = *GImGui;
3516 if (!hasNav && !g.ActiveId) // no nav and no activated inputs
3517 canWeExplore = true;
3518
3519 if (g.NavId && g.NavId == vListViewID) {
3520 if (ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_KeypadEnter) || ImGui::IsKeyPressed(ImGuiKey_Space)) {
3521 ImGui::ActivateItemByID(vListViewID);
3522 ImGui::SetActiveID(vListViewID, g.CurrentWindow);
3523 }
3524 }
3525
3526 if (vListViewID == g.LastActiveId - 1) // if listview id is the last acticated nav id (ImGui::ActivateItemByID(vListViewID);)
3527 canWeExplore = true;
3528
3529 if (canWeExplore && ImGui::IsWindowFocused()) {
3530 if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
3531 ImGui::ClearActiveID();
3532 g.LastActiveId = 0;
3533 }
3534
3535 auto countFiles = fdi.GetFilteredListSize();
3536
3537 // explore
3538 bool exploreByKey = false;
3539 bool enterInDirectory = false;
3540 bool exitDirectory = false;
3541
3542 if ((hasNav && ImGui::IsKeyPressed(ImGuiKey_UpArrow)) || (!hasNav && ImGui::IsKeyPressed(ImGuiKey_UpArrow))) {
3543 exploreByKey = true;
3544 if (m_LocateFileByInputChar_lastFileIdx > 0)
3545 m_LocateFileByInputChar_lastFileIdx--;
3546 else
3547 m_LocateFileByInputChar_lastFileIdx = countFiles - 1U;
3548 } else if ((hasNav && ImGui::IsKeyPressed(ImGuiKey_DownArrow)) || (!hasNav && ImGui::IsKeyPressed(ImGuiKey_DownArrow))) {
3549 exploreByKey = true;
3550 if (m_LocateFileByInputChar_lastFileIdx < countFiles - 1U)
3551 m_LocateFileByInputChar_lastFileIdx++;
3552 else
3553 m_LocateFileByInputChar_lastFileIdx = 0U;
3554 } else if (ImGui::IsKeyReleased(ImGuiKey_Enter)) {
3555 exploreByKey = true;
3556 enterInDirectory = true;
3557 } else if (ImGui::IsKeyReleased(ImGuiKey_Backspace)) {
3558 exploreByKey = true;
3559 exitDirectory = true;
3560 }
3561
3562 if (exploreByKey) {
3563 // float totalHeight = m_FilteredFileList.size() * ImGui::GetTextLineHeightWithSpacing();
3564 float p = (float)((double)m_LocateFileByInputChar_lastFileIdx / (double)(countFiles - 1U)) * ImGui::GetScrollMaxY(); // seems not udpated in tables version outside tables
3565 // float p = ((float)locateFileByInputChar_lastFileIdx) * ImGui::GetTextLineHeightWithSpacing();
3566 ImGui::SetScrollY(p);

Callers

nothing calls this directly

Calls 11

IsFilteredListEmptyMethod · 0.80
GetFilteredListSizeMethod · 0.80
GetFilteredFileAtMethod · 0.80
isDirMethod · 0.80
SelectDirectoryMethod · 0.80
OpenCurrentPathMethod · 0.80
SelectFileNameMethod · 0.80
GetComposerSizeMethod · 0.80
GetDevicesMethod · 0.80
ifFunction · 0.50

Tested by

no test coverage detected