From 23cd3d8dfb8e8c563f152926226c6c097a6e3903 Mon Sep 17 00:00:00 2001 From: Joep Vanlier Date: Sat, 14 Sep 2024 16:59:39 +0200 Subject: [PATCH] plugin: delay window construction until needed --- include/ysfx.h | 2 +- plugin/components/ide_view.cpp | 1 + plugin/editor.cpp | 10 ++++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/ysfx.h b/include/ysfx.h index 524b8ae..9620947 100644 --- a/include/ysfx.h +++ b/include/ysfx.h @@ -616,7 +616,7 @@ YSFX_DEFINE_AUTO_PTR(ysfx_menu_u, ysfx_menu_t, ysfx_menu_free); return sptr(ptr, sptr##_deleter()); \ } -YSFX_DEFINE_SHARED_PTR(ysfx_bank_shared, ysfx_bank_t, ysfx_bank_free); +YSFX_DEFINE_SHARED_PTR(ysfx_bank_shared, ysfx_bank_t, ysfx_bank_free) #endif // defined(__cplusplus) && (__cplusplus >= 201103L || (defined(_MSC_VER) && _MSVC_LANG >= 201103L)) diff --git a/plugin/components/ide_view.cpp b/plugin/components/ide_view.cpp index c8cb92b..bf01535 100644 --- a/plugin/components/ide_view.cpp +++ b/plugin/components/ide_view.cpp @@ -75,6 +75,7 @@ YsfxIDEView::YsfxIDEView() m_impl->relayoutUILater(); m_impl->setupNewFx(); + this->setVisible(false); } YsfxIDEView::~YsfxIDEView() diff --git a/plugin/editor.cpp b/plugin/editor.cpp index d3837d5..2512eef 100644 --- a/plugin/editor.cpp +++ b/plugin/editor.cpp @@ -673,6 +673,12 @@ void YsfxEditor::Impl::switchEditor(bool showGfx) void YsfxEditor::Impl::openCodeEditor() { + if (!m_codeWindow) { + m_codeWindow.reset(new CodeWindow(TRANS("Edit"), m_self->findColour(juce::DocumentWindow::backgroundColourId), juce::DocumentWindow::allButtons)); + m_codeWindow->setResizable(true, false); + m_codeWindow->setContentNonOwned(m_ideView.get(), true); + } + m_codeWindow->setVisible(true); m_codeWindow->toFront(true); m_ideView->focusOnCodeEditor(); @@ -798,11 +804,7 @@ void YsfxEditor::Impl::createUI() m_miniParametersPanel.reset(new YsfxParametersPanel); m_graphicsView.reset(new YsfxGraphicsView); m_ideView.reset(new YsfxIDEView); - m_ideView->setVisible(true); m_ideView->setSize(1000, 600); - m_codeWindow.reset(new CodeWindow(TRANS("Edit"), m_self->findColour(juce::DocumentWindow::backgroundColourId), juce::DocumentWindow::allButtons)); - m_codeWindow->setResizable(true, false); - m_codeWindow->setContentNonOwned(m_ideView.get(), true); m_tooltipWindow.reset(new juce::TooltipWindow); }