Skip to content

Commit

Permalink
Some WT Script Tweaks (#7888)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
baconpaul authored Dec 1, 2024
1 parent 1b9391f commit 03373f9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 5 deletions.
60 changes: 55 additions & 5 deletions src/surge-xt/gui/overlays/LuaEditors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
Expand Down Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit 03373f9

Please sign in to comment.