From dd50bd024923c2af0bff73f976844fea498ff66b Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 13 Jan 2025 01:14:57 -0600 Subject: [PATCH] [studio] Remap toggle explorer keyboard shortcut, add Ctrl+1-0 mappings for jumping between tabs --- src/olympic/studio/applib/src/studioapp.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/olympic/studio/applib/src/studioapp.cpp b/src/olympic/studio/applib/src/studioapp.cpp index 1fbea6eb..c9a70da7 100644 --- a/src/olympic/studio/applib/src/studioapp.cpp +++ b/src/olympic/studio/applib/src/studioapp.cpp @@ -82,7 +82,7 @@ StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexce } } -void StudioUI::handleKeyEvent(turbine::Key key, bool down) noexcept { +void StudioUI::handleKeyEvent(turbine::Key const key, bool const down) noexcept { for (auto p : m_popups) { if (p->isOpen()) { if (key == turbine::Key::Escape) { @@ -168,7 +168,7 @@ void StudioUI::drawMenu() noexcept { ImGui::EndMenu(); } if (ImGui::BeginMenu("View")) { - if (ImGui::MenuItem("Project Explorer", "Ctrl+1", m_showProjectExplorer)) { + if (ImGui::MenuItem("Project Explorer", "Ctrl+Shift+1", m_showProjectExplorer)) { toggleProjectExplorer(); } ImGui::EndMenu(); @@ -317,8 +317,22 @@ void StudioUI::handleKeyInput() noexcept { } else if (ImGui::IsKeyPressed(ImGuiKey_Z)) { auto const undoStack = m_activeEditor ? m_activeEditor->undoStack() : nullptr; if (undoStack) { oxLogError(undoStack->undo()); } - } else if (ImGui::IsKeyPressed(ImGuiKey_1)) { + } else if (ImGui::IsKeyPressed(ImGuiKey_1) && ImGui::IsKeyPressed(ImGuiKey_ModShift)) { toggleProjectExplorer(); + } else { + if (!m_editors.empty()) { + auto const range = ox::min(9u, m_editors.size()) - 1; + for (auto i = 0u; i < 9; ++i) { + if (ImGui::IsKeyPressed(static_cast(static_cast(ImGuiKey_1) + i))) { + m_activeEditor = m_editors[i < m_editors.size() ? i : range].get(); + m_activeEditorUpdatePending = m_activeEditor; + } + } + if (ImGui::IsKeyPressed(ImGuiKey_0)) { + m_activeEditor = m_editors[10 < m_editors.size() ? 10 : range].get(); + m_activeEditorUpdatePending = m_activeEditor; + } + } } } }