From 6673b211f3a4dff9ed0908ed221a09712e17762a Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Tue, 7 Jan 2025 13:17:33 -0500 Subject: [PATCH] Add a navigation menu for easier accessible nav Basically let you hop around the UI in a menu bound to cmd n. Closes #22 --- src/ui/main-panel.cpp | 5 ++ src/ui/matrix-panel.cpp | 6 ++ src/ui/mixer-panel.cpp | 5 ++ src/ui/six-sines-editor.cpp | 135 +++++++++++++++++++++++++++++++++++- src/ui/six-sines-editor.h | 2 + src/ui/source-panel.cpp | 5 ++ 6 files changed, 157 insertions(+), 1 deletion(-) diff --git a/src/ui/main-panel.cpp b/src/ui/main-panel.cpp index 6e6469a..cecde9f 100644 --- a/src/ui/main-panel.cpp +++ b/src/ui/main-panel.cpp @@ -94,6 +94,11 @@ void MainPanel::resized() void MainPanel::mouseDown(const juce::MouseEvent &e) { + if (e.mods.isPopupMenu()) + { + editor.showNavigationMenu(); + return; + } for (int i = 0; i < numOps; ++i) { if (rectangleFor(i).contains(e.position.toInt())) diff --git a/src/ui/matrix-panel.cpp b/src/ui/matrix-panel.cpp index 5678cd9..f4dae31 100644 --- a/src/ui/matrix-panel.cpp +++ b/src/ui/matrix-panel.cpp @@ -162,6 +162,12 @@ void MatrixPanel::paint(juce::Graphics &g) void MatrixPanel::mouseDown(const juce::MouseEvent &e) { + if (e.mods.isPopupMenu()) + { + editor.showNavigationMenu(); + return; + } + for (int i = 0; i < numOps; ++i) { if (rectangleFor(i, true).contains(e.position.toInt())) diff --git a/src/ui/mixer-panel.cpp b/src/ui/mixer-panel.cpp index 586ce36..928c15a 100644 --- a/src/ui/mixer-panel.cpp +++ b/src/ui/mixer-panel.cpp @@ -83,6 +83,11 @@ void MixerPanel::resized() void MixerPanel::mouseDown(const juce::MouseEvent &e) { + if (e.mods.isPopupMenu()) + { + editor.showNavigationMenu(); + return; + } for (int i = 0; i < numOps; ++i) { if (rectangleFor(i).contains(e.position.toInt())) diff --git a/src/ui/six-sines-editor.cpp b/src/ui/six-sines-editor.cpp index 9bde21b..bcc4640 100644 --- a/src/ui/six-sines-editor.cpp +++ b/src/ui/six-sines-editor.cpp @@ -711,11 +711,144 @@ void SixSinesEditor::postPatchChange(const std::string &dn) repaint(); } +void SixSinesEditor::showNavigationMenu() +{ + auto p = juce::PopupMenu(); + p.addSectionHeader("Navigation"); + p.addSeparator(); + p.addItem("Preset Browser", + [w = juce::Component::SafePointer(this)]() + { + if (w) + { + w->presetButton->grabKeyboardFocus(); + } + }); + p.addSeparator(); + + auto src = juce::PopupMenu(); + for (int i = 0; i < numOps; ++i) + { + src.addItem(sourcePanel->knobs[i]->getTitle(), + [i, w = juce::Component::SafePointer(this)]() + { + if (w) + { + w->sourcePanel->beginEdit(i); + w->sourcePanel->knobs[i]->grabKeyboardFocus(); + } + }); + } + p.addSubMenu("Sources", src); + + auto fb = juce::PopupMenu(); + for (int i = 0; i < numOps; ++i) + { + fb.addItem(matrixPanel->Sknobs[i]->getTitle(), + [i, w = juce::Component::SafePointer(this)]() + { + if (w) + { + w->matrixPanel->beginEdit(i, true); + w->matrixPanel->Sknobs[i]->grabKeyboardFocus(); + } + }); + } + p.addSubMenu("Matrix Feedback", fb); + + auto md = juce::PopupMenu(); + for (int i = 0; i < matrixSize; ++i) + { + md.addItem(matrixPanel->Mknobs[i]->getTitle(), + [i, w = juce::Component::SafePointer(this)]() + { + if (w) + { + w->matrixPanel->beginEdit(i, false); + w->matrixPanel->Mknobs[i]->grabKeyboardFocus(); + } + }); + } + p.addSubMenu("Matrix Modulation", md); + + auto mx = juce::PopupMenu(); + for (int i = 0; i < numOps; ++i) + { + mx.addItem(mixerPanel->knobs[i]->getTitle(), + [i, w = juce::Component::SafePointer(this)]() + { + if (w) + { + w->mixerPanel->beginEdit(i); + w->mixerPanel->knobs[i]->grabKeyboardFocus(); + } + }); + } + p.addSubMenu("Mixer", mx); + + auto mc = juce::PopupMenu(); + for (int i = 0; i < numOps; ++i) + { + mc.addItem(macroPanel->knobs[i]->getTitle(), + [i, w = juce::Component::SafePointer(this)]() + { + if (w) + { + w->macroPanel->knobs[i]->grabKeyboardFocus(); + } + }); + } + p.addSubMenu("Macros", mc); + + auto mn = juce::PopupMenu(); + int idx{0}; + for (const auto &l : {&mainPanel->lev, &mainPanel->pan, &mainPanel->tun}) + { + mn.addItem((*l)->getTitle(), + [idx, x = (*l).get(), w = juce::Component::SafePointer(this)]() + { + if (w) + { + w->mainPanel->beginEdit(idx); + x->grabKeyboardFocus(); + } + }); + idx++; + } + p.addSubMenu("Main", mn); + + p.addSeparator(); + + auto enam = std::string("Edit Area"); + if (!singlePanel->getName().isEmpty()) + enam = "Edit " + singlePanel->getName().toStdString(); + p.addItem(enam, + [w = juce::Component::SafePointer(this)]() + { + if (w) + { + w->singlePanel->grabKeyboardFocus(); + } + }); + + p.addItem("Settings", + [w = juce::Component::SafePointer(this)]() + { + if (w) + { + w->mainPanel->beginEdit(3); + w->singlePanel->grabKeyboardFocus(); + } + }); + + p.showMenuAsync(juce::PopupMenu::Options().withParentComponent(this)); +} + bool SixSinesEditor::keyPressed(const juce::KeyPress &key) { if (key.getModifiers().isCommandDown() && (char)key.getKeyCode() == 'N') { - SXSNLOG("Navigation Menu"); + showNavigationMenu(); return true; } diff --git a/src/ui/six-sines-editor.h b/src/ui/six-sines-editor.h index 38941e9..825a4bd 100644 --- a/src/ui/six-sines-editor.h +++ b/src/ui/six-sines-editor.h @@ -122,6 +122,8 @@ struct SixSinesEditor : jcmp::WindowPanel bool keyPressed(const juce::KeyPress &key) override; + void showNavigationMenu(); + std::unique_ptr vuMeter; // To turn this on, recompile with it on in six-sines-editor.cpp diff --git a/src/ui/source-panel.cpp b/src/ui/source-panel.cpp index adf4bd3..f4f59d2 100644 --- a/src/ui/source-panel.cpp +++ b/src/ui/source-panel.cpp @@ -64,6 +64,11 @@ void SourcePanel::resized() void SourcePanel::mouseDown(const juce::MouseEvent &e) { + if (e.mods.isPopupMenu()) + { + editor.showNavigationMenu(); + return; + } for (int i = 0; i < numOps; ++i) { if (rectangleFor(i).contains(e.position.toInt()))