mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 08:59:28 +02:00
Undo the temporary rewrites of WaveTrackView draw and hit-test...
... switching on display type and replicating what the sub-view classes did; now these methods of WaveTrackView should not be reached
This commit is contained in:
parent
8d29746af9
commit
fd7e06e458
@ -36,18 +36,9 @@ std::vector<UIHandlePtr> SpectrumView::DetailedHitTest(
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool )
|
||||
{
|
||||
const auto wt = std::static_pointer_cast< WaveTrack >( FindTrack() );
|
||||
return DoDetailedHitTest( state, pProject, currentTool, bMultiTool, wt,
|
||||
*this );
|
||||
}
|
||||
|
||||
std::vector<UIHandlePtr> SpectrumView::DoDetailedHitTest(
|
||||
const TrackPanelMouseState &state,
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool,
|
||||
const std::shared_ptr<WaveTrack> &wt,
|
||||
CommonTrackView &view)
|
||||
{
|
||||
return WaveTrackView::DoDetailedHitTest(
|
||||
state, pProject, currentTool, bMultiTool,wt, view
|
||||
state, pProject, currentTool, bMultiTool, wt, *this
|
||||
).second;
|
||||
}
|
||||
|
||||
|
@ -41,16 +41,9 @@ private:
|
||||
const TrackPanelMouseState &state,
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool )
|
||||
override;
|
||||
static std::vector<UIHandlePtr> DoDetailedHitTest(
|
||||
const TrackPanelMouseState &state,
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool,
|
||||
const std::shared_ptr<WaveTrack> &wt,
|
||||
CommonTrackView &view);
|
||||
|
||||
protected:
|
||||
void DoSetMinimized( bool minimized ) override;
|
||||
|
||||
friend class WaveTrackView;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -47,14 +47,9 @@ std::vector<UIHandlePtr> WaveTrackView::DetailedHitTest
|
||||
(const TrackPanelMouseState &st,
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool)
|
||||
{
|
||||
const auto pTrack = std::static_pointer_cast< WaveTrack >( FindTrack() );
|
||||
bool isWaveform = (pTrack->GetDisplay() == WaveTrackViewConstants::Waveform);
|
||||
if ( isWaveform )
|
||||
return WaveformView::DoDetailedHitTest(
|
||||
st, pProject, currentTool, bMultiTool, pTrack, *this);
|
||||
else
|
||||
return SpectrumView::DoDetailedHitTest(
|
||||
st, pProject, currentTool, bMultiTool, pTrack, *this);
|
||||
// should not come here any more, delegation to sub-view instead
|
||||
wxASSERT( false );
|
||||
return {};
|
||||
}
|
||||
|
||||
std::pair< bool, std::vector<UIHandlePtr> >
|
||||
@ -64,6 +59,9 @@ WaveTrackView::DoDetailedHitTest
|
||||
const std::shared_ptr<WaveTrack> &pTrack,
|
||||
CommonTrackView &view)
|
||||
{
|
||||
// common hit-testing for different sub-view types, to help implement their
|
||||
// DetailedHitTest()
|
||||
|
||||
// This is the only override of Track::DetailedHitTest that still
|
||||
// depends on the state of the Tools toolbar.
|
||||
// If that toolbar were eliminated, this could simplify to a sequence of
|
||||
@ -100,38 +98,11 @@ auto WaveTrackView::GetSubViews( const wxRect &rect ) -> Refinement
|
||||
|
||||
void WaveTrackView::DoSetMinimized( bool minimized )
|
||||
{
|
||||
auto wt = static_cast<WaveTrack*>( FindTrack().get() );
|
||||
|
||||
#ifdef EXPERIMENTAL_HALF_WAVE
|
||||
bool bHalfWave;
|
||||
gPrefs->Read(wxT("/GUI/CollapseToHalfWave"), &bHalfWave, false);
|
||||
if( bHalfWave )
|
||||
{
|
||||
const bool spectral =
|
||||
(wt->GetDisplay() == WaveTrackViewConstants::Spectrum);
|
||||
if ( spectral ) {
|
||||
// It is all right to set the top of scale to a huge number,
|
||||
// not knowing the track rate here -- because when retrieving the
|
||||
// value, then we pass in a sample rate and clamp it above to the
|
||||
// Nyquist frequency.
|
||||
constexpr auto max = std::numeric_limits<float>::max();
|
||||
const bool spectrumLinear =
|
||||
(wt->GetSpectrogramSettings().scaleType ==
|
||||
SpectrogramSettings::stLinear);
|
||||
// Zoom out full
|
||||
wt->SetSpectrumBounds( spectrumLinear ? 0.0f : 1.0f, max );
|
||||
}
|
||||
else {
|
||||
if (minimized)
|
||||
// Zoom to show fractionally more than the top half of the wave.
|
||||
wt->SetDisplayBounds( -0.01f, 1.0f );
|
||||
else
|
||||
// Zoom out full
|
||||
wt->SetDisplayBounds( -1.0f, 1.0f );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// May come here. Invoke also on sub-views.
|
||||
if ( mWaveformView )
|
||||
mWaveformView->DoSetMinimized( minimized );
|
||||
if ( mSpectrumView )
|
||||
mSpectrumView->DoSetMinimized( minimized );
|
||||
TrackView::DoSetMinimized( minimized );
|
||||
}
|
||||
|
||||
@ -348,39 +319,8 @@ void WaveTrackView::Draw(
|
||||
TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, unsigned iPass )
|
||||
{
|
||||
if ( iPass == TrackArtist::PassTracks ) {
|
||||
auto &dc = context.dc;
|
||||
const auto wt = std::static_pointer_cast<const WaveTrack>(
|
||||
FindTrack()->SubstitutePendingChangedTrack());
|
||||
// Should not come here, drawing is now delegated to sub-views
|
||||
wxASSERT( false );
|
||||
|
||||
for (const auto &clip : wt->GetClips()) {
|
||||
clip->ClearDisplayRect();
|
||||
}
|
||||
|
||||
const auto artist = TrackArtist::Get( context );
|
||||
const auto hasSolo = artist->hasSolo;
|
||||
bool muted = (hasSolo || wt->GetMute()) &&
|
||||
!wt->GetSolo();
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
wxAntialiasMode aamode = dc.GetGraphicsContext()->GetAntialiasMode();
|
||||
dc.GetGraphicsContext()->SetAntialiasMode(wxANTIALIAS_NONE);
|
||||
#endif
|
||||
|
||||
switch (wt->GetDisplay()) {
|
||||
case WaveTrackViewConstants::Waveform:
|
||||
WaveformView::DoDraw(context, wt.get(), rect, muted);
|
||||
break;
|
||||
case WaveTrackViewConstants::Spectrum:
|
||||
SpectrumView::DoDraw( context, wt.get(), rect );
|
||||
break;
|
||||
default:
|
||||
wxASSERT(false);
|
||||
}
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
dc.GetGraphicsContext()->SetAntialiasMode(aamode);
|
||||
#endif
|
||||
}
|
||||
CommonTrackView::Draw( context, rect, iPass );
|
||||
}
|
||||
|
@ -38,20 +38,13 @@ Paul Licameli split from WaveTrackView.cpp
|
||||
WaveformView::~WaveformView() = default;
|
||||
|
||||
std::vector<UIHandlePtr> WaveformView::DetailedHitTest(
|
||||
const TrackPanelMouseState &state,
|
||||
const TrackPanelMouseState &st,
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool )
|
||||
{
|
||||
const auto wt = std::static_pointer_cast< WaveTrack >( FindTrack() );
|
||||
return DoDetailedHitTest( state, pProject, currentTool, bMultiTool, wt,
|
||||
*this );
|
||||
}
|
||||
|
||||
std::vector<UIHandlePtr> WaveformView::DoDetailedHitTest(
|
||||
const TrackPanelMouseState &st,
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool,
|
||||
const std::shared_ptr<WaveTrack> &wt,
|
||||
CommonTrackView &view )
|
||||
{
|
||||
auto &view = *this;
|
||||
|
||||
auto pair = WaveTrackView::DoDetailedHitTest(
|
||||
st, pProject, currentTool, bMultiTool, wt, view);
|
||||
auto &results = pair.second;
|
||||
|
@ -14,6 +14,9 @@ Paul Licameli split from WaveTrackView.h
|
||||
#include "../../../ui/CommonTrackView.h" // to inherit
|
||||
|
||||
class WaveTrack;
|
||||
class CutlineHandle;
|
||||
class SampleHandle;
|
||||
class EnvelopeHandle;
|
||||
|
||||
class WaveformView final : public CommonTrackView
|
||||
{
|
||||
@ -41,16 +44,13 @@ private:
|
||||
const TrackPanelMouseState &state,
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool )
|
||||
override;
|
||||
static std::vector<UIHandlePtr> DoDetailedHitTest(
|
||||
const TrackPanelMouseState &state,
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool,
|
||||
const std::shared_ptr<WaveTrack> &wt,
|
||||
CommonTrackView &view);
|
||||
|
||||
protected:
|
||||
void DoSetMinimized( bool minimized ) override;
|
||||
|
||||
friend class WaveTrackView;
|
||||
std::weak_ptr<CutlineHandle> mCutlineHandle;
|
||||
std::weak_ptr<SampleHandle> mSampleHandle;
|
||||
std::weak_ptr<EnvelopeHandle> mEnvelopeHandle;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -16,10 +16,6 @@ Paul Licameli split from class TrackView
|
||||
class SelectHandle;
|
||||
class TimeShiftHandle;
|
||||
|
||||
class CutlineHandle;
|
||||
class SampleHandle;
|
||||
class EnvelopeHandle;
|
||||
|
||||
class CommonTrackView /* not final */ : public TrackView
|
||||
{
|
||||
public:
|
||||
@ -35,6 +31,8 @@ public:
|
||||
(const TrackPanelMouseState &, const AudacityProject *pProject)
|
||||
final override;
|
||||
|
||||
void TimeShiftHitTest();
|
||||
|
||||
// TrackPanelDrawable implementation
|
||||
void Draw(
|
||||
TrackPanelDrawingContext &context,
|
||||
@ -52,14 +50,9 @@ protected:
|
||||
Track *GetTrack() const;
|
||||
|
||||
std::weak_ptr<SelectHandle> mSelectHandle;
|
||||
std::weak_ptr<TimeShiftHandle> mTimeShiftHandle;
|
||||
|
||||
// Temporarily demoting these fields here from WaveTrackView
|
||||
std::weak_ptr<CutlineHandle> mCutlineHandle;
|
||||
std::weak_ptr<SampleHandle> mSampleHandle;
|
||||
std::weak_ptr<EnvelopeHandle> mEnvelopeHandle;
|
||||
friend class WaveformView;
|
||||
friend class WaveTrackView;
|
||||
public:
|
||||
std::weak_ptr<TimeShiftHandle> mTimeShiftHandle;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -79,9 +79,10 @@ public:
|
||||
> >;
|
||||
virtual Refinement GetSubViews( const wxRect &rect );
|
||||
|
||||
protected:
|
||||
virtual void DoSetMinimized( bool isMinimized );
|
||||
|
||||
protected:
|
||||
|
||||
// No need yet to make this virtual
|
||||
void DoSetY(int y);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user