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

Define and use ShuttleGui::ToolTip

This commit is contained in:
Paul Licameli 2017-10-28 20:29:20 -04:00
parent 1d32824e02
commit 3ea0209e5c
6 changed files with 83 additions and 62 deletions

View File

@ -2075,6 +2075,9 @@ void ShuttleGuiBase::UpdateSizersCore(bool bPrepend, int Flags, bool prompt)
if ( mItem.mValidatorSetter ) if ( mItem.mValidatorSetter )
mItem.mValidatorSetter( mpWind ); mItem.mValidatorSetter( mpWind );
if ( !mItem.mToolTip.empty() )
mpWind->SetToolTip( mItem.mToolTip.Translation() );
// Reset to defaults // Reset to defaults
mItem = {}; mItem = {};
} }

View File

@ -140,7 +140,14 @@ struct Item {
Item&& Validator( Args&&... args ) && Item&& Validator( Args&&... args ) &&
{ return std::move(*this).Validator( [args...]{ return V( args... ); } ); } { return std::move(*this).Validator( [args...]{ return V( args... ); } ); }
Item&& ToolTip( const TranslatableString &tip ) &&
{
mToolTip = tip;
return std::move( *this );
}
std::function< void(wxWindow*) > mValidatorSetter; std::function< void(wxWindow*) > mValidatorSetter;
TranslatableString mToolTip;
}; };
} }
@ -497,6 +504,12 @@ public:
ShuttleGui & Optional( bool & bVar ); ShuttleGui & Optional( bool & bVar );
ShuttleGui & Id(int id ); ShuttleGui & Id(int id );
ShuttleGui & ToolTip( const TranslatableString &tip )
{
std::move( mItem ).ToolTip( tip );
return *this;
}
template<typename Factory> template<typename Factory>
ShuttleGui& Validator( const Factory &f ) ShuttleGui& Validator( const Factory &f )
{ {

View File

@ -378,8 +378,8 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S)
.MenuEnabled(false)); .MenuEnabled(false));
mpFromLengthCtrl->SetName(_("from")); mpFromLengthCtrl->SetName(_("from"));
mpFromLengthCtrl->SetToolTip(_("Current length of selection.")); S.ToolTip(XO("Current length of selection.")).
S.AddWindow(mpFromLengthCtrl, wxALIGN_LEFT); AddWindow(mpFromLengthCtrl, wxALIGN_LEFT);
S.AddPrompt(_("New Length:")); S.AddPrompt(_("New Length:"));

View File

@ -607,13 +607,10 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S)
mParameters[p].maxValue == 1.0) mParameters[p].maxValue == 1.0)
{ {
S.Id(ID_Toggles + p); S.Id(ID_Toggles + p);
mToggles[p] = S.AddCheckBox( {}, mToggles[p] = S.ToolTip( TranslatableString{ tip } )
value > 0.5); .AddCheckBox( {},
value > 0.5 );
mToggles[p]->SetName(labelText); mToggles[p]->SetName(labelText);
if (!tip.empty())
{
mToggles[p]->SetToolTip(tip);
}
wxSizer *s = mToggles[p]->GetContainingSizer(); wxSizer *s = mToggles[p]->GetContainingSizer();
s->GetItem(mToggles[p])->SetFlag(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL); s->GetItem(mToggles[p])->SetFlag(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL);
@ -640,13 +637,10 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S)
} }
S.Id(ID_Choices + p); S.Id(ID_Choices + p);
mChoices[p] = S.AddChoice( {}, choices, selected ); mChoices[p] = S.ToolTip( TranslatableString{ tip } )
.AddChoice( {}, choices, selected );
mChoices[p]->SetName(labelText); mChoices[p]->SetName(labelText);
mChoices[p]->SetSizeHints(-1, -1); mChoices[p]->SetSizeHints(-1, -1);
if (!tip.empty())
{
mChoices[p]->SetToolTip(tip);
}
wxSizer *s = mChoices[p]->GetContainingSizer(); wxSizer *s = mChoices[p]->GetContainingSizer();
s->GetItem(mChoices[p])->SetFlag(wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL); s->GetItem(mChoices[p])->SetFlag(wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL);
@ -661,7 +655,7 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S)
float range = mParameters[p].maxValue - mParameters[p].minValue; float range = mParameters[p].maxValue - mParameters[p].minValue;
S.Id(ID_Texts + p); S.Id(ID_Texts + p);
mFields[p] = S mFields[p] = S.ToolTip( TranslatableString{ tip } )
.Validator<FloatingPointValidator<float>>( .Validator<FloatingPointValidator<float>>(
6, &mValues[p], 6, &mValues[p],
(range < 10 (range < 10
@ -672,10 +666,6 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S)
mParameters[p].minValue, mParameters[p].maxValue) mParameters[p].minValue, mParameters[p].maxValue)
.AddTextBox( {}, wxT(""), 12); .AddTextBox( {}, wxT(""), 12);
mFields[p]->SetName(labelText); mFields[p]->SetName(labelText);
if (!tip.empty())
{
mFields[p]->SetToolTip(tip);
}
wxSizer *s = mFields[p]->GetContainingSizer(); wxSizer *s = mFields[p]->GetContainingSizer();
s->GetItem(mFields[p])->SetFlag(wxALIGN_CENTER_VERTICAL | wxALL); s->GetItem(mFields[p])->SetFlag(wxALIGN_CENTER_VERTICAL | wxALL);
@ -684,13 +674,10 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S)
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
S.Id(ID_Sliders + p); S.Id(ID_Sliders + p);
mSliders[p] = S.AddSlider( {}, 0, 1000, 0); mSliders[p] = S.ToolTip( TranslatableString{ tip } )
.AddSlider( {}, 0, 1000, 0);
mSliders[p]->SetName(labelText); mSliders[p]->SetName(labelText);
mSliders[p]->SetSizeHints(150, -1); mSliders[p]->SetSizeHints(150, -1);
if (!tip.empty())
{
mSliders[p]->SetToolTip(tip);
}
str = Internat::ToDisplayString(mParameters[p].maxValue); str = Internat::ToDisplayString(mParameters[p].maxValue);
S.AddUnits(str); S.AddUnits(str);

View File

@ -1574,8 +1574,9 @@ void ExportFFmpegOptions::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartMultiColumn(8, wxEXPAND); S.StartMultiColumn(8, wxEXPAND);
{ {
mLanguageText = S.Id(FELanguageID).TieTextBox(_("Language:"), {wxT("/FileFormats/FFmpegLanguage"), wxEmptyString}, 9); mLanguageText = S.Id(FELanguageID)
mLanguageText->SetToolTip(_("ISO 639 3-letter language code\nOptional\nempty - automatic")); .ToolTip(XO("ISO 639 3-letter language code\nOptional\nempty - automatic"))
.TieTextBox(_("Language:"), {wxT("/FileFormats/FFmpegLanguage"), wxEmptyString}, 9);
S.AddSpace( 20,0 ); S.AddSpace( 20,0 );
S.AddVariableText(_("Bit Reservoir")); S.AddVariableText(_("Bit Reservoir"));
@ -1588,26 +1589,30 @@ void ExportFFmpegOptions::PopulateOrExchange(ShuttleGui & S)
S.EndMultiColumn(); S.EndMultiColumn();
S.StartMultiColumn(4, wxALIGN_LEFT); S.StartMultiColumn(4, wxALIGN_LEFT);
{ {
mTag = S.Id(FETagID).TieTextBox(_("Tag:"), {wxT("/FileFormats/FFmpegTag"), wxEmptyString}, 4); mTag = S.Id(FETagID)
mTag->SetToolTip(_("Codec tag (FOURCC)\nOptional\nempty - automatic")); .ToolTip(XO("Codec tag (FOURCC)\nOptional\nempty - automatic"))
.TieTextBox(_("Tag:"), {wxT("/FileFormats/FFmpegTag"), wxEmptyString}, 4);
mBitrateSpin = S.Id(FEBitrateID).TieSpinCtrl(_("Bit Rate:"), {wxT("/FileFormats/FFmpegBitRate"), 0}, 1000000, 0); mBitrateSpin = S.Id(FEBitrateID)
mBitrateSpin->SetToolTip(_("Bit Rate (bits/second) - influences the resulting file size and quality\nSome codecs may only accept specific values (128k, 192k, 256k etc)\n0 - automatic\nRecommended - 192000")); .ToolTip(XO("Bit Rate (bits/second) - influences the resulting file size and quality\nSome codecs may only accept specific values (128k, 192k, 256k etc)\n0 - automatic\nRecommended - 192000"))
.TieSpinCtrl(_("Bit Rate:"), {wxT("/FileFormats/FFmpegBitRate"), 0}, 1000000, 0);
mQualitySpin = S.Id(FEQualityID).TieSpinCtrl(_("Quality:"), {wxT("/FileFormats/FFmpegQuality"), 0}, 500, -1); mQualitySpin = S.Id(FEQualityID)
mQualitySpin->SetToolTip(_("Overall quality, used differently by different codecs\nRequired for vorbis\n0 - automatic\n-1 - off (use bitrate instead)")); .ToolTip(XO("Overall quality, used differently by different codecs\nRequired for vorbis\n0 - automatic\n-1 - off (use bitrate instead)"))
.TieSpinCtrl(_("Quality:"), {wxT("/FileFormats/FFmpegQuality"), 0}, 500, -1);
mSampleRateSpin = S.Id(FESampleRateID).TieSpinCtrl(_("Sample Rate:"), {wxT("/FileFormats/FFmpegSampleRate"), 0}, 200000, 0); mSampleRateSpin = S.Id(FESampleRateID)
mSampleRateSpin->SetToolTip(_("Sample rate (Hz)\n0 - don't change sample rate")); .ToolTip(XO("Sample rate (Hz)\n0 - don't change sample rate"))
.TieSpinCtrl(_("Sample Rate:"), {wxT("/FileFormats/FFmpegSampleRate"), 0}, 200000, 0);
mCutoffSpin = S.Id(FECutoffID).TieSpinCtrl(_("Cutoff:"), {wxT("/FileFormats/FFmpegCutOff"), 0}, 10000000, 0); mCutoffSpin = S.Id(FECutoffID)
mCutoffSpin->SetToolTip(_("Audio cutoff bandwidth (Hz)\nOptional\n0 - automatic")); .ToolTip(XO("Audio cutoff bandwidth (Hz)\nOptional\n0 - automatic"))
.TieSpinCtrl(_("Cutoff:"), {wxT("/FileFormats/FFmpegCutOff"), 0}, 10000000, 0);
mProfileChoice = S.Id(FEProfileID) mProfileChoice = S.Id(FEProfileID)
.ToolTip(XO("AAC Profile\nLow Complexity - default\nMost players won't play anything other than LC"))
.TieChoice(_("Profile:"), AACProfiles); .TieChoice(_("Profile:"), AACProfiles);
mProfileChoice->SetSizeHints( 100,-1); mProfileChoice->SetSizeHints( 100,-1);
mProfileChoice->SetToolTip(_("AAC Profile\nLow Complexity - default\nMost players won't play anything other than LC"));
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }
@ -1616,16 +1621,20 @@ void ExportFFmpegOptions::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartMultiColumn(4, wxALIGN_LEFT); S.StartMultiColumn(4, wxALIGN_LEFT);
{ {
mCompressionLevelSpin = S.Id(FECompLevelID).TieSpinCtrl(_("Compression:"), {wxT("/FileFormats/FFmpegCompLevel"), 0}, 10, -1); mCompressionLevelSpin = S
mCompressionLevelSpin->SetToolTip(_("Compression level\nRequired for FLAC\n-1 - automatic\nmin - 0 (fast encoding, large output file)\nmax - 10 (slow encoding, small output file)")); .ToolTip(XO("Compression level\nRequired for FLAC\n-1 - automatic\nmin - 0 (fast encoding, large output file)\nmax - 10 (slow encoding, small output file)"))
.Id(FECompLevelID).TieSpinCtrl(_("Compression:"), {wxT("/FileFormats/FFmpegCompLevel"), 0}, 10, -1);
mFrameSizeSpin = S.Id(FEFrameSizeID).TieSpinCtrl(_("Frame:"), {wxT("/FileFormats/FFmpegFrameSize"), 0}, 65535, 0); mFrameSizeSpin = S.Id(FEFrameSizeID)
mFrameSizeSpin->SetToolTip(_("Frame size\nOptional\n0 - default\nmin - 16\nmax - 65535")); .ToolTip(XO("Frame size\nOptional\n0 - default\nmin - 16\nmax - 65535"))
.TieSpinCtrl(_("Frame:"), {wxT("/FileFormats/FFmpegFrameSize"), 0}, 65535, 0);
mLPCCoeffsPrecisionSpin = S.Id(FELPCCoeffsID).TieSpinCtrl(_("LPC"), {wxT("/FileFormats/FFmpegLPCCoefPrec"), 0}, 15, 0); mLPCCoeffsPrecisionSpin = S.Id(FELPCCoeffsID)
mLPCCoeffsPrecisionSpin->SetToolTip(_("LPC coefficients precision\nOptional\n0 - default\nmin - 1\nmax - 15")); .ToolTip(XO("LPC coefficients precision\nOptional\n0 - default\nmin - 1\nmax - 15"))
.TieSpinCtrl(_("LPC"), {wxT("/FileFormats/FFmpegLPCCoefPrec"), 0}, 15, 0);
mPredictionOrderMethodChoice = S.Id(FEPredOrderID) mPredictionOrderMethodChoice = S.Id(FEPredOrderID)
.ToolTip(XO("Prediction Order Method\nEstimate - fastest, lower compression\nLog search - slowest, best compression\nFull search - default"))
.TieNumberAsChoice( .TieNumberAsChoice(
_("PdO Method:"), _("PdO Method:"),
{wxT("/FileFormats/FFmpegPredOrderMethod"), {wxT("/FileFormats/FFmpegPredOrderMethod"),
@ -1633,19 +1642,22 @@ void ExportFFmpegOptions::PopulateOrExchange(ShuttleGui & S)
PredictionOrderMethodNames PredictionOrderMethodNames
); );
mPredictionOrderMethodChoice->SetSizeHints( 100,-1); mPredictionOrderMethodChoice->SetSizeHints( 100,-1);
mPredictionOrderMethodChoice->SetToolTip(_("Prediction Order Method\nEstimate - fastest, lower compression\nLog search - slowest, best compression\nFull search - default"));
mMinPredictionOrderSpin = S.Id(FEMinPredID).TieSpinCtrl(_("Min. PdO"), {wxT("/FileFormats/FFmpegMinPredOrder"), -1}, 32, -1); mMinPredictionOrderSpin = S.Id(FEMinPredID)
mMinPredictionOrderSpin->SetToolTip(_("Minimal prediction order\nOptional\n-1 - default\nmin - 0\nmax - 32 (with LPC) or 4 (without LPC)")); .ToolTip(XO("Minimal prediction order\nOptional\n-1 - default\nmin - 0\nmax - 32 (with LPC) or 4 (without LPC)"))
.TieSpinCtrl(_("Min. PdO"), {wxT("/FileFormats/FFmpegMinPredOrder"), -1}, 32, -1);
mMaxPredictionOrderSpin = S.Id(FEMaxPredID).TieSpinCtrl(_("Max. PdO"), {wxT("/FileFormats/FFmpegMaxPredOrder"), -1}, 32, -1); mMaxPredictionOrderSpin = S.Id(FEMaxPredID)
mMaxPredictionOrderSpin->SetToolTip(_("Maximal prediction order\nOptional\n-1 - default\nmin - 0\nmax - 32 (with LPC) or 4 (without LPC)")); .ToolTip(XO("Maximal prediction order\nOptional\n-1 - default\nmin - 0\nmax - 32 (with LPC) or 4 (without LPC)"))
.TieSpinCtrl(_("Max. PdO"), {wxT("/FileFormats/FFmpegMaxPredOrder"), -1}, 32, -1);
mMinPartitionOrderSpin = S.Id(FEMinPartOrderID).TieSpinCtrl(_("Min. PtO"), {wxT("/FileFormats/FFmpegMinPartOrder"), -1}, 8, -1); mMinPartitionOrderSpin = S.Id(FEMinPartOrderID)
mMinPartitionOrderSpin->SetToolTip(_("Minimal partition order\nOptional\n-1 - default\nmin - 0\nmax - 8")); .ToolTip(XO("Minimal partition order\nOptional\n-1 - default\nmin - 0\nmax - 8"))
.TieSpinCtrl(_("Min. PtO"), {wxT("/FileFormats/FFmpegMinPartOrder"), -1}, 8, -1);
mMaxPartitionOrderSpin = S.Id(FEMaxPartOrderID).TieSpinCtrl(_("Max. PtO"), {wxT("/FileFormats/FFmpegMaxPartOrder"), -1}, 8, -1); mMaxPartitionOrderSpin = S.Id(FEMaxPartOrderID)
mMaxPartitionOrderSpin->SetToolTip(_("Maximal partition order\nOptional\n-1 - default\nmin - 0\nmax - 8")); .ToolTip(XO("Maximal partition order\nOptional\n-1 - default\nmin - 0\nmax - 8"))
.TieSpinCtrl(_("Max. PtO"), {wxT("/FileFormats/FFmpegMaxPartOrder"), -1}, 8, -1);
/* i18n-hint: Abbreviates "Linear Predictive Coding", /* i18n-hint: Abbreviates "Linear Predictive Coding",
but this text needs to be kept very short */ but this text needs to be kept very short */
@ -1663,13 +1675,15 @@ void ExportFFmpegOptions::PopulateOrExchange(ShuttleGui & S)
/* i18n-hint: 'mux' is short for multiplexor, a device that selects between several inputs /* i18n-hint: 'mux' is short for multiplexor, a device that selects between several inputs
'Mux Rate' is a parameter that has some bearing on compression ratio for MPEG 'Mux Rate' is a parameter that has some bearing on compression ratio for MPEG
it has a hard to predict effect on the degree of compression */ it has a hard to predict effect on the degree of compression */
mMuxRate = S.Id(FEMuxRateID).TieSpinCtrl(_("Mux Rate:"), {wxT("/FileFormats/FFmpegMuxRate"), 0}, 10000000, 0); mMuxRate = S.Id(FEMuxRateID)
mMuxRate->SetToolTip(_("Maximum bit rate of the multiplexed stream\nOptional\n0 - default")); .ToolTip(XO("Maximum bit rate of the multiplexed stream\nOptional\n0 - default"))
.TieSpinCtrl(_("Mux Rate:"), {wxT("/FileFormats/FFmpegMuxRate"), 0}, 10000000, 0);
/* i18n-hint: 'Packet Size' is a parameter that has some bearing on compression ratio for MPEG /* i18n-hint: 'Packet Size' is a parameter that has some bearing on compression ratio for MPEG
compression. It measures how big a chunk of audio is compressed in one piece. */ compression. It measures how big a chunk of audio is compressed in one piece. */
mPacketSize = S.Id(FEPacketSizeID).TieSpinCtrl(_("Packet Size:"), {wxT("/FileFormats/FFmpegPacketSize"), 0}, 10000000, 0); mPacketSize = S.Id(FEPacketSizeID)
mPacketSize->SetToolTip(_("Packet size\nOptional\n0 - default")); .ToolTip(XO("Packet size\nOptional\n0 - default"))
.TieSpinCtrl(_("Packet Size:"), {wxT("/FileFormats/FFmpegPacketSize"), 0}, 10000000, 0);
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }

View File

@ -165,14 +165,18 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
{ {
S.StartHorizontalLay( wxEXPAND, false ); S.StartHorizontalLay( wxEXPAND, false );
{ {
wxButton * pWndBackwards = S.Id( wxID_BACKWARD ).AddButton( _("<") ); wxButton * pWndBackwards = S.Id( wxID_BACKWARD )
wxButton * pWndForwards = S.Id( wxID_FORWARD ).AddButton( _(">") ); #if wxUSE_TOOLTIPS
.ToolTip( XO("Backwards" ) )
#endif
.AddButton( _("<") );
wxButton * pWndForwards = S.Id( wxID_FORWARD )
#if wxUSE_TOOLTIPS
.ToolTip( XO("Forwards" ) )
#endif
.AddButton( _(">") );
pWndForwards->Enable( false ); pWndForwards->Enable( false );
pWndBackwards->Enable( false ); pWndBackwards->Enable( false );
#if wxUSE_TOOLTIPS
pWndForwards->SetToolTip( _("Forwards" ));
pWndBackwards->SetToolTip( _("Backwards" ));
#endif
} }
S.EndHorizontalLay(); S.EndHorizontalLay();