1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-29 22:58:39 +02:00

ScrubbingToolBar consumes less idle time

This commit is contained in:
Paul Licameli 2019-07-07 12:20:59 -04:00
parent e03c9cdee3
commit 9b98f4be0c
2 changed files with 51 additions and 27 deletions

View File

@ -142,6 +142,11 @@ void ScrubbingToolBar::UpdatePrefs()
} }
void ScrubbingToolBar::RegenerateTooltips() void ScrubbingToolBar::RegenerateTooltips()
{
DoRegenerateTooltips( true );
}
void ScrubbingToolBar::DoRegenerateTooltips( bool force )
{ {
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
auto fn = [&] auto fn = [&]
@ -159,34 +164,46 @@ void ScrubbingToolBar::RegenerateTooltips()
const auto seekButton = mButtons[STBSeekID]; const auto seekButton = mButtons[STBSeekID];
wxString label; wxString label;
label = ( bool scrubs = scrubber.Scrubs();
scrubber.Scrubs() if (force || mLastScrub != scrubs) {
/* i18n-hint: These commands assist the user in finding a sound by ear. ... label = (
"Scrubbing" is variable-speed playback, ... scrubs
"Seeking" is normal speed playback but with skips /* i18n-hint: These commands assist the user in finding a sound by ear. ...
*/ "Scrubbing" is variable-speed playback, ...
? _("Stop Scrubbing") "Seeking" is normal speed playback but with skips
: _("Start Scrubbing") */
); ? _("Stop Scrubbing")
fn(*scrubButton, label, wxT("Scrub")); : _("Start Scrubbing")
);
fn(*scrubButton, label, wxT("Scrub"));
}
mLastScrub = scrubs;
label = ( bool seeks = scrubber.Seeks();
scrubber.Seeks() if (force || mLastSeek != seeks) {
/* i18n-hint: These commands assist the user in finding a sound by ear. ... label = (
"Scrubbing" is variable-speed playback, ... seeks
"Seeking" is normal speed playback but with skips /* i18n-hint: These commands assist the user in finding a sound by ear. ...
*/ "Scrubbing" is variable-speed playback, ...
? _("Stop Seeking") "Seeking" is normal speed playback but with skips
: _("Start Seeking") */
); ? _("Stop Seeking")
fn(*seekButton, label, wxT("Seek")); : _("Start Seeking")
);
fn(*seekButton, label, wxT("Seek"));
}
mLastSeek = seeks;
label = ( bool showingRuler = AdornedRulerPanel::Get( *project ).ShowingScrubRuler();
AdornedRulerPanel::Get( *project ).ShowingScrubRuler() if (force || mLastRuler != showingRuler) {
? _("Hide Scrub Ruler") label = (
: _("Show Scrub Ruler") showingRuler
); ? _("Hide Scrub Ruler")
fn(*mButtons[STBRulerID], label, wxT("ToggleScrubRuler")); : _("Show Scrub Ruler")
);
fn(*mButtons[STBRulerID], label, wxT("ToggleScrubRuler"));
}
mLastRuler = showingRuler;
} }
#endif #endif
} }
@ -256,7 +273,7 @@ void ScrubbingToolBar::EnableDisableButtons()
barButton->PushDown(); barButton->PushDown();
else else
barButton->PopUp(); barButton->PopUp();
RegenerateTooltips(); DoRegenerateTooltips( false );
scrubber.CheckMenuItems(); scrubber.CheckMenuItems();
} }

View File

@ -78,6 +78,13 @@ public:
DECLARE_CLASS(ScrubbingToolBar) DECLARE_CLASS(ScrubbingToolBar)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
private:
void DoRegenerateTooltips( bool force );
bool mLastScrub{ false };
bool mLastSeek{ false };
bool mLastRuler{ false };
}; };
#endif #endif