Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh Formula overlay after loading LFO preset or undo/redo, if applicable #7310

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3209,27 +3209,30 @@ juce::PopupMenu SurgeGUIEditor::makeLfoMenu(const juce::Point<int> &where)
.lfo[currentLfoId]
.shape.val.i;

if (isAnyOverlayPresent(MSEG_EDITOR))
if (isAnyOverlayPresent(MSEG_EDITOR) || isAnyOverlayPresent(FORMULA_EDITOR))
{
auto editorEnum =
isAnyOverlayPresent(MSEG_EDITOR) ? MSEG_EDITOR : FORMULA_EDITOR;
bool tornOut = false;
juce::Point<int> tearOutPos;

auto olw = getOverlayWrapperIfOpen(MSEG_EDITOR);
auto olw = getOverlayWrapperIfOpen(editorEnum);

if (olw && olw->isTornOut())
{
tornOut = true;
tearOutPos = olw->currentTearOutLocation();
}

closeOverlay(SurgeGUIEditor::MSEG_EDITOR);
closeOverlay(editorEnum);

if (newshape == lt_mseg)
if (newshape == lt_mseg || newshape == lt_formula)
{
showOverlay(SurgeGUIEditor::MSEG_EDITOR);
showOverlay(editorEnum);

if (tornOut)
{
auto olw = getOverlayWrapperIfOpen(MSEG_EDITOR);
auto olw = getOverlayWrapperIfOpen(editorEnum);

if (olw)
{
Expand All @@ -3241,9 +3244,12 @@ juce::PopupMenu SurgeGUIEditor::makeLfoMenu(const juce::Point<int> &where)

this->synth->refresh_editor = true;
};

m.addItem(p.name, action);
}

bool haveD = false;

if (cat.path.empty())
{
// This is a preset in the root
Expand Down Expand Up @@ -5131,23 +5137,24 @@ void SurgeGUIEditor::reloadFromSkin()
}

// update overlays, if opened
if (isAnyOverlayPresent(MSEG_EDITOR))
if (isAnyOverlayPresent(MSEG_EDITOR) || isAnyOverlayPresent(FORMULA_EDITOR))
{
auto editorEnum = isAnyOverlayPresent(MSEG_EDITOR) ? MSEG_EDITOR : FORMULA_EDITOR;
bool tornOut = false;
juce::Point<int> tearOutPos;
auto olw = getOverlayWrapperIfOpen(MSEG_EDITOR);
auto olw = getOverlayWrapperIfOpen(editorEnum);

if (olw && olw->isTornOut())
{
tornOut = true;
tearOutPos = olw->currentTearOutLocation();
}

showOverlay(SurgeGUIEditor::MSEG_EDITOR);
showOverlay(editorEnum);

if (tornOut)
{
auto olw = getOverlayWrapperIfOpen(MSEG_EDITOR);
auto olw = getOverlayWrapperIfOpen(editorEnum);

if (olw)
{
Expand Down Expand Up @@ -7066,6 +7073,7 @@ void SurgeGUIEditor::lfoShapeChanged(int prior, int curr)
bool hadExtendedEditor = false;
bool isTornOut = false;
juce::Point<int> tearOutPos;

if (isAnyOverlayPresent(MSEG_EDITOR))
{
auto olw = getOverlayWrapperIfOpen(MSEG_EDITOR);
Expand All @@ -7077,6 +7085,7 @@ void SurgeGUIEditor::lfoShapeChanged(int prior, int curr)
closeOverlay(SurgeGUIEditor::MSEG_EDITOR);
hadExtendedEditor = true;
}

if (isAnyOverlayPresent(FORMULA_EDITOR))
{
auto olw = getOverlayWrapperIfOpen(FORMULA_EDITOR);
Expand Down
6 changes: 6 additions & 0 deletions src/surge-xt/gui/overlays/LuaEditors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,12 @@ void FormulaModulatorEditor::applyCode()
mainEditor->grabKeyboardFocus();
}

void FormulaModulatorEditor::forceRefresh()
{
mainDocument->insertText(0, formulastorage->formulaString);
editor->repaintFrame();
}

void FormulaModulatorEditor::setApplyEnabled(bool b)
{
if (controlArea)
Expand Down
2 changes: 1 addition & 1 deletion src/surge-xt/gui/overlays/LuaEditors.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct FormulaModulatorEditor : public CodeEditorContainerWithApply, public Refr
void onSkinChanged() override;
void setApplyEnabled(bool b) override;

void forceRefresh() override {}
void forceRefresh() override;

DAWExtraStateStorage::EditorState::FormulaEditState &getEditState();

Expand Down