mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-14 17:14:07 +01:00
Bug2279 fix reimplemented...
... Don't hard-code the number of sub-views as two.
This modifies the fix at commit 596fd7c02f
This commit is contained in:
@@ -770,10 +770,10 @@ void WaveTrackMenuTable::OnMultiView(wxCommandEvent & event)
|
|||||||
{
|
{
|
||||||
const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
||||||
const auto &view = WaveTrackView::Get( *pTrack );
|
const auto &view = WaveTrackView::Get( *pTrack );
|
||||||
const int nViewTypes = 2;
|
|
||||||
bool multi = !view.GetMultiView();
|
bool multi = !view.GetMultiView();
|
||||||
WaveTrackView::WaveTrackDisplay display;
|
const auto &displays = view.GetDisplays();
|
||||||
display = *view.GetDisplays().begin();
|
const auto display = displays.empty()
|
||||||
|
? WaveTrackViewConstants::Waveform : *displays.begin();
|
||||||
for (const auto channel : TrackList::Channels(pTrack)) {
|
for (const auto channel : TrackList::Channels(pTrack)) {
|
||||||
auto &channelView = WaveTrackView::Get( *channel );
|
auto &channelView = WaveTrackView::Get( *channel );
|
||||||
channelView.SetMultiView( multi );
|
channelView.SetMultiView( multi );
|
||||||
@@ -781,7 +781,7 @@ void WaveTrackMenuTable::OnMultiView(wxCommandEvent & event)
|
|||||||
// Whichever sub-view was on top stays on top
|
// Whichever sub-view was on top stays on top
|
||||||
// If going into Multi-view, it will be 1/nth the height.
|
// If going into Multi-view, it will be 1/nth the height.
|
||||||
// If exiting multi-view, it will be full height.
|
// If exiting multi-view, it will be full height.
|
||||||
channelView.SetDisplay(display, multi ? 1.0/nViewTypes :1.0);
|
channelView.SetDisplay(display, !multi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -540,10 +540,10 @@ auto WaveTrackView::GetDisplays() const -> std::vector<WaveTrackDisplay>
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveTrackView::SetDisplay(WaveTrackDisplay display, float frac)
|
void WaveTrackView::SetDisplay(WaveTrackDisplay display, bool exclusive)
|
||||||
{
|
{
|
||||||
BuildSubViews();
|
BuildSubViews();
|
||||||
DoSetDisplay( display, frac );
|
DoSetDisplay( display, exclusive );
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveTrackView::ToggleSubView(WaveTrackDisplay display)
|
void WaveTrackView::ToggleSubView(WaveTrackDisplay display)
|
||||||
@@ -572,7 +572,7 @@ void WaveTrackView::ToggleSubView(WaveTrackDisplay display)
|
|||||||
// if removing the last one, then don't!
|
// if removing the last one, then don't!
|
||||||
// Switch to radio-button view instead.
|
// Switch to radio-button view instead.
|
||||||
if (nn <= 1) {
|
if (nn <= 1) {
|
||||||
DoSetDisplay(display, 1.0);
|
DoSetDisplay(display);
|
||||||
SetMultiView(false);
|
SetMultiView(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -610,32 +610,38 @@ void WaveTrackView::ToggleSubView(WaveTrackDisplay display)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// frac sets proportion/height of the chosen display, which will be first.
|
// If exclusive, make the chosen view take up all the height. Else,
|
||||||
// use 1.0 to take up entire space
|
// partition equally, putting the specified view on top.
|
||||||
// use some fraction to take up that proportion, leaving the rest for
|
// Be sure the sequence in which the other views appear is determinate.
|
||||||
// one each of the other types.
|
void WaveTrackView::DoSetDisplay(WaveTrackDisplay display, bool exclusive)
|
||||||
// use 1.0/number-of-types for equal spacing.
|
|
||||||
void WaveTrackView::DoSetDisplay(WaveTrackDisplay display,float frac)
|
|
||||||
{
|
{
|
||||||
|
// Some generality here anticipating more than two views.
|
||||||
|
// The order of sub-views in the array is not specified, so make it definite
|
||||||
|
// by sorting by the view type constants.
|
||||||
size_t ii = 0;
|
size_t ii = 0;
|
||||||
size_t jj = 1;
|
std::vector< std::pair< WaveTrackViewConstants::Display, size_t > > pairs;
|
||||||
const int nViewTypes = 2;
|
WaveTrackSubViews::ForEach( [&pairs, &ii]( WaveTrackSubView &subView ){
|
||||||
WaveTrackSubViews::ForEach( [&,display]( WaveTrackSubView &subView ){
|
pairs.push_back( { subView.SubViewType(), ii++ } );
|
||||||
auto viewType = subView.SubViewType();
|
|
||||||
if (viewType == display) {
|
|
||||||
// 0 for first view
|
|
||||||
mPlacements[ii] = { 0, frac };
|
|
||||||
--jj;
|
|
||||||
}
|
|
||||||
else if( frac > 0.999)
|
|
||||||
// -1 for not displayed
|
|
||||||
mPlacements[ii] = { -1, 0.0 };
|
|
||||||
else
|
|
||||||
// jj for positions excluding the first.
|
|
||||||
mPlacements[ii] = { (int)jj, (1.0f-frac)/(nViewTypes-1) };
|
|
||||||
++ii;
|
|
||||||
++jj;
|
|
||||||
} );
|
} );
|
||||||
|
std::sort( pairs.begin(), pairs.end() );
|
||||||
|
|
||||||
|
int jj = 1;
|
||||||
|
for ( const auto &pair : pairs ) {
|
||||||
|
auto &placement = mPlacements[ pair.second ];
|
||||||
|
if (pair.first == display) {
|
||||||
|
// 0 for first view
|
||||||
|
placement = { 0, 1.0 };
|
||||||
|
}
|
||||||
|
else if( exclusive )
|
||||||
|
// -1 for not displayed
|
||||||
|
placement = { -1, 0.0 };
|
||||||
|
else
|
||||||
|
// positions other than the first.
|
||||||
|
// (Note that the fractions in the placement don't need to be
|
||||||
|
// denominated to 1. Just make them all equal to get an equal
|
||||||
|
// partitioning of the sub-views.)
|
||||||
|
placement = { jj++, 1.0 };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto WaveTrackView::GetSubViews( const wxRect &rect ) -> Refinement
|
auto WaveTrackView::GetSubViews( const wxRect &rect ) -> Refinement
|
||||||
@@ -943,7 +949,7 @@ void WaveTrackView::BuildSubViews() const
|
|||||||
settings.scaleType = WaveformSettings::stLogarithmic;
|
settings.scaleType = WaveformSettings::stLogarithmic;
|
||||||
}
|
}
|
||||||
|
|
||||||
pThis->DoSetDisplay( display, 1.0 );
|
pThis->DoSetDisplay( display );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
using WaveTrackDisplay = WaveTrackViewConstants::Display;
|
using WaveTrackDisplay = WaveTrackViewConstants::Display;
|
||||||
|
|
||||||
std::vector<WaveTrackDisplay> GetDisplays() const;
|
std::vector<WaveTrackDisplay> GetDisplays() const;
|
||||||
void SetDisplay(WaveTrackDisplay display, float frac=1.0);
|
void SetDisplay(WaveTrackDisplay display, bool exclusive = true);
|
||||||
|
|
||||||
const WaveTrackSubViewPlacements &SavePlacements() const
|
const WaveTrackSubViewPlacements &SavePlacements() const
|
||||||
{ return mPlacements; }
|
{ return mPlacements; }
|
||||||
@@ -105,7 +105,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void BuildSubViews() const;
|
void BuildSubViews() const;
|
||||||
void DoSetDisplay(WaveTrackDisplay display, float frac);
|
void DoSetDisplay(WaveTrackDisplay display, bool exclusive = true);
|
||||||
|
|
||||||
// TrackPanelDrawable implementation
|
// TrackPanelDrawable implementation
|
||||||
void Draw(
|
void Draw(
|
||||||
|
|||||||
Reference in New Issue
Block a user