From 03373f93ec502dd0513221e5ea771cf9a731add6 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 1 Dec 2024 13:54:48 -0500 Subject: [PATCH] Some WT Script Tweaks (#7888) 1. Menu in OSC RMB 2. Don't blow up n times if you have a frame error in filmstrip mode 3. Hand currsor on enter not just drag. Addresses #4539 --- src/surge-xt/gui/overlays/LuaEditors.cpp | 60 +++++++++++++++++-- .../gui/widgets/OscillatorWaveformDisplay.cpp | 13 ++++ 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/src/surge-xt/gui/overlays/LuaEditors.cpp b/src/surge-xt/gui/overlays/LuaEditors.cpp index 346eb851264..c5f29fe06af 100644 --- a/src/surge-xt/gui/overlays/LuaEditors.cpp +++ b/src/surge-xt/gui/overlays/LuaEditors.cpp @@ -1137,6 +1137,39 @@ struct WavetablePreviewComponent : public juce::Component, public Surge::GUI::Sk } void resized() override {} + bool isHandMove{false}; + void mouseEnter(const juce::MouseEvent &event) override + { + if (event.x > axisSpaceX) + { + setMouseCursor(juce::MouseCursor::DraggingHandCursor); + isHandMove = true; + } + else + { + isHandMove = false; + } + } + void mouseMove(const juce::MouseEvent &event) override + { + if (event.x > axisSpaceX) + { + if (!isHandMove) + setMouseCursor(juce::MouseCursor::DraggingHandCursor); + isHandMove = true; + } + else + { + if (isHandMove) + setMouseCursor(juce::MouseCursor::NormalCursor); + isHandMove = false; + } + } + void mouseExit(const juce::MouseEvent &event) override + { + setMouseCursor(juce::MouseCursor::NormalCursor); + isHandMove = false; + } void mouseDown(const juce::MouseEvent &event) override { lastDrag = event.getPosition().x + -event.getPosition().y; @@ -1210,7 +1243,15 @@ struct WavetablePreviewComponent : public juce::Component, public Surge::GUI::Sk } void mouseUp(const juce::MouseEvent &event) override { - setMouseCursor(juce::MouseCursor::NormalCursor); + if (event.x < axisSpaceX) + { + isHandMove = false; + setMouseCursor(juce::MouseCursor::NormalCursor); + } + else + { + isHandMove = true; + } } void mouseDoubleClick(const juce::MouseEvent &event) override @@ -1934,16 +1975,25 @@ void WavetableScriptEditor::rerenderFromUIState() else { rendererComponent->fsPoints.clear(); + bool hasFailed{false}; for (int i = 0; i < nfr; ++i) { - auto rs = evaluator->evaluateScriptAtFrame(i); - if (rs.has_value()) + if (hasFailed) { - rendererComponent->fsPoints.emplace_back(*rs); + rendererComponent->fsPoints.emplace_back(); } else { - rendererComponent->fsPoints.emplace_back(); + auto rs = evaluator->evaluateScriptAtFrame(i); + if (rs.has_value()) + { + rendererComponent->fsPoints.emplace_back(*rs); + } + else + { + rendererComponent->fsPoints.emplace_back(); + hasFailed = true; + } } } rendererComponent->adjustStartX(0); diff --git a/src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp b/src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp index fc6d67eae34..e9b278ad2d4 100644 --- a/src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp +++ b/src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp @@ -601,6 +601,7 @@ void OscillatorWaveformDisplay::populateMenu(juce::PopupMenu &contextMenu, int s // Change this to 0 to disable WTSE component, to disable for release: change value, test, and push #define INCLUDE_WT_SCRIPTING_EDITOR 1 +#if HAS_LUA #if INCLUDE_WT_SCRIPTING_EDITOR contextMenu.addSeparator(); @@ -611,6 +612,7 @@ void OscillatorWaveformDisplay::populateMenu(juce::PopupMenu &contextMenu, int s contextMenu.addItem(Surge::GUI::toOSCase("Wavetable Script Editor..."), owts); contextMenu.addSeparator(); +#endif #endif // add this option only if we have any wavetables in the list @@ -727,6 +729,17 @@ void OscillatorWaveformDisplay::createWTMenuItems(juce::PopupMenu &contextMenu, contextMenu.addItem( Surge::GUI::toOSCase(fmt::format("Frame Length: {} samples", oscdata->wt.size)), true, false, nullptr); + +#if HAS_LUA + contextMenu.addSeparator(); + contextMenu.addItem(Surge::GUI::toOSCase("Wavetable Script Editor..."), + [w = juce::Component::SafePointer(this)]() { + if (!w) + return; + if (w->sge) + w->sge->showOverlay(SurgeGUIEditor::WTSCRIPT_EDITOR); + }); +#endif } } }