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

TranslatableString for tooltips and status bar messages

This commit is contained in:
Paul Licameli 2019-12-08 16:24:20 -05:00
parent 2007346551
commit 49cab86fc1
45 changed files with 156 additions and 165 deletions

View File

@ -626,7 +626,7 @@ protected:
static wxCursor cursor{ wxCURSOR_SIZEWE };
return {
_( "Click and drag to adjust, double-click to reset" ),
XO( "Click and drag to adjust, double-click to reset" ),
&cursor,
XO( "Record/Play head" )
};
@ -1501,7 +1501,7 @@ auto AdornedRulerPanel::ScrubbingHandle::Preview
auto message = ScrubbingMessage(scrubber, mClicked == Button::Left);
return {
message.Translation(),
message,
{},
// Tooltip is same as status message, or blank
((mParent && mParent->mTimelineToolTip) ? message : TranslatableString{}),
@ -1543,7 +1543,7 @@ auto AdornedRulerPanel::QPHandle::Preview
state.state.m_x, mParent->mOldPlayRegion.GetEnd());
return {
message.Translation(),
message,
showArrows ? &cursorSizeWE : &cursorHand,
tooltip,
};
@ -2307,7 +2307,7 @@ void AdornedRulerPanel::ProcessUIHandleResult
DrawBothOverlays();
}
void AdornedRulerPanel::UpdateStatusMessage( const wxString &message )
void AdornedRulerPanel::UpdateStatusMessage( const TranslatableString &message )
{
ProjectStatus::Get( *GetProject() ).Set(message);
}

View File

@ -200,7 +200,7 @@ private:
(TrackPanelCell *pClickedTrack, TrackPanelCell *pLatestCell,
unsigned refreshResult) override;
void UpdateStatusMessage( const wxString & ) override;
void UpdateStatusMessage( const TranslatableString & ) override;
void CreateOverlays();

View File

@ -271,8 +271,7 @@ void CellularPanel::HandleMotion
auto oldCell = state.mLastCell.lock();
auto oldHandle = Target();
wxString status{};
TranslatableString tooltip{};
TranslatableString status, tooltip;
wxCursor *pCursor{};
unsigned refreshCode = 0;
@ -386,7 +385,7 @@ void CellularPanel::HandleMotion
}
else if ( oldCell || oldHandle )
// Leaving a cell or hit test target with no replacement
UpdateStatusMessage( wxString{} );
UpdateStatusMessage( {} );
if (newCell)
ProcessUIHandleResult(newCell.get(), newCell.get(), refreshCode);

View File

@ -22,6 +22,7 @@ class TrackPanelGroup;
class TrackPanelNode;
struct TrackPanelMouseEvent;
struct TrackPanelMouseState;
class TranslatableString;
class UIHandle;
using UIHandlePtr = std::shared_ptr<UIHandle>;
@ -55,7 +56,7 @@ public:
(TrackPanelCell *pClickedCell, TrackPanelCell *pLatestCell,
unsigned refreshResult) = 0;
virtual void UpdateStatusMessage( const wxString & ) = 0;
virtual void UpdateStatusMessage( const TranslatableString & ) = 0;
public:
// Structure and functions for generalized visitation of the subdivision

View File

@ -21,12 +21,12 @@ struct HitTestPreview
HitTestPreview()
{}
HitTestPreview(const wxString &message_, wxCursor *cursor_,
HitTestPreview(const TranslatableString &message_, wxCursor *cursor_,
const TranslatableString &tooltip_ = {})
: message(message_), cursor(cursor_), tooltip{ tooltip_ }
: message{ message_ }, cursor{ cursor_ }, tooltip{ tooltip_ }
{}
wxString message {};
TranslatableString message {};
wxCursor *cursor {};
TranslatableString tooltip{};
};

View File

@ -73,10 +73,10 @@ ProjectAudioManager::ProjectAudioManager( AudacityProject &project )
ProjectAudioManager::~ProjectAudioManager() = default;
static wxString FormatRate( int rate )
static TranslatableString FormatRate( int rate )
{
if (rate > 0) {
return wxString::Format(_("Actual Rate: %d"), rate);
return XO("Actual Rate: %d").Format( rate );
}
else
// clear the status field
@ -804,7 +804,7 @@ void ProjectAudioManager::OnAudioIORate(int rate)
mDisplayedRate = rate;
wxString display = FormatRate( rate );
auto display = FormatRate( rate );
ProjectStatus::Get( project ).Set( display, rateStatusBarField );
}

View File

@ -153,7 +153,7 @@ private:
bool mStopping{ false };
int mDisplayedRate{ 0 };
static std::pair< std::vector< wxString >, unsigned >
static std::pair< TranslatableStrings, unsigned >
StatusWidthFunction(
const AudacityProject &project, StatusBarField field);
};

View File

@ -612,8 +612,7 @@ bool ProjectFileManager::DoSave (const bool fromSaveAs,
// cancel the cleanup:
safetyFileName = wxT("");
ProjectStatus::Get( proj ).Set(
wxString::Format(_("Saved %s"), fileName) );
ProjectStatus::Get( proj ).Set( XO("Saved %s").Format( fileName ) );
return true;
}

View File

@ -1020,7 +1020,7 @@ void ProjectManager::OnStatusChange( wxCommandEvent &evt )
auto field = static_cast<StatusBarField>( evt.GetInt() );
const auto &msg = ProjectStatus::Get( project ).Get( field );
window.GetStatusBar()->SetStatusText(msg, field);
window.GetStatusBar()->SetStatusText(msg.Translation(), field);
if ( field == mainStatusBarField )
// When recording, let the NEW status message stay at least as long as

View File

@ -57,16 +57,16 @@ auto ProjectStatus::GetStatusWidthFunctions() -> const StatusWidthFunctions &
return statusWidthFunctions();
}
const wxString &ProjectStatus::Get( StatusBarField field ) const
const TranslatableString &ProjectStatus::Get( StatusBarField field ) const
{
return mLastStatusMessages[ field - 1 ];
}
void ProjectStatus::Set(const wxString &msg, StatusBarField field )
void ProjectStatus::Set(const TranslatableString &msg, StatusBarField field )
{
auto &project = mProject;
wxString &lastMessage = mLastStatusMessages[ field - 1 ];
if ( msg != lastMessage ) {
auto &lastMessage = mLastStatusMessages[ field - 1 ];
if ( msg.Translation() != lastMessage.Translation() ) {
lastMessage = msg;
wxCommandEvent evt{ EVT_PROJECT_STATUS_UPDATE };
evt.SetInt( field );

View File

@ -46,10 +46,10 @@ public:
ProjectStatus &operator= ( const ProjectStatus & ) = delete;
~ProjectStatus() override;
// Type of a function to report translated strings, and also report an extra
// Type of a function to report translatable strings, and also report an extra
// margin, to request that the corresponding field of the status bar should
// be wide enough to contain any of those strings plus the margin.
using StatusWidthResult = std::pair< std::vector<wxString>, unsigned >;
using StatusWidthResult = std::pair< std::vector<TranslatableString>, unsigned >;
using StatusWidthFunction = std::function<
StatusWidthResult( const AudacityProject &, StatusBarField )
>;
@ -64,11 +64,11 @@ public:
static const StatusWidthFunctions &GetStatusWidthFunctions();
const wxString &Get( StatusBarField field = mainStatusBarField ) const;
void Set(const wxString &msg,
const TranslatableString &Get( StatusBarField field = mainStatusBarField ) const;
void Set(const TranslatableString &msg,
StatusBarField field = mainStatusBarField);
private:
AudacityProject &mProject;
wxString mLastStatusMessages[ nStatusBarFields ];
TranslatableString mLastStatusMessages[ nStatusBarFields ];
};

View File

@ -1224,7 +1224,7 @@ void ProjectWindow::UpdateStatusWidths()
function( mProject, static_cast< StatusBarField >( ii ) );
for ( const auto &string : results.first ) {
int w;
statusBar->GetTextExtent(string, &w, nullptr);
statusBar->GetTextExtent(string.Translation(), &w, nullptr);
width = std::max<int>( width, w + results.second );
}
}

View File

@ -650,12 +650,12 @@ bool TrackPanel::IsAudioActive()
return ProjectAudioIO::Get( *p ).IsAudioActive();
}
void TrackPanel::UpdateStatusMessage( const wxString &st )
void TrackPanel::UpdateStatusMessage( const TranslatableString &st )
{
auto status = st;
if (HasEscape())
/* i18n-hint Esc is a key on the keyboard */
status += wxT(" "), status += _("(Esc to cancel)");
/* i18n-hint Esc is a key on the keyboard */
status.Join( XO("(Esc to cancel)"), " " );
ProjectStatus::Get( *GetProject() ).Set( status );
}
@ -693,7 +693,7 @@ void TrackPanel::UpdateViewIfNoTracks()
mListener->TP_HandleResize();
//STM: Clear message if all tracks are removed
ProjectStatus::Get( *GetProject() ).Set(wxT(""));
ProjectStatus::Get( *GetProject() ).Set({});
}
}

View File

@ -225,7 +225,7 @@ protected:
(TrackPanelCell *pClickedTrack, TrackPanelCell *pLatestCell,
unsigned refreshResult) override;
void UpdateStatusMessage( const wxString &status ) override;
void UpdateStatusMessage( const TranslatableString &status ) override;
};
// A predicate class

View File

@ -35,13 +35,13 @@ HitTestPreview TrackPanelResizeHandle::HitPreview(bool bLinked)
// is shorter when it is between stereo tracks).
return {
_("Click and drag to adjust relative size of stereo tracks."),
XO("Click and drag to adjust relative size of stereo tracks."),
&resizeCursor
};
}
else {
return {
_("Click and drag to resize the track."),
XO("Click and drag to resize the track."),
&resizeCursor
};
}

View File

@ -1169,7 +1169,7 @@ void OnTrackClose(const CommandContext &context)
if (isAudioActive)
{
ProjectStatus::Get( project ).Set(
_("Can't delete track with active audio"));
XO("Can't delete track with active audio"));
wxBell();
return;
}

View File

@ -44,7 +44,8 @@ class ODComputeSummaryTask final : public ODTask
///Return the task name
const char* GetTaskName() override { return "ODComputeSummaryTask"; }
const wxChar* GetTip() override { return _("Import complete. Calculating waveform"); }
TranslatableString GetTip() override
{ return XO("Import complete. Calculating waveform"); }
bool UsesCustomWorkUntilPercentage() override { return true; }
float ComputeNextWorkUntilPercentageComplete() override;

View File

@ -53,7 +53,7 @@ class ODDecodeTask /* not final */ : public ODTask
///Return the task name
const char* GetTaskName() override { return "ODDecodeTask"; }
const wxChar* GetTip() override { return _("Decoding Waveform"); }
TranslatableString GetTip() override { return XO("Decoding Waveform"); }
///Subclasses should override to return respective type.
unsigned int GetODType() override { return eODNone; }

View File

@ -622,7 +622,7 @@ bool ODManager::HasLoadedODFlag()
}
///fills in the status bar message for a given track
void ODManager::FillTipForWaveTrack( const WaveTrack * t, wxString &tip )
void ODManager::FillTipForWaveTrack( const WaveTrack * t, TranslatableString &tip )
{
mQueuesMutex.Lock();
for(unsigned int i=0;i<mQueues.size();i++)

View File

@ -37,6 +37,7 @@ wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
int CompareNoCaseFileName(const wxString& first, const wxString& second);
/// A singleton that manages currently running Tasks on an arbitrary
/// number of threads.
class TranslatableString;
class Track;
class WaveTrack;
class ODWaveTrackTaskQueue;
@ -100,7 +101,7 @@ class ODManager final
static bool IsInstanceCreated();
///fills in the status bar message for a given track
void FillTipForWaveTrack( const WaveTrack * t, wxString &tip );
void FillTipForWaveTrack( const WaveTrack * t, TranslatableString &tip );
///Gets the total percent complete for all tasks combined.
float GetOverallPercentComplete();

View File

@ -117,7 +117,7 @@ class ODTask /* not final */
bool GetNeedsODUpdate();
void ResetNeedsODUpdate();
virtual const wxChar* GetTip()=0;
virtual TranslatableString GetTip()=0;
///returns true if the task is associated with the project.
virtual bool IsTaskAssociatedWithProject(AudacityProject* proj);

View File

@ -304,15 +304,20 @@ ODTask* ODWaveTrackTaskQueue::GetFrontTask()
}
///fills in the status bar message for a given track
void ODWaveTrackTaskQueue::FillTipForWaveTrack( const WaveTrack * t, wxString &tip )
void ODWaveTrackTaskQueue::FillTipForWaveTrack(
const WaveTrack * t, TranslatableString &tip )
{
if(ContainsWaveTrack(t) && GetNumTasks())
{
// if(GetNumTasks()==1)
mTipMsg.Printf(_("%s %2.0f%% complete. Click to change task focal point."), GetFrontTask()->GetTip(), GetFrontTask()->PercentComplete()*100.0 );
mTipMsg = XO("%s %2.0f%% complete. Click to change task focal point.")
.Format(
GetFrontTask()->GetTip(),
GetFrontTask()->PercentComplete()*100.0 );
// else
// msg.Printf(_("%s %d additional tasks remaining."), GetFrontTask()->GetTip(), GetNumTasks());
// msg = XO("%s %d additional tasks remaining.")
// .Format( GetFrontTask()->GetTip(), GetNumTasks());
tip = mTipMsg;

View File

@ -24,6 +24,7 @@ tasks associated with a WaveTrack.
#include <vector>
#include "ODTaskThread.h"
#include "../Internat.h" // for TranslatableString
class Track;
class WaveTrack;
class ODTask;
@ -87,7 +88,7 @@ class ODWaveTrackTaskQueue final
ODTask* GetTask(size_t x);
///fills in the status bar message for a given track
void FillTipForWaveTrack( const WaveTrack * t, wxString &tip );
void FillTipForWaveTrack( const WaveTrack * t, TranslatableString &tip );
protected:
@ -95,7 +96,7 @@ class ODWaveTrackTaskQueue final
void Compress();
//because we need to save this around for the tool tip.
wxString mTipMsg;
TranslatableString mTipMsg;
///the list of tracks associated with this queue.

View File

@ -96,7 +96,6 @@ static const TranslatableString
sStatePlay = XO("Playing")
, sStateStop = XO("Stopped")
, sStateRecord = XO("Recording")
, sStatePause = XO("Paused")
;
//Standard constructor
@ -687,14 +686,12 @@ registeredStatusWidthFunction{
-> ProjectStatus::StatusWidthResult
{
if ( field == stateStatusBarField ) {
const auto pauseString = wxT(" ") + sStatePause.Translation();
std::vector<wxString> strings;
TranslatableStrings strings;
for ( auto pString :
{ &sStatePlay, &sStateStop, &sStateRecord } )
{
strings.push_back(
pString->Translation() + pauseString + wxT(".") );
XO("%s Paused.").Format(*pString) );
}
// added constant needed because xMax isn't large enough for some reason, plus some space.
@ -704,9 +701,9 @@ registeredStatusWidthFunction{
}
};
wxString ControlToolBar::StateForStatusBar()
TranslatableString ControlToolBar::StateForStatusBar()
{
wxString state;
TranslatableString state;
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
auto pProject = &mProject;
@ -714,23 +711,16 @@ wxString ControlToolBar::StateForStatusBar()
? Scrubber::Get( *pProject ).GetUntranslatedStateString()
: TranslatableString{};
if (!scrubState.empty())
state = scrubState.Translation();
state = scrubState;
else if (mPlay->IsDown())
state = sStatePlay.Translation();
state = sStatePlay;
else if (projectAudioManager.Recording())
state = sStateRecord.Translation();
state = sStateRecord;
else
state = sStateStop.Translation();
state = sStateStop;
if (mPause->IsDown())
{
state.Append(wxT(" "));
state.Append(sStatePause.Translation());
}
state.Append(wxT("."));
return state;
return ((mPause->IsDown()) ? XO("%s Paused.") : XO("%s."))
.Format( state );
}
void ControlToolBar::UpdateStatusBar()

View File

@ -97,7 +97,7 @@ class ControlToolBar final : public ToolBar {
teBmps eDisabled);
void ArrangeButtons();
wxString StateForStatusBar();
TranslatableString StateForStatusBar();
enum
{

View File

@ -293,25 +293,21 @@ void MixerToolBar::AdjustInputGain(int adj)
void MixerToolBar::SetToolTips()
{
if (mInputSlider->IsEnabled()) {
mInputSlider->SetToolTipTemplate(_("Recording Volume: %.2f"));
mInputSlider->SetToolTipTemplate(XO("Recording Volume: %.2f"));
}
else {
mInputSlider->SetToolTipTemplate(_("Recording Volume (Unavailable; use system mixer.)"));
mInputSlider->SetToolTipTemplate(XO("Recording Volume (Unavailable; use system mixer.)"));
}
if (mOutputSlider->IsEnabled()) {
wxString format;
auto gAudioIO = AudioIO::Get();
if (gAudioIO->OutputMixerEmulated())
format = _("Playback Volume: %s (emulated)");
else
format = _("Playback Volume: %s");
auto format = (AudioIO::Get()->OutputMixerEmulated()
? XO("Playback Volume: %.2f (emulated)")
: XO("Playback Volume: %.2f"));
mOutputSlider->SetToolTipTemplate(
wxString::Format( format, "%.2f" ) );
mOutputSlider->SetToolTipTemplate( format );
}
else {
mOutputSlider->SetToolTipTemplate(_("Playback Volume (Unavailable; use system mixer.)"));
mOutputSlider->SetToolTipTemplate(XO("Playback Volume (Unavailable; use system mixer.)"));
}
}

View File

@ -87,8 +87,8 @@ HitTestPreview LabelGlyphHandle::HitPreview(bool hitCenter)
static wxCursor arrowCursor{ wxCURSOR_ARROW };
return {
(hitCenter
? _("Drag one or more label boundaries.")
: _("Drag label boundary.")),
? XO("Drag one or more label boundaries.")
: XO("Drag label boundary.")),
&arrowCursor
};
}

View File

@ -45,7 +45,7 @@ HitTestPreview LabelTextHandle::HitPreview()
static auto ibeamCursor =
::MakeCursor(wxCURSOR_IBEAM, IBeamCursorXpm, 17, 16);
return {
_("Click to edit label text"),
XO("Click to edit label text"),
ibeamCursor.get()
};
}

View File

@ -78,8 +78,8 @@ HitTestPreview NoteTrackVZoomHandle::HitPreview(const wxMouseState &state)
gPrefs->Read(wxT("/GUI/VerticalZooming"), &bVZoom, false);
bVZoom &= !state.RightIsDown();
const auto message = bVZoom ?
_("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.") :
_("Right-click for menu.");
XO("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.") :
XO("Right-click for menu.");
return {
message,

View File

@ -44,7 +44,7 @@ HitTestPreview StretchHandle::HitPreview( StretchEnum stretchMode, bool unsafe )
::MakeCursor(wxCURSOR_BULLSEYE, StretchCursorXpm, 16, 16);
if (unsafe) {
return { wxT(""), &*disabledCursor };
return { {}, &*disabledCursor };
}
else {
wxCursor *pCursor = NULL;
@ -59,7 +59,7 @@ HitTestPreview StretchHandle::HitPreview( StretchEnum stretchMode, bool unsafe )
pCursor = &*stretchRightCursor; break;
}
return {
_("Click and drag to stretch selected region."),
XO("Click and drag to stretch selected region."),
pCursor
};
}

View File

@ -45,8 +45,8 @@ HitTestPreview CutlineHandle::HitPreview(bool cutline, bool unsafe)
static wxCursor arrowCursor{ wxCURSOR_ARROW };
return {
(cutline
? _("Left-Click to expand, Right-Click to remove")
: _("Left-Click to merge clips")),
? XO("Left-Click to expand, Right-Click to remove")
: XO("Left-Click to merge clips")),
(unsafe
? &*disabledCursor
: &arrowCursor)

View File

@ -59,7 +59,7 @@ HitTestPreview SampleHandle::HitPreview
// TODO: message should also mention the brush. Describing the modifier key
// (alt, or other) varies with operating system.
auto message = _("Click and drag to edit the samples");
auto message = XO("Click and drag to edit the samples");
return {
message,

View File

@ -65,8 +65,8 @@ HitTestPreview WaveTrackVZoomHandle::HitPreview(const wxMouseState &state)
gPrefs->Read(wxT("/GUI/VerticalZooming"), &bVZoom, false);
bVZoom &= !state.RightIsDown();
const auto message = bVZoom ?
_("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.") :
_("Right-click for menu.");
XO("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.") :
XO("Right-click for menu.");
return {
message,

View File

@ -323,7 +323,7 @@ public:
{
static wxCursor resizeCursor{ wxCURSOR_SIZENS };
return {
_("Click and drag to adjust sizes of sub-views."),
XO("Click and drag to adjust sizes of sub-views."),
&resizeCursor
};
}

View File

@ -75,7 +75,7 @@ HitTestPreview ButtonHandle::Preview
{
// No special cursor
auto message = Tip(st.state);
return { message.Translation(), {}, message };
return { message, {}, message };
}
UIHandle::Result ButtonHandle::Release

View File

@ -256,11 +256,9 @@ HitTestPreview EnvelopeHandle::Preview
static auto envelopeCursor =
::MakeCursor(wxCURSOR_ARROW, EnvCursorXpm, 16, 16);
wxString message;
if (mTimeTrack)
message = _("Click and drag to warp playback time");
else
message = _("Click and drag to edit the amplitude envelope");
auto message = mTimeTrack
? XO("Click and drag to warp playback time")
: XO("Click and drag to edit the amplitude envelope");
return {
message,

View File

@ -997,15 +997,12 @@ registeredStatusWidthFunction{
-> ProjectStatus::StatusWidthResult
{
if ( field == stateStatusBarField ) {
std::vector< wxString > strings;
TranslatableStrings strings;
// Note that Scrubbing + Paused is not allowed.
for (const auto &item : menuItems)
strings.push_back( item.GetStatus().Translation() );
strings.push_back( item.GetStatus() );
strings.push_back(
sPlayAtSpeedStatus.Translation() +
wxT(" ") +
XO("Paused").Translation() +
wxT(".")
XO("%s Paused.").Format( sPlayAtSpeedStatus )
);
// added constant needed because xMax isn't large enough for some reason, plus some space.
return { std::move( strings ), 30 };

View File

@ -65,7 +65,7 @@ bool SelectHandle::IsClicked() const
namespace
{
// If we're in OnDemand mode, we may change the tip.
void MaySetOnDemandTip(const Track * t, wxString &tip)
void MaySetOnDemandTip(const Track * t, TranslatableString &tip)
{
wxASSERT(t);
//For OD regions, we need to override and display the percent complete for this task.
@ -312,7 +312,7 @@ namespace
void SetTipAndCursorForBoundary
(SelectionBoundary boundary, bool frequencySnapping,
wxString &tip, wxCursor *&pCursor)
TranslatableString &tip, wxCursor *&pCursor)
{
static wxCursor adjustLeftSelectionCursor{ wxCURSOR_POINT_LEFT };
static wxCursor adjustRightSelectionCursor{ wxCURSOR_POINT_RIGHT };
@ -329,20 +329,20 @@ namespace
pCursor = SelectCursor();
break;
case SBLeft:
tip = _("Click and drag to move left selection boundary.");
tip = XO("Click and drag to move left selection boundary.");
pCursor = &adjustLeftSelectionCursor;
break;
case SBRight:
tip = _("Click and drag to move right selection boundary.");
tip = XO("Click and drag to move right selection boundary.");
pCursor = &adjustRightSelectionCursor;
break;
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
case SBBottom:
tip = _("Click and drag to move bottom selection frequency.");
tip = XO("Click and drag to move bottom selection frequency.");
pCursor = &*bottomFrequencyCursor;
break;
case SBTop:
tip = _("Click and drag to move top selection frequency.");
tip = XO("Click and drag to move top selection frequency.");
pCursor = &*topFrequencyCursor;
break;
case SBCenter:
@ -350,8 +350,8 @@ namespace
#ifndef SPECTRAL_EDITING_ESC_KEY
tip =
frequencySnapping ?
_("Click and drag to move center selection frequency to a spectral peak.") :
_("Click and drag to move center selection frequency.");
XO("Click and drag to move center selection frequency to a spectral peak.") :
XO("Click and drag to move center selection frequency.");
#else
shiftDown;
@ -365,7 +365,7 @@ namespace
}
break;
case SBWidth:
tip = _("Click and drag to adjust frequency bandwidth.");
tip = XO("Click and drag to adjust frequency bandwidth.");
pCursor = &*bandWidthCursor;
break;
#endif
@ -909,7 +909,7 @@ HitTestPreview SelectHandle::Preview
if (!pTrack)
return {};
wxString tip;
TranslatableString tip;
wxCursor *pCursor = SelectCursor();
if ( IsClicked() )
// Use same cursor as at the clck
@ -942,9 +942,8 @@ HitTestPreview SelectHandle::Preview
keyStr = _("Edit, Preferences...");
/* i18n-hint: %s is usually replaced by "Ctrl+P" for Windows/Linux, "Command+," for Mac */
tip = wxString::Format(
_("Multi-Tool Mode: %s for Mouse and Keyboard Preferences."),
keyStr);
tip = XO("Multi-Tool Mode: %s for Mouse and Keyboard Preferences.")
.Format( keyStr );
// Later in this function we may point to some other string instead.
if (!pTrack->GetSelected() ||
!viewInfo.bAdjustSelectionEdges)
@ -974,7 +973,7 @@ HitTestPreview SelectHandle::Preview
if ((mFreqSelMode == FREQ_SEL_SNAPPING_CENTER) &&
isSpectralSelectionView(pView)) {
// Not shift-down, but center frequency snapping toggle is on
tip = _("Click and drag to set frequency bandwidth.");
tip = XO("Click and drag to set frequency bandwidth.");
pCursor = &*envelopeCursor;
return {};
}
@ -997,12 +996,13 @@ HitTestPreview SelectHandle::Preview
MaySetOnDemandTip(pTrack.get(), tip);
}
if (tip.empty()) {
tip = _("Click and drag to select audio");
tip = XO("Click and drag to select audio");
}
if (HasEscape() && mUseSnap) {
tip += wxT(" ") +
tip.Join(
/* i18n-hint: "Snapping" means automatic alignment of selection edges to any nearby label or clip boundaries */
_("(snapping)");
XO("(snapping)"), wxT(" ")
);
}
return { tip, pCursor };
}

View File

@ -54,7 +54,7 @@ HitTestPreview TimeShiftHandle::HitPreview
// TODO: Should it say "track or clip" ? Non-wave tracks can move, or clips in a wave track.
// TODO: mention effects of shift (move all clips of selected wave track) and ctrl (move vertically only) ?
// -- but not all of that is available in multi tool.
auto message = _("Click and drag to move a track in time");
auto message = XO("Click and drag to move a track in time");
return {
message,

View File

@ -156,7 +156,7 @@ HitTestPreview TrackSelectHandle::Preview
const bool unsafe =
ProjectAudioIO::Get( *GetActiveProject() ).IsAudioActive();
return {
message.Translation(),
message,
(unsafe
? &*disabledCursor
: &*rearrangeCursor)
@ -168,7 +168,7 @@ HitTestPreview TrackSelectHandle::Preview
// Don't test safety, because the click to change selection is allowed
static wxCursor arrowCursor{ wxCURSOR_ARROW };
return {
message.Translation(),
message,
&arrowCursor,
message
};

View File

@ -46,14 +46,14 @@ HitTestPreview ZoomHandle::HitPreview
::MakeCursor(wxCURSOR_MAGNIFIER, ZoomInCursorXpm, 19, 15);
static auto zoomOutCursor =
::MakeCursor(wxCURSOR_MAGNIFIER, ZoomOutCursorXpm, 19, 15);
wxString message;
TranslatableString message;
// TODO: Why not mention middle click to zoom normal on Windows too?
#if defined( __WXMAC__ )
message = _("Click to Zoom In, Shift-Click to Zoom Out");
message = XO("Click to Zoom In, Shift-Click to Zoom Out");
#elif defined( __WXMSW__ )
message = _("Drag to Zoom Into Region, Right-Click to Zoom Out");
message = XO("Drag to Zoom Into Region, Right-Click to Zoom Out");
#elif defined( __WXGTK__ )
message = _("Left=Zoom In, Right=Zoom Out, Middle=Normal");
message = XO("Left=Zoom In, Right=Zoom Out, Middle=Normal");
#endif
return {
message,

View File

@ -497,7 +497,7 @@ void AButton::OnMouseEvent(wxMouseEvent & event)
if (mCursorIsInWindow)
UpdateStatus();
else {
ProjectStatus::Get( *GetActiveProject() ).Set(wxT(""));
ProjectStatus::Get( *GetActiveProject() ).Set({});
}
}
else
@ -511,9 +511,9 @@ void AButton::UpdateStatus()
// Display the tooltip in the status bar
wxToolTip * pTip = this->GetToolTip();
if( pTip ) {
wxString tipText = pTip->GetTip();
auto tipText = Verbatim( pTip->GetTip() );
if (!mEnabled)
tipText += _(" (disabled)");
tipText.Join( XO("(disabled)"), " " );
ProjectStatus::Get( *GetActiveProject() ).Set(tipText);
}
#endif

View File

@ -156,12 +156,12 @@ class wxArrayString;
class TipWindow final : public wxFrame
{
public:
TipWindow(wxWindow *parent, const wxArrayString & labels);
TipWindow(wxWindow *parent, const TranslatableStrings & labels);
virtual ~TipWindow() {}
wxSize GetSize() const;
void SetPos(const wxPoint & pos);
void SetLabel(const wxString & label);
void SetLabel(const TranslatableString & label);
private:
void OnPaint(wxPaintEvent & event);
@ -170,7 +170,7 @@ private:
#endif
private:
wxString mLabel;
TranslatableString mLabel;
int mWidth;
int mHeight;
@ -184,7 +184,7 @@ BEGIN_EVENT_TABLE(TipWindow, wxFrame)
#endif
END_EVENT_TABLE()
TipWindow::TipWindow(wxWindow *parent, const wxArrayString & labels)
TipWindow::TipWindow(wxWindow *parent, const TranslatableStrings & labels)
: wxFrame(parent, wxID_ANY, wxString{}, wxDefaultPosition, wxDefaultSize,
wxFRAME_SHAPED | wxFRAME_FLOAT_ON_PARENT)
{
@ -194,7 +194,7 @@ TipWindow::TipWindow(wxWindow *parent, const wxArrayString & labels)
mWidth = mHeight = 0;
for ( const auto &label : labels ) {
int width, height;
GetTextExtent(label, &width, &height, NULL, NULL, &labelFont);
GetTextExtent(label.Translation(), &width, &height, NULL, NULL, &labelFont);
mWidth = std::max( mWidth, width );
mHeight = std::max( mHeight, height );
}
@ -223,7 +223,7 @@ void TipWindow::SetPos(const wxPoint & pos)
#endif
}
void TipWindow::SetLabel(const wxString & label)
void TipWindow::SetLabel(const TranslatableString & label)
{
mLabel = label;
}
@ -240,8 +240,9 @@ void TipWindow::OnPaint(wxPaintEvent & WXUNUSED(event))
dc.SetTextForeground(AColor::tooltipPen.GetColour());
int textWidth, textHeight;
dc.GetTextExtent(mLabel, &textWidth, &textHeight);
dc.DrawText(mLabel, (mWidth - textWidth) / 2, (mHeight - textHeight) / 2);
const auto visibleLabel = mLabel.Translation();
dc.GetTextExtent(visibleLabel, &textWidth, &textHeight);
dc.DrawText(visibleLabel, (mWidth - textWidth) / 2, (mHeight - textHeight) / 2);
}
#if defined(__WXGTK__)
@ -858,7 +859,7 @@ void LWSlider::DrawToBitmap(wxDC & paintDC)
mBitmap->SetMask(safenew wxMask(*mBitmap, backgroundColour));
}
void LWSlider::SetToolTipTemplate(const wxString & tip)
void LWSlider::SetToolTipTemplate(const TranslatableString & tip)
{
mTipTemplate = tip;
}
@ -930,72 +931,74 @@ void LWSlider::FormatPopWin()
mTipPanel->Refresh();
}
wxString LWSlider::GetTip(float value) const
TranslatableString LWSlider::GetTip(float value) const
{
wxString label;
TranslatableString label;
if (mTipTemplate.empty())
{
wxString val;
TranslatableString val;
switch(mStyle)
{
case FRAC_SLIDER:
val.Printf( wxT("%.2f"), value );
Verbatim("%.2f").Format( value );
break;
case DB_SLIDER:
val.Printf( wxT("%+.1f dB"), value );
/* i18n-hint dB abbreviates decibels */
XO("%+.1f dB").Format( value );
break;
case PAN_SLIDER:
if (value == 0.0)
{
val = _("Center");
val = XO("Center");
}
else
{
const auto v = 100.0f * fabsf(value);
if (value < 0.0)
/* i18n-hint: Stereo pan setting */
val = wxString::Format( _("%.0f%% Left"), v );
val = XO("%.0f%% Left").Format( v );
else
/* i18n-hint: Stereo pan setting */
val = wxString::Format( _("%.0f%% Right"), v );
val = XO("%.0f%% Right").Format( v );
}
break;
case SPEED_SLIDER:
/* i18n-hint: "x" suggests a multiplicative factor */
val.Printf( wxT("%.2fx"), value );
XO("%.2fx").Format( value );
break;
#ifdef EXPERIMENTAL_MIDI_OUT
case VEL_SLIDER:
if (value > 0.0f)
// Signed
val.Printf( wxT("%+d"), (int) value );
Verbatim("%+d").Format( (int) value );
else
// Zero, or signed negative
val.Printf( wxT("%d"), (int) value );
Verbatim("%d").Format( (int) value );
break;
#endif
}
/* i18n-hint: An item name followed by a value, with appropriate separating punctuation */
label = XO("%s: %s").Format( mName, val ).Translation();
label = XO("%s: %s").Format( mName, val );
}
else
{
label.Printf(mTipTemplate, value);
label = mTipTemplate;
label.Format( value );
}
return label;
}
wxArrayString LWSlider::GetWidestTips() const
TranslatableStrings LWSlider::GetWidestTips() const
{
wxArrayString results;
TranslatableStrings results;
if (mTipTemplate.empty())
{
@ -1090,7 +1093,7 @@ void LWSlider::OnMouseEvent(wxMouseEvent & event)
if (event.Entering())
{
// Display the tooltip in the status bar
wxString tip = GetTip(mCurrentValue);
auto tip = GetTip(mCurrentValue);
ProjectStatus::Get( *GetActiveProject() ).Set(tip);
Refresh();
}
@ -1100,7 +1103,7 @@ void LWSlider::OnMouseEvent(wxMouseEvent & event)
{
ShowTip(false);
}
ProjectStatus::Get( *GetActiveProject() ).Set(wxT(""));
ProjectStatus::Get( *GetActiveProject() ).Set({});
Refresh();
}
@ -1663,7 +1666,7 @@ void ASlider::SetScroll(float line, float page)
mLWSlider->SetScroll(line, page);
}
void ASlider::SetToolTipTemplate(const wxString & tip)
void ASlider::SetToolTipTemplate(const TranslatableString & tip)
{
mLWSlider->SetToolTipTemplate(tip);
}

View File

@ -116,7 +116,7 @@ class LWSlider
void SetScroll(float line, float page);
void ShowTip(bool show);
void SetToolTipTemplate(const wxString & tip);
void SetToolTipTemplate(const TranslatableString & tip);
float Get(bool convert = true);
void Set(float value);
@ -151,8 +151,8 @@ class LWSlider
private:
wxString GetTip(float value) const;
wxArrayString GetWidestTips() const;
TranslatableString GetTip(float value) const;
TranslatableStrings GetWidestTips() const;
void FormatPopWin();
void SetPopWinPosition();
void CreatePopWin();
@ -218,7 +218,7 @@ class LWSlider
wxWindowID mID;
std::unique_ptr<TipWindow> mTipPanel;
wxString mTipTemplate;
TranslatableString mTipTemplate;
bool mIsDragging;
@ -273,7 +273,7 @@ class ASlider /* not final */ : public wxPanel
void GetScroll(float & line, float & page);
void SetScroll(float line, float page);
void SetToolTipTemplate(const wxString & tip);
void SetToolTipTemplate(const TranslatableString & tip);
float Get( bool convert = true );
void Set(float value);

View File

@ -758,13 +758,13 @@ void MeterPanel::OnMouse(wxMouseEvent &evt)
#if wxUSE_TOOLTIPS // Not available in wxX11
if (evt.Leaving()){
ProjectStatus::Get( *GetActiveProject() ).Set(wxT(""));
ProjectStatus::Get( *GetActiveProject() ).Set({});
}
else if (evt.Entering()) {
// Display the tooltip in the status bar
wxToolTip * pTip = this->GetToolTip();
if( pTip ) {
wxString tipText = pTip->GetTip();
auto tipText = Verbatim( pTip->GetTip() );
ProjectStatus::Get( *GetActiveProject() ).Set(tipText);
}
}