Bug2493, Enh2460: Multi-view option in Tracks preferences & macros...
... Implemented giving the Multi-view choice the special implementation that it needs. The "multi" choice is always last in the preference and in the command editing drop-down menus, but that could be changed. Multi-view should not be treated as another registered kind of sub-view on par with others. This would complicate the implementation in worse ways.
This commit is contained in:
parent
42d99db8b8
commit
c7896a3656
|
@ -297,8 +297,10 @@ static const EnumValueSymbol kZoomTypeStrings[nZoomTypes] =
|
|||
static EnumValueSymbols DiscoverSubViewTypes()
|
||||
{
|
||||
const auto &types = WaveTrackSubViewType::All();
|
||||
return transform_container< EnumValueSymbols >(
|
||||
auto result = transform_container< EnumValueSymbols >(
|
||||
types, std::mem_fn( &WaveTrackSubView::Type::name ) );
|
||||
result.push_back( WaveTrackViewConstants::MultiViewSymbol );
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SetTrackVisualsCommand::DefineParams( ShuttleParams & S ){
|
||||
|
@ -374,9 +376,16 @@ bool SetTrackVisualsCommand::ApplyInner(const CommandContext & context, Track *
|
|||
if( t && bHasHeight )
|
||||
TrackView::Get( *t ).SetHeight( mHeight );
|
||||
|
||||
if( wt && bHasDisplayType )
|
||||
WaveTrackView::Get( *wt ).SetDisplay(
|
||||
WaveTrackSubViewType::All()[ mDisplayType ].id );
|
||||
if( wt && bHasDisplayType ) {
|
||||
auto &view = WaveTrackView::Get( *wt );
|
||||
auto &all = WaveTrackSubViewType::All();
|
||||
if (mDisplayType < all.size())
|
||||
view.SetDisplay( all[ mDisplayType ].id );
|
||||
else {
|
||||
view.SetMultiView( true );
|
||||
view.SetDisplay( WaveTrackSubViewType::Default(), false );
|
||||
}
|
||||
}
|
||||
if( wt && bHasScaleType )
|
||||
wt->GetIndependentWaveformSettings().scaleType =
|
||||
(mScaleType==kLinear) ?
|
||||
|
|
|
@ -154,6 +154,11 @@ static TracksViewModeEnumSetting viewModeSetting()
|
|||
types, std::mem_fn( &WaveTrackSubViewType::name ) );
|
||||
auto ids = transform_container< std::vector< WaveTrackSubViewType::Display > >(
|
||||
types, std::mem_fn( &WaveTrackSubViewType::id ) );
|
||||
|
||||
// Special entry for multi
|
||||
symbols.push_back( WaveTrackViewConstants::MultiViewSymbol );
|
||||
ids.push_back( WaveTrackViewConstants::MultiView );
|
||||
|
||||
return {
|
||||
key3,
|
||||
symbols,
|
||||
|
|
|
@ -1273,6 +1273,11 @@ void WaveTrackView::BuildSubViews() const
|
|||
|
||||
auto pTrack = pThis->FindTrack();
|
||||
auto display = TracksPrefs::ViewModeChoice();
|
||||
bool multi = (display == WaveTrackViewConstants::MultiView);
|
||||
if ( multi ) {
|
||||
pThis->SetMultiView( true );
|
||||
display = WaveTrackSubViewType::Default();
|
||||
}
|
||||
|
||||
// Force creation always:
|
||||
WaveformSettings &settings = static_cast< WaveTrack* >( pTrack.get() )
|
||||
|
@ -1282,7 +1287,7 @@ void WaveTrackView::BuildSubViews() const
|
|||
// spectrogram
|
||||
settings.scaleType = TracksPrefs::WaveformScaleChoice();
|
||||
|
||||
pThis->DoSetDisplay( display );
|
||||
pThis->DoSetDisplay( display, !multi );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ Paul Licameli split from class WaveTrack
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
#include "../../../../Internat.h"
|
||||
#include "WaveTrackViewConstants.h"
|
||||
|
||||
// static
|
||||
|
@ -91,3 +92,16 @@ auto WaveTrackSubViewType::All()
|
|||
{
|
||||
return GetRegistry().Get();
|
||||
}
|
||||
|
||||
// static
|
||||
auto WaveTrackSubViewType::Default() -> Display
|
||||
{
|
||||
auto &all = All();
|
||||
if (all.empty())
|
||||
return WaveTrackViewConstants::Waveform;
|
||||
return all[0].id;
|
||||
}
|
||||
|
||||
const EnumValueSymbol WaveTrackViewConstants::MultiViewSymbol{
|
||||
wxT("Multiview"), XXO("&Multi-view")
|
||||
};
|
||||
|
|
|
@ -11,10 +11,14 @@ Paul Licameli split from class WaveTrack
|
|||
#ifndef __AUDACITY_WAVE_TRACK_VIEW_CONSTANTS__
|
||||
#define __AUDACITY_WAVE_TRACK_VIEW_CONSTANTS__
|
||||
|
||||
#include "audacity/ComponentInterface.h" // for EnumValueSymbol
|
||||
|
||||
namespace WaveTrackViewConstants
|
||||
{
|
||||
enum Display : int {
|
||||
|
||||
MultiView = -1, //!< "Multi" is special, not really a view type on par with the others.
|
||||
|
||||
// DO NOT REORDER OLD VALUES! Replace obsoletes with placeholders.
|
||||
|
||||
Waveform = 0,
|
||||
|
@ -77,10 +81,12 @@ namespace WaveTrackViewConstants
|
|||
|
||||
// Handle remapping of enum values from 2.1.0 and earlier
|
||||
Display ConvertLegacyDisplayValue(int oldValue);
|
||||
|
||||
//! String identifier for a preference for one of each type of view
|
||||
extern const EnumValueSymbol MultiViewSymbol;
|
||||
}
|
||||
|
||||
#include <vector>
|
||||
#include "audacity/ComponentInterface.h" // for EnumValueSymbol
|
||||
|
||||
struct WaveTrackSubViewType {
|
||||
using Display = WaveTrackViewConstants::Display;
|
||||
|
@ -103,8 +109,11 @@ struct WaveTrackSubViewType {
|
|||
RegisteredType( WaveTrackSubViewType type );
|
||||
};
|
||||
|
||||
// Discover all registered types
|
||||
//! Discover all registered types
|
||||
static const std::vector<WaveTrackSubViewType> &All();
|
||||
|
||||
//! Return a preferred type
|
||||
static Display Default();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user