From e060a69fdb6506c335a19cc6479572e0e4d9c71e Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 3 Nov 2023 11:43:17 -0400 Subject: [PATCH] Break dependency of PluginMenus on ProjectWindow --- libraries/lib-viewport/Viewport.cpp | 6 ++++++ libraries/lib-viewport/Viewport.h | 4 ++++ src/ProjectWindow.cpp | 16 ++++++---------- src/ProjectWindow.h | 8 ++------ src/menus/PluginMenus.cpp | 4 ++-- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/libraries/lib-viewport/Viewport.cpp b/libraries/lib-viewport/Viewport.cpp index d19667a61ca6..dd8478c9dbbd 100644 --- a/libraries/lib-viewport/Viewport.cpp +++ b/libraries/lib-viewport/Viewport.cpp @@ -794,6 +794,12 @@ void Viewport::Redraw() }); } +void Viewport::SetToDefaultSize() +{ + if (mpCallbacks) + mpCallbacks->SetToDefaultSize(); +} + void Viewport::OnUndoPushedModified() { Redraw(); diff --git a/libraries/lib-viewport/Viewport.h b/libraries/lib-viewport/Viewport.h index 3292a0dcd55f..712f12d5a4bf 100644 --- a/libraries/lib-viewport/Viewport.h +++ b/libraries/lib-viewport/Viewport.h @@ -50,6 +50,8 @@ class VIEWPORT_API ViewportCallbacks { virtual void SetVerticalScrollbar(int position, int thumbSize, int range, int pageSize, bool refresh) = 0; virtual void ShowVerticalScrollbar(bool shown) = 0; + + virtual void SetToDefaultSize() = 0; }; struct ViewportMessage { @@ -175,6 +177,8 @@ class VIEWPORT_API Viewport final void Redraw(); + void SetToDefaultSize(); + private: // How many pixels are covered by the period from lowermost scrollable time, to the given time: // PRL: Bug1197: we seem to need to compute all in double, to avoid differing results on Mac diff --git a/src/ProjectWindow.cpp b/src/ProjectWindow.cpp index e50cd1c4f2c0..a753080a1877 100644 --- a/src/ProjectWindow.cpp +++ b/src/ProjectWindow.cpp @@ -21,7 +21,6 @@ Paul Licameli split from AudacityProject.cpp #include "ViewInfo.h" #include "WaveClip.h" #include "WaveTrack.h" -#include "commands/CommandContext.h" #include "prefs/ThemePrefs.h" #include "prefs/TracksPrefs.h" #include "toolbars/ToolManager.h" @@ -430,14 +429,6 @@ const ProjectWindow *ProjectWindow::Find( const AudacityProject *pProject ) return Find( const_cast< AudacityProject * >( pProject ) ); } -void ProjectWindow::OnResetWindow(const CommandContext& context) -{ - auto& project = context.project; - auto& window = ProjectWindow::Get(project); - - window.Reset(); -} - int ProjectWindow::NextWindowID() { return mNextWindowID++; @@ -524,6 +515,11 @@ struct Adapter final : ViewportCallbacks { if (mwWindow) mwWindow->ShowVerticalScrollbar(shown); } + void SetToDefaultSize() override + { + if (mwWindow) + mwWindow->SetToDefaultSize(); + } wxWeakRef mwWindow; }; @@ -919,7 +915,7 @@ wxPanel* ProjectWindow::GetTopPanel() noexcept return mTopPanel; } -void ProjectWindow::Reset() +void ProjectWindow::SetToDefaultSize() { wxRect defaultRect; GetDefaultWindowRect(&defaultRect); diff --git a/src/ProjectWindow.h b/src/ProjectWindow.h index 7f9a56d6ca35..718aa35aea96 100644 --- a/src/ProjectWindow.h +++ b/src/ProjectWindow.h @@ -16,8 +16,6 @@ Paul Licameli split from AudacityProject.h #include "Prefs.h" #include "Viewport.h" -class CommandContext; - class wxScrollBar; class wxPanel; class wxSplitterWindow; @@ -44,8 +42,6 @@ class AUDACITY_DLL_API ProjectWindow final : public ProjectWindowBase static ProjectWindow *Find( AudacityProject *pProject ); static const ProjectWindow *Find( const AudacityProject *pProject ); - static void OnResetWindow(const CommandContext& context); - explicit ProjectWindow( wxWindow * parent, wxWindowID id, const wxPoint & pos, const wxSize &size, @@ -61,8 +57,6 @@ class AUDACITY_DLL_API ProjectWindow final : public ProjectWindowBase bool IsBeingDeleted() const { return mIsDeleting; } void SetIsBeingDeleted() { mIsDeleting = true; } - void Reset(); - /** * \brief Track list window is the parent container for TrackPanel * \return Pointer to a track list window (not null) @@ -155,6 +149,8 @@ class AUDACITY_DLL_API ProjectWindow final : public ProjectWindowBase int range, int pageSize, bool refresh) override; void ShowVerticalScrollbar(bool shown) override; + void SetToDefaultSize() override; + // PRL: old and incorrect comment below, these functions are used elsewhere than TrackPanel // TrackPanel access wxSize GetTPTracksUsableArea() /* not override */; diff --git a/src/menus/PluginMenus.cpp b/src/menus/PluginMenus.cpp index 305fb0e7233e..f38506b2ffba 100644 --- a/src/menus/PluginMenus.cpp +++ b/src/menus/PluginMenus.cpp @@ -11,7 +11,6 @@ #include "ProjectRate.h" #include "ProjectSnap.h" #include "../ProjectSettings.h" -#include "../ProjectWindow.h" #include "../ProjectWindows.h" #include "../ProjectSelectionManager.h" #include "RealtimeEffectPanel.h" @@ -22,6 +21,7 @@ #include "TrackFocus.h" #include "TempDirectory.h" #include "UndoManager.h" +#include "Viewport.h" #include "../commands/CommandContext.h" #include "../commands/CommandManager.h" #include "../effects/EffectManager.h" @@ -99,7 +99,7 @@ void OnResetConfig(const CommandContext &context) gPrefs->Flush(); DoReloadPreferences(project); - ProjectWindow::OnResetWindow(context); + Viewport::Get(project).SetToDefaultSize(); ToolManager::OnResetToolBars(context); // These are necessary to preserve the newly correctly laid out toolbars.