mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-14 17:14:07 +01:00
No more separate start/stop button on Scrubbing toolbar...
... This finalizes (I hope) the set of buttons, but maybe not their left to right order. Behavior of the scrub bar is still not settled.
This commit is contained in:
@@ -69,6 +69,7 @@
|
|||||||
|
|
||||||
#include "../tracks/ui/Scrubbing.h"
|
#include "../tracks/ui/Scrubbing.h"
|
||||||
#include "../prefs/PlaybackPrefs.h"
|
#include "../prefs/PlaybackPrefs.h"
|
||||||
|
#include "../toolbars/ToolManager.h"
|
||||||
|
|
||||||
IMPLEMENT_CLASS(ControlToolBar, ToolBar);
|
IMPLEMENT_CLASS(ControlToolBar, ToolBar);
|
||||||
|
|
||||||
@@ -831,6 +832,9 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
|
|||||||
meter->Clear();
|
meter->Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto toolbar = project->GetToolManager()->GetToolBar(ScrubbingBarID);
|
||||||
|
toolbar->EnableDisableButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::Pause()
|
void ControlToolBar::Pause()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|
||||||
Audacity: A Digital Audio Editor
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
@@ -389,8 +389,8 @@ IMPLEMENT_CLASS(ScrubbingToolBar, ToolBar);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE( ScrubbingToolBar, ToolBar )
|
BEGIN_EVENT_TABLE( ScrubbingToolBar, ToolBar )
|
||||||
EVT_COMMAND_RANGE( STBStartID,
|
EVT_COMMAND_RANGE( STBFirstButton,
|
||||||
STBStartID + STBNumButtons - 1,
|
STBFirstButton + STBNumButtons - 1,
|
||||||
wxEVT_COMMAND_BUTTON_CLICKED,
|
wxEVT_COMMAND_BUTTON_CLICKED,
|
||||||
ScrubbingToolBar::OnButton )
|
ScrubbingToolBar::OnButton )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
@@ -444,8 +444,6 @@ void ScrubbingToolBar::Populate()
|
|||||||
MakeButtonBackgroundsSmall();
|
MakeButtonBackgroundsSmall();
|
||||||
|
|
||||||
/* Buttons */
|
/* Buttons */
|
||||||
AddButton(bmpPlay, bmpStop, bmpPlayDisabled, STBStartID,
|
|
||||||
_("Start scrubbing"), true);
|
|
||||||
AddButton(bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
|
AddButton(bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
|
||||||
_("Scrub"), true);
|
_("Scrub"), true);
|
||||||
AddButton(bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
|
AddButton(bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
|
||||||
@@ -472,29 +470,34 @@ void ScrubbingToolBar::UpdatePrefs()
|
|||||||
void ScrubbingToolBar::RegenerateTooltips()
|
void ScrubbingToolBar::RegenerateTooltips()
|
||||||
{
|
{
|
||||||
#if wxUSE_TOOLTIPS
|
#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
|
|
||||||
*/
|
|
||||||
auto project = GetActiveProject();
|
auto project = GetActiveProject();
|
||||||
if (project) {
|
if (project) {
|
||||||
auto startStop = mButtons[STBStartID];
|
|
||||||
auto &scrubber = project->GetScrubber();
|
auto &scrubber = project->GetScrubber();
|
||||||
if(scrubber.HasStartedScrubbing() || scrubber.IsScrubbing()) {
|
|
||||||
if (scrubber.Seeks())
|
const auto scrubButton = mButtons[STBScrubID];
|
||||||
startStop->SetToolTip(_("Stop seeking"));
|
const auto seekButton = mButtons[STBSeekID];
|
||||||
else
|
|
||||||
startStop->SetToolTip(_("Stop scrubbing"));
|
scrubButton->SetToolTip(
|
||||||
}
|
scrubber.Scrubs()
|
||||||
else {
|
/* i18n-hint: These commands assist the user in finding a sound by ear. ...
|
||||||
if (scrubber.Seeks())
|
"Scrubbing" is variable-speed playback, ...
|
||||||
startStop->SetToolTip(_("Start seeking"));
|
"Seeking" is normal speed playback but with skips
|
||||||
else
|
*/
|
||||||
startStop->SetToolTip(_("Start scrubbing"));
|
? _("Stop Scrubbing")
|
||||||
}
|
: _("Start Scrubbing")
|
||||||
|
);
|
||||||
|
|
||||||
|
seekButton->SetToolTip(
|
||||||
|
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")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
mButtons[STBScrubID]->SetToolTip(_("Scrub"));
|
|
||||||
mButtons[STBSeekID]->SetToolTip(_("Seek"));
|
|
||||||
mButtons[STBBarID]->SetToolTip(_("Scrub bar"));
|
mButtons[STBBarID]->SetToolTip(_("Scrub bar"));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -508,9 +511,6 @@ void ScrubbingToolBar::OnButton(wxCommandEvent &event)
|
|||||||
int id = event.GetId();
|
int id = event.GetId();
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case STBStartID:
|
|
||||||
scrubber.OnStartStop(event);
|
|
||||||
break;
|
|
||||||
case STBScrubID:
|
case STBScrubID:
|
||||||
scrubber.OnScrub(event);
|
scrubber.OnScrub(event);
|
||||||
break;
|
break;
|
||||||
@@ -538,25 +538,36 @@ void ScrubbingToolBar::EnableDisableButtons()
|
|||||||
if (!p) return;
|
if (!p) return;
|
||||||
|
|
||||||
auto &scrubber = p->GetScrubber();
|
auto &scrubber = p->GetScrubber();
|
||||||
if (scrubber.Scrubs())
|
const auto canScrub = scrubber.CanScrub();
|
||||||
|
|
||||||
|
if (scrubber.Scrubs()) {
|
||||||
scrubButton->PushDown();
|
scrubButton->PushDown();
|
||||||
else
|
scrubButton->Enable();
|
||||||
|
}
|
||||||
|
else {
|
||||||
scrubButton->PopUp();
|
scrubButton->PopUp();
|
||||||
|
if (canScrub)
|
||||||
|
scrubButton->Enable();
|
||||||
|
else
|
||||||
|
scrubButton->Disable();
|
||||||
|
}
|
||||||
|
|
||||||
if (scrubber.Seeks())
|
if (scrubber.Seeks()) {
|
||||||
seekButton->PushDown();
|
seekButton->PushDown();
|
||||||
else
|
seekButton->Enable();
|
||||||
|
}
|
||||||
|
else {
|
||||||
seekButton->PopUp();
|
seekButton->PopUp();
|
||||||
|
if (canScrub)
|
||||||
|
seekButton->Enable();
|
||||||
|
else
|
||||||
|
seekButton->Disable();
|
||||||
|
}
|
||||||
|
|
||||||
const auto startButton = mButtons[STBStartID];
|
const auto barButton = mButtons[STBBarID];
|
||||||
if (scrubber.CanScrub())
|
barButton->Enable();
|
||||||
startButton->Enable();
|
|
||||||
else
|
|
||||||
startButton->Disable();
|
|
||||||
|
|
||||||
mButtons[STBBarID]->Enable();
|
|
||||||
if (p->GetRulerPanel()->ShowingScrubBar())
|
if (p->GetRulerPanel()->ShowingScrubBar())
|
||||||
mButtons[STBBarID]->PushDown();
|
barButton->PushDown();
|
||||||
else
|
else
|
||||||
mButtons[STBBarID]->PopUp();
|
barButton->PopUp();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,12 +113,12 @@ class wxWindow;
|
|||||||
class AButton;
|
class AButton;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
STBStartID,
|
|
||||||
STBScrubID,
|
STBScrubID,
|
||||||
STBSeekID,
|
STBSeekID,
|
||||||
STBBarID,
|
STBBarID,
|
||||||
|
|
||||||
STBNumButtons
|
STBNumButtons,
|
||||||
|
STBFirstButton = STBScrubID
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScrubbingToolBar final : public ToolBar {
|
class ScrubbingToolBar final : public ToolBar {
|
||||||
|
|||||||
@@ -229,18 +229,13 @@ namespace {
|
|||||||
"Seeking" is normal speed playback but with skips, ...
|
"Seeking" is normal speed playback but with skips, ...
|
||||||
*/
|
*/
|
||||||
{ wxT("Scrub"), XO("&Scrub"), XO("Scrubbing"),
|
{ wxT("Scrub"), XO("&Scrub"), XO("Scrubbing"),
|
||||||
AlwaysEnabledFlag,
|
CanStopAudioStreamFlag,
|
||||||
&Scrubber::OnScrub, false, &Scrubber::Scrubs,
|
&Scrubber::OnScrub, false, &Scrubber::Scrubs,
|
||||||
},
|
},
|
||||||
|
|
||||||
{ wxT("Seek"), XO("See&k"), XO("Seeking"),
|
{ wxT("Seek"), XO("See&k"), XO("Seeking"),
|
||||||
AlwaysEnabledFlag,
|
|
||||||
&Scrubber::OnSeek, true, &Scrubber::Seeks,
|
|
||||||
},
|
|
||||||
|
|
||||||
{ wxT("StartStopScrubSeek"), XO("Star&t/Stop"), XO(""),
|
|
||||||
CanStopAudioStreamFlag,
|
CanStopAudioStreamFlag,
|
||||||
&Scrubber::OnStartStop, true, nullptr
|
&Scrubber::OnSeek, true, &Scrubber::Seeks,
|
||||||
},
|
},
|
||||||
|
|
||||||
{ wxT("ToggleScrubBar"), XO("Scrub Bar"), XO(""),
|
{ 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)
|
inline const MenuItem &FindMenuItem(bool seek)
|
||||||
{
|
{
|
||||||
@@ -535,7 +530,8 @@ bool Scrubber::IsScrubbing() const
|
|||||||
{
|
{
|
||||||
if (mScrubToken <= 0)
|
if (mScrubToken <= 0)
|
||||||
return false;
|
return false;
|
||||||
else if (mScrubToken == mProject->GetAudioIOToken())
|
else if (mScrubToken == mProject->GetAudioIOToken() &&
|
||||||
|
mProject->IsAudioActive())
|
||||||
return true;
|
return true;
|
||||||
else {
|
else {
|
||||||
const_cast<Scrubber&>(*this).mScrubToken = -1;
|
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()
|
bool Scrubber::ShouldDrawScrubSpeed()
|
||||||
{
|
{
|
||||||
if (mDragging)
|
if (mDragging)
|
||||||
@@ -800,11 +806,9 @@ void Scrubber::DoScrub()
|
|||||||
mProject->GetControlToolBar()->StopPlaying();
|
mProject->GetControlToolBar()->StopPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrubber::OnScrubOrSeek(bool &toToggle, bool &other)
|
void Scrubber::OnScrubOrSeek(bool seek)
|
||||||
{
|
{
|
||||||
toToggle = !toToggle;
|
mSeeking = seek;
|
||||||
if (toToggle)
|
|
||||||
other = false;
|
|
||||||
|
|
||||||
if (HasStartedScrubbing()) {
|
if (HasStartedScrubbing()) {
|
||||||
// Show the correct status.
|
// Show the correct status.
|
||||||
@@ -821,22 +825,19 @@ void Scrubber::OnScrubOrSeek(bool &toToggle, bool &other)
|
|||||||
scrubbingToolBar->EnableDisableButtons();
|
scrubbingToolBar->EnableDisableButtons();
|
||||||
scrubbingToolBar->RegenerateTooltips();
|
scrubbingToolBar->RegenerateTooltips();
|
||||||
|
|
||||||
|
DoScrub();
|
||||||
|
|
||||||
CheckMenuItems();
|
CheckMenuItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrubber::OnScrub(wxCommandEvent&)
|
void Scrubber::OnScrub(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
OnScrubOrSeek(mScrubbing, mSeeking);
|
OnScrubOrSeek(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrubber::OnSeek(wxCommandEvent&)
|
void Scrubber::OnSeek(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
OnScrubOrSeek(mSeeking, mScrubbing);
|
OnScrubOrSeek(true);
|
||||||
}
|
|
||||||
|
|
||||||
void Scrubber::OnStartStop(wxCommandEvent&)
|
|
||||||
{
|
|
||||||
DoScrub();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrubber::OnToggleScrubBar(wxCommandEvent&)
|
void Scrubber::OnToggleScrubBar(wxCommandEvent&)
|
||||||
@@ -852,15 +853,14 @@ enum { CMD_ID = 8000 };
|
|||||||
BEGIN_EVENT_TABLE(Scrubber, wxEvtHandler)
|
BEGIN_EVENT_TABLE(Scrubber, wxEvtHandler)
|
||||||
EVT_MENU(CMD_ID, Scrubber::OnScrub)
|
EVT_MENU(CMD_ID, Scrubber::OnScrub)
|
||||||
EVT_MENU(CMD_ID + 1, Scrubber::OnSeek)
|
EVT_MENU(CMD_ID + 1, Scrubber::OnSeek)
|
||||||
EVT_MENU(CMD_ID + 2, Scrubber::OnStartStop)
|
EVT_MENU(CMD_ID + 2, Scrubber::OnToggleScrubBar)
|
||||||
EVT_MENU(CMD_ID + 3, Scrubber::OnToggleScrubBar)
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(Scrubber::Forwarder, wxEvtHandler)
|
BEGIN_EVENT_TABLE(Scrubber::Forwarder, wxEvtHandler)
|
||||||
EVT_MOUSE_EVENTS(Scrubber::Forwarder::OnMouse)
|
EVT_MOUSE_EVENTS(Scrubber::Forwarder::OnMouse)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
static_assert(nMenuItems == 4, "wrong number of items");
|
static_assert(nMenuItems == 3, "wrong number of items");
|
||||||
|
|
||||||
const wxString &Scrubber::GetUntranslatedStateString() const
|
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.
|
// Return the enabled state for the menu item that really launches the scrub or seek.
|
||||||
auto cm = mProject->GetCommandManager();
|
auto cm = mProject->GetCommandManager();
|
||||||
return cm->GetEnabled(menuItems[StartMenuItem].name);
|
return cm->GetEnabled(menuItems[ 0 ].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrubber::AddMenuItems()
|
void Scrubber::AddMenuItems()
|
||||||
|
|||||||
@@ -97,12 +97,8 @@ public:
|
|||||||
void SetScrollScrubbing(bool value)
|
void SetScrollScrubbing(bool value)
|
||||||
{ mSmoothScrollingScrub = value; }
|
{ mSmoothScrollingScrub = value; }
|
||||||
|
|
||||||
bool Seeks() const
|
bool Seeks() const;
|
||||||
{ return mSeeking; }
|
bool Scrubs() const;
|
||||||
|
|
||||||
bool Scrubs() const
|
|
||||||
{ return mScrubbing; }
|
|
||||||
|
|
||||||
bool ShowsBar() const;
|
bool ShowsBar() const;
|
||||||
|
|
||||||
void Cancel()
|
void Cancel()
|
||||||
@@ -122,10 +118,9 @@ public:
|
|||||||
// For popup
|
// For popup
|
||||||
void PopulatePopupMenu(wxMenu &menu);
|
void PopulatePopupMenu(wxMenu &menu);
|
||||||
|
|
||||||
void OnScrubOrSeek(bool &toToggle, bool &other);
|
void OnScrubOrSeek(bool seek);
|
||||||
void OnScrub(wxCommandEvent&);
|
void OnScrub(wxCommandEvent&);
|
||||||
void OnSeek(wxCommandEvent&);
|
void OnSeek(wxCommandEvent&);
|
||||||
void OnStartStop(wxCommandEvent&);
|
|
||||||
void OnToggleScrubBar(wxCommandEvent&);
|
void OnToggleScrubBar(wxCommandEvent&);
|
||||||
|
|
||||||
// A string to put in the leftmost part of the status bar
|
// A string to put in the leftmost part of the status bar
|
||||||
@@ -163,9 +158,6 @@ private:
|
|||||||
wxCoord mLastScrubPosition {};
|
wxCoord mLastScrubPosition {};
|
||||||
bool mSmoothScrollingScrub;
|
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 mSeeking {};
|
||||||
|
|
||||||
bool mDragging {};
|
bool mDragging {};
|
||||||
|
|||||||
Reference in New Issue
Block a user