From 01001fdea9a0dcdd8711b6eeae20299384a14e83 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 19 Apr 2016 17:34:38 -0400 Subject: [PATCH] New alternative appearance for the transport toolbar play button, for scrubbing --- src/AllThemeResources.h | 2 ++ src/Menus.cpp | 6 +++++- src/toolbars/ControlToolBar.cpp | 26 ++++++++++++++++++-------- src/toolbars/ControlToolBar.h | 10 ++++++++-- src/toolbars/SelectionBar.cpp | 2 ++ src/toolbars/TranscriptionToolBar.cpp | 6 +++++- src/tracks/ui/Scrubbing.cpp | 4 +++- src/widgets/Ruler.cpp | 6 +++++- 8 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/AllThemeResources.h b/src/AllThemeResources.h index 869a99c44..016b6a099 100644 --- a/src/AllThemeResources.h +++ b/src/AllThemeResources.h @@ -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")); diff --git a/src/Menus.cpp b/src/Menus.cpp index d346006b0..417a5cc23 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -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; diff --git a/src/toolbars/ControlToolBar.cpp b/src/toolbars/ControlToolBar.cpp index 694f0539e..18f43a995 100644 --- a/src/toolbars/ControlToolBar.cpp +++ b/src/toolbars/ControlToolBar.cpp @@ -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(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); } } diff --git a/src/toolbars/ControlToolBar.h b/src/toolbars/ControlToolBar.h index 2dddccdf1..bac16e409 100644 --- a/src/toolbars/ControlToolBar.h +++ b/src/toolbars/ControlToolBar.h @@ -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(); diff --git a/src/toolbars/SelectionBar.cpp b/src/toolbars/SelectionBar.cpp index 90a3eb596..ce665490c 100644 --- a/src/toolbars/SelectionBar.cpp +++ b/src/toolbars/SelectionBar.cpp @@ -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)); diff --git a/src/toolbars/TranscriptionToolBar.cpp b/src/toolbars/TranscriptionToolBar.cpp index 3d4d6ffa3..0e49a775f 100644 --- a/src/toolbars/TranscriptionToolBar.cpp +++ b/src/toolbars/TranscriptionToolBar.cpp @@ -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); } } diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index f752cb178..30a5d7a6c 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -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 diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index a26531e4b..11fc88fb2 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -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);