mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-01 15:43:44 +02:00
Move minimize and close details out of TrackPanel.cpp
This commit is contained in:
parent
45e91f165a
commit
f49dbae9e2
@ -2954,7 +2954,21 @@ void AudacityProject::OnTrackSolo()
|
||||
|
||||
void AudacityProject::OnTrackClose()
|
||||
{
|
||||
mTrackPanel->OnTrackClose();
|
||||
Track *t = mTrackPanel->GetFocusedTrack();
|
||||
if (!t)
|
||||
return;
|
||||
|
||||
if (IsAudioActive())
|
||||
{
|
||||
this->TP_DisplayStatusMessage(_("Can't delete track with active audio"));
|
||||
wxBell();
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveTrack(t);
|
||||
|
||||
GetTrackPanel()->UpdateViewIfNoTracks();
|
||||
GetTrackPanel()->Refresh(false);
|
||||
}
|
||||
|
||||
void AudacityProject::OnTrackMoveUp()
|
||||
|
@ -4916,6 +4916,49 @@ void AudacityProject::SetTrackPan(Track * track, LWSlider * slider)
|
||||
GetTrackPanel()->RefreshTrack(track);
|
||||
}
|
||||
|
||||
/// Removes the specified track. Called from HandleClosing.
|
||||
void AudacityProject::RemoveTrack(Track * toRemove)
|
||||
{
|
||||
// If it was focused, reassign focus to the next or, if
|
||||
// unavailable, the previous track.
|
||||
if (mTrackPanel->GetFocusedTrack() == toRemove) {
|
||||
Track *t = mTracks->GetNext(toRemove, true);
|
||||
if (t == NULL) {
|
||||
t = mTracks->GetPrev(toRemove, true);
|
||||
}
|
||||
mTrackPanel->SetFocusedTrack(t); // It's okay if this is NULL
|
||||
}
|
||||
|
||||
wxString name = toRemove->GetName();
|
||||
Track *partner = toRemove->GetLink();
|
||||
|
||||
if (toRemove->GetKind() == Track::Wave)
|
||||
{
|
||||
// Update mixer board displayed tracks.
|
||||
MixerBoard* pMixerBoard = this->GetMixerBoard();
|
||||
if (pMixerBoard)
|
||||
pMixerBoard->RemoveTrackCluster((WaveTrack*)toRemove); // Will remove partner shown in same cluster.
|
||||
}
|
||||
|
||||
mTracks->Remove(toRemove, true);
|
||||
if (partner) {
|
||||
mTracks->Remove(partner, true);
|
||||
}
|
||||
|
||||
if (mTracks->IsEmpty()) {
|
||||
mTrackPanel->SetFocusedTrack(NULL);
|
||||
}
|
||||
|
||||
PushState(
|
||||
wxString::Format(_("Removed track '%s.'"),
|
||||
name.c_str()),
|
||||
_("Track Remove"));
|
||||
|
||||
TP_RedrawScrollbars();
|
||||
TP_HandleResize();
|
||||
GetTrackPanel()->Refresh(false);
|
||||
}
|
||||
|
||||
void AudacityProject::HandleTrackMute(Track *t, const bool exclusive)
|
||||
{
|
||||
// "exclusive" mute means mute the chosen track and unmute all others.
|
||||
|
@ -342,6 +342,7 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
||||
void SetTrackGain(Track * track, LWSlider * slider);
|
||||
void SetTrackPan(Track * track, LWSlider * slider);
|
||||
|
||||
void RemoveTrack(Track * toRemove);
|
||||
|
||||
// "exclusive" mute means mute the chosen track and unmute all others.
|
||||
void HandleTrackMute(Track *t, const bool exclusive);
|
||||
|
@ -5182,7 +5182,7 @@ void TrackPanel::HandleClosing(wxMouseEvent & event)
|
||||
mTrackInfo.DrawCloseBox(&dc, rect, false);
|
||||
if (closeRect.Contains(event.m_x, event.m_y)) {
|
||||
if (!IsUnsafe())
|
||||
RemoveTrack(t);
|
||||
GetProject()->RemoveTrack(t);
|
||||
}
|
||||
SetCapturedTrack( NULL );
|
||||
}
|
||||
@ -5212,48 +5212,6 @@ void TrackPanel::UpdateViewIfNoTracks()
|
||||
}
|
||||
}
|
||||
|
||||
/// Removes the specified track. Called from HandleClosing.
|
||||
void TrackPanel::RemoveTrack(Track * toRemove)
|
||||
{
|
||||
// If it was focused, reassign focus to the next or, if
|
||||
// unavailable, the previous track.
|
||||
if (GetFocusedTrack() == toRemove) {
|
||||
Track *t = mTracks->GetNext(toRemove, true);
|
||||
if (t == NULL) {
|
||||
t = mTracks->GetPrev( toRemove, true );
|
||||
}
|
||||
SetFocusedTrack(t); // It's okay if this is NULL
|
||||
}
|
||||
|
||||
wxString name = toRemove->GetName();
|
||||
Track *partner = toRemove->GetLink();
|
||||
|
||||
if (toRemove->GetKind() == Track::Wave)
|
||||
{
|
||||
// Update mixer board displayed tracks.
|
||||
MixerBoard* pMixerBoard = this->GetMixerBoard();
|
||||
if (pMixerBoard)
|
||||
pMixerBoard->RemoveTrackCluster((WaveTrack*)toRemove); // Will remove partner shown in same cluster.
|
||||
}
|
||||
|
||||
mTracks->Remove(toRemove, true);
|
||||
if (partner) {
|
||||
mTracks->Remove(partner, true);
|
||||
}
|
||||
|
||||
if (mTracks->IsEmpty()) {
|
||||
SetFocusedTrack( NULL );
|
||||
}
|
||||
|
||||
MakeParentPushState(
|
||||
wxString::Format(_("Removed track '%s.'"),
|
||||
name.c_str()),
|
||||
_("Track Remove"));
|
||||
MakeParentRedrawScrollbars();
|
||||
MakeParentResize();
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
void TrackPanel::HandlePopping(wxMouseEvent & event)
|
||||
{
|
||||
Track *t = mCapturedTrack;
|
||||
@ -8502,39 +8460,6 @@ void TrackPanel::OnVRulerMenu(Track *t, wxMouseEvent *pEvent)
|
||||
mPopupMenuTarget = NULL;
|
||||
}
|
||||
|
||||
void TrackPanel::OnTrackClose()
|
||||
{
|
||||
Track *t = GetFocusedTrack();
|
||||
if(!t) return;
|
||||
|
||||
if (IsUnsafe())
|
||||
{
|
||||
mListener->TP_DisplayStatusMessage( _( "Can't delete track with active audio" ) );
|
||||
wxBell();
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveTrack( t );
|
||||
|
||||
SetCapturedTrack( NULL );
|
||||
|
||||
// BG: There are no more tracks on screen
|
||||
if( mTracks->IsEmpty() )
|
||||
{
|
||||
//BG: Set zoom to normal
|
||||
mViewInfo->SetZoom(ZoomInfo::GetDefaultZoom());
|
||||
|
||||
//STM: Set selection to 0,0
|
||||
//PRL: and default the rest of the selection information
|
||||
mViewInfo->selectedRegion = SelectedRegion();
|
||||
|
||||
mListener->TP_RedrawScrollbars();
|
||||
mListener->TP_DisplayStatusMessage( wxT( "" ) ); //STM: Clear message if all tracks are removed
|
||||
}
|
||||
|
||||
Refresh( false );
|
||||
}
|
||||
|
||||
void TrackPanel::OnTrackMoveUp()
|
||||
{
|
||||
if (mTracks->CanMoveUp(GetFocusedTrack()))
|
||||
|
@ -201,7 +201,6 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel {
|
||||
|
||||
virtual void OnTrackMenu(Track *t = NULL);
|
||||
virtual void OnVRulerMenu(Track *t, wxMouseEvent *pEvent = NULL);
|
||||
virtual void OnTrackClose();
|
||||
virtual void OnTrackMoveUp();
|
||||
virtual void OnTrackMoveDown();
|
||||
virtual void OnTrackMoveTop();
|
||||
@ -501,8 +500,6 @@ protected:
|
||||
virtual void SplitStereo(bool stereo);
|
||||
virtual void OnMergeStereo(wxCommandEvent &event);
|
||||
|
||||
virtual void RemoveTrack(Track * toRemove);
|
||||
|
||||
// Find track info by coordinate
|
||||
virtual Track *FindTrack(int mouseX, int mouseY, bool label, bool link,
|
||||
wxRect * trackRect = NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user