1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-08 22:23:59 +01:00

Attempt #2 at taming the meter toolbars

It corrects several "multiple project" problems with the
meter toolbars and meters.

In addition, there was a "multiple project" issue where
the transport buttons didn't disable properly in the
non-active project.
This commit is contained in:
lllucius
2014-12-19 16:38:56 +00:00
parent 5d526a8009
commit 9bbc261321
11 changed files with 162 additions and 88 deletions

View File

@@ -2106,9 +2106,14 @@ EffectUIHost::EffectUIHost(wxWindow *parent,
mEffect = effect;
mClient = client;
mProject = GetActiveProject();
mInitialized = false;
mDisableTransport = false;
mEnable = false;
mPlayPos = 0.0;
mClient->SetUIHost(this);
@@ -2341,9 +2346,7 @@ void EffectUIHost::OnClose(wxCloseEvent & WXUNUSED(evt))
void EffectUIHost::OnApply(wxCommandEvent & WXUNUSED(evt))
{
AudacityProject *p = GetActiveProject();
if (p->mViewInfo.selectedRegion.isPoint())
if (mProject->mViewInfo.selectedRegion.isPoint())
{
wxMessageBox(_("You must select audio in the project window."));
return;
@@ -2531,26 +2534,24 @@ void EffectUIHost::OnEnable(wxCommandEvent & WXUNUSED(evt))
void EffectUIHost::OnPlay(wxCommandEvent & WXUNUSED(evt))
{
AudacityProject *p = GetActiveProject();
if (mPlaying)
{
mPlayPos = gAudioIO->GetStreamTime();
p->GetControlToolBar()->StopPlaying();
mProject->GetControlToolBar()->StopPlaying();
}
else
{
if (p->IsPlayRegionLocked())
if (mProject->IsPlayRegionLocked())
{
double t0, t1;
p->GetPlayRegion(&t0, &t1);
mProject->GetPlayRegion(&t0, &t1);
mRegion.setTimes(t0, t1);
mPlayPos = mRegion.t0();
}
else if (p->mViewInfo.selectedRegion.t0() != mRegion.t0() ||
p->mViewInfo.selectedRegion.t1() != mRegion.t1())
else if (mProject->mViewInfo.selectedRegion.t0() != mRegion.t0() ||
mProject->mViewInfo.selectedRegion.t1() != mRegion.t1())
{
mRegion = p->mViewInfo.selectedRegion;
mRegion = mProject->mViewInfo.selectedRegion;
mPlayPos = mRegion.t0();
}
@@ -2559,7 +2560,7 @@ void EffectUIHost::OnPlay(wxCommandEvent & WXUNUSED(evt))
mPlayPos = mRegion.t1();
}
p->GetControlToolBar()->PlayPlayRegion(mPlayPos, mRegion.t1());
mProject->GetControlToolBar()->PlayPlayRegion(mPlayPos, mRegion.t1());
}
}
@@ -2610,11 +2611,26 @@ void EffectUIHost::OnPlayback(wxCommandEvent & evt)
{
evt.Skip();
mPlaying = evt.GetInt() != 0;
if (evt.GetInt() != 0)
{
if (evt.GetEventObject() != mProject)
{
mDisableTransport = true;
}
else
{
mPlaying = true;
}
}
else
{
mDisableTransport = false;
mPlaying = false;
}
if (mPlaying)
{
mRegion = GetActiveProject()->mViewInfo.selectedRegion;
mRegion = mProject->mViewInfo.selectedRegion;
mPlayPos = mRegion.t0();
}
@@ -2625,8 +2641,23 @@ void EffectUIHost::OnCapture(wxCommandEvent & evt)
{
evt.Skip();
mCapturing = evt.GetInt() != 0;
mCloseBtn->SetFocus();
if (evt.GetInt() != 0)
{
if (evt.GetEventObject() != mProject)
{
mDisableTransport = true;
}
else
{
mCapturing = true;
}
}
else
{
mDisableTransport = false;
mCapturing = false;
}
UpdateControls();
}
@@ -2781,9 +2812,21 @@ wxBitmap EffectUIHost::CreateBitmap(const char *xpm[], bool up, bool pusher)
void EffectUIHost::UpdateControls()
{
if (mCapturing || mDisableTransport)
{
// Don't allow focus to get trapped
wxWindow *focus = FindFocus();
if (focus == mRewindBtn || focus == mFFwdBtn || focus == mPlayBtn || focus == mEnableBtn)
{
mCloseBtn->SetFocus();
}
}
mApplyBtn->Enable(!mCapturing);
mRewindBtn->Enable(!mCapturing);
mFFwdBtn->Enable(!mCapturing);
mRewindBtn->Enable(!(mCapturing || mDisableTransport));
mFFwdBtn->Enable(!(mCapturing || mDisableTransport));
(!mIsGUI ? mPlayToggleBtn : mPlayBtn)->Enable(!(mCapturing || mDisableTransport));
(!mIsGUI ? mEnableToggleBtn : mEnableBtn)->Enable(!(mCapturing || mDisableTransport));
wxBitmapButton *bb;
@@ -2794,8 +2837,6 @@ void EffectUIHost::UpdateControls()
/* i18n-hint: The access key "&P" should be the same in
"Stop &Playback" and "Start &Playback" */
mPlayToggleBtn->SetLabel(_("Stop &Playback"));
//mPlayToggleBtn->SetValue(true);
mPlayToggleBtn->Enable(!mCapturing);
mPlayToggleBtn->Refresh();
}
else
@@ -2803,7 +2844,6 @@ void EffectUIHost::UpdateControls()
bb = (wxBitmapButton *) mPlayBtn;
bb->SetBitmapLabel(mStopBM);
bb->SetBitmapDisabled(mStopDisabledBM);
mPlayBtn->Enable(!mCapturing);
#if defined(__WXMAC__)
mPlayBtn->SetName(_("Stop &Playback"));
#else
@@ -2818,8 +2858,6 @@ void EffectUIHost::UpdateControls()
/* i18n-hint: The access key "&P" should be the same in
"Stop &Playback" and "Start &Playback" */
mPlayToggleBtn->SetLabel(_("Start &Playback"));
//mPlayToggleBtn->SetValue(false);
mPlayToggleBtn->Enable(!mCapturing);
mPlayToggleBtn->Refresh();
}
else
@@ -2827,7 +2865,6 @@ void EffectUIHost::UpdateControls()
bb = (wxBitmapButton *) mPlayBtn;
bb->SetBitmapLabel(mPlayBM);
bb->SetBitmapDisabled(mPlayDisabledBM);
mPlayBtn->Enable(!mCapturing);
#if defined(__WXMAC__)
mPlayBtn->SetName(_("Start &Playback"));
#else
@@ -2843,8 +2880,6 @@ void EffectUIHost::UpdateControls()
/* i18n-hint: The access key "&O" should be the same in
"Enable &Effect" and "Disable &Effect" */
mEnableToggleBtn->SetLabel(_("Enable &Effect"));
//mEnableToggleBtn->SetValue(true);
mEnableToggleBtn->Enable(!mCapturing);
mEnableToggleBtn->Refresh();
}
else
@@ -2852,7 +2887,6 @@ void EffectUIHost::UpdateControls()
bb = (wxBitmapButton *) mEnableBtn;
bb->SetBitmapLabel(mEnableBM);
bb->SetBitmapDisabled(mEnableDisabledBM);
mEnableBtn->Enable(!mCapturing);
#if defined(__WXMAC__)
mEnableBtn->SetName(_("Enable &Effect"));
#else
@@ -2867,8 +2901,6 @@ void EffectUIHost::UpdateControls()
/* i18n-hint: The access key "&O" should be the same in
"Enable &Effect" and "Disable &Effect" */
mEnableToggleBtn->SetLabel(_("Disable &Effect"));
//mEnableToggleBtn->SetValue(false);
mEnableToggleBtn->Enable(!mCapturing);
mEnableToggleBtn->Refresh();
}
else
@@ -2876,7 +2908,6 @@ void EffectUIHost::UpdateControls()
bb = (wxBitmapButton *) mEnableBtn;
bb->SetBitmapLabel(mDisableBM);
bb->SetBitmapDisabled(mDisableDisabledBM);
mEnableBtn->Enable(!mCapturing);
#if defined(__WXMAC__)
mEnableBtn->SetName(_("Disable &Effect"));
#else

View File

@@ -28,6 +28,7 @@ class wxWindow;
#include "../Experimental.h"
#include "../WaveTrack.h"
#include "../Project.h"
#include "../SelectedRegion.h"
#include "../Shuttle.h"
#include "../ShuttleGui.h"
@@ -523,6 +524,7 @@ private:
void LoadUserPresets();
private:
AudacityProject *mProject;
wxWindow *mParent;
Effect *mEffect;
EffectUIClientInterface *mClient;
@@ -554,6 +556,7 @@ private:
wxBitmap mDisableBM;
wxBitmap mDisableDisabledBM;
bool mDisableTransport;
bool mPlaying;
bool mCapturing;