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

Pass tooltips by wxString, not const wxChar*

This commit is contained in:
Paul Licameli 2015-07-06 17:20:48 -04:00
parent 4a4918a3f8
commit edba89d704
6 changed files with 53 additions and 55 deletions

View File

@ -1739,29 +1739,29 @@ bool TrackPanel::SetCursorByActivity( )
/// When in the "label" (TrackInfo or vertical ruler), we can either vertical zoom or re-order tracks. /// When in the "label" (TrackInfo or vertical ruler), we can either vertical zoom or re-order tracks.
/// Dont't change cursor/tip to zoom if display is not waveform (either linear of dB) or Spectrum /// Dont't change cursor/tip to zoom if display is not waveform (either linear of dB) or Spectrum
void TrackPanel::SetCursorAndTipWhenInLabel( Track * t, void TrackPanel::SetCursorAndTipWhenInLabel( Track * t,
wxMouseEvent &event, const wxChar ** ppTip ) wxMouseEvent &event, wxString &tip )
{ {
if (event.m_x >= GetVRulerOffset() && (t->GetKind() == Track::Wave) ) if (event.m_x >= GetVRulerOffset() && (t->GetKind() == Track::Wave) )
{ {
*ppTip = _("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region."); tip = _("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.");
SetCursor(event.ShiftDown()? *mZoomOutCursor : *mZoomInCursor); SetCursor(event.ShiftDown()? *mZoomOutCursor : *mZoomInCursor);
} }
#ifdef USE_MIDI #ifdef USE_MIDI
else if (event.m_x >= GetVRulerOffset() && t->GetKind() == Track::Note) { else if (event.m_x >= GetVRulerOffset() && t->GetKind() == Track::Note) {
*ppTip = _("Click to verticaly zoom in, Shift-click to zoom out, Drag to create a particular zoom region."); tip = _("Click to verticaly zoom in, Shift-click to zoom out, Drag to create a particular zoom region.");
SetCursor(event.ShiftDown() ? *mZoomOutCursor : *mZoomInCursor); SetCursor(event.ShiftDown() ? *mZoomOutCursor : *mZoomInCursor);
} }
#endif #endif
else { else {
// Set a status message if over TrackInfo. // Set a status message if over TrackInfo.
*ppTip = _("Drag the track vertically to change the order of the tracks."); tip = _("Drag the track vertically to change the order of the tracks.");
SetCursor(*mArrowCursor); SetCursor(*mArrowCursor);
} }
} }
/// When in the resize area we can adjust size or relative size. /// When in the resize area we can adjust size or relative size.
void TrackPanel::SetCursorAndTipWhenInVResizeArea( Track * label, void TrackPanel::SetCursorAndTipWhenInVResizeArea( Track * label,
bool bLinked, const wxChar ** ppTip ) bool bLinked, wxString &tip )
{ {
// Check to see whether it is the first channel of a stereo track // Check to see whether it is the first channel of a stereo track
if (bLinked) { if (bLinked) {
@ -1774,10 +1774,10 @@ void TrackPanel::SetCursorAndTipWhenInVResizeArea( Track * label,
// cursor are still needed. // cursor are still needed.
if (label) if (label)
return; return;
*ppTip = _("Click and drag to adjust relative size of stereo tracks."); tip = _("Click and drag to adjust relative size of stereo tracks.");
SetCursor(*mResizeCursor); SetCursor(*mResizeCursor);
} else { } else {
*ppTip = _("Click and drag to resize the track."); tip = _("Click and drag to resize the track.");
SetCursor(*mResizeCursor); SetCursor(*mResizeCursor);
} }
} }
@ -1785,7 +1785,7 @@ void TrackPanel::SetCursorAndTipWhenInVResizeArea( Track * label,
/// When in a label track, find out if we've hit anything that /// When in a label track, find out if we've hit anything that
/// would cause a cursor change. /// would cause a cursor change.
void TrackPanel::SetCursorAndTipWhenInLabelTrack( LabelTrack * pLT, void TrackPanel::SetCursorAndTipWhenInLabelTrack( LabelTrack * pLT,
wxMouseEvent & event, const wxChar ** ppTip ) wxMouseEvent & event, wxString &tip )
{ {
int edge=pLT->OverGlyph(event.m_x, event.m_y); int edge=pLT->OverGlyph(event.m_x, event.m_y);
if(edge !=0) if(edge !=0)
@ -1806,7 +1806,7 @@ void TrackPanel::SetCursorAndTipWhenInLabelTrack( LabelTrack * pLT,
// signal this by setting the tip. // signal this by setting the tip.
if( edge != 0 ) if( edge != 0 )
{ {
*ppTip = tip =
(pLT->mbHitCenter ) ? (pLT->mbHitCenter ) ?
_("Drag one or more label boundaries.") : _("Drag one or more label boundaries.") :
_("Drag label boundary."); _("Drag label boundary.");
@ -1832,7 +1832,7 @@ inline bool isSpectralSelectionTrack(const Track *pTrack) {
} // namespace } // namespace
// If we're in OnDemand mode, we may change the tip. // If we're in OnDemand mode, we may change the tip.
void TrackPanel::MaySetOnDemandTip( Track * t, const wxChar ** ppTip ) void TrackPanel::MaySetOnDemandTip( Track * t, wxString &tip )
{ {
wxASSERT( t ); wxASSERT( t );
//For OD regions, we need to override and display the percent complete for this task. //For OD regions, we need to override and display the percent complete for this task.
@ -1842,17 +1842,17 @@ void TrackPanel::MaySetOnDemandTip( Track * t, const wxChar ** ppTip )
//see if the wavetrack exists in the ODManager (if the ODManager exists) //see if the wavetrack exists in the ODManager (if the ODManager exists)
if(!ODManager::IsInstanceCreated()) if(!ODManager::IsInstanceCreated())
return; return;
//ask the wavetrack for the corresponding tip - it may not change **pptip, but that's fine. //ask the wavetrack for the corresponding tip - it may not change tip, but that's fine.
ODManager::Instance()->FillTipForWaveTrack((WaveTrack*)t,ppTip); ODManager::Instance()->FillTipForWaveTrack(static_cast<WaveTrack*>(t), tip);
return; return;
} }
#ifdef EXPERIMENTAL_SPECTRAL_EDITING #ifdef EXPERIMENTAL_SPECTRAL_EDITING
void TrackPanel::HandleCenterFrequencyCursor void TrackPanel::HandleCenterFrequencyCursor
(bool shiftDown, const wxChar ** ppTip, const wxCursor ** ppCursor) (bool shiftDown, wxString &tip, const wxCursor ** ppCursor)
{ {
#ifndef SPECTRAL_EDITING_ESC_KEY #ifndef SPECTRAL_EDITING_ESC_KEY
*ppTip = tip =
shiftDown ? shiftDown ?
_("Click and drag to move center selection frequency.") : _("Click and drag to move center selection frequency.") :
_("Click and drag to move center selection frequency to a spectral peak."); _("Click and drag to move center selection frequency to a spectral peak.");
@ -1860,7 +1860,7 @@ void TrackPanel::HandleCenterFrequencyCursor
#else #else
shiftDown; shiftDown;
*ppTip = tip =
_("Click and drag to move center selection frequency."); _("Click and drag to move center selection frequency.");
#endif #endif
@ -1897,7 +1897,7 @@ void TrackPanel::HandleCenterFrequencyClick
// Determine and set the cursor and tip accordingly. // Determine and set the cursor and tip accordingly.
void TrackPanel::SetCursorAndTipWhenSelectTool( Track * t, void TrackPanel::SetCursorAndTipWhenSelectTool( Track * t,
wxMouseEvent & event, wxRect &r, bool bMultiToolMode, wxMouseEvent & event, wxRect &r, bool bMultiToolMode,
const wxChar ** ppTip, const wxCursor ** ppCursor ) wxString &tip, const wxCursor ** ppCursor )
{ {
// Do not set the default cursor here and re-set later, that causes // Do not set the default cursor here and re-set later, that causes
// flashing. // flashing.
@ -1915,13 +1915,10 @@ void TrackPanel::SetCursorAndTipWhenSelectTool( Track * t,
keyStr = _("Edit, Preferences..."); keyStr = _("Edit, Preferences...");
else else
keyStr = KeyStringDisplay(keyStr); keyStr = KeyStringDisplay(keyStr);
// Must compose a string that survives the function call, hence static.
static wxString result;
/* i18n-hint: %s is usually replaced by "Ctrl+P" for Windows/Linux, "Command+," for Mac */ /* i18n-hint: %s is usually replaced by "Ctrl+P" for Windows/Linux, "Command+," for Mac */
result = wxString::Format( tip = wxString::Format(
_("Multi-Tool Mode: %s for Mouse and Keyboard Preferences."), _("Multi-Tool Mode: %s for Mouse and Keyboard Preferences."),
keyStr.c_str()); keyStr.c_str());
*ppTip = result;
// Later in this function we may point to some other string instead. // Later in this function we may point to some other string instead.
} }
@ -1934,7 +1931,7 @@ void TrackPanel::SetCursorAndTipWhenSelectTool( Track * t,
// the preferences... // the preferences...
if ( !t->GetSelected() || !mAdjustSelectionEdges) if ( !t->GetSelected() || !mAdjustSelectionEdges)
{ {
MaySetOnDemandTip( t, ppTip ); MaySetOnDemandTip( t, tip );
return; return;
} }
@ -1951,7 +1948,7 @@ void TrackPanel::SetCursorAndTipWhenSelectTool( Track * t,
if ( (mFreqSelMode == FREQ_SEL_SNAPPING_CENTER) && if ( (mFreqSelMode == FREQ_SEL_SNAPPING_CENTER) &&
isSpectralSelectionTrack(t)) { isSpectralSelectionTrack(t)) {
// Not shift-down, but center frequency snapping toggle is on // Not shift-down, but center frequency snapping toggle is on
*ppTip = _("Click and drag to set frequency bandwidth."); tip = _("Click and drag to set frequency bandwidth.");
*ppCursor = mEnvelopeCursor; *ppCursor = mEnvelopeCursor;
return; return;
} }
@ -1977,7 +1974,7 @@ void TrackPanel::SetCursorAndTipWhenSelectTool( Track * t,
case SBLeft: case SBLeft:
case SBRight: case SBRight:
if ( HitTestStretch(t, r, event)) { if ( HitTestStretch(t, r, event)) {
*ppTip = _("Click and drag to stretch within selected region."); tip = _("Click and drag to stretch within selected region.");
*ppCursor = mStretchCursor; *ppCursor = mStretchCursor;
return; return;
} }
@ -1992,33 +1989,33 @@ void TrackPanel::SetCursorAndTipWhenSelectTool( Track * t,
if( bShiftDown ){ if( bShiftDown ){
// wxASSERT( false ); // wxASSERT( false );
// Same message is used for moving left right top or bottom edge. // Same message is used for moving left right top or bottom edge.
*ppTip = _("Click to move selection boundary to cursor."); tip = _("Click to move selection boundary to cursor.");
// No cursor change. // No cursor change.
return; return;
} }
break; break;
case SBLeft: case SBLeft:
*ppTip = _("Click and drag to move left selection boundary."); tip = _("Click and drag to move left selection boundary.");
*ppCursor = mAdjustLeftSelectionCursor; *ppCursor = mAdjustLeftSelectionCursor;
return; return;
case SBRight: case SBRight:
*ppTip = _("Click and drag to move right selection boundary."); tip = _("Click and drag to move right selection boundary.");
*ppCursor = mAdjustRightSelectionCursor; *ppCursor = mAdjustRightSelectionCursor;
return; return;
#ifdef EXPERIMENTAL_SPECTRAL_EDITING #ifdef EXPERIMENTAL_SPECTRAL_EDITING
case SBBottom: case SBBottom:
*ppTip = _("Click and drag to move bottom selection frequency."); tip = _("Click and drag to move bottom selection frequency.");
*ppCursor = mBottomFrequencyCursor; *ppCursor = mBottomFrequencyCursor;
return; return;
case SBTop: case SBTop:
*ppTip = _("Click and drag to move top selection frequency."); tip = _("Click and drag to move top selection frequency.");
*ppCursor = mTopFrequencyCursor; *ppCursor = mTopFrequencyCursor;
return; return;
case SBCenter: case SBCenter:
HandleCenterFrequencyCursor(bShiftDown, ppTip, ppCursor); HandleCenterFrequencyCursor(bShiftDown, tip, ppCursor);
return; return;
case SBWidth: case SBWidth:
*ppTip = _("Click and drag to adjust frequency bandwidth."); tip = _("Click and drag to adjust frequency bandwidth.");
*ppCursor = mBandWidthCursor; *ppCursor = mBandWidthCursor;
return; return;
#endif #endif
@ -2027,13 +2024,13 @@ void TrackPanel::SetCursorAndTipWhenSelectTool( Track * t,
} // switch } // switch
// Falls through the switch if there was no boundary found. // Falls through the switch if there was no boundary found.
MaySetOnDemandTip( t, ppTip ); MaySetOnDemandTip( t, tip );
} }
/// In this method we know what tool we are using, /// In this method we know what tool we are using,
/// so set the cursor accordingly. /// so set the cursor accordingly.
void TrackPanel::SetCursorAndTipByTool( int tool, void TrackPanel::SetCursorAndTipByTool( int tool,
wxMouseEvent & event, const wxChar ** /*ppTip*/ ) wxMouseEvent & event, wxString& )
{ {
bool unsafe = IsUnsafe(); bool unsafe = IsUnsafe();
@ -2094,30 +2091,31 @@ void TrackPanel::HandleCursor(wxMouseEvent & event)
// Strategy here is to set the tip when we have determined and // Strategy here is to set the tip when we have determined and
// set the correct cursor. We stop doing tests for what we've // set the correct cursor. We stop doing tests for what we've
// hit once the tip is not NULL. // hit once the tip is not NULL.
const wxChar *tip = NULL;
wxString tip;
if (label) { if (label) {
SetCursorAndTipWhenInLabel( label, event, &tip ); SetCursorAndTipWhenInLabel( label, event, tip );
} }
// Are we within the vertical resize area? // Are we within the vertical resize area?
if ((tip == NULL ) && within(event.m_y, r.y + r.height, TRACK_RESIZE_REGION)) if ((tip == wxString() ) && within(event.m_y, r.y + r.height, TRACK_RESIZE_REGION))
{ {
SetCursorAndTipWhenInVResizeArea( label, t->GetLinked(), &tip ); SetCursorAndTipWhenInVResizeArea( label, t->GetLinked(), tip );
// tip may still be NULL at this point, in which case we go on looking. // tip may still be NULL at this point, in which case we go on looking.
} }
// Otherwise, we must be over a track of some kind // Otherwise, we must be over a track of some kind
// Is it a label track? // Is it a label track?
if ((tip==NULL) && (t->GetKind() == Track::Label)) if ((tip == wxString()) && (t->GetKind() == Track::Label))
{ {
// We are over a label track // We are over a label track
SetCursorAndTipWhenInLabelTrack( (LabelTrack*)t, event, &tip ); SetCursorAndTipWhenInLabelTrack( (LabelTrack*)t, event, tip );
// ..and if we haven't yet determined the cursor, // ..and if we haven't yet determined the cursor,
// we go on to do all the standard track hit tests. // we go on to do all the standard track hit tests.
} }
if( tip==NULL ) if( tip == wxString() )
{ {
ToolsToolBar * ttb = mListener->TP_GetToolsToolBar(); ToolsToolBar * ttb = mListener->TP_GetToolsToolBar();
if( ttb == NULL ) if( ttb == NULL )
@ -2136,21 +2134,21 @@ void TrackPanel::HandleCursor(wxMouseEvent & event)
// the other tool cases. // the other tool cases.
if( tool != selectTool ) if( tool != selectTool )
{ {
SetCursorAndTipByTool( tool, event, &tip); SetCursorAndTipByTool( tool, event, tip);
} }
else else
{ {
bool bMultiToolMode = ttb->IsDown(multiTool); bool bMultiToolMode = ttb->IsDown(multiTool);
const wxCursor *pSelection = 0; const wxCursor *pSelection = 0;
SetCursorAndTipWhenSelectTool SetCursorAndTipWhenSelectTool
( t, event, r, bMultiToolMode, &tip, &pSelection ); ( t, event, r, bMultiToolMode, tip, &pSelection );
if (pSelection) if (pSelection)
// Set cursor once only here, to avoid flashing during drags // Set cursor once only here, to avoid flashing during drags
SetCursor(*pSelection); SetCursor(*pSelection);
} }
} }
if (tip) if (tip != wxString())
mListener->TP_DisplayStatusMessage(tip); mListener->TP_DisplayStatusMessage(tip);
} }

View File

@ -355,14 +355,14 @@ protected:
// AS: Cursor handling // AS: Cursor handling
virtual bool SetCursorByActivity( ); virtual bool SetCursorByActivity( );
virtual void SetCursorAndTipWhenInLabel( Track * t, wxMouseEvent &event, const wxChar ** ppTip ); virtual void SetCursorAndTipWhenInLabel( Track * t, wxMouseEvent &event, wxString &tip );
virtual void SetCursorAndTipWhenInVResizeArea( Track * label, bool blinked, const wxChar ** ppTip ); virtual void SetCursorAndTipWhenInVResizeArea( Track * label, bool blinked, wxString &tip );
virtual void SetCursorAndTipWhenInLabelTrack( LabelTrack * pLT, wxMouseEvent & event, const wxChar ** ppTip ); virtual void SetCursorAndTipWhenInLabelTrack( LabelTrack * pLT, wxMouseEvent & event, wxString &tip );
virtual void SetCursorAndTipWhenSelectTool virtual void SetCursorAndTipWhenSelectTool
( Track * t, wxMouseEvent & event, wxRect &r, bool bMultiToolMode, const wxChar ** ppTip, const wxCursor ** ppCursor ); ( Track * t, wxMouseEvent & event, wxRect &r, bool bMultiToolMode, wxString &tip, const wxCursor ** ppCursor );
virtual void SetCursorAndTipByTool( int tool, wxMouseEvent & event, const wxChar **ppTip ); virtual void SetCursorAndTipByTool( int tool, wxMouseEvent & event, wxString &tip );
virtual void HandleCursor(wxMouseEvent & event); virtual void HandleCursor(wxMouseEvent & event);
virtual void MaySetOnDemandTip( Track * t, const wxChar ** ppTip ); virtual void MaySetOnDemandTip( Track * t, wxString &tip );
// AS: Envelope editing handlers // AS: Envelope editing handlers
virtual void HandleEnvelope(wxMouseEvent & event); virtual void HandleEnvelope(wxMouseEvent & event);
@ -693,7 +693,7 @@ protected:
#ifdef EXPERIMENTAL_SPECTRAL_EDITING #ifdef EXPERIMENTAL_SPECTRAL_EDITING
void HandleCenterFrequencyCursor void HandleCenterFrequencyCursor
(bool shiftDown, const wxChar ** ppTip, const wxCursor ** ppCursor); (bool shiftDown, wxString &tip, const wxCursor ** ppCursor);
void HandleCenterFrequencyClick void HandleCenterFrequencyClick
(bool shiftDown, Track *pTrack, double value); (bool shiftDown, Track *pTrack, double value);

View File

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

View File

@ -98,7 +98,7 @@ class ODManager
static bool IsInstanceCreated(); static bool IsInstanceCreated();
///fills in the status bar message for a given track ///fills in the status bar message for a given track
void FillTipForWaveTrack( WaveTrack * t, const wxChar ** ppTip ); void FillTipForWaveTrack( WaveTrack * t, wxString &tip );
///Gets the total percent complete for all tasks combined. ///Gets the total percent complete for all tasks combined.
float GetOverallPercentComplete(); float GetOverallPercentComplete();

View File

@ -325,7 +325,7 @@ ODTask* ODWaveTrackTaskQueue::GetFrontTask()
} }
///fills in the status bar message for a given track ///fills in the status bar message for a given track
void ODWaveTrackTaskQueue::FillTipForWaveTrack( WaveTrack * t, const wxChar ** ppTip ) void ODWaveTrackTaskQueue::FillTipForWaveTrack( WaveTrack * t, wxString &tip )
{ {
if(ContainsWaveTrack(t) && GetNumTasks()) if(ContainsWaveTrack(t) && GetNumTasks())
{ {
@ -335,7 +335,7 @@ void ODWaveTrackTaskQueue::FillTipForWaveTrack( WaveTrack * t, const wxChar ** p
// else // else
// msg.Printf(_("%s %d additional tasks remaining."), GetFrontTask()->GetTip().c_str(), GetNumTasks()); // msg.Printf(_("%s %d additional tasks remaining."), GetFrontTask()->GetTip().c_str(), GetNumTasks());
*ppTip = mTipMsg.c_str(); tip = mTipMsg.c_str();
} }
} }

View File

@ -92,7 +92,7 @@ class ODWaveTrackTaskQueue
ODTask* GetTask(size_t x); ODTask* GetTask(size_t x);
///fills in the status bar message for a given track ///fills in the status bar message for a given track
void FillTipForWaveTrack( WaveTrack * t, const wxChar ** ppTip ); void FillTipForWaveTrack( WaveTrack * t, wxString &tip );
protected: protected: