mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
GetProjectPanel analogous to GetProjectFrame breaks dependencies...
... in places that need the TrackPanel but only to invoke common wxWindow methods on it. This eliminates direct use of TrackPanel by Scrubbing and ProjectWindow
This commit is contained in:
parent
7597080418
commit
1e4812f470
@ -132,6 +132,11 @@ void AudacityProject::SetFrame( wxFrame *pFrame )
|
||||
mFrame = pFrame;
|
||||
}
|
||||
|
||||
void AudacityProject::SetPanel( wxWindow *pPanel )
|
||||
{
|
||||
mPanel = pPanel;
|
||||
}
|
||||
|
||||
wxString AudacityProject::GetProjectName() const
|
||||
{
|
||||
wxString name = wxFileNameFromPath(mFileName);
|
||||
@ -159,3 +164,20 @@ AUDACITY_DLL_API const wxFrame &GetProjectFrame( const AudacityProject &project
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
AUDACITY_DLL_API wxWindow &GetProjectPanel( AudacityProject &project )
|
||||
{
|
||||
auto ptr = project.GetPanel();
|
||||
if ( !ptr )
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
AUDACITY_DLL_API const wxWindow &GetProjectPanel(
|
||||
const AudacityProject &project )
|
||||
{
|
||||
auto ptr = project.GetPanel();
|
||||
if ( !ptr )
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
return *ptr;
|
||||
}
|
||||
|
@ -115,6 +115,10 @@ class AUDACITY_DLL_API AudacityProject final
|
||||
const wxFrame *GetFrame() const { return mFrame; }
|
||||
void SetFrame( wxFrame *pFrame );
|
||||
|
||||
wxWindow *GetPanel() { return mPanel; }
|
||||
const wxWindow *GetPanel() const { return mPanel; }
|
||||
void SetPanel( wxWindow *pPanel );
|
||||
|
||||
wxString GetProjectName() const;
|
||||
|
||||
const FilePath &GetFileName() { return mFileName; }
|
||||
@ -136,6 +140,7 @@ class AUDACITY_DLL_API AudacityProject final
|
||||
|
||||
private:
|
||||
wxWeakRef< wxFrame > mFrame{};
|
||||
wxWeakRef< wxWindow > mPanel{};
|
||||
};
|
||||
|
||||
///\brief Get the top-level window associated with the project (as a wxFrame
|
||||
@ -152,4 +157,10 @@ inline const wxFrame *FindProjectFrame( const AudacityProject *project ) {
|
||||
return project ? &GetProjectFrame( *project ) : nullptr;
|
||||
}
|
||||
|
||||
///\brief Get the main sub-window of the project frame that displays track data
|
||||
// (as a wxWindow only, when you do not need to use the subclass TrackPanel)
|
||||
AUDACITY_DLL_API wxWindow &GetProjectPanel( AudacityProject &project );
|
||||
AUDACITY_DLL_API const wxWindow &GetProjectPanel(
|
||||
const AudacityProject &project );
|
||||
|
||||
#endif
|
||||
|
@ -1081,3 +1081,14 @@ int ProjectManager::GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels) {
|
||||
int iRecMins = (int)round(dRecTime / 60.0);
|
||||
return iRecMins;
|
||||
}
|
||||
|
||||
/// This was moved here to eliminate dependency of Scrubbing.cpp on
|
||||
/// TrackPanel, but perhaps a better home should be found for it in future
|
||||
#include "tracks/ui/Scrubbing.h"
|
||||
static const AudacityProject::AttachedObjects::RegisteredFactory sOverlayKey{
|
||||
[]( AudacityProject &parent ){
|
||||
auto result = std::make_shared< ScrubbingOverlay >( &parent );
|
||||
TrackPanel::Get( parent ).AddOverlay( result );
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
@ -19,7 +19,6 @@ Paul Licameli split from AudacityProject.cpp
|
||||
#include "ProjectAudioIO.h"
|
||||
#include "ProjectStatus.h"
|
||||
#include "RefreshCode.h"
|
||||
#include "TrackPanel.h"
|
||||
#include "TrackPanelMouseEvent.h"
|
||||
#include "UndoManager.h"
|
||||
#include "ViewInfo.h"
|
||||
@ -710,7 +709,7 @@ void ProjectWindow::RedrawProject(const bool bForceWaveTracks /*= false*/)
|
||||
|
||||
auto &project = pThis->mProject ;
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &trackPanel = GetProjectPanel( project );
|
||||
pThis->FixScrollbars();
|
||||
if (bForceWaveTracks)
|
||||
{
|
||||
@ -777,7 +776,7 @@ const int sbarHjump = 30; //STM: This is how far the thumb jumps when the
|
||||
// Make sure selection edge is in view
|
||||
void ProjectWindow::ScrollIntoView(double pos)
|
||||
{
|
||||
auto &trackPanel = TrackPanel::Get( mProject );
|
||||
auto &trackPanel = GetProjectPanel( mProject );
|
||||
auto &viewInfo = ViewInfo::Get( mProject );
|
||||
auto w = viewInfo.GetTracksUsableWidth();
|
||||
|
||||
@ -1002,7 +1001,7 @@ void ProjectWindow::FixScrollbars()
|
||||
{
|
||||
auto &project = mProject;
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &trackPanel = GetProjectPanel( project );
|
||||
auto &viewInfo = ViewInfo::Get( project );
|
||||
|
||||
bool refresh = false;
|
||||
@ -1157,7 +1156,7 @@ void ProjectWindow::FixScrollbars()
|
||||
void ProjectWindow::UpdateLayout()
|
||||
{
|
||||
auto &project = mProject;
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &trackPanel = GetProjectPanel( project );
|
||||
auto &toolManager = ToolManager::Get( project );
|
||||
|
||||
// 1. Layout panel, to get widths of the docks.
|
||||
@ -1364,7 +1363,7 @@ void ProjectWindow::OnScroll(wxScrollEvent & WXUNUSED(event))
|
||||
void ProjectWindow::DoScroll()
|
||||
{
|
||||
auto &project = mProject;
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &trackPanel = GetProjectPanel( project );
|
||||
auto &viewInfo = ViewInfo::Get( project );
|
||||
const double lowerBound = ScrollingLowerBoundTime();
|
||||
|
||||
@ -1480,7 +1479,7 @@ void ProjectWindow::OnActivate(wxActivateEvent & event)
|
||||
auto &toolManager = ToolManager::Get( project );
|
||||
SetActiveProject( &project );
|
||||
if ( ! toolManager.RestoreFocus() )
|
||||
TrackPanel::Get( project ).SetFocus();
|
||||
GetProjectPanel( project ).SetFocus();
|
||||
|
||||
#ifdef __WXMAC__
|
||||
MacShowUndockedToolbars(true);
|
||||
@ -1505,7 +1504,7 @@ void ProjectWindow::ZoomAfterImport(Track *pTrack)
|
||||
{
|
||||
auto &project = mProject;
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &trackPanel = GetProjectPanel( project );
|
||||
|
||||
DoZoomFit();
|
||||
|
||||
@ -1655,7 +1654,7 @@ void ProjectWindow::PlaybackScroller::OnTimer(wxCommandEvent &event)
|
||||
// to the application, so scrub speed control is smoother.
|
||||
// (So I see at least with OS 10.10 and wxWidgets 3.0.2.)
|
||||
// Is there another way to ensure that than by refreshing?
|
||||
auto &trackPanel = TrackPanel::Get( *mProject );
|
||||
auto &trackPanel = GetProjectPanel( *mProject );
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
else if (mMode != Mode::Off) {
|
||||
@ -1663,7 +1662,7 @@ void ProjectWindow::PlaybackScroller::OnTimer(wxCommandEvent &event)
|
||||
// fraction of the window width.
|
||||
|
||||
auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
auto &trackPanel = TrackPanel::Get( *mProject );
|
||||
auto &trackPanel = GetProjectPanel( *mProject );
|
||||
const int posX = viewInfo.TimeToPosition(viewInfo.mRecentStreamTime);
|
||||
auto width = viewInfo.GetTracksUsableWidth();
|
||||
int deltaX;
|
||||
|
@ -205,7 +205,7 @@ AudacityProject::AttachedWindows::RegisteredFactory sKey{
|
||||
wxASSERT( mainPage ); // to justify safenew
|
||||
|
||||
auto &tracks = TrackList::Get( project );
|
||||
return safenew TrackPanel(mainPage,
|
||||
auto result = safenew TrackPanel(mainPage,
|
||||
window.NextWindowID(),
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
@ -213,6 +213,8 @@ AudacityProject::AttachedWindows::RegisteredFactory sKey{
|
||||
&viewInfo,
|
||||
&project,
|
||||
&ruler);
|
||||
project.SetPanel( result );
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -25,7 +25,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../ProjectSettings.h"
|
||||
#include "../../ProjectStatus.h"
|
||||
#include "../../Track.h"
|
||||
#include "../../TrackPanel.h"
|
||||
#include "../../ViewInfo.h"
|
||||
#include "../../WaveTrack.h"
|
||||
#include "../../prefs/PlaybackPrefs.h"
|
||||
@ -597,7 +596,7 @@ void Scrubber::ContinueScrubbingPoll()
|
||||
gAudioIO->UpdateScrub(speed, mOptions);
|
||||
} else {
|
||||
const wxMouseState state(::wxGetMouseState());
|
||||
auto &trackPanel = TrackPanel::Get( *mProject );
|
||||
auto &trackPanel = GetProjectPanel( *mProject );
|
||||
const wxPoint position = trackPanel.ScreenToClient(state.GetPosition());
|
||||
auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
#ifdef DRAG_SCRUB
|
||||
@ -904,14 +903,6 @@ void Scrubber::Forwarder::OnMouse(wxMouseEvent &event)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// class ScrubbingOverlay is responsible for drawing the speed numbers
|
||||
|
||||
static const AudacityProject::AttachedObjects::RegisteredFactory sOverlayKey{
|
||||
[]( AudacityProject &parent ){
|
||||
auto result = std::make_shared< ScrubbingOverlay >( &parent );
|
||||
TrackPanel::Get( parent ).AddOverlay( result );
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
ScrubbingOverlay::ScrubbingOverlay(AudacityProject *project)
|
||||
: mProject(project)
|
||||
, mLastScrubRect()
|
||||
@ -1003,7 +994,7 @@ void ScrubbingOverlay::OnTimer(wxCommandEvent &event)
|
||||
mNextScrubRect = wxRect();
|
||||
}
|
||||
else {
|
||||
TrackPanel &trackPanel = TrackPanel::Get( *mProject );
|
||||
auto &trackPanel = GetProjectPanel( *mProject );
|
||||
auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
int panelWidth, panelHeight;
|
||||
trackPanel.GetSize(&panelWidth, &panelHeight);
|
||||
@ -1070,7 +1061,7 @@ void Scrubber::DoScrub(bool seek)
|
||||
const bool wasScrubbing = HasMark() || IsScrubbing();
|
||||
const bool scroll = ShouldScrubPinned();
|
||||
if (!wasScrubbing) {
|
||||
auto &tp = TrackPanel::Get( *mProject );
|
||||
auto &tp = GetProjectPanel( *mProject );
|
||||
const auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
wxCoord xx = tp.ScreenToClient(::wxGetMouseState().GetPosition()).x;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user