mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-29 06:38:38 +02:00
WaveTrackView now delegates to the proper sub-view...
... by a redefined area subdivision policy in TrackPanel So the SpectrumView, WaveformView, and associated ruler and handle classes find real use, while WaveTrackView is really used only for its height and to supply the delegate, and WaveTrackVRulerControls and WaveTrackVZoomHandle are not used There is also some anticipation of multiple track views
This commit is contained in:
parent
ecbbf7afe8
commit
c7b888b903
@ -916,15 +916,29 @@ void TrackPanel::UpdateTrackVRuler(Track *t)
|
||||
return;
|
||||
|
||||
wxRect rect(mViewInfo->GetVRulerOffset(),
|
||||
kTopMargin,
|
||||
0,
|
||||
mViewInfo->GetVRulerWidth(),
|
||||
0);
|
||||
|
||||
|
||||
for (auto channel : TrackList::Channels(t)) {
|
||||
auto &view = TrackView::Get( *channel );
|
||||
rect.height = view.GetHeight() - (kTopMargin + kBottomMargin);
|
||||
TrackVRulerControls::Get( *channel ).UpdateRuler( rect );
|
||||
const auto height = view.GetHeight() - (kTopMargin + kBottomMargin);
|
||||
const auto subViews = view.GetSubViews( rect );
|
||||
if (subViews.empty())
|
||||
continue;
|
||||
|
||||
auto iter = subViews.begin(), end = subViews.end(), next = iter;
|
||||
auto yy = iter->first;
|
||||
for ( ; iter != end; iter = next ) {
|
||||
++next;
|
||||
auto nextY = ( next == end )
|
||||
? height
|
||||
: next->first;
|
||||
rect.SetHeight( nextY - yy );
|
||||
TrackVRulerControls::Get( *iter->second ).UpdateRuler( rect );
|
||||
yy = nextY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1093,39 +1107,48 @@ struct EmptyCell final : CommonTrackPanelCell {
|
||||
// A vertical ruler left of a channel
|
||||
struct VRulerAndChannel final : TrackPanelGroup {
|
||||
VRulerAndChannel(
|
||||
const std::shared_ptr< Track > &pChannel, wxCoord leftOffset )
|
||||
: mpChannel{ pChannel }, mLeftOffset{ leftOffset } {}
|
||||
const std::shared_ptr< TrackView > &pView, wxCoord leftOffset )
|
||||
: mpView{ pView }, mLeftOffset{ leftOffset } {}
|
||||
Subdivision Children( const wxRect &rect ) override
|
||||
{
|
||||
return { Axis::X, Refinement{
|
||||
{ rect.GetLeft(),
|
||||
TrackVRulerControls::Get( *mpChannel ).shared_from_this() },
|
||||
{ mLeftOffset,
|
||||
TrackView::Get( *mpChannel ).shared_from_this() }
|
||||
TrackVRulerControls::Get( *mpView ).shared_from_this() },
|
||||
{ mLeftOffset, mpView }
|
||||
} };
|
||||
}
|
||||
std::shared_ptr< Track > mpChannel;
|
||||
std::shared_ptr< TrackView > mpView;
|
||||
wxCoord mLeftOffset;
|
||||
};
|
||||
|
||||
// n channels with vertical rulers, alternating with n - 1 resizers
|
||||
// n channels with vertical rulers, alternating with n - 1 resizers;
|
||||
// each channel-ruler pair might be divided into multiple views
|
||||
struct ChannelGroup final : TrackPanelGroup {
|
||||
ChannelGroup( const std::shared_ptr< Track > &pTrack, wxCoord leftOffset )
|
||||
: mpTrack{ pTrack }, mLeftOffset{ leftOffset } {}
|
||||
Subdivision Children( const wxRect &rect ) override
|
||||
Subdivision Children( const wxRect &rect_ ) override
|
||||
{
|
||||
auto rect = rect_;
|
||||
Refinement refinement;
|
||||
|
||||
const auto channels = TrackList::Channels( mpTrack.get() );
|
||||
const auto pLast = *channels.rbegin();
|
||||
wxCoord yy = rect.GetTop();
|
||||
for ( auto channel : channels ) {
|
||||
refinement.emplace_back( yy,
|
||||
std::make_shared< VRulerAndChannel >(
|
||||
channel->SharedPointer(), mLeftOffset ) );
|
||||
if ( channel != pLast ) {
|
||||
auto &view = TrackView::Get( *channel );
|
||||
yy += view.GetHeight();
|
||||
auto height = view.GetHeight();
|
||||
rect.SetTop( yy );
|
||||
rect.SetHeight( height );
|
||||
const auto subViews = TrackView::Get( *channel ).GetSubViews( rect );
|
||||
auto y1 = yy;
|
||||
for ( const auto &subView : subViews ) {
|
||||
y1 = std::max( y1, subView.first );
|
||||
refinement.emplace_back( y1,
|
||||
std::make_shared< VRulerAndChannel >(
|
||||
subView.second, mLeftOffset ) );
|
||||
}
|
||||
if ( channel != pLast ) {
|
||||
yy += height;
|
||||
refinement.emplace_back(
|
||||
yy - kSeparatorThickness,
|
||||
TrackView::Get( *channel ).GetResizer() );
|
||||
|
@ -85,6 +85,19 @@ WaveTrackView::DoDetailedHitTest
|
||||
return { false, results };
|
||||
}
|
||||
|
||||
auto WaveTrackView::GetSubViews( const wxRect &rect ) -> Refinement
|
||||
{
|
||||
auto wt = static_cast<WaveTrack*>( FindTrack().get() );
|
||||
return {
|
||||
{
|
||||
rect.GetTop(),
|
||||
wt->GetDisplay() == WaveTrackViewConstants::Waveform
|
||||
? mWaveformView
|
||||
: mSpectrumView
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void WaveTrackView::DoSetMinimized( bool minimized )
|
||||
{
|
||||
auto wt = static_cast<WaveTrack*>( FindTrack().get() );
|
||||
|
@ -50,6 +50,9 @@ private:
|
||||
const std::shared_ptr<WaveTrack> &wt,
|
||||
CommonTrackView &view);
|
||||
|
||||
// TrackView implementation
|
||||
Refinement GetSubViews( const wxRect &rect ) override;
|
||||
|
||||
protected:
|
||||
void DoSetMinimized( bool minimized ) override;
|
||||
|
||||
|
@ -33,16 +33,6 @@ TrackVRulerControls::~TrackVRulerControls()
|
||||
{
|
||||
}
|
||||
|
||||
TrackVRulerControls &TrackVRulerControls::Get( Track &track )
|
||||
{
|
||||
return *TrackView::Get( track ).GetVRulerControls();
|
||||
}
|
||||
|
||||
const TrackVRulerControls &TrackVRulerControls::Get( const Track &track )
|
||||
{
|
||||
return *TrackView::Get( track ).GetVRulerControls();
|
||||
}
|
||||
|
||||
TrackVRulerControls &TrackVRulerControls::Get( TrackView &trackView )
|
||||
{
|
||||
return *trackView.GetVRulerControls();
|
||||
|
@ -28,9 +28,6 @@ public:
|
||||
|
||||
virtual ~TrackVRulerControls() = 0;
|
||||
|
||||
static TrackVRulerControls &Get( Track& );
|
||||
static const TrackVRulerControls &Get( const Track& );
|
||||
|
||||
static TrackVRulerControls &Get( TrackView& );
|
||||
static const TrackVRulerControls &Get( const TrackView& );
|
||||
|
||||
|
@ -106,6 +106,11 @@ bool TrackView::HandleXMLAttribute( const wxChar *attr, const wxChar *value )
|
||||
return false;
|
||||
}
|
||||
|
||||
auto TrackView::GetSubViews( const wxRect &rect ) -> Refinement
|
||||
{
|
||||
return { { rect.GetTop(), shared_from_this() } };
|
||||
}
|
||||
|
||||
void TrackView::DoSetMinimized(bool isMinimized)
|
||||
{
|
||||
mMinimized = isMinimized;
|
||||
|
@ -72,6 +72,13 @@ public:
|
||||
void WriteXMLAttributes( XMLWriter & ) const override;
|
||||
bool HandleXMLAttribute( const wxChar *attr, const wxChar *value ) override;
|
||||
|
||||
// New virtual function. The default just returns a one-element array
|
||||
// containing this. Overrides might refine the Y axis.
|
||||
using Refinement = std::vector< std::pair<
|
||||
wxCoord, std::shared_ptr< TrackView >
|
||||
> >;
|
||||
virtual Refinement GetSubViews( const wxRect &rect );
|
||||
|
||||
protected:
|
||||
virtual void DoSetMinimized( bool isMinimized );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user