mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-29 14:48:39 +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;
|
return;
|
||||||
|
|
||||||
wxRect rect(mViewInfo->GetVRulerOffset(),
|
wxRect rect(mViewInfo->GetVRulerOffset(),
|
||||||
kTopMargin,
|
0,
|
||||||
mViewInfo->GetVRulerWidth(),
|
mViewInfo->GetVRulerWidth(),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
|
||||||
for (auto channel : TrackList::Channels(t)) {
|
for (auto channel : TrackList::Channels(t)) {
|
||||||
auto &view = TrackView::Get( *channel );
|
auto &view = TrackView::Get( *channel );
|
||||||
rect.height = view.GetHeight() - (kTopMargin + kBottomMargin);
|
const auto height = view.GetHeight() - (kTopMargin + kBottomMargin);
|
||||||
TrackVRulerControls::Get( *channel ).UpdateRuler( rect );
|
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
|
// A vertical ruler left of a channel
|
||||||
struct VRulerAndChannel final : TrackPanelGroup {
|
struct VRulerAndChannel final : TrackPanelGroup {
|
||||||
VRulerAndChannel(
|
VRulerAndChannel(
|
||||||
const std::shared_ptr< Track > &pChannel, wxCoord leftOffset )
|
const std::shared_ptr< TrackView > &pView, wxCoord leftOffset )
|
||||||
: mpChannel{ pChannel }, mLeftOffset{ leftOffset } {}
|
: mpView{ pView }, mLeftOffset{ leftOffset } {}
|
||||||
Subdivision Children( const wxRect &rect ) override
|
Subdivision Children( const wxRect &rect ) override
|
||||||
{
|
{
|
||||||
return { Axis::X, Refinement{
|
return { Axis::X, Refinement{
|
||||||
{ rect.GetLeft(),
|
{ rect.GetLeft(),
|
||||||
TrackVRulerControls::Get( *mpChannel ).shared_from_this() },
|
TrackVRulerControls::Get( *mpView ).shared_from_this() },
|
||||||
{ mLeftOffset,
|
{ mLeftOffset, mpView }
|
||||||
TrackView::Get( *mpChannel ).shared_from_this() }
|
|
||||||
} };
|
} };
|
||||||
}
|
}
|
||||||
std::shared_ptr< Track > mpChannel;
|
std::shared_ptr< TrackView > mpView;
|
||||||
wxCoord mLeftOffset;
|
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 {
|
struct ChannelGroup final : TrackPanelGroup {
|
||||||
ChannelGroup( const std::shared_ptr< Track > &pTrack, wxCoord leftOffset )
|
ChannelGroup( const std::shared_ptr< Track > &pTrack, wxCoord leftOffset )
|
||||||
: mpTrack{ pTrack }, mLeftOffset{ leftOffset } {}
|
: mpTrack{ pTrack }, mLeftOffset{ leftOffset } {}
|
||||||
Subdivision Children( const wxRect &rect ) override
|
Subdivision Children( const wxRect &rect_ ) override
|
||||||
{
|
{
|
||||||
|
auto rect = rect_;
|
||||||
Refinement refinement;
|
Refinement refinement;
|
||||||
|
|
||||||
const auto channels = TrackList::Channels( mpTrack.get() );
|
const auto channels = TrackList::Channels( mpTrack.get() );
|
||||||
const auto pLast = *channels.rbegin();
|
const auto pLast = *channels.rbegin();
|
||||||
wxCoord yy = rect.GetTop();
|
wxCoord yy = rect.GetTop();
|
||||||
for ( auto channel : channels ) {
|
for ( auto channel : channels ) {
|
||||||
refinement.emplace_back( yy,
|
auto &view = TrackView::Get( *channel );
|
||||||
std::make_shared< VRulerAndChannel >(
|
auto height = view.GetHeight();
|
||||||
channel->SharedPointer(), mLeftOffset ) );
|
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 ) {
|
if ( channel != pLast ) {
|
||||||
auto &view = TrackView::Get( *channel );
|
yy += height;
|
||||||
yy += view.GetHeight();
|
|
||||||
refinement.emplace_back(
|
refinement.emplace_back(
|
||||||
yy - kSeparatorThickness,
|
yy - kSeparatorThickness,
|
||||||
TrackView::Get( *channel ).GetResizer() );
|
TrackView::Get( *channel ).GetResizer() );
|
||||||
|
@ -85,6 +85,19 @@ WaveTrackView::DoDetailedHitTest
|
|||||||
return { false, results };
|
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 )
|
void WaveTrackView::DoSetMinimized( bool minimized )
|
||||||
{
|
{
|
||||||
auto wt = static_cast<WaveTrack*>( FindTrack().get() );
|
auto wt = static_cast<WaveTrack*>( FindTrack().get() );
|
||||||
|
@ -50,6 +50,9 @@ private:
|
|||||||
const std::shared_ptr<WaveTrack> &wt,
|
const std::shared_ptr<WaveTrack> &wt,
|
||||||
CommonTrackView &view);
|
CommonTrackView &view);
|
||||||
|
|
||||||
|
// TrackView implementation
|
||||||
|
Refinement GetSubViews( const wxRect &rect ) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void DoSetMinimized( bool minimized ) override;
|
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 )
|
TrackVRulerControls &TrackVRulerControls::Get( TrackView &trackView )
|
||||||
{
|
{
|
||||||
return *trackView.GetVRulerControls();
|
return *trackView.GetVRulerControls();
|
||||||
|
@ -28,9 +28,6 @@ public:
|
|||||||
|
|
||||||
virtual ~TrackVRulerControls() = 0;
|
virtual ~TrackVRulerControls() = 0;
|
||||||
|
|
||||||
static TrackVRulerControls &Get( Track& );
|
|
||||||
static const TrackVRulerControls &Get( const Track& );
|
|
||||||
|
|
||||||
static TrackVRulerControls &Get( TrackView& );
|
static TrackVRulerControls &Get( TrackView& );
|
||||||
static const TrackVRulerControls &Get( const TrackView& );
|
static const TrackVRulerControls &Get( const TrackView& );
|
||||||
|
|
||||||
|
@ -106,6 +106,11 @@ bool TrackView::HandleXMLAttribute( const wxChar *attr, const wxChar *value )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto TrackView::GetSubViews( const wxRect &rect ) -> Refinement
|
||||||
|
{
|
||||||
|
return { { rect.GetTop(), shared_from_this() } };
|
||||||
|
}
|
||||||
|
|
||||||
void TrackView::DoSetMinimized(bool isMinimized)
|
void TrackView::DoSetMinimized(bool isMinimized)
|
||||||
{
|
{
|
||||||
mMinimized = isMinimized;
|
mMinimized = isMinimized;
|
||||||
|
@ -72,6 +72,13 @@ public:
|
|||||||
void WriteXMLAttributes( XMLWriter & ) const override;
|
void WriteXMLAttributes( XMLWriter & ) const override;
|
||||||
bool HandleXMLAttribute( const wxChar *attr, const wxChar *value ) 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:
|
protected:
|
||||||
virtual void DoSetMinimized( bool isMinimized );
|
virtual void DoSetMinimized( bool isMinimized );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user