mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 15:20:15 +02:00
Vary status string (leftmost in the status bar) for the four kinds of scrub.
This commit is contained in:
commit
c7feb793c5
@ -107,7 +107,6 @@ ControlToolBar::ControlToolBar()
|
|||||||
/* i18n-hint: These are strings for the status bar, and indicate whether Audacity
|
/* i18n-hint: These are strings for the status bar, and indicate whether Audacity
|
||||||
is playing or recording or stopped, and whether it is paused. */
|
is playing or recording or stopped, and whether it is paused. */
|
||||||
mStatePlay = XO("Playing");
|
mStatePlay = XO("Playing");
|
||||||
mStateScrub = XO("Scrubbing");
|
|
||||||
mStateStop = XO("Stopped");
|
mStateStop = XO("Stopped");
|
||||||
mStateRecord = XO("Recording");
|
mStateRecord = XO("Recording");
|
||||||
mStatePause = XO("Paused");
|
mStatePause = XO("Paused");
|
||||||
@ -1175,28 +1174,24 @@ void ControlToolBar::ClearCutPreviewTracks()
|
|||||||
int ControlToolBar::WidthForStatusBar(wxStatusBar* const sb)
|
int ControlToolBar::WidthForStatusBar(wxStatusBar* const sb)
|
||||||
{
|
{
|
||||||
int xMax = 0;
|
int xMax = 0;
|
||||||
int x, y;
|
const auto pauseString = wxT(" ") + wxGetTranslation(mStatePause);
|
||||||
|
|
||||||
sb->GetTextExtent(wxString(wxGetTranslation(mStatePlay)) + wxT(" ") +
|
auto update = [&] (const wxString &state, bool pauseToo) {
|
||||||
wxString(wxGetTranslation(mStatePause)) + wxT("."), &x, &y);
|
int x, y;
|
||||||
if (x > xMax)
|
sb->GetTextExtent(
|
||||||
xMax = x;
|
wxGetTranslation(state) + ( pauseToo ? pauseString : wxString{} ) + wxT("."),
|
||||||
|
&x, &y
|
||||||
|
);
|
||||||
|
xMax = std::max(x, xMax);
|
||||||
|
};
|
||||||
|
|
||||||
sb->GetTextExtent(wxString(wxGetTranslation(mStateStop)) + wxT(" ") +
|
update(mStatePlay, true);
|
||||||
wxString(wxGetTranslation(mStatePause)) + wxT("."), &x, &y);
|
update(mStateStop, true);
|
||||||
if (x > xMax)
|
update(mStateRecord, true);
|
||||||
xMax = x;
|
|
||||||
|
|
||||||
sb->GetTextExtent(wxString(wxGetTranslation(mStateRecord)) + wxT(" ") +
|
|
||||||
wxString(wxGetTranslation(mStatePause)) + wxT("."), &x, &y);
|
|
||||||
if (x > xMax)
|
|
||||||
xMax = x;
|
|
||||||
|
|
||||||
// Note that Scrubbing + Paused is not allowed.
|
// Note that Scrubbing + Paused is not allowed.
|
||||||
sb->GetTextExtent(wxString(wxGetTranslation(mStateScrub)) +
|
for(const auto &state : Scrubber::GetAllUntranslatedStatusStrings())
|
||||||
wxT("."), &x, &y);
|
update(state, false);
|
||||||
if (x > xMax)
|
|
||||||
xMax = x;
|
|
||||||
|
|
||||||
return xMax + 30; // added constant needed because xMax isn't large enough for some reason, plus some space.
|
return xMax + 30; // added constant needed because xMax isn't large enough for some reason, plus some space.
|
||||||
}
|
}
|
||||||
@ -1206,8 +1201,10 @@ wxString ControlToolBar::StateForStatusBar()
|
|||||||
wxString state;
|
wxString state;
|
||||||
|
|
||||||
auto pProject = GetActiveProject();
|
auto pProject = GetActiveProject();
|
||||||
if (pProject && pProject->GetScrubber().HasStartedScrubbing())
|
auto scrubState =
|
||||||
state = wxGetTranslation(mStateScrub);
|
pProject ? pProject->GetScrubber().GetUntranslatedStateString() : wxString();
|
||||||
|
if (!scrubState.IsEmpty())
|
||||||
|
state = wxGetTranslation(scrubState);
|
||||||
else if (mPlay->IsDown())
|
else if (mPlay->IsDown())
|
||||||
state = wxGetTranslation(mStatePlay);
|
state = wxGetTranslation(mStatePlay);
|
||||||
else if (mRecord->IsDown())
|
else if (mRecord->IsDown())
|
||||||
|
@ -158,7 +158,6 @@ class ControlToolBar final : public ToolBar {
|
|||||||
|
|
||||||
// strings for status bar
|
// strings for status bar
|
||||||
wxString mStatePlay;
|
wxString mStatePlay;
|
||||||
wxString mStateScrub;
|
|
||||||
wxString mStateStop;
|
wxString mStateStop;
|
||||||
wxString mStateRecord;
|
wxString mStateRecord;
|
||||||
wxString mStatePause;
|
wxString mStatePause;
|
||||||
|
@ -139,22 +139,43 @@ namespace {
|
|||||||
const struct MenuItem {
|
const struct MenuItem {
|
||||||
wxString name;
|
wxString name;
|
||||||
wxString label;
|
wxString label;
|
||||||
|
wxString status;
|
||||||
void (Scrubber::*memFn)();
|
void (Scrubber::*memFn)();
|
||||||
bool scroll;
|
bool scroll;
|
||||||
bool seek;
|
bool seek;
|
||||||
|
|
||||||
|
const wxString &GetStatus() const { return status; }
|
||||||
} menuItems[] = {
|
} menuItems[] = {
|
||||||
/* 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, ...
|
||||||
"Scrolling" keeps the playback position at a fixed place on screen while the waveform moves
|
"Scrolling" keeps the playback position at a fixed place on screen while the waveform moves
|
||||||
*/
|
*/
|
||||||
{ wxT("Scrub"), XO("&Scrub"), &Scrubber::OnScrub, false, false },
|
{ wxT("Scrub"), XO("&Scrub"), XO("Scrubbing"),
|
||||||
{ wxT("ScrollScrub"), XO("Sc&rolling Scrub"), &Scrubber::OnScrollScrub, true, false },
|
&Scrubber::OnScrub, false, false },
|
||||||
{ wxT("Seek"), XO("See&k"), &Scrubber::OnSeek, false, true },
|
|
||||||
{ wxT("ScrollSeek"), XO("Scrollin&g Seek"), &Scrubber::OnScrollSeek, true, true },
|
{ wxT("ScrollScrub"), XO("Sc&rolling Scrub"), XO("Scrolling Scrub"),
|
||||||
|
&Scrubber::OnScrollScrub, true, false },
|
||||||
|
|
||||||
|
{ wxT("Seek"), XO("See&k"), XO("Seeking"),
|
||||||
|
&Scrubber::OnSeek, false, true },
|
||||||
|
|
||||||
|
{ wxT("ScrollSeek"), XO("Scrollin&g Seek"), XO("Scrolling Seek"),
|
||||||
|
&Scrubber::OnScrollSeek, true, true }
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { nMenuItems = sizeof(menuItems) / sizeof(*menuItems) };
|
enum { nMenuItems = sizeof(menuItems) / sizeof(*menuItems) };
|
||||||
|
|
||||||
|
inline const MenuItem &FindMenuItem(bool scroll, bool seek)
|
||||||
|
{
|
||||||
|
return *std::find_if(menuItems, menuItems + nMenuItems,
|
||||||
|
[=](const MenuItem &item) {
|
||||||
|
return scroll == item.scroll &&
|
||||||
|
seek == item.seek;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrubber::MarkScrubStart(
|
void Scrubber::MarkScrubStart(
|
||||||
@ -619,6 +640,24 @@ void Scrubber::OnScrollSeek()
|
|||||||
DoScrub(true, true);
|
DoScrub(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wxString &Scrubber::GetUntranslatedStateString() const
|
||||||
|
{
|
||||||
|
if (HasStartedScrubbing()) {
|
||||||
|
auto item = FindMenuItem(mSmoothScrollingScrub, mAlwaysSeeking);
|
||||||
|
return item.status;
|
||||||
|
}
|
||||||
|
else return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<wxString> Scrubber::GetAllUntranslatedStatusStrings()
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
vector<wxString> results;
|
||||||
|
transform(menuItems, menuItems + nMenuItems, back_inserter(results),
|
||||||
|
mem_fun_ref(&MenuItem::GetStatus));
|
||||||
|
return move(results);
|
||||||
|
}
|
||||||
|
|
||||||
void Scrubber::AddMenuItems()
|
void Scrubber::AddMenuItems()
|
||||||
{
|
{
|
||||||
auto cm = mProject->GetCommandManager();
|
auto cm = mProject->GetCommandManager();
|
||||||
@ -644,13 +683,8 @@ void Scrubber::UncheckAllMenuItems()
|
|||||||
void Scrubber::CheckMenuItem()
|
void Scrubber::CheckMenuItem()
|
||||||
{
|
{
|
||||||
if(HasStartedScrubbing()) {
|
if(HasStartedScrubbing()) {
|
||||||
auto &item = *std::find_if(menuItems, menuItems + nMenuItems,
|
|
||||||
[=](const MenuItem &item) {
|
|
||||||
return mSmoothScrollingScrub == item.scroll &&
|
|
||||||
mAlwaysSeeking == item.seek;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
auto cm = mProject->GetCommandManager();
|
auto cm = mProject->GetCommandManager();
|
||||||
|
auto item = FindMenuItem(mSmoothScrollingScrub, mAlwaysSeeking);
|
||||||
cm->Check(item.name, true);
|
cm->Check(item.name, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#ifndef __AUDACITY_SCRUBBING__
|
#ifndef __AUDACITY_SCRUBBING__
|
||||||
#define __AUDACITY_SCRUBBING__
|
#define __AUDACITY_SCRUBBING__
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include <wx/event.h>
|
#include <wx/event.h>
|
||||||
#include <wx/longlong.h>
|
#include <wx/longlong.h>
|
||||||
|
|
||||||
@ -68,6 +69,12 @@ public:
|
|||||||
void OnSeek();
|
void OnSeek();
|
||||||
void OnScrollSeek();
|
void OnScrollSeek();
|
||||||
|
|
||||||
|
// A string to put in the leftmost part of the status bar.
|
||||||
|
const wxString &GetUntranslatedStateString() const;
|
||||||
|
|
||||||
|
// All possible status strings.
|
||||||
|
static std::vector<wxString> GetAllUntranslatedStatusStrings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DoScrub(bool scroll, bool seek);
|
void DoScrub(bool scroll, bool seek);
|
||||||
void OnActivateOrDeactivateApp(wxActivateEvent & event);
|
void OnActivateOrDeactivateApp(wxActivateEvent & event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user