Skip to content

Commit

Permalink
Add a navigation menu for easier accessible nav (#104)
Browse files Browse the repository at this point in the history
* Add a navigation menu for easier accessible nav

Basically let you hop around the UI in a menu bound to
cmd n.

Closes #22

* And add Andreya's last minute patch

* log
  • Loading branch information
baconpaul authored Jan 7, 2025
1 parent fa3d402 commit 25df770
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libs/sst/sst-voicemanager
1 change: 1 addition & 0 deletions resources/factory_patches/Keys/Out With The New.sxsnp

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/ui/main-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
6 changes: 6 additions & 0 deletions src/ui/matrix-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
5 changes: 5 additions & 0 deletions src/ui/mixer-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
135 changes: 134 additions & 1 deletion src/ui/six-sines-editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/ui/six-sines-editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ struct SixSinesEditor : jcmp::WindowPanel

bool keyPressed(const juce::KeyPress &key) override;

void showNavigationMenu();

std::unique_ptr<jcmp::VUMeter> vuMeter;

// To turn this on, recompile with it on in six-sines-editor.cpp
Expand Down
5 changes: 5 additions & 0 deletions src/ui/source-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit 25df770

Please sign in to comment.