1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Define and use ShuttleGui::Focus

This commit is contained in:
Paul Licameli 2018-01-27 22:36:34 -05:00
parent 30d375d6fa
commit c72dbf5b51
8 changed files with 25 additions and 13 deletions

View File

@ -393,11 +393,10 @@ visit our [[https://forum.audacityteam.org/|forum]].");
wxDefaultPosition,
wxSize(ABOUT_DIALOG_WIDTH, 359),
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
html->SetFocus();
html->SetPage(creditStr);
/* locate the html renderer where it fits in the dialogue */
S.Prop(1).AddWindow( html, wxEXPAND );
S.Prop(1).Focus().AddWindow( html, wxEXPAND );
S.EndVerticalLay();
S.EndNotebookPage();

View File

@ -364,12 +364,12 @@ void DependencyDialog::PopulateOrExchange(ShuttleGui& S)
mCopySelectedFilesButton =
S.Id(CopySelectedFilesButtonID)
.Focus()
.AddButton(
_("Copy Selected Files"),
wxALIGN_LEFT, true);
mCopySelectedFilesButton->Enable(
mFileListCtrl->GetSelectedItemCount() > 0);
mCopySelectedFilesButton->SetFocus();
}
S.EndStatic();

View File

@ -447,7 +447,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
S.AddSpace(5);
mAlgChoice = S.Id(FreqAlgChoiceID)
mAlgChoice = S.Id(FreqAlgChoiceID).Focus()
.AddChoice(_("&Algorithm:"), algChoices, mAlg);
S.SetSizeHints(wxDefaultCoord, wxDefaultCoord);
@ -514,7 +514,6 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
mCloseButton = static_cast<wxButton*>(FindWindowById( wxID_CANCEL ));
mCloseButton->SetDefault();
mCloseButton->SetFocus();
Layout();
Fit();
@ -522,7 +521,6 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
Center();
SetMinSize(GetSize());
mAlgChoice->SetFocus();
#if defined(__WXGTK__)
// This should be rechecked with wx3.

View File

@ -2084,6 +2084,9 @@ void ShuttleGuiBase::UpdateSizersCore(bool bPrepend, int Flags, bool prompt)
mpWind->SetName(
mpWind->GetName() + mItem.mNameSuffix.Translation() );
if (mItem.mFocused)
mpWind->SetFocus();
// Reset to defaults
mItem = {};
}

View File

@ -167,12 +167,21 @@ struct Item {
return std::move( *this );
}
// Only the last item specified as focused (if more than one) will be
Item&& Focus( bool focused = true ) &&
{
mFocused = focused;
return std::move( *this );
}
std::function< void(wxWindow*) > mValidatorSetter;
TranslatableString mToolTip;
TranslatableString mName;
TranslatableString mNameSuffix;
long miStyle{};
bool mFocused { false };
};
}
@ -529,6 +538,13 @@ public:
ShuttleGui & Optional( bool & bVar );
ShuttleGui & Id(int id );
// Only the last item specified as focused (if more than one) will be
ShuttleGui & Focus( bool focused = true )
{
std::move( mItem ).Focus( focused );
return *this;
}
ShuttleGui & ToolTip( const TranslatableString &tip )
{
std::move( mItem ).ToolTip( tip );

View File

@ -458,6 +458,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
wxASSERT(nTypes == WXSIZEOF(kTypeStrings));
mFilterTypeCtl = S.Id(ID_Type)
.Focus()
.Validator<wxGenericValidator>(&mFilterType)
.AddChoice(_("&Filter Type:"),
LocalizedStrings(kTypeStrings, nTypes)
@ -516,8 +517,6 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
}
S.EndMultiColumn();
mFilterTypeCtl->SetFocus();
return;
}

View File

@ -2587,7 +2587,7 @@ void NyquistEffect::BuildPromptWindow(ShuttleGui & S)
S.StartHorizontalLay(wxEXPAND, 1);
{
mCommandText = S.AddTextWindow(wxT(""));
mCommandText = S.Focus().AddTextWindow(wxT(""));
mCommandText->SetMinSize(wxSize(500, 200));
}
S.EndHorizontalLay();
@ -2600,8 +2600,6 @@ void NyquistEffect::BuildPromptWindow(ShuttleGui & S)
S.EndHorizontalLay();
}
S.EndVerticalLay();
mCommandText->SetFocus();
}
void NyquistEffect::BuildEffectWindow(ShuttleGui & S)

View File

@ -192,7 +192,7 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
else
html->SetPage( HtmlText);
S.Prop(1).AddWindow( html, wxEXPAND );
S.Prop(1).Focus().AddWindow( html, wxEXPAND );
S.Id( wxID_CANCEL ).AddButton( _("Close"), wxALIGN_CENTER, true );
}
@ -228,7 +228,6 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
}
html->SetRelatedStatusBar( 0 );
html->SetFocus();
return;
}