1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-02-04 10:43:08 +01: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,8 +164,10 @@ void ScrubbingToolBar::RegenerateTooltips()
const auto seekButton = mButtons[STBSeekID]; const auto seekButton = mButtons[STBSeekID];
wxString label; wxString label;
bool scrubs = scrubber.Scrubs();
if (force || mLastScrub != scrubs) {
label = ( label = (
scrubber.Scrubs() scrubs
/* i18n-hint: These commands assist the user in finding a sound by ear. ... /* i18n-hint: These commands assist the user in finding a sound by ear. ...
"Scrubbing" is variable-speed playback, ... "Scrubbing" is variable-speed playback, ...
"Seeking" is normal speed playback but with skips "Seeking" is normal speed playback but with skips
@@ -169,9 +176,13 @@ void ScrubbingToolBar::RegenerateTooltips()
: _("Start Scrubbing") : _("Start Scrubbing")
); );
fn(*scrubButton, label, wxT("Scrub")); fn(*scrubButton, label, wxT("Scrub"));
}
mLastScrub = scrubs;
bool seeks = scrubber.Seeks();
if (force || mLastSeek != seeks) {
label = ( label = (
scrubber.Seeks() seeks
/* i18n-hint: These commands assist the user in finding a sound by ear. ... /* i18n-hint: These commands assist the user in finding a sound by ear. ...
"Scrubbing" is variable-speed playback, ... "Scrubbing" is variable-speed playback, ...
"Seeking" is normal speed playback but with skips "Seeking" is normal speed playback but with skips
@@ -180,14 +191,20 @@ void ScrubbingToolBar::RegenerateTooltips()
: _("Start Seeking") : _("Start Seeking")
); );
fn(*seekButton, label, wxT("Seek")); fn(*seekButton, label, wxT("Seek"));
}
mLastSeek = seeks;
bool showingRuler = AdornedRulerPanel::Get( *project ).ShowingScrubRuler();
if (force || mLastRuler != showingRuler) {
label = ( label = (
AdornedRulerPanel::Get( *project ).ShowingScrubRuler() showingRuler
? _("Hide Scrub Ruler") ? _("Hide Scrub Ruler")
: _("Show Scrub Ruler") : _("Show Scrub Ruler")
); );
fn(*mButtons[STBRulerID], label, wxT("ToggleScrubRuler")); 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