New alternative appearance for the transport toolbar play button, for scrubbing

This commit is contained in:
Paul Licameli 2016-04-19 17:34:38 -04:00
parent 1ef1c0620d
commit 01001fdea9
8 changed files with 48 additions and 14 deletions

View File

@ -67,6 +67,8 @@ from there. Audacity will look for a file called "Pause.png".
DEFINE_IMAGE( bmpCutPreviewDisabled, wxImage( 16, 16 ), wxT("CutPreviewDisabled"));
DEFINE_IMAGE( bmpAppendRecord, wxImage( 16, 16 ), wxT("AppendRecord"));
DEFINE_IMAGE( bmpAppendRecordDisabled, wxImage( 16, 16 ), wxT("AppendRecordDisabled"));
DEFINE_IMAGE( bmpScrubDisabled, wxImage( 16, 16 ), wxT("ScrubDisabled"));
DEFINE_IMAGE( bmpScrub, wxImage( 16, 16 ), wxT("Scrub"));
SET_THEME_FLAGS( resFlagNewLine );
DEFINE_IMAGE( bmpUpButtonLarge, wxImage( 48, 48 ), wxT("UpButtonLarge"));

View File

@ -2071,7 +2071,11 @@ bool AudacityProject::MakeReadyToPlay(bool loop, bool cutpreview)
if (gAudioIO->IsBusy())
return false;
toolbar->SetPlay(true, loop, cutpreview);
ControlToolBar::PlayAppearance appearance =
cutpreview ? ControlToolBar::PlayAppearance::CutPreview
: loop ? ControlToolBar::PlayAppearance::Looped
: ControlToolBar::PlayAppearance::Straight;
toolbar->SetPlay(true, appearance);
toolbar->SetStop(false);
return true;

View File

@ -166,6 +166,8 @@ void ControlToolBar::Populate()
MakeAlternateImages(*mPlay, 1, bmpLoop, bmpLoop, bmpLoopDisabled);
MakeAlternateImages(*mPlay, 2,
bmpCutPreview, bmpCutPreview, bmpCutPreviewDisabled);
MakeAlternateImages(*mPlay, 3,
bmpScrub, bmpScrub, bmpScrubDisabled);
mPlay->FollowModifierKeys();
mStop = MakeButton( bmpStop, bmpStop, bmpStopDisabled ,
@ -361,7 +363,10 @@ void ControlToolBar::ReCreateButtons()
if (playDown)
{
SetPlay(playDown, playShift, false);
ControlToolBar::PlayAppearance appearance =
playShift ? ControlToolBar::PlayAppearance::Looped
: ControlToolBar::PlayAppearance::Straight;
SetPlay(playDown, appearance);
}
if (pauseDown)
@ -432,12 +437,12 @@ void ControlToolBar::EnableDisableButtons()
pProject->GetScrubber().HasStartedScrubbing()));
}
void ControlToolBar::SetPlay(bool down, bool looped, bool cutPreview)
void ControlToolBar::SetPlay(bool down, PlayAppearance appearance)
{
if (down) {
mPlay->SetShift(looped);
mPlay->SetControl(cutPreview);
mPlay->SetAlternateIdx(cutPreview ? 2 : looped ? 1 : 0);
mPlay->SetShift(appearance == PlayAppearance::Looped);
mPlay->SetControl(appearance == PlayAppearance::CutPreview);
mPlay->SetAlternateIdx(static_cast<int>(appearance));
mPlay->PushDown();
}
else {
@ -483,7 +488,7 @@ bool ControlToolBar::IsRecordDown()
int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
const AudioIOStartStreamOptions &options,
PlayMode mode,
bool cutpreview, /* = false */
PlayAppearance appearance, /* = PlayOption::Straight */
bool backwards, /* = false */
bool playWhiteSpace /* = false */)
{
@ -502,13 +507,14 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
if (backwards)
std::swap(t0, t1);
SetPlay(true, looped, cutpreview);
SetPlay(true, appearance);
if (gAudioIO->IsBusy()) {
SetPlay(false);
return -1;
}
const bool cutpreview = appearance == PlayAppearance::CutPreview;
if (cutpreview && t0==t1) {
SetPlay(false);
return -1; /* msmeyer: makes no sense */
@ -691,10 +697,14 @@ void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
options.playLooped = looped;
if (cutpreview)
options.timeTrack = NULL;
ControlToolBar::PlayAppearance appearance =
cutpreview ? ControlToolBar::PlayAppearance::CutPreview
: looped ? ControlToolBar::PlayAppearance::Looped
: ControlToolBar::PlayAppearance::Straight;
PlayPlayRegion(SelectedRegion(playRegionStart, playRegionEnd),
options,
(looped ? PlayMode::loopedPlay : PlayMode::normalPlay),
cutpreview);
appearance);
}
}

View File

@ -60,8 +60,13 @@ class ControlToolBar final : public ToolBar {
void OnFF(wxCommandEvent & evt);
void OnPause(wxCommandEvent & evt);
// Choice among the appearances of the play button:
enum class PlayAppearance {
Straight, Looped, CutPreview, Scrub
};
//These allow buttons to be controlled externally:
void SetPlay(bool down, bool looped=false, bool cutPreview = false);
void SetPlay(bool down, PlayAppearance appearance = PlayAppearance::Straight);
void SetStop(bool down);
void SetRecord(bool down, bool append=false);
@ -78,7 +83,8 @@ class ControlToolBar final : public ToolBar {
int PlayPlayRegion(const SelectedRegion &selectedRegion,
const AudioIOStartStreamOptions &options,
PlayMode playMode,
bool cutpreview = false, bool backwards = false,
PlayAppearance appearance = PlayAppearance::Straight,
bool backwards = false,
// Allow t0 and t1 to be beyond end of tracks
bool playWhiteSpace = false);
void PlayDefault();

View File

@ -110,6 +110,8 @@ void SelectionBar::Create(wxWindow * parent)
void SelectionBar::Populate()
{
mLeftTime = mRightTime = mAudioTime = nullptr;
// This will be inherited by all children:
SetFont(wxFont(9, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));

View File

@ -459,11 +459,15 @@ void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
AudioIOStartStreamOptions options(p->GetDefaultPlayOptions());
options.playLooped = looped;
options.timeTrack = mTimeTrack.get();
ControlToolBar::PlayAppearance appearance =
cutPreview ? ControlToolBar::PlayAppearance::CutPreview
: looped ? ControlToolBar::PlayAppearance::Looped
: ControlToolBar::PlayAppearance::Straight;
p->GetControlToolBar()->PlayPlayRegion
(SelectedRegion(playRegionStart, playRegionEnd),
options,
PlayMode::normalPlay,
cutPreview);
appearance);
}
}

View File

@ -211,6 +211,8 @@ bool Scrubber::MaybeStartScrubbing(const wxMouseEvent &event)
mMaxScrubSpeed = options.maxScrubSpeed = 1.0;
#endif
options.maxScrubTime = mProject->GetTracks()->GetEndTime();
ControlToolBar::PlayAppearance appearance =
ControlToolBar::PlayAppearance::Scrub;
const bool cutPreview = false;
const bool backwards = time1 < time0;
#ifdef EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL
@ -223,7 +225,7 @@ bool Scrubber::MaybeStartScrubbing(const wxMouseEvent &event)
mScrubSpeedDisplayCountdown = 0;
mScrubToken =
ctb->PlayPlayRegion(SelectedRegion(time0, time1), options,
PlayMode::normalPlay, cutPreview, backwards);
PlayMode::normalPlay, appearance, backwards);
}
}
else

View File

@ -2288,9 +2288,13 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
else
options.timeTrack = NULL;
ControlToolBar::PlayAppearance appearance =
evt.ControlDown() ? ControlToolBar::PlayAppearance::CutPreview
: loopEnabled ? ControlToolBar::PlayAppearance::Looped
: ControlToolBar::PlayAppearance::Straight;
ctb->PlayPlayRegion((SelectedRegion(start, end)),
options, PlayMode::normalPlay,
evt.ControlDown(),
appearance,
false,
true);