1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 00:59:43 +02:00

Scrub play button becomes a stop button when pressed...

... also the corresponding menu command can stop as well as start the scrub
or seek
This commit is contained in:
Paul Licameli 2016-06-06 02:11:12 -04:00
parent fd9d6a8fcf
commit d1fe0a89b5
4 changed files with 31 additions and 13 deletions

View File

@ -427,8 +427,8 @@ void ScrubbingToolBar::Populate()
MakeButtonBackgroundsSmall();
/* Buttons */
AddButton(bmpPlay, bmpPlay, bmpPlayDisabled, STBStartID,
_("Start scrubbing"), false);
AddButton(bmpPlay, bmpStop, bmpPlayDisabled, STBStartID,
_("Start scrubbing"), true);
AddButton(bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
_("Scrub"), true);
AddButton(bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
@ -456,7 +456,23 @@ void ScrubbingToolBar::RegenerateTooltips()
"Scrubbing" is variable-speed playback, ...
"Seeking" is normal speed playback but with skips
*/
mButtons[STBStartID]->SetToolTip(_("Start scrubbing or seeking"));
auto project = GetActiveProject();
if (project) {
auto startStop = mButtons[STBStartID];
auto &scrubber = project->GetScrubber();
if(scrubber.HasStartedScrubbing() || scrubber.IsScrubbing()) {
if (scrubber.Seeks())
startStop->SetToolTip(_("Stop seeking"));
else
startStop->SetToolTip(_("Stop scrubbing"));
}
else {
if (scrubber.Seeks())
startStop->SetToolTip(_("Start seeking"));
else
startStop->SetToolTip(_("Start scrubbing"));
}
}
mButtons[STBScrubID]->SetToolTip(_("Scrub"));
mButtons[STBSeekID]->SetToolTip(_("Seek"));
#endif
@ -472,8 +488,7 @@ void ScrubbingToolBar::OnButton(wxCommandEvent &event)
switch (id) {
case STBStartID:
mButtons[STBStartID]->PopUp();
scrubber.OnStart(event);
scrubber.OnStartStop(event);
break;
case STBScrubID:
scrubber.OnScrub(event);

View File

@ -136,6 +136,8 @@ public:
void EnableDisableButtons();
void UpdatePrefs();
void RegenerateTooltips();
private:
AButton *AddButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
@ -143,8 +145,6 @@ private:
void MakeButtons();
void RegenerateTooltips();
AButton *mButtons[STBNumButtons];
wxImage *upImage;

View File

@ -232,8 +232,8 @@ namespace {
{ wxT("Seek"), XO("See&k"), XO("Seeking"),
&Scrubber::OnSeek, true, &Scrubber::Seeks },
{ wxT("StartScrubSeek"), XO("Star&t"), XO(""),
&Scrubber::OnStart, true, nullptr },
{ wxT("StartStopScrubSeek"), XO("Star&t/Stop"), XO(""),
&Scrubber::OnStartStop, true, nullptr },
};
enum { nMenuItems = sizeof(menuItems) / sizeof(*menuItems), StartMenuItem = 2 };
@ -765,7 +765,7 @@ Scrubber &ScrubbingOverlay::GetScrubber()
void Scrubber::DoScrub()
{
const bool wasScrubbing = IsScrubbing();
const bool wasScrubbing = HasStartedScrubbing() || IsScrubbing();
const bool scroll = PlaybackPrefs::GetPinnedHeadPreference();
if (!wasScrubbing) {
auto tp = mProject->GetTrackPanel();
@ -779,6 +779,8 @@ void Scrubber::DoScrub()
MarkScrubStart(xx, scroll);
}
else
mProject->GetControlToolBar()->StopPlaying();
}
void Scrubber::OnScrubOrSeek(bool &toToggle, bool &other)
@ -800,6 +802,7 @@ void Scrubber::OnScrubOrSeek(bool &toToggle, bool &other)
auto scrubbingToolBar = mProject->GetScrubbingToolBar();
scrubbingToolBar->EnableDisableButtons();
scrubbingToolBar->RegenerateTooltips();
CheckMenuItem();
}
@ -814,7 +817,7 @@ void Scrubber::OnSeek(wxCommandEvent&)
OnScrubOrSeek(mSeeking, mScrubbing);
}
void Scrubber::OnStart(wxCommandEvent&)
void Scrubber::OnStartStop(wxCommandEvent&)
{
DoScrub();
}
@ -824,7 +827,7 @@ enum { CMD_ID = 8000 };
BEGIN_EVENT_TABLE(Scrubber, wxEvtHandler)
EVT_MENU(CMD_ID, Scrubber::OnScrub)
EVT_MENU(CMD_ID + 1, Scrubber::OnSeek)
EVT_MENU(CMD_ID + 2, Scrubber::OnStart)
EVT_MENU(CMD_ID + 2, Scrubber::OnStartStop)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(Scrubber::Forwarder, wxEvtHandler)

View File

@ -123,7 +123,7 @@ public:
void OnScrubOrSeek(bool &toToggle, bool &other);
void OnScrub(wxCommandEvent&);
void OnSeek(wxCommandEvent&);
void OnStart(wxCommandEvent&);
void OnStartStop(wxCommandEvent&);
// A string to put in the leftmost part of the status bar
// when scrub or seek is in progress, or else empty.