From 3b0e17e74dc6e3770fea3fe3647b2d535b3d9a47 Mon Sep 17 00:00:00 2001 From: vsvsv Date: Wed, 15 May 2024 01:31:59 +0300 Subject: [PATCH] Add a button to reload script --- plugin/editor.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugin/editor.cpp b/plugin/editor.cpp index 64654f53..99f3e8b9 100644 --- a/plugin/editor.cpp +++ b/plugin/editor.cpp @@ -68,6 +68,7 @@ struct YsfxEditor::Impl { std::unique_ptr m_btnRecentFiles; std::unique_ptr m_btnEditCode; std::unique_ptr m_btnLoadPreset; + std::unique_ptr m_btnReloadScript; std::unique_ptr m_btnSwitchEditor; std::unique_ptr m_lblFilePath; std::unique_ptr m_lblIO; @@ -347,6 +348,8 @@ void YsfxEditor::Impl::createUI() m_self->addAndMakeVisible(*m_btnLoadFile); m_btnRecentFiles.reset(new juce::TextButton(TRANS("Recent"))); m_self->addAndMakeVisible(*m_btnRecentFiles); + m_btnReloadScript.reset(new juce::TextButton(TRANS("Reload"))); + m_self->addAndMakeVisible(*m_btnReloadScript); m_btnEditCode.reset(new juce::TextButton(TRANS("Edit"))); m_self->addAndMakeVisible(*m_btnEditCode); m_btnLoadPreset.reset(new juce::TextButton(TRANS("Preset"))); @@ -384,6 +387,14 @@ void YsfxEditor::Impl::connectUI() m_btnSwitchEditor->onClick = [this]() { switchEditor(m_btnSwitchEditor->getToggleState()); }; m_btnEditCode->onClick = [this]() { openCodeEditor(); }; m_btnLoadPreset->onClick = [this]() { popupPresets(); }; + m_btnReloadScript->onClick = [this]() { + YsfxInfo::Ptr info = m_info; + ysfx_t *fx = info->effect.get(); + if (!fx) return; + + juce::File file{juce::CharPointer_UTF8{ysfx_get_file_path(fx)}}; + loadFile(file); + }; m_ideView->onFileSaved = [this](const juce::File &file) { loadFile(file); }; m_ideView->onReloadRequested = [this](const juce::File &file) { loadFile(file); }; @@ -419,6 +430,8 @@ void YsfxEditor::Impl::relayoutUI() temp.removeFromLeft(10); m_btnRecentFiles->setBounds(temp.removeFromLeft(80)); temp.removeFromLeft(10); + m_btnReloadScript->setBounds(temp.removeFromLeft(60)); + temp.removeFromLeft(10); m_btnSwitchEditor->setBounds(temp.removeFromRight(80)); temp.removeFromRight(10); m_btnLoadPreset->setBounds(temp.removeFromRight(80));