mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-29 23:19:28 +02:00
Some briefer type aliases for wave track display type
This commit is contained in:
parent
d9ddb41410
commit
fb8ba0ce43
@ -150,7 +150,7 @@ void WaveformSettings::NextHigherDBRange()
|
|||||||
const TranslatableStrings &WaveformSettings::GetScaleNames()
|
const TranslatableStrings &WaveformSettings::GetScaleNames()
|
||||||
{
|
{
|
||||||
static const TranslatableStrings result{
|
static const TranslatableStrings result{
|
||||||
// Keep in correspondence with enum WaveTrack::WaveTrackDisplay:
|
// Keep in correspondence with ScaleTypeValues:
|
||||||
XO("Linear"),
|
XO("Linear"),
|
||||||
XO("dB"),
|
XO("dB"),
|
||||||
};
|
};
|
||||||
|
@ -73,7 +73,7 @@ void SpectrumView::DoSetMinimized( bool minimized )
|
|||||||
TrackView::DoSetMinimized( minimized );
|
TrackView::DoSetMinimized( minimized );
|
||||||
}
|
}
|
||||||
|
|
||||||
WaveTrackViewConstants::Display SpectrumView::SubViewType() const
|
auto SpectrumView::SubViewType() const -> Display
|
||||||
{
|
{
|
||||||
return WaveTrackViewConstants::Spectrum;
|
return WaveTrackViewConstants::Spectrum;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
using WaveTrackSubView::WaveTrackSubView;
|
using WaveTrackSubView::WaveTrackSubView;
|
||||||
~SpectrumView() override;
|
~SpectrumView() override;
|
||||||
|
|
||||||
virtual WaveTrackViewConstants::Display SubViewType() const override;
|
virtual Display SubViewType() const override;
|
||||||
|
|
||||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||||
|
|
||||||
|
@ -804,7 +804,7 @@ void WaveTrackMenuTable::OnSetDisplay(wxCommandEvent & event)
|
|||||||
wxASSERT(idInt >= OnWaveformID && idInt <= OnSpectrumID);
|
wxASSERT(idInt >= OnWaveformID && idInt <= OnSpectrumID);
|
||||||
const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
||||||
|
|
||||||
WaveTrackView::WaveTrackDisplay id;
|
WaveTrackView::Display id;
|
||||||
switch (idInt) {
|
switch (idInt) {
|
||||||
default:
|
default:
|
||||||
case OnWaveformID:
|
case OnWaveformID:
|
||||||
@ -816,7 +816,8 @@ void WaveTrackMenuTable::OnSetDisplay(wxCommandEvent & event)
|
|||||||
auto &view = WaveTrackView::Get( *pTrack );
|
auto &view = WaveTrackView::Get( *pTrack );
|
||||||
if ( view.GetMultiView() ) {
|
if ( view.GetMultiView() ) {
|
||||||
for (auto channel : TrackList::Channels(pTrack)) {
|
for (auto channel : TrackList::Channels(pTrack)) {
|
||||||
if ( !WaveTrackView::Get( *channel ).ToggleSubView( id ) ) {
|
if ( !WaveTrackView::Get( *channel )
|
||||||
|
.ToggleSubView( WaveTrackView::Display{ id } ) ) {
|
||||||
// Trying to toggle off the last sub-view. It was refused.
|
// Trying to toggle off the last sub-view. It was refused.
|
||||||
// Decide what to do here. Turn off multi-view instead?
|
// Decide what to do here. Turn off multi-view instead?
|
||||||
// PRL: I don't agree that it makes sense
|
// PRL: I don't agree that it makes sense
|
||||||
@ -832,7 +833,7 @@ void WaveTrackMenuTable::OnSetDisplay(wxCommandEvent & event)
|
|||||||
for (auto channel : TrackList::Channels(pTrack)) {
|
for (auto channel : TrackList::Channels(pTrack)) {
|
||||||
channel->SetLastScaleType();
|
channel->SetLastScaleType();
|
||||||
WaveTrackView::Get( *channel )
|
WaveTrackView::Get( *channel )
|
||||||
.SetDisplay(WaveTrackView::WaveTrackDisplay(id));
|
.SetDisplay( WaveTrackView::Display{ id } );
|
||||||
}
|
}
|
||||||
|
|
||||||
AudacityProject *const project = &mpData->project;
|
AudacityProject *const project = &mpData->project;
|
||||||
|
@ -842,12 +842,12 @@ WaveTrackView::DoDetailedHitTest
|
|||||||
return { false, results };
|
return { false, results };
|
||||||
}
|
}
|
||||||
|
|
||||||
auto WaveTrackView::GetDisplays() const -> std::vector<WaveTrackDisplay>
|
auto WaveTrackView::GetDisplays() const -> std::vector<Display>
|
||||||
{
|
{
|
||||||
BuildSubViews();
|
BuildSubViews();
|
||||||
|
|
||||||
// Collect the display types of visible views and sort them by position
|
// Collect the display types of visible views and sort them by position
|
||||||
using Pair = std::pair< int, WaveTrackDisplay >;
|
using Pair = std::pair< int, Display >;
|
||||||
std::vector< Pair > pairs;
|
std::vector< Pair > pairs;
|
||||||
size_t ii = 0;
|
size_t ii = 0;
|
||||||
WaveTrackSubViews::ForEach( [&]( const WaveTrackSubView &subView ){
|
WaveTrackSubViews::ForEach( [&]( const WaveTrackSubView &subView ){
|
||||||
@ -857,19 +857,19 @@ auto WaveTrackView::GetDisplays() const -> std::vector<WaveTrackDisplay>
|
|||||||
++ii;
|
++ii;
|
||||||
} );
|
} );
|
||||||
std::sort( pairs.begin(), pairs.end() );
|
std::sort( pairs.begin(), pairs.end() );
|
||||||
std::vector<WaveTrackDisplay> results;
|
std::vector<Display> results;
|
||||||
for ( const auto &pair : pairs )
|
for ( const auto &pair : pairs )
|
||||||
results.push_back( pair.second );
|
results.push_back( pair.second );
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveTrackView::SetDisplay(WaveTrackDisplay display, bool exclusive)
|
void WaveTrackView::SetDisplay(Display display, bool exclusive)
|
||||||
{
|
{
|
||||||
BuildSubViews();
|
BuildSubViews();
|
||||||
DoSetDisplay( display, exclusive );
|
DoSetDisplay( display, exclusive );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaveTrackView::ToggleSubView(WaveTrackDisplay display)
|
bool WaveTrackView::ToggleSubView(Display display)
|
||||||
{
|
{
|
||||||
size_t ii = 0;
|
size_t ii = 0;
|
||||||
size_t found = 0;
|
size_t found = 0;
|
||||||
@ -927,7 +927,7 @@ bool WaveTrackView::ToggleSubView(WaveTrackDisplay display)
|
|||||||
// If exclusive, make the chosen view take up all the height. Else,
|
// If exclusive, make the chosen view take up all the height. Else,
|
||||||
// partition equally, putting the specified view on top.
|
// partition equally, putting the specified view on top.
|
||||||
// Be sure the sequence in which the other views appear is determinate.
|
// Be sure the sequence in which the other views appear is determinate.
|
||||||
void WaveTrackView::DoSetDisplay(WaveTrackDisplay display, bool exclusive)
|
void WaveTrackView::DoSetDisplay(Display display, bool exclusive)
|
||||||
{
|
{
|
||||||
// Some generality here anticipating more than two views.
|
// Some generality here anticipating more than two views.
|
||||||
// The order of sub-views in the array is not specified, so make it definite
|
// The order of sub-views in the array is not specified, so make it definite
|
||||||
|
@ -22,10 +22,12 @@ class WaveTrackView;
|
|||||||
class WaveTrackSubView : public CommonTrackView
|
class WaveTrackSubView : public CommonTrackView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using Display = WaveTrackViewConstants::Display;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
WaveTrackSubView( WaveTrackView &waveTrackView );
|
WaveTrackSubView( WaveTrackView &waveTrackView );
|
||||||
|
|
||||||
virtual WaveTrackViewConstants::Display SubViewType() const = 0;
|
virtual Display SubViewType() const = 0;
|
||||||
|
|
||||||
std::pair<
|
std::pair<
|
||||||
bool, // if true, hit-testing is finished
|
bool, // if true, hit-testing is finished
|
||||||
@ -67,6 +69,8 @@ class WaveTrackView final
|
|||||||
WaveTrackView &operator=( const WaveTrackView& ) = delete;
|
WaveTrackView &operator=( const WaveTrackView& ) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using Display = WaveTrackViewConstants::Display;
|
||||||
|
|
||||||
static WaveTrackView &Get( WaveTrack &track );
|
static WaveTrackView &Get( WaveTrack &track );
|
||||||
static const WaveTrackView &Get( const WaveTrack &track );
|
static const WaveTrackView &Get( const WaveTrack &track );
|
||||||
|
|
||||||
@ -91,10 +95,8 @@ public:
|
|||||||
const std::shared_ptr<WaveTrack> &wt,
|
const std::shared_ptr<WaveTrack> &wt,
|
||||||
CommonTrackView &view);
|
CommonTrackView &view);
|
||||||
|
|
||||||
using WaveTrackDisplay = WaveTrackViewConstants::Display;
|
std::vector<Display> GetDisplays() const;
|
||||||
|
void SetDisplay(Display display, bool exclusive = true);
|
||||||
std::vector<WaveTrackDisplay> GetDisplays() const;
|
|
||||||
void SetDisplay(WaveTrackDisplay display, bool exclusive = true);
|
|
||||||
|
|
||||||
const WaveTrackSubViewPlacements &SavePlacements() const
|
const WaveTrackSubViewPlacements &SavePlacements() const
|
||||||
{ return mPlacements; }
|
{ return mPlacements; }
|
||||||
@ -103,7 +105,7 @@ public:
|
|||||||
|
|
||||||
// Return true if successful. Fails if you try to toggle off the only
|
// Return true if successful. Fails if you try to toggle off the only
|
||||||
// sub-view.
|
// sub-view.
|
||||||
bool ToggleSubView( WaveTrackDisplay id );
|
bool ToggleSubView( Display id );
|
||||||
|
|
||||||
// Get all the sub-views, in a sequence that is unspecified but in
|
// Get all the sub-views, in a sequence that is unspecified but in
|
||||||
// correspondence with the result of SavePlacements
|
// correspondence with the result of SavePlacements
|
||||||
@ -117,7 +119,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void BuildSubViews() const;
|
void BuildSubViews() const;
|
||||||
void DoSetDisplay(WaveTrackDisplay display, bool exclusive = true);
|
void DoSetDisplay(Display display, bool exclusive = true);
|
||||||
|
|
||||||
// TrackPanelDrawable implementation
|
// TrackPanelDrawable implementation
|
||||||
void Draw(
|
void Draw(
|
||||||
|
@ -119,7 +119,7 @@ void WaveformView::DoSetMinimized( bool minimized )
|
|||||||
TrackView::DoSetMinimized( minimized );
|
TrackView::DoSetMinimized( minimized );
|
||||||
}
|
}
|
||||||
|
|
||||||
WaveTrackViewConstants::Display WaveformView::SubViewType() const
|
auto WaveformView::SubViewType() const -> Display
|
||||||
{
|
{
|
||||||
return WaveTrackViewConstants::Waveform;
|
return WaveTrackViewConstants::Waveform;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
using WaveTrackSubView::WaveTrackSubView;
|
using WaveTrackSubView::WaveTrackSubView;
|
||||||
~WaveformView() override;
|
~WaveformView() override;
|
||||||
|
|
||||||
virtual WaveTrackViewConstants::Display SubViewType() const override;
|
virtual Display SubViewType() const override;
|
||||||
|
|
||||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user