Remove Get/Set functions for selection bounds from AudacityProject
This commit is contained in:
parent
7766d9a192
commit
4018b191b4
|
@ -198,8 +198,9 @@ void AdornedRulerPanel::QuickPlayRulerOverlay::Update()
|
|||
&& (!project->GetScrubber().IsScrubbing() || project->GetScrubber().IsSpeedPlaying()))
|
||||
mNewQPIndicatorPos = -1;
|
||||
else {
|
||||
const auto &selectedRegion = project->GetViewInfo().selectedRegion;
|
||||
double latestEnd =
|
||||
std::max(ruler->mTracks->GetEndTime(), project->GetSel1());
|
||||
std::max(ruler->mTracks->GetEndTime(), selectedRegion.t1());
|
||||
if (ruler->mQuickPlayPos >= latestEnd)
|
||||
mNewQPIndicatorPos = -1;
|
||||
else {
|
||||
|
@ -1461,8 +1462,9 @@ void AdornedRulerPanel::HandleQPRelease(wxMouseEvent &evt)
|
|||
|
||||
const double t0 = mTracks->GetStartTime();
|
||||
const double t1 = mTracks->GetEndTime();
|
||||
const double sel0 = mProject->GetSel0();
|
||||
const double sel1 = mProject->GetSel1();
|
||||
const auto &selectedRegion = mProject->GetViewInfo().selectedRegion;
|
||||
const double sel0 = selectedRegion.t0();
|
||||
const double sel1 = selectedRegion.t1();
|
||||
|
||||
// We want some audio in the selection, but we allow a dragged
|
||||
// region to include selected white-space and space before audio start.
|
||||
|
@ -1529,8 +1531,9 @@ void AdornedRulerPanel::StartQPPlay(bool looped, bool cutPreview)
|
|||
{
|
||||
const double t0 = mTracks->GetStartTime();
|
||||
const double t1 = mTracks->GetEndTime();
|
||||
const double sel0 = mProject->GetSel0();
|
||||
const double sel1 = mProject->GetSel1();
|
||||
const auto &selectedRegion = mProject->GetViewInfo().selectedRegion;
|
||||
const double sel0 = selectedRegion.t0();
|
||||
const double sel1 = selectedRegion.t1();
|
||||
|
||||
// Start / Restart playback on left click.
|
||||
bool startPlaying = (mPlayRegionStart >= 0);
|
||||
|
|
|
@ -2191,6 +2191,7 @@ void LabelTrack::ShowContextMenu()
|
|||
void LabelTrack::OnContextMenu(wxCommandEvent & evt)
|
||||
{
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto &selectedRegion = p->GetViewInfo().selectedRegion;
|
||||
|
||||
switch (evt.GetId())
|
||||
{
|
||||
|
@ -2211,7 +2212,7 @@ void LabelTrack::OnContextMenu(wxCommandEvent & evt)
|
|||
|
||||
/// paste selected text if paste menu item is selected
|
||||
case OnPasteSelectedTextID:
|
||||
if (PasteSelectedText(p->GetSel0(), p->GetSel1()))
|
||||
if (PasteSelectedText(selectedRegion.t0(), selectedRegion.t1()))
|
||||
{
|
||||
p->PushState(_("Modified Label"),
|
||||
_("Label Edit"),
|
||||
|
@ -2221,7 +2222,7 @@ void LabelTrack::OnContextMenu(wxCommandEvent & evt)
|
|||
|
||||
/// DELETE selected label
|
||||
case OnDeleteSelectedLabelID: {
|
||||
int ndx = GetLabelIndex(p->GetSel0(), p->GetSel1());
|
||||
int ndx = GetLabelIndex(selectedRegion.t0(), selectedRegion.t1());
|
||||
if (ndx != -1)
|
||||
{
|
||||
DeleteLabel(ndx);
|
||||
|
@ -2233,7 +2234,7 @@ void LabelTrack::OnContextMenu(wxCommandEvent & evt)
|
|||
break;
|
||||
|
||||
case OnEditSelectedLabelID: {
|
||||
int ndx = GetLabelIndex(p->GetSel0(), p->GetSel1());
|
||||
int ndx = GetLabelIndex(selectedRegion.t0(), selectedRegion.t1());
|
||||
if (ndx != -1)
|
||||
DoEditLabels(*p, this, ndx);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,8 @@ void HighlightTextCtrl::OnMouseEvent(wxMouseEvent& event)
|
|||
{
|
||||
Syllable* pCurSyl = mLyricsPanel->GetSyllable(nNewSyl);
|
||||
AudacityProject* pProj = GetActiveProject();
|
||||
pProj->SetSel0(pCurSyl->t);
|
||||
auto &selectedRegion = pProj->GetViewInfo().selectedRegion;
|
||||
selectedRegion.setT0( pCurSyl->t );
|
||||
|
||||
//v Should probably select to end as in
|
||||
// SelectActions::Handler::OnSelectCursorEnd,
|
||||
|
@ -438,7 +439,8 @@ void LyricsPanel::Update(double t)
|
|||
// TrackPanel::OnTimer passes gAudioIO->GetStreamTime(), which is -DBL_MAX if !IsStreamActive().
|
||||
// In that case, use the selection start time.
|
||||
AudacityProject* pProj = GetActiveProject();
|
||||
mT = pProj->GetSel0();
|
||||
const auto &selectedRegion = pProj->GetViewInfo().selectedRegion;
|
||||
mT = selectedRegion.t0();
|
||||
}
|
||||
else
|
||||
mT = t;
|
||||
|
@ -501,7 +503,8 @@ void LyricsPanel::UpdateLyrics(wxEvent &e)
|
|||
|
||||
AddLabels(pLabelTrack);
|
||||
Finish(pLabelTrack->GetEndTime());
|
||||
Update(mProject->GetSel0());
|
||||
const auto &selectedRegion = mProject->GetViewInfo().selectedRegion;
|
||||
Update(selectedRegion.t0());
|
||||
}
|
||||
|
||||
void LyricsPanel::OnStartStop(wxCommandEvent &e)
|
||||
|
|
|
@ -158,7 +158,8 @@ void LyricsWindow::OnTimer(wxCommandEvent &event)
|
|||
else
|
||||
{
|
||||
// Reset lyrics display.
|
||||
GetLyricsPanel()->Update(mProject->GetSel0());
|
||||
const auto &selectedRegion = mProject->GetViewInfo().selectedRegion;
|
||||
GetLyricsPanel()->Update(selectedRegion.t0());
|
||||
}
|
||||
|
||||
// Let other listeners get the notification
|
||||
|
|
|
@ -1470,20 +1470,6 @@ void AudacityProject::RefreshCursor()
|
|||
mTrackPanel->HandleCursorForPresentMouseState();
|
||||
}
|
||||
|
||||
void AudacityProject::SetSel0(double newSel0)
|
||||
{
|
||||
//Bound checking should go on here
|
||||
|
||||
mViewInfo.selectedRegion.setT0(newSel0);
|
||||
}
|
||||
|
||||
void AudacityProject::SetSel1(double newSel1)
|
||||
{
|
||||
//Bound checking should go on here
|
||||
|
||||
mViewInfo.selectedRegion.setT1(newSel1);
|
||||
}
|
||||
|
||||
void AudacityProject::OnCapture(wxCommandEvent& evt)
|
||||
{
|
||||
evt.Skip();
|
||||
|
|
|
@ -220,8 +220,6 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
|||
bool ZoomOutAvailable() const { return mViewInfo.ZoomOutAvailable(); }
|
||||
const SelectedRegion &GetSelection() const { return mViewInfo.selectedRegion; }
|
||||
SelectedRegion &GetSelection() { return mViewInfo.selectedRegion; }
|
||||
double GetSel0() const { return mViewInfo.selectedRegion.t0(); }
|
||||
double GetSel1() const { return mViewInfo.selectedRegion.t1(); }
|
||||
const ZoomInfo &GetZoomInfo() const { return mViewInfo; }
|
||||
const ViewInfo &GetViewInfo() const { return mViewInfo; }
|
||||
ViewInfo &GetViewInfo() { return mViewInfo; }
|
||||
|
@ -230,8 +228,6 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
|||
bool IsPlayRegionLocked() { return mLockPlayRegion; }
|
||||
void SetPlayRegionLocked(bool value) { mLockPlayRegion = value; }
|
||||
|
||||
void SetSel0(double); //Added by STM
|
||||
void SetSel1(double); //Added by STM
|
||||
|
||||
bool Clipboard() { return (msClipT1 - msClipT0) > 0.0; }
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ bool SelectTimeCommand::Apply(const CommandContext & context){
|
|||
double t0;
|
||||
double t1;
|
||||
|
||||
const auto &selectedRegion = p->GetViewInfo().selectedRegion;
|
||||
switch( bHasRelativeSpec ? mRelativeTo : 0 ){
|
||||
default:
|
||||
case 0: //project start
|
||||
|
@ -117,16 +118,16 @@ bool SelectTimeCommand::Apply(const CommandContext & context){
|
|||
t1 = end - mT1;
|
||||
break;
|
||||
case 3: //selection start
|
||||
t0 = mT0 + p->GetSel0();
|
||||
t1 = mT1 + p->GetSel0();
|
||||
t0 = mT0 + selectedRegion.t0();
|
||||
t1 = mT1 + selectedRegion.t0();
|
||||
break;
|
||||
case 4: //selection
|
||||
t0 = mT0 + p->GetSel0();
|
||||
t1 = mT1 + p->GetSel1();
|
||||
t0 = mT0 + selectedRegion.t0();
|
||||
t1 = mT1 + selectedRegion.t1();
|
||||
break;
|
||||
case 5: //selection end
|
||||
t0 = p->GetSel1() - mT0;
|
||||
t1 = p->GetSel1() - mT1;
|
||||
t0 = selectedRegion.t1() - mT0;
|
||||
t1 = selectedRegion.t1() - mT1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1869,8 +1869,10 @@ bool Effect::ProcessTrack(int count,
|
|||
// Transfer the data from the temporary tracks to the actual ones
|
||||
genLeft->Flush();
|
||||
// mT1 gives us the NEW selection. We want to replace up to GetSel1().
|
||||
left->ClearAndPaste(mT0, p->GetSel1(), genLeft.get(), true, true,
|
||||
nullptr /* &warper */);
|
||||
auto &selectedRegion = p->GetViewInfo().selectedRegion;
|
||||
left->ClearAndPaste(mT0,
|
||||
selectedRegion.t1(), genLeft.get(), true, true,
|
||||
nullptr /* &warper */);
|
||||
|
||||
if (genRight)
|
||||
{
|
||||
|
|
|
@ -79,8 +79,10 @@ bool Generator::Process()
|
|||
tmp->Flush();
|
||||
StepTimeWarper warper{
|
||||
mT0+GetDuration(), GetDuration()-(mT1-mT0) };
|
||||
const auto &selectedRegion = p->GetViewInfo().selectedRegion;
|
||||
track->ClearAndPaste(
|
||||
p->GetSel0(), p->GetSel1(), &*tmp, true, false, &warper);
|
||||
selectedRegion.t0(), selectedRegion.t1(),
|
||||
&*tmp, true, false, &warper);
|
||||
}
|
||||
|
||||
if (!bGoodResult) {
|
||||
|
|
|
@ -925,8 +925,9 @@ finish:
|
|||
// Selection is to be set to whatever it is in the project.
|
||||
AudacityProject *project = GetActiveProject();
|
||||
if (project) {
|
||||
mT0 = project->GetSel0();
|
||||
mT1 = project->GetSel1();
|
||||
auto &selectedRegion = project->GetViewInfo().selectedRegion;
|
||||
mT0 = selectedRegion.t0();
|
||||
mT1 = selectedRegion.t1();
|
||||
}
|
||||
else {
|
||||
mT0 = 0;
|
||||
|
|
|
@ -612,13 +612,14 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
|||
|
||||
if (t1 == t0) {
|
||||
if (looped) {
|
||||
const auto &selectedRegion = p->GetViewInfo().selectedRegion;
|
||||
// play selection if there is one, otherwise
|
||||
// set start of play region to project start,
|
||||
// and loop the project from current play position.
|
||||
|
||||
if ((t0 > p->GetSel0()) && (t0 < p->GetSel1())) {
|
||||
t0 = p->GetSel0();
|
||||
t1 = p->GetSel1();
|
||||
if ((t0 > selectedRegion.t0()) && (t0 < selectedRegion.t1())) {
|
||||
t0 = selectedRegion.t0();
|
||||
t1 = selectedRegion.t1();
|
||||
}
|
||||
else {
|
||||
// loop the entire project
|
||||
|
@ -983,8 +984,9 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||
const bool appendRecord = (altAppearance == bPreferNewTrack);
|
||||
|
||||
if (p) {
|
||||
double t0 = p->GetSel0();
|
||||
double t1 = p->GetSel1();
|
||||
const auto &selectedRegion = p->GetViewInfo().selectedRegion;
|
||||
double t0 = selectedRegion.t0();
|
||||
double t1 = selectedRegion.t1();
|
||||
// When no time selection, recording duration is 'unlimited'.
|
||||
if (t1 == t0)
|
||||
t1 = DBL_MAX;
|
||||
|
@ -1008,8 +1010,8 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||
}
|
||||
|
||||
// Whether we decided on NEW tracks or not:
|
||||
if (t1 <= p->GetSel0() && p->GetSel1() > p->GetSel0()) {
|
||||
t1 = p->GetSel1(); // record within the selection
|
||||
if (t1 <= selectedRegion.t0() && selectedRegion.t1() > selectedRegion.t0()) {
|
||||
t1 = selectedRegion.t1(); // record within the selection
|
||||
}
|
||||
else {
|
||||
t1 = DBL_MAX; // record for a long, long time
|
||||
|
|
|
@ -414,8 +414,9 @@ void TranscriptionToolBar::GetSamples(
|
|||
//First, get the current selection. It is part of the mViewInfo, which is
|
||||
//part of the project
|
||||
|
||||
double start = p->GetSel0();
|
||||
double end = p->GetSel1();
|
||||
const auto &selectedRegion = p->GetViewInfo().selectedRegion;
|
||||
double start = selectedRegion.t0();
|
||||
double end = selectedRegion.t1();
|
||||
|
||||
auto ss0 = sampleCount( (start - t->GetOffset()) * t->GetRate() );
|
||||
auto ss1 = sampleCount( (end - t->GetOffset()) * t->GetRate() );
|
||||
|
@ -563,7 +564,8 @@ void TranscriptionToolBar::OnStartOn(wxCommandEvent & WXUNUSED(event))
|
|||
auto newstart = mVk->OnForward(*wt, start, len);
|
||||
double newpos = newstart.as_double() / wt->GetRate();
|
||||
|
||||
p->SetSel0(newpos);
|
||||
auto &selectedRegion = p->GetViewInfo().selectedRegion;
|
||||
selectedRegion.setT0( newpos );
|
||||
p->RedrawProject();
|
||||
|
||||
SetButton(false, mButtons[TTB_StartOn]);
|
||||
|
@ -594,7 +596,8 @@ void TranscriptionToolBar::OnStartOff(wxCommandEvent & WXUNUSED(event))
|
|||
auto newstart = mVk->OffForward(*wt, start, len);
|
||||
double newpos = newstart.as_double() / wt->GetRate();
|
||||
|
||||
p->SetSel0(newpos);
|
||||
auto &selectedRegion = p->GetViewInfo().selectedRegion;
|
||||
selectedRegion.setT0( newpos );
|
||||
p->RedrawProject();
|
||||
|
||||
SetButton(false, mButtons[TTB_StartOn]);
|
||||
|
@ -699,8 +702,9 @@ void TranscriptionToolBar::OnSelectSound(wxCommandEvent & WXUNUSED(event))
|
|||
mVk->OffForward(*wt, start + len, (int)(tl->GetEndTime() * rate));
|
||||
|
||||
//reset the selection bounds.
|
||||
p->SetSel0(newstart.as_double() / rate);
|
||||
p->SetSel1(newend.as_double() / rate);
|
||||
auto &selectedRegion = p->GetViewInfo().selectedRegion;
|
||||
selectedRegion.setTimes(
|
||||
newstart.as_double() / rate, newend.as_double() / rate );
|
||||
p->RedrawProject();
|
||||
|
||||
}
|
||||
|
|
|
@ -248,8 +248,8 @@ UIHandle::Result CutlineHandle::Cancel(AudacityProject *pProject)
|
|||
pProject->RollbackState();
|
||||
if (mOperation == Expand) {
|
||||
AudacityProject *const project = pProject;
|
||||
project->SetSel0(mStartTime);
|
||||
project->SetSel1(mEndTime);
|
||||
auto &selectedRegion = project->GetViewInfo().selectedRegion;
|
||||
selectedRegion.setTimes( mStartTime, mEndTime );
|
||||
result |= UpdateSelection;
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Reference in New Issue