1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 08:38:39 +02:00

Scrub bar no longer has separate start/stop; tooltips mention keys

This commit is contained in:
Paul Licameli 2016-06-15 23:40:37 -04:00
commit 801724a852
5 changed files with 103 additions and 78 deletions

View File

@ -69,6 +69,7 @@
#include "../tracks/ui/Scrubbing.h"
#include "../prefs/PlaybackPrefs.h"
#include "../toolbars/ToolManager.h"
IMPLEMENT_CLASS(ControlToolBar, ToolBar);
@ -831,6 +832,9 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
meter->Clear();
}
}
const auto toolbar = project->GetToolManager()->GetToolBar(ScrubbingBarID);
toolbar->EnableDisableButtons();
}
void ControlToolBar::Pause()

View File

@ -1,4 +1,4 @@
/**********************************************************************
/**********************************************************************
Audacity: A Digital Audio Editor
@ -389,8 +389,8 @@ IMPLEMENT_CLASS(ScrubbingToolBar, ToolBar);
////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( ScrubbingToolBar, ToolBar )
EVT_COMMAND_RANGE( STBStartID,
STBStartID + STBNumButtons - 1,
EVT_COMMAND_RANGE( STBFirstButton,
STBFirstButton + STBNumButtons - 1,
wxEVT_COMMAND_BUTTON_CLICKED,
ScrubbingToolBar::OnButton )
END_EVENT_TABLE()
@ -444,8 +444,6 @@ void ScrubbingToolBar::Populate()
MakeButtonBackgroundsSmall();
/* Buttons */
AddButton(bmpPlay, bmpStop, bmpPlayDisabled, STBStartID,
_("Start scrubbing"), true);
AddButton(bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
_("Scrub"), true);
AddButton(bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
@ -472,30 +470,53 @@ void ScrubbingToolBar::UpdatePrefs()
void ScrubbingToolBar::RegenerateTooltips()
{
#if wxUSE_TOOLTIPS
/* i18n-hint: These commands assist the user in finding a sound by ear. ...
"Scrubbing" is variable-speed playback, ...
"Seeking" is normal speed playback but with skips
*/
std::vector<wxString> commands;
auto fn = [&]
(AButton &button, const wxString &label, const wxString &command)
{
commands.clear();
commands.push_back(label);
commands.push_back(command);
ToolBar::SetButtonToolTip(button, commands);
};
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"));
}
const auto scrubButton = mButtons[STBScrubID];
const auto seekButton = mButtons[STBSeekID];
wxString label;
label = (
scrubber.Scrubs()
/* i18n-hint: These commands assist the user in finding a sound by ear. ...
"Scrubbing" is variable-speed playback, ...
"Seeking" is normal speed playback but with skips
*/
? _("Stop Scrubbing")
: _("Start Scrubbing")
);
fn(*scrubButton, label, wxT("Scrub"));
label = (
scrubber.Seeks()
/* i18n-hint: These commands assist the user in finding a sound by ear. ...
"Scrubbing" is variable-speed playback, ...
"Seeking" is normal speed playback but with skips
*/
? _("Stop Seeking")
: _("Start Seeking")
);
fn(*seekButton, label, wxT("Seek"));
label = (
project->GetRulerPanel()->ShowingScrubBar()
? _("Hide Scrub Bar")
: _("Show Scrub Bar")
);
fn(*mButtons[STBBarID], label, wxT("ToggleScrubBar"));
}
mButtons[STBScrubID]->SetToolTip(_("Scrub"));
mButtons[STBSeekID]->SetToolTip(_("Seek"));
mButtons[STBBarID]->SetToolTip(_("Scrub bar"));
#endif
}
@ -508,9 +529,6 @@ void ScrubbingToolBar::OnButton(wxCommandEvent &event)
int id = event.GetId();
switch (id) {
case STBStartID:
scrubber.OnStartStop(event);
break;
case STBScrubID:
scrubber.OnScrub(event);
break;
@ -538,25 +556,36 @@ void ScrubbingToolBar::EnableDisableButtons()
if (!p) return;
auto &scrubber = p->GetScrubber();
if (scrubber.Scrubs())
const auto canScrub = scrubber.CanScrub();
if (scrubber.Scrubs()) {
scrubButton->PushDown();
else
scrubButton->Enable();
}
else {
scrubButton->PopUp();
if (canScrub)
scrubButton->Enable();
else
scrubButton->Disable();
}
if (scrubber.Seeks())
if (scrubber.Seeks()) {
seekButton->PushDown();
else
seekButton->Enable();
}
else {
seekButton->PopUp();
if (canScrub)
seekButton->Enable();
else
seekButton->Disable();
}
const auto startButton = mButtons[STBStartID];
if (scrubber.CanScrub())
startButton->Enable();
else
startButton->Disable();
mButtons[STBBarID]->Enable();
const auto barButton = mButtons[STBBarID];
barButton->Enable();
if (p->GetRulerPanel()->ShowingScrubBar())
mButtons[STBBarID]->PushDown();
barButton->PushDown();
else
mButtons[STBBarID]->PopUp();
barButton->PopUp();
}

View File

@ -113,12 +113,12 @@ class wxWindow;
class AButton;
enum {
STBStartID,
STBScrubID,
STBSeekID,
STBBarID,
STBNumButtons
STBNumButtons,
STBFirstButton = STBScrubID
};
class ScrubbingToolBar final : public ToolBar {

View File

@ -229,18 +229,13 @@ namespace {
"Seeking" is normal speed playback but with skips, ...
*/
{ wxT("Scrub"), XO("&Scrub"), XO("Scrubbing"),
AlwaysEnabledFlag,
CanStopAudioStreamFlag,
&Scrubber::OnScrub, false, &Scrubber::Scrubs,
},
{ wxT("Seek"), XO("See&k"), XO("Seeking"),
AlwaysEnabledFlag,
&Scrubber::OnSeek, true, &Scrubber::Seeks,
},
{ wxT("StartStopScrubSeek"), XO("Star&t/Stop"), XO(""),
CanStopAudioStreamFlag,
&Scrubber::OnStartStop, true, nullptr
&Scrubber::OnSeek, true, &Scrubber::Seeks,
},
{ wxT("ToggleScrubBar"), XO("Scrub Bar"), XO(""),
@ -249,7 +244,7 @@ namespace {
},
};
enum { nMenuItems = sizeof(menuItems) / sizeof(*menuItems), StartMenuItem = 2 };
enum { nMenuItems = sizeof(menuItems) / sizeof(*menuItems) };
inline const MenuItem &FindMenuItem(bool seek)
{
@ -535,7 +530,8 @@ bool Scrubber::IsScrubbing() const
{
if (mScrubToken <= 0)
return false;
else if (mScrubToken == mProject->GetAudioIOToken())
else if (mScrubToken == mProject->GetAudioIOToken() &&
mProject->IsAudioActive())
return true;
else {
const_cast<Scrubber&>(*this).mScrubToken = -1;
@ -545,6 +541,16 @@ bool Scrubber::IsScrubbing() const
}
}
bool Scrubber::Seeks() const
{
return (HasStartedScrubbing() || IsScrubbing()) && mSeeking;
}
bool Scrubber::Scrubs() const
{
return (HasStartedScrubbing() || IsScrubbing()) && !mSeeking;
}
bool Scrubber::ShouldDrawScrubSpeed()
{
if (mDragging)
@ -800,11 +806,9 @@ void Scrubber::DoScrub()
mProject->GetControlToolBar()->StopPlaying();
}
void Scrubber::OnScrubOrSeek(bool &toToggle, bool &other)
void Scrubber::OnScrubOrSeek(bool seek)
{
toToggle = !toToggle;
if (toToggle)
other = false;
mSeeking = seek;
if (HasStartedScrubbing()) {
// Show the correct status.
@ -821,22 +825,19 @@ void Scrubber::OnScrubOrSeek(bool &toToggle, bool &other)
scrubbingToolBar->EnableDisableButtons();
scrubbingToolBar->RegenerateTooltips();
DoScrub();
CheckMenuItems();
}
void Scrubber::OnScrub(wxCommandEvent&)
{
OnScrubOrSeek(mScrubbing, mSeeking);
OnScrubOrSeek(false);
}
void Scrubber::OnSeek(wxCommandEvent&)
{
OnScrubOrSeek(mSeeking, mScrubbing);
}
void Scrubber::OnStartStop(wxCommandEvent&)
{
DoScrub();
OnScrubOrSeek(true);
}
void Scrubber::OnToggleScrubBar(wxCommandEvent&)
@ -852,15 +853,14 @@ 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::OnStartStop)
EVT_MENU(CMD_ID + 3, Scrubber::OnToggleScrubBar)
EVT_MENU(CMD_ID + 2, Scrubber::OnToggleScrubBar)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(Scrubber::Forwarder, wxEvtHandler)
EVT_MOUSE_EVENTS(Scrubber::Forwarder::OnMouse)
END_EVENT_TABLE()
static_assert(nMenuItems == 4, "wrong number of items");
static_assert(nMenuItems == 3, "wrong number of items");
const wxString &Scrubber::GetUntranslatedStateString() const
{
@ -890,7 +890,7 @@ bool Scrubber::CanScrub() const
{
// Return the enabled state for the menu item that really launches the scrub or seek.
auto cm = mProject->GetCommandManager();
return cm->GetEnabled(menuItems[StartMenuItem].name);
return cm->GetEnabled(menuItems[ 0 ].name);
}
void Scrubber::AddMenuItems()

View File

@ -97,12 +97,8 @@ public:
void SetScrollScrubbing(bool value)
{ mSmoothScrollingScrub = value; }
bool Seeks() const
{ return mSeeking; }
bool Scrubs() const
{ return mScrubbing; }
bool Seeks() const;
bool Scrubs() const;
bool ShowsBar() const;
void Cancel()
@ -122,10 +118,9 @@ public:
// For popup
void PopulatePopupMenu(wxMenu &menu);
void OnScrubOrSeek(bool &toToggle, bool &other);
void OnScrubOrSeek(bool seek);
void OnScrub(wxCommandEvent&);
void OnSeek(wxCommandEvent&);
void OnStartStop(wxCommandEvent&);
void OnToggleScrubBar(wxCommandEvent&);
// A string to put in the leftmost part of the status bar
@ -163,9 +158,6 @@ private:
wxCoord mLastScrubPosition {};
bool mSmoothScrollingScrub;
// These hold the three-way choice among click-to-scrub, click-to-seek, or disabled.
// Not both true.
bool mScrubbing {};
bool mSeeking {};
bool mDragging {};