mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-18 09:00:07 +02:00
WaveTrackView does not depend on SpectrumView, WaveformView
This commit is contained in:
parent
22dbe69f5c
commit
d7a0fa72db
@ -67,6 +67,11 @@ void SpectrumView::DoSetMinimized( bool minimized )
|
||||
TrackView::DoSetMinimized( minimized );
|
||||
}
|
||||
|
||||
WaveTrackViewConstants::Display SpectrumView::SubViewType() const
|
||||
{
|
||||
return WaveTrackViewConstants::Spectrum;
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> SpectrumView::DoGetVRulerControls()
|
||||
{
|
||||
return std::make_shared<SpectrumVRulerControls>( shared_from_this() );
|
||||
@ -635,3 +640,9 @@ void SpectrumView::Draw(
|
||||
}
|
||||
CommonTrackView::Draw( context, rect, iPass );
|
||||
}
|
||||
|
||||
static const WaveTrackSubViews::RegisteredFactory key{
|
||||
[]( WaveTrackView &view ){
|
||||
return std::make_shared< SpectrumView >( view.FindTrack() );
|
||||
}
|
||||
};
|
||||
|
@ -11,19 +11,21 @@ Paul Licameli split from WaveTrackView.h
|
||||
#ifndef __AUDACITY_SPECTRUM_VIEW__
|
||||
#define __AUDACITY_SPECTRUM_VIEW__
|
||||
|
||||
#include "../../../ui/CommonTrackView.h" // to inherit
|
||||
#include "WaveTrackView.h" // to inherit
|
||||
|
||||
class WaveTrack;
|
||||
|
||||
class SpectrumView final : public CommonTrackView
|
||||
class SpectrumView final : public WaveTrackSubView
|
||||
{
|
||||
SpectrumView( const SpectrumView& ) = delete;
|
||||
SpectrumView &operator=( const SpectrumView& ) = delete;
|
||||
|
||||
public:
|
||||
using CommonTrackView::CommonTrackView;
|
||||
using WaveTrackSubView::WaveTrackSubView;
|
||||
~SpectrumView() override;
|
||||
|
||||
virtual WaveTrackViewConstants::Display SubViewType() const override;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
|
||||
|
||||
|
@ -17,9 +17,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../../../WaveClip.h"
|
||||
#include "../../../../WaveTrack.h"
|
||||
|
||||
#include "SpectrumView.h"
|
||||
#include "WaveformView.h"
|
||||
|
||||
#include "../../../../TrackArtist.h"
|
||||
#include "../../../../TrackPanelDrawingContext.h"
|
||||
#include "../../../../TrackPanelMouseEvent.h"
|
||||
@ -30,9 +27,8 @@ Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
WaveTrackView::WaveTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack }
|
||||
, mWaveformView{ std::make_shared< WaveformView >( pTrack ) }
|
||||
, mSpectrumView{ std::make_shared< SpectrumView >( pTrack ) }
|
||||
{
|
||||
WaveTrackSubViews::BuildAll();
|
||||
}
|
||||
|
||||
WaveTrackView::~WaveTrackView()
|
||||
@ -82,12 +78,18 @@ WaveTrackView::DoDetailedHitTest
|
||||
auto WaveTrackView::GetSubViews( const wxRect &rect ) -> Refinement
|
||||
{
|
||||
auto wt = static_cast<WaveTrack*>( FindTrack().get() );
|
||||
auto display = wt->GetDisplay();
|
||||
std::shared_ptr<TrackView> pSubView;
|
||||
WaveTrackSubViews::ForEach( [&,display]( WaveTrackSubView &subView ){
|
||||
if ( subView.SubViewType() == display )
|
||||
pSubView = subView.shared_from_this();
|
||||
} );
|
||||
if ( !pSubView )
|
||||
return {};
|
||||
return {
|
||||
{
|
||||
rect.GetTop(),
|
||||
wt->GetDisplay() == WaveTrackViewConstants::Waveform
|
||||
? mWaveformView
|
||||
: mSpectrumView
|
||||
pSubView
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -95,11 +97,10 @@ auto WaveTrackView::GetSubViews( const wxRect &rect ) -> Refinement
|
||||
void WaveTrackView::DoSetMinimized( bool minimized )
|
||||
{
|
||||
// May come here. Invoke also on sub-views.
|
||||
if ( mWaveformView )
|
||||
mWaveformView->DoSetMinimized( minimized );
|
||||
if ( mSpectrumView )
|
||||
mSpectrumView->DoSetMinimized( minimized );
|
||||
TrackView::DoSetMinimized( minimized );
|
||||
WaveTrackSubViews::ForEach( [minimized](WaveTrackSubView &subView){
|
||||
subView.DoSetMinimized( minimized );
|
||||
} );
|
||||
}
|
||||
|
||||
using DoGetWaveTrackView = DoGetView::Override< WaveTrack >;
|
||||
@ -305,10 +306,9 @@ ClipParameters::ClipParameters
|
||||
void WaveTrackView::Reparent( const std::shared_ptr<Track> &parent )
|
||||
{
|
||||
CommonTrackView::Reparent( parent );
|
||||
if ( mWaveformView )
|
||||
mWaveformView->Reparent( parent );
|
||||
if ( mSpectrumView )
|
||||
mSpectrumView->Reparent( parent );
|
||||
WaveTrackSubViews::ForEach( [&parent](WaveTrackSubView &subView){
|
||||
subView.Reparent( parent );
|
||||
} );
|
||||
}
|
||||
|
||||
void WaveTrackView::Draw(
|
||||
|
@ -12,10 +12,26 @@ Paul Licameli split from class WaveTrack
|
||||
#define __AUDACITY_WAVE_TRACK_VIEW__
|
||||
|
||||
#include "../../../ui/CommonTrackView.h"
|
||||
#include "../../../../ClientData.h"
|
||||
namespace WaveTrackViewConstants{ enum Display : int; }
|
||||
|
||||
class WaveTrack;
|
||||
class WaveTrackSubView : public CommonTrackView
|
||||
{
|
||||
public:
|
||||
using CommonTrackView::CommonTrackView;
|
||||
|
||||
virtual WaveTrackViewConstants::Display SubViewType() const = 0;
|
||||
};
|
||||
|
||||
class WaveTrackView final : public CommonTrackView
|
||||
class WaveTrackView;
|
||||
using WaveTrackSubViews = ClientData::Site<
|
||||
WaveTrackView, WaveTrackSubView, ClientData::SkipCopying, std::shared_ptr
|
||||
>;
|
||||
|
||||
class WaveTrackView final
|
||||
: public CommonTrackView
|
||||
, public WaveTrackSubViews
|
||||
{
|
||||
WaveTrackView( const WaveTrackView& ) = delete;
|
||||
WaveTrackView &operator=( const WaveTrackView& ) = delete;
|
||||
@ -55,8 +71,6 @@ private:
|
||||
|
||||
protected:
|
||||
void DoSetMinimized( bool minimized ) override;
|
||||
|
||||
std::shared_ptr< CommonTrackView > mWaveformView, mSpectrumView;
|
||||
};
|
||||
|
||||
// Helper for drawing routines
|
||||
|
@ -125,6 +125,11 @@ void WaveformView::DoSetMinimized( bool minimized )
|
||||
TrackView::DoSetMinimized( minimized );
|
||||
}
|
||||
|
||||
WaveTrackViewConstants::Display WaveformView::SubViewType() const
|
||||
{
|
||||
return WaveTrackViewConstants::Waveform;
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> WaveformView::DoGetVRulerControls()
|
||||
{
|
||||
return std::make_shared<WaveformVRulerControls>( shared_from_this() );
|
||||
@ -1074,3 +1079,9 @@ void WaveformView::Draw(
|
||||
}
|
||||
CommonTrackView::Draw( context, rect, iPass );
|
||||
}
|
||||
|
||||
static const WaveTrackSubViews::RegisteredFactory key{
|
||||
[]( WaveTrackView &view ){
|
||||
return std::make_shared< WaveformView >( view.FindTrack() );
|
||||
}
|
||||
};
|
||||
|
@ -11,22 +11,24 @@ Paul Licameli split from WaveTrackView.h
|
||||
#ifndef __AUDACITY_WAVEFORM_VIEW__
|
||||
#define __AUDACITY_WAVEFORM_VIEW__
|
||||
|
||||
#include "../../../ui/CommonTrackView.h" // to inherit
|
||||
#include "WaveTrackView.h" // to inherit
|
||||
|
||||
class WaveTrack;
|
||||
class CutlineHandle;
|
||||
class SampleHandle;
|
||||
class EnvelopeHandle;
|
||||
|
||||
class WaveformView final : public CommonTrackView
|
||||
class WaveformView final : public WaveTrackSubView
|
||||
{
|
||||
WaveformView( const WaveformView& ) = delete;
|
||||
WaveformView &operator=( const WaveformView& ) = delete;
|
||||
|
||||
public:
|
||||
using CommonTrackView::CommonTrackView;
|
||||
using WaveTrackSubView::WaveTrackSubView;
|
||||
~WaveformView() override;
|
||||
|
||||
virtual WaveTrackViewConstants::Display SubViewType() const override;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user