Skip to content

Commit

Permalink
Step Sequencer RMB / Edit Part 1 (#6805)
Browse files Browse the repository at this point in the history
This opens a menu on the RMB gesture on the step sequencer and
preserves the right drag with a timer; it links to documentation
properly and formats the item. The only thing we need to do now is
to pop upen the edit box and figure out what else we want on this
menu. Neither of those are easy so checkpointing along the way.

Menu pops from both mouse and accessible gestures.

Addesses #6516

foo
  • Loading branch information
baconpaul authored Jan 14, 2023
1 parent 21bfcdb commit fbcf047
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
1 change: 1 addition & 0 deletions resources/surge-shared/paramdocumentation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<special id="patch-navigation" help_url="#navigation"/>
<special id="save-dialog" help_url="#the-save-dialog"/>
<special id="wavetables" help_url="#wavetable"/>
<special id="step-sequencer" help_url="#step-sequencer"/>
<special id="mseg-editor" help_url="#multi-segment-envelope-generator"/>
<special id="formula-editor" help_url="#formula"/>
<special id="mod-list" help_url="#modulation-list"/>
Expand Down
7 changes: 7 additions & 0 deletions src/surge-xt/gui/AccessibleHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ template <typename T> struct OverlayAsAccessibleSlider : public juce::Component
std::function<void(T *, int, bool, bool)> onJogValue = [](T *, int, bool, bool) {
jassert(false);
};
std::function<void(T *)> onMenuKey = [](T *) {};
// called with 1 0 -1 for max default min
std::function<void(T *, int)> onMinMaxDef = [](T *, int) {};

Expand Down Expand Up @@ -549,6 +550,12 @@ template <typename T> bool OverlayAsAccessibleSlider<T>::keyPressed(const juce::
ah->notifyAccessibilityEvent(juce::AccessibilityEvent::valueChanged);
return true;
}

if (action == OpenMenu)
{
onMenuKey(under);
return true;
}
return false;
}

Expand Down
53 changes: 52 additions & 1 deletion src/surge-xt/gui/widgets/LFOAndStepDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ LFOAndStepDisplay::LFOAndStepDisplay(SurgeGUIEditor *e)
stepSeqDirty();
repaint();
};
q->onMenuKey = [this, i](auto *t) { showStepRMB(i); };
stepLayer->addChildComponent(*q);
stepSliderOverlays[i] = std::move(q);
}
Expand Down Expand Up @@ -1675,6 +1676,12 @@ void LFOAndStepDisplay::mouseDown(const juce::MouseEvent &event)
dragMode = ARROW;
arrowStart = event.position;
arrowEnd = event.position;
juce::Timer::callAfterDelay(
1000, [w = juce::Component::SafePointer(this), event] {
if (w && w->dragMode == ARROW &&
w->arrowStart.getDistanceSquaredFrom(w->arrowEnd) < 2)
w->showStepRMB(event);
});
}
else
{
Expand Down Expand Up @@ -2057,7 +2064,12 @@ void LFOAndStepDisplay::mouseUp(const juce::MouseEvent &event)
}
}

if (dragMode == ARROW)
if (dragMode == ARROW && (!event.mouseWasDraggedSinceMouseDown() ||
(arrowStart.getDistanceSquaredFrom(arrowEnd) < 2)))
{
showStepRMB(event);
}
else if (dragMode == ARROW)
{
auto l = juce::Line<float>{arrowStart, arrowEnd};

Expand Down Expand Up @@ -2461,5 +2473,44 @@ void LFOAndStepDisplay::stepSeqDirty()
guiEditor->undoManager()->pushStepSequencer(scene, lfoid, undoStorageCopy);
}

void LFOAndStepDisplay::showStepRMB(const juce::MouseEvent &event)
{
dragMode = NONE;

for (int i = 0; i < n_stepseqsteps; ++i)
{
if (steprect[i].contains(event.position))
{
showStepRMB(i);
}
}
}

void LFOAndStepDisplay::showStepRMB(int i)
{

auto contextMenu = juce::PopupMenu();

std::string olname = "Step Sequencer";
std::string helpname = "step-sequencer";

auto msurl = storage ? SurgeGUIEditor::helpURLForSpecial(storage, helpname) : std::string();
auto hurl = SurgeGUIEditor::fullyResolvedHelpURL(msurl);

auto hmen = std::make_unique<Surge::Widgets::MenuTitleHelpComponent>(olname, hurl);
hmen->setSkin(skin, associatedBitmapStore);
auto hment = hmen->getTitle();

contextMenu.addCustomItem(-1, std::move(hmen), nullptr, hment);

contextMenu.addSeparator();

auto msg = fmt::format("Edit Step {}: {:.3f}", i + 1, ss->steps[i]);
contextMenu.addItem(Surge::GUI::toOSCase(msg), true, false,
[i]() { std::cout << "Would edit step " << i << std::endl; });

contextMenu.showMenuAsync(guiEditor->popupMenuOptions());
}

} // namespace Widgets
} // namespace Surge
3 changes: 3 additions & 0 deletions src/surge-xt/gui/widgets/LFOAndStepDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ struct LFOAndStepDisplay : public juce::Component,
const juce::MouseWheelDetails &wheel) override;
void mouseExit(const juce::MouseEvent &event) override;

void showStepRMB(const juce::MouseEvent &);
void showStepRMB(int step);

void endHover() override
{
if (stuckHover)
Expand Down

0 comments on commit fbcf047

Please sign in to comment.