1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-15 07:50:22 +02:00

EffectUIHost::BuildButtonBar uses ShuttleGui

This commit is contained in:
Paul Licameli 2017-10-27 14:42:04 -04:00
parent c28c170cc0
commit b5b9ab6ecd

View File

@ -858,49 +858,45 @@ int EffectUIHost::ShowModal()
wxPanel *EffectUIHost::BuildButtonBar(wxWindow *parent) wxPanel *EffectUIHost::BuildButtonBar(wxWindow *parent)
{ {
mSupportsRealtime = mEffect && mEffect->SupportsRealtime();
mIsGUI = mClient->IsGraphicalUI();
mIsBatch = (mEffect && mEffect->IsBatchProcessing()) ||
(mCommand && mCommand->IsBatchProcessing());
int margin = 0;
#if defined(__WXMAC__)
margin = 3; // I'm sure it's needed because of the order things are created...
#endif
const auto bar = safenew wxPanelWrapper(parent, wxID_ANY); const auto bar = safenew wxPanelWrapper(parent, wxID_ANY);
// This fools NVDA into not saying "Panel" when the dialog gets focus // This fools NVDA into not saying "Panel" when the dialog gets focus
bar->SetName(TranslatableString::Inaudible); bar->SetName(TranslatableString::Inaudible);
bar->SetLabel(TranslatableString::Inaudible); bar->SetLabel(TranslatableString::Inaudible);
ShuttleGui S{ bar, eIsCreating,
false /* horizontal */,
{ -1, -1 } /* minimum size */
};
{ {
auto bs = std::make_unique<wxBoxSizer>(wxHORIZONTAL); S.SetBorder( margin );
mSupportsRealtime = mEffect && mEffect->SupportsRealtime();
mIsGUI = mClient->IsGraphicalUI();
mIsBatch = (mEffect && mEffect->IsBatchProcessing()) ||
(mCommand && mCommand->IsBatchProcessing());
wxBitmapButton *bb;
int margin = 0;
#if defined(__WXMAC__)
margin = 3; // I'm sure it's needed because of the order things are created...
#endif
if (!mIsGUI) if (!mIsGUI)
{ {
wxASSERT(bar); // To justify safenew mMenuBtn = S.Id( kMenuID )
mMenuBtn = safenew wxButton(bar, kMenuID, _("&Manage")); .ToolTip(XO("Manage presets and options"))
bs->Add(mMenuBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); .AddButton( XO("&Manage"), wxALIGN_CENTER | wxTOP | wxBOTTOM );
} }
else else
{ {
wxASSERT(bar); // To justify safenew mMenuBtn = S.Id( kMenuID )
mMenuBtn = safenew wxBitmapButton(bar, kMenuID, CreateBitmap(effect_menu_xpm, true, true)); .ToolTip(XO("Manage presets and options"))
.Name(XO("&Manage"))
.AddBitmapButton( CreateBitmap(effect_menu_xpm, true, true) );
mMenuBtn->SetBitmapPressed(CreateBitmap(effect_menu_xpm, false, true)); mMenuBtn->SetBitmapPressed(CreateBitmap(effect_menu_xpm, false, true));
#if defined(__WXMAC__)
mMenuBtn->SetName(_("&Manage"));
#else
mMenuBtn->SetLabel(_("&Manage"));
#endif
bs->Add(mMenuBtn);
} }
mMenuBtn->SetToolTip(_("Manage presets and options"));
bs->Add(5, 5); S.AddSpace( 5, 5 );
if (!mIsBatch) if (!mIsBatch)
{ {
@ -908,19 +904,19 @@ wxPanel *EffectUIHost::BuildButtonBar(wxWindow *parent)
{ {
if (mSupportsRealtime) if (mSupportsRealtime)
{ {
wxASSERT(bar); // To justify safenew mPlayToggleBtn = S.Id( kPlayID )
mPlayToggleBtn = safenew wxButton(bar, kPlayID, _("Start &Playback")); .ToolTip(XO("Start and stop playback"))
mPlayToggleBtn->SetToolTip(_("Start and stop playback")); .AddButton( XO("Start &Playback"),
bs->Add(mPlayToggleBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); wxALIGN_CENTER | wxTOP | wxBOTTOM );
} }
else if (mEffect && else if (mEffect &&
(mEffect->GetType() != EffectTypeAnalyze) && (mEffect->GetType() != EffectTypeAnalyze) &&
(mEffect->GetType() != EffectTypeTool) ) (mEffect->GetType() != EffectTypeTool) )
{ {
wxASSERT(bar); // To justify safenew mPlayToggleBtn = S.Id( kPlayID )
mPlayToggleBtn = safenew wxButton(bar, kPlayID, _("&Preview")); .ToolTip(XO("Preview effect"))
mPlayToggleBtn->SetToolTip(_("Preview effect")); .AddButton( XO("&Preview"),
bs->Add(mPlayToggleBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); wxALIGN_CENTER | wxTOP | wxBOTTOM );
} }
} }
else else
@ -929,12 +925,9 @@ wxPanel *EffectUIHost::BuildButtonBar(wxWindow *parent)
mPlayDisabledBM = CreateBitmap(effect_play_disabled_xpm, true, true); mPlayDisabledBM = CreateBitmap(effect_play_disabled_xpm, true, true);
mStopBM = CreateBitmap(effect_stop_xpm, true, false); mStopBM = CreateBitmap(effect_stop_xpm, true, false);
mStopDisabledBM = CreateBitmap(effect_stop_disabled_xpm, true, false); mStopDisabledBM = CreateBitmap(effect_stop_disabled_xpm, true, false);
wxASSERT(bar); // To justify safenew mPlayBtn = S.Id( kPlayID ).AddBitmapButton( mPlayBM );
bb = safenew wxBitmapButton(bar, kPlayID, mPlayBM); mPlayBtn->SetBitmapDisabled(mPlayDisabledBM);
bb->SetBitmapDisabled(mPlayDisabledBM); mPlayBtn->SetBitmapPressed(CreateBitmap(effect_play_xpm, false, true));
bb->SetBitmapPressed(CreateBitmap(effect_play_xpm, false, true));
mPlayBtn = bb;
bs->Add(mPlayBtn);
if (!mSupportsRealtime) if (!mSupportsRealtime)
{ {
mPlayBtn->SetToolTip(_("Preview effect")); mPlayBtn->SetToolTip(_("Preview effect"));
@ -950,60 +943,55 @@ wxPanel *EffectUIHost::BuildButtonBar(wxWindow *parent)
{ {
if (!mIsGUI) if (!mIsGUI)
{ {
wxASSERT(bar); // To justify safenew mRewindBtn = S.Id( kRewindID )
mRewindBtn = safenew wxButton(bar, kRewindID, _("Skip &Backward")); .ToolTip(XO("Skip backward"))
bs->Add(mRewindBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); .AddButton( XO("Skip &Backward"),
wxALIGN_CENTER | wxTOP | wxBOTTOM );
} }
else else
{ {
wxASSERT(bar); // To justify safenew mRewindBtn = S.Id( kRewindID )
bb = safenew wxBitmapButton(bar, kRewindID, CreateBitmap(effect_rewind_xpm, true, true)); .ToolTip(XO("Skip backward"))
bb->SetBitmapDisabled(CreateBitmap(effect_rewind_disabled_xpm, true, false)); .Name(XO("Skip &Backward"))
bb->SetBitmapPressed(CreateBitmap(effect_rewind_xpm, false, true)); .AddBitmapButton( CreateBitmap(
mRewindBtn = bb; effect_rewind_xpm, true, true) );
#if defined(__WXMAC__) mRewindBtn->SetBitmapDisabled(
mRewindBtn->SetName(_("Skip &Backward")); CreateBitmap(effect_rewind_disabled_xpm, true, false));
#else mRewindBtn->SetBitmapPressed(CreateBitmap(effect_rewind_xpm, false, true));
mRewindBtn->SetLabel(_("Skip &Backward"));
#endif
bs->Add(mRewindBtn);
} }
mRewindBtn->SetToolTip(_("Skip backward"));
if (!mIsGUI) if (!mIsGUI)
{ {
wxASSERT(bar); // To justify safenew mFFwdBtn = S.Id( kFFwdID )
mFFwdBtn = safenew wxButton(bar, kFFwdID, _("Skip &Forward")); .ToolTip(XO("Skip forward"))
bs->Add(mFFwdBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); .AddButton( XO("Skip &Forward"),
wxALIGN_CENTER | wxTOP | wxBOTTOM );
} }
else else
{ {
wxASSERT(bar); // To justify safenew mFFwdBtn = S.Id( kFFwdID )
bb = safenew wxBitmapButton(bar, kFFwdID, CreateBitmap(effect_ffwd_xpm, true, true)); .ToolTip(XO("Skip forward"))
bb->SetBitmapDisabled(CreateBitmap(effect_ffwd_disabled_xpm, true, false)); .Name(XO("Skip &Forward"))
bb->SetBitmapPressed(CreateBitmap(effect_ffwd_xpm, false, true)); .AddBitmapButton( CreateBitmap(
mFFwdBtn = bb; effect_ffwd_xpm, true, true) );
#if defined(__WXMAC__) mFFwdBtn->SetBitmapDisabled(
mFFwdBtn->SetName(_("Skip &Forward")); CreateBitmap(effect_ffwd_disabled_xpm, true, false));
#else mFFwdBtn->SetBitmapPressed(CreateBitmap(effect_ffwd_xpm, false, true));
mFFwdBtn->SetLabel(_("Skip &Forward"));
#endif
bs->Add(mFFwdBtn);
} }
mFFwdBtn->SetToolTip(_("Skip forward"));
bs->Add(5, 5); S.AddSpace( 5, 5 );
mEnableCb = safenew wxCheckBox(bar, kEnableID, _("&Enable")); mEnableCb = S.Id( kEnableID )
mEnableCb->SetValue(mEnabled); .Position(wxALIGN_CENTER | wxTOP | wxBOTTOM)
mEnableCb->SetName(_("Enable")); .Name(XO("Enable"))
bs->Add(mEnableCb, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); .AddCheckBox( XO("&Enable"), mEnabled );
//
} }
} }
bar->SetSizerAndFit(bs.release());
} }
bar->GetSizer()->SetSizeHints( bar );
return bar; return bar;
} }