Skip to content

Commit

Permalink
Even more LuaEditors work (surge-synthesizer#7920)
Browse files Browse the repository at this point in the history
Add keybinding for toggling the WT editor (Alt+W by default)
Undo/Redo respond to keybinds set by the user
Minor adjustment of button padding in find/goto popup
Rename "wt script" to "wt editor" in several places
Removed debug couts and some leftover debug comments
  • Loading branch information
mkruselj authored Dec 13, 2024
1 parent 5995081 commit fe778c0
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 117 deletions.
4 changes: 2 additions & 2 deletions src/common/SkinModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,8 @@ Connector mseg_editor = Connector("msegeditor.window", 0, 58, 750, 365, Componen
Connector formula_editor = Connector("formulaeditor.window", 0, 58, 750, 365, Components::Custom,
Connector::FORMULA_EDITOR_WINDOW);

Connector wtscript_editor = Connector("wtscripteditor.window", 0, 58, 750, 511, Components::Custom,
Connector::WTSCRIPT_EDITOR_WINDOW);
Connector wt_editor =
Connector("wteditor.window", 0, 58, 750, 511, Components::Custom, Connector::WT_EDITOR_WINDOW);

Connector tuning_editor = Connector("tuningeditor.window", 0, 58, 750, 511, Components::Custom,
Connector::TUNING_EDITOR_WINDOW);
Expand Down
4 changes: 2 additions & 2 deletions src/common/SkinModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ struct Connector
OSCILLOSCOPE_WINDOW,
WAVESHAPER_ANALYSIS_WINDOW,
FORMULA_EDITOR_WINDOW,
WTSCRIPT_EDITOR_WINDOW,
WT_EDITOR_WINDOW,
TUNING_EDITOR_WINDOW,
MOD_LIST_WINDOW,

Expand Down Expand Up @@ -454,7 +454,7 @@ extern Surge::Skin::Connector vu_meter;

extern Surge::Skin::Connector patch_browser;

extern Surge::Skin::Connector mseg_editor, formula_editor, wtscript_editor, tuning_editor;
extern Surge::Skin::Connector mseg_editor, formula_editor, wt_editor, tuning_editor;

extern Surge::Skin::Connector mod_list;

Expand Down
2 changes: 1 addition & 1 deletion src/common/SurgeStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const int FIRoffsetI16 = FIRipolI16_N >> 1;
// added deform option for Release parameter of Filter/Amp EG, which only produces an open gate for the release stage
// 23 -> 24 (XT 1.3.3 nightlies) added actually functioning extend mode to FM2 oscillator's M1/2 Offset parameter
// (old patches load with extend disabled even if they had it enabled)
// 24 -> 25 (XT 1.3.4 nightlies) added storing of Wavetable Script Editor window state
// 24 -> 25 (XT 1.3.4 nightlies) added storing of Wavetable Editor window state
// 25 -> 26 (XT 1.4.* nightlies) added WT Deform for new WT features
// clang-format on

Expand Down
44 changes: 41 additions & 3 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ void SurgeGUIEditor::idle()
{
refreshOverlayWithOpenClose(MSEG_EDITOR);
refreshOverlayWithOpenClose(FORMULA_EDITOR);
refreshOverlayWithOpenClose(WTSCRIPT_EDITOR);
refreshOverlayWithOpenClose(WT_EDITOR);
refreshOverlayWithOpenClose(TUNING_EDITOR);
refreshOverlayWithOpenClose(MODULATION_EDITOR);
}
Expand Down Expand Up @@ -2040,7 +2040,7 @@ void SurgeGUIEditor::openOrRecreateEditor()
case Surge::Skin::Connector::NonParameterConnection::SAVE_PATCH_DIALOG:
case Surge::Skin::Connector::NonParameterConnection::MSEG_EDITOR_WINDOW:
case Surge::Skin::Connector::NonParameterConnection::FORMULA_EDITOR_WINDOW:
case Surge::Skin::Connector::NonParameterConnection::WTSCRIPT_EDITOR_WINDOW:
case Surge::Skin::Connector::NonParameterConnection::WT_EDITOR_WINDOW:
case Surge::Skin::Connector::NonParameterConnection::TUNING_EDITOR_WINDOW:
case Surge::Skin::Connector::NonParameterConnection::MOD_LIST_WINDOW:
case Surge::Skin::Connector::NonParameterConnection::FILTER_ANALYSIS_WINDOW:
Expand Down Expand Up @@ -5495,6 +5495,9 @@ void SurgeGUIEditor::setupKeymapManager()
keyMapManager->addBinding(Surge::GUI::SHOW_KEYBINDINGS_EDITOR,
{keymap_t::Modifiers::ALT, (int)'B'});
keyMapManager->addBinding(Surge::GUI::SHOW_LFO_EDITOR, {keymap_t::Modifiers::ALT, (int)'E'});
#if INCLUDE_WT_SCRIPTING_EDITOR
keyMapManager->addBinding(Surge::GUI::SHOW_WT_EDITOR, {keymap_t::Modifiers::ALT, (int)'W'});
#endif
keyMapManager->addBinding(Surge::GUI::SHOW_MODLIST, {keymap_t::Modifiers::ALT, (int)'M'});
keyMapManager->addBinding(Surge::GUI::SHOW_TUNING_EDITOR, {keymap_t::Modifiers::ALT, (int)'T'});
keyMapManager->addBinding(Surge::GUI::TOGGLE_OSCILLOSCOPE,
Expand Down Expand Up @@ -5601,12 +5604,41 @@ bool SurgeGUIEditor::keyPressed(const juce::KeyPress &key, juce::Component *orig
switch (action)
{
case Surge::GUI::UNDO:
{
#if INCLUDE_WT_SCRIPTING_EDITOR
auto ol = getOverlayIfOpenAs<Surge::Overlays::WavetableScriptEditor>(WT_EDITOR);

if (ol)
{
ol->mainDocument->undo();
}
else
{
undoManager()->undo();
}
#else
undoManager()->undo();
#endif
return true;
}
case Surge::GUI::REDO:
{
#if INCLUDE_WT_SCRIPTING_EDITOR
auto ol = getOverlayIfOpenAs<Surge::Overlays::WavetableScriptEditor>(WT_EDITOR);

if (ol)
{
ol->mainDocument->redo();
}
else
{
undoManager()->redo();
}
#else
undoManager()->redo();
#endif
return true;

}
case Surge::GUI::SAVE_PATCH:
showOverlay(SurgeGUIEditor::SAVE_PATCH);
return true;
Expand Down Expand Up @@ -5712,6 +5744,12 @@ bool SurgeGUIEditor::keyPressed(const juce::KeyPress &key, juce::Component *orig
}

return true;
#if INCLUDE_WT_SCRIPTING_EDITOR
case Surge::GUI::SHOW_WT_EDITOR:
toggleOverlay(SurgeGUIEditor::WT_EDITOR);
frame->repaint();
return true;
#endif
case Surge::GUI::SHOW_MODLIST:
toggleOverlay(SurgeGUIEditor::MODULATION_EDITOR);
frame->repaint();
Expand Down
5 changes: 4 additions & 1 deletion src/surge-xt/gui/SurgeGUIEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
#include <bitset>
#include "UndoManager.h"

// Change this to 0 to disable WTSE component, to disable for release: change value, test, and push
#define INCLUDE_WT_SCRIPTING_EDITOR 1

class SurgeSynthEditor;

#if SURGE_INCLUDE_MELATONIN_INSPECTOR
Expand Down Expand Up @@ -403,7 +406,7 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener,
PATCH_BROWSER,
MODULATION_EDITOR,
FORMULA_EDITOR,
WTSCRIPT_EDITOR, // This code is here but incomplete, and off in XT 1.0
WT_EDITOR,
TUNING_EDITOR,
WAVESHAPER_ANALYZER,
FILTER_ANALYZER,
Expand Down
10 changes: 10 additions & 0 deletions src/surge-xt/gui/SurgeGUIEditorKeyboardActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ enum KeyboardActions
#endif
SHOW_KEYBINDINGS_EDITOR,
SHOW_LFO_EDITOR,
#if INCLUDE_WT_SCRIPTING_EDITOR
SHOW_WT_EDITOR,
#endif
SHOW_MODLIST,
SHOW_TUNING_EDITOR,
TOGGLE_OSCILLOSCOPE,
Expand Down Expand Up @@ -142,6 +145,8 @@ inline std::string keyboardActionName(KeyboardActions a)
return "SHOW_KEYBINDINGS_EDITOR";
case SHOW_LFO_EDITOR:
return "SHOW_LFO_EDITOR";
case SHOW_WT_EDITOR:
return "SHOW_WT_EDITOR";
case SHOW_MODLIST:
return "SHOW_MODLIST";
case SHOW_TUNING_EDITOR:
Expand Down Expand Up @@ -274,6 +279,11 @@ inline std::string keyboardActionDescription(KeyboardActions a)
case SHOW_LFO_EDITOR:
desc = "LFO Editor (MSEG or Formula)";
break;
#if INCLUDE_WT_SCRIPTING_EDITOR
case SHOW_WT_EDITOR:
desc = "Wavetable Editor";
break;
#endif
case SHOW_MODLIST:
desc = "Modulation List";
break;
Expand Down
8 changes: 3 additions & 5 deletions src/surge-xt/gui/SurgeGUIEditorOverlays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ std::unique_ptr<Surge::Overlays::OverlayComponent> SurgeGUIEditor::createOverlay
return fme;
}

case WTSCRIPT_EDITOR:
case WT_EDITOR:
{

auto os = &synth->storage.getPatch().scene[current_scene].osc[current_osc[current_scene]];
Expand All @@ -294,8 +294,7 @@ std::unique_ptr<Surge::Overlays::OverlayComponent> SurgeGUIEditor::createOverlay
this, &(this->synth->storage), os, current_osc[current_scene], current_scene,
currentSkin);

std::string title = "Wavetable Script Editor Osc ";
title += std::to_string(current_osc[current_scene] + 1);
std::string title = fmt::format("Osc {} Wavetable Editor", current_osc[current_scene] + 1);

wtse->setSkin(currentSkin, bitmapStore);
wtse->setEnclosingParentTitle(title);
Expand All @@ -304,8 +303,7 @@ std::unique_ptr<Surge::Overlays::OverlayComponent> SurgeGUIEditor::createOverlay
Surge::Storage::WTScriptOverlayTearOutAlwaysOnTop_Plugin});
wtse->setCanTearOutResize({true, Surge::Storage::WTScriptOverlaySizeTearOut});
wtse->setMinimumSize(500, 400);
locationGet(wtse.get(),
Surge::Skin::Connector::NonParameterConnection::WTSCRIPT_EDITOR_WINDOW,
locationGet(wtse.get(), Surge::Skin::Connector::NonParameterConnection::WT_EDITOR_WINDOW,
Surge::Storage::WTScriptOverlayLocation);

return wtse;
Expand Down
Loading

0 comments on commit fe778c0

Please sign in to comment.