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