1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 16:49:41 +02:00

Allow button state to persist across toolbar reset

This commit is contained in:
lllucius 2015-01-01 11:46:52 +00:00
parent 0c447f3108
commit 622b609f91
2 changed files with 44 additions and 7 deletions

View File

@ -323,18 +323,47 @@ void ControlToolBar::ArrangeButtons()
void ControlToolBar::ReCreateButtons() void ControlToolBar::ReCreateButtons()
{ {
bool playDown = false;
bool playShift = false;
bool pauseDown = false;
bool recordDown = false;
bool recordShift = false;
// ToolBar::ReCreateButtons() will get rid of its sizer and // ToolBar::ReCreateButtons() will get rid of its sizer and
// since we've attached our sizer to it, ours will get deleted too // since we've attached our sizer to it, ours will get deleted too
// so clean ours up first. // so clean ours up first.
if( mSizer ) if( mSizer )
{ {
playDown = mPlay->IsDown();
playShift = mPlay->WasShiftDown();
pauseDown = mPause->IsDown();
recordDown = mRecord->IsDown();
recordShift = mRecord->WasShiftDown();
Detach( mSizer ); Detach( mSizer );
delete mSizer; delete mSizer;
mSizer = NULL; mSizer = NULL;
} }
ToolBar::ReCreateButtons(); ToolBar::ReCreateButtons();
if (playDown)
{
SetPlay(playDown, playShift, false);
}
if (pauseDown)
{
mPause->PushDown();
}
if (recordDown)
{
SetRecord(recordDown, recordShift);
}
EnableDisableButtons();
RegenerateToolsTooltips(); RegenerateToolsTooltips();
} }
@ -376,9 +405,12 @@ void ControlToolBar::EnableDisableButtons()
const bool enablePlay = (!recording) || (tracks && !busy); const bool enablePlay = (!recording) || (tracks && !busy);
mPlay->SetEnabled(enablePlay); mPlay->SetEnabled(enablePlay);
// Enable and disable the other play button // Enable and disable the other play button
if (p)
{
TranscriptionToolBar *const pttb = p->GetTranscriptionToolBar(); TranscriptionToolBar *const pttb = p->GetTranscriptionToolBar();
if (pttb) if (pttb)
pttb->SetEnabled(enablePlay); pttb->SetEnabled(enablePlay);
}
mRecord->SetEnabled(!busy && !playing); mRecord->SetEnabled(!busy && !playing);
@ -414,11 +446,16 @@ void ControlToolBar::SetStop(bool down)
EnableDisableButtons(); EnableDisableButtons();
} }
void ControlToolBar::SetRecord(bool down) void ControlToolBar::SetRecord(bool down, bool append)
{ {
if (down) if (down)
{
mRecord->SetAlternateIdx(append ? 1 : 0);
mRecord->PushDown(); mRecord->PushDown();
else { }
else
{
mRecord->SetAlternateIdx(0);
mRecord->PopUp(); mRecord->PopUp();
} }
EnableDisableButtons(); EnableDisableButtons();
@ -733,7 +770,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
if( evt.GetInt() == 2 ) if( evt.GetInt() == 2 )
mRecord->SetShift(false); mRecord->SetShift(false);
SetRecord(true); SetRecord(true, mRecord->WasShiftDown());
if (p) { if (p) {
TrackList *t = p->GetTracks(); TrackList *t = p->GetTracks();

View File

@ -56,7 +56,7 @@ class ControlToolBar:public ToolBar {
//These allow buttons to be controlled externally: //These allow buttons to be controlled externally:
void SetPlay(bool down, bool looped=false, bool cutPreview = false); void SetPlay(bool down, bool looped=false, bool cutPreview = false);
void SetStop(bool down); void SetStop(bool down);
void SetRecord(bool down); void SetRecord(bool down, bool append=false);
bool IsRecordDown(); bool IsRecordDown();