1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 16:48:44 +02:00

Double click on Record button pins record head right, not center

This commit is contained in:
Paul Licameli 2016-05-17 12:26:05 -04:00
commit 24f89c36e4
7 changed files with 47 additions and 14 deletions

View File

@ -257,6 +257,9 @@ void ScrollBar::SetScrollbar(int position, int thumbSize,
{ {
// Mitigate flashing of scrollbars by refreshing only when something really changes. // Mitigate flashing of scrollbars by refreshing only when something really changes.
// PRL: This may have been made unnecessary by other fixes for flashing, see
// commit ac05b190bee7dd0000bce56edb0e5e26185c972f
auto changed = auto changed =
position != GetThumbPosition() || position != GetThumbPosition() ||
thumbSize != GetThumbSize() || thumbSize != GetThumbSize() ||
@ -5366,7 +5369,7 @@ void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
// Let other listeners get the notification // Let other listeners get the notification
event.Skip(); event.Skip();
if (mActive && mProject->IsAudioActive()) if (mMode != Mode::Off && mProject->IsAudioActive())
{ {
// Pan the view, so that we center the play indicator. // Pan the view, so that we center the play indicator.
@ -5375,9 +5378,19 @@ void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
const int posX = viewInfo.TimeToPosition(viewInfo.mRecentStreamTime); const int posX = viewInfo.TimeToPosition(viewInfo.mRecentStreamTime);
int width; int width;
trackPanel->GetTracksUsableArea(&width, NULL); trackPanel->GetTracksUsableArea(&width, NULL);
const int deltaX = posX - width / 2; int deltaX;
switch (mMode)
{
default:
wxASSERT(false);
/* fallthru */
case Mode::Centered:
deltaX = posX - width / 2; break;
case Mode::Right:
deltaX = posX - width; break;
}
viewInfo.h = viewInfo.h =
viewInfo.OffsetTimeByPixels(viewInfo.h, deltaX, true); viewInfo.OffsetTimeByPixels(viewInfo.h, deltaX, true);
if (!viewInfo.bScrollBeyondZero) if (!viewInfo.bScrollBeyondZero)
// Can't scroll too far left // Can't scroll too far left
viewInfo.h = std::max(0.0, viewInfo.h); viewInfo.h = std::max(0.0, viewInfo.h);

View File

@ -728,16 +728,23 @@ public:
explicit PlaybackScroller(AudacityProject *project); explicit PlaybackScroller(AudacityProject *project);
~PlaybackScroller(); ~PlaybackScroller();
void Activate(bool active) enum class Mode {
Off,
Centered,
Right,
};
Mode GetMode() const { return mMode; }
void Activate(Mode mode)
{ {
mActive = active; mMode = mode;
} }
private: private:
void OnTimer(wxCommandEvent &event); void OnTimer(wxCommandEvent &event);
AudacityProject *mProject; AudacityProject *mProject;
bool mActive { false }; Mode mMode { Mode::Off };
}; };
std::unique_ptr<PlaybackScroller> mPlaybackScroller; std::unique_ptr<PlaybackScroller> mPlaybackScroller;

View File

@ -751,7 +751,8 @@ void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
auto p = GetActiveProject(); auto p = GetActiveProject();
if (doubleClicked) if (doubleClicked)
p->GetPlaybackScroller().Activate(true); p->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Centered);
else { else {
if (!CanStopAudioStream()) if (!CanStopAudioStream())
return; return;
@ -794,7 +795,8 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
AudacityProject *project = GetActiveProject(); AudacityProject *project = GetActiveProject();
if(project) { if(project) {
project->GetPlaybackScroller().Activate(false); project->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Off);
// Let scrubbing code do some appearance change // Let scrubbing code do some appearance change
project->GetScrubber().StopScrubbing(); project->GetScrubber().StopScrubbing();
} }
@ -855,7 +857,8 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
mRecord->ClearDoubleClicked(); mRecord->ClearDoubleClicked();
if (doubleClicked) { if (doubleClicked) {
GetActiveProject()->GetPlaybackScroller().Activate(true); GetActiveProject()->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Right);
return; return;
} }

View File

@ -480,7 +480,8 @@ void TranscriptionToolBar::OnPlaySpeed(wxCommandEvent & WXUNUSED(event))
button->ClearDoubleClicked(); button->ClearDoubleClicked();
if (doubleClicked) { if (doubleClicked) {
GetActiveProject()->GetPlaybackScroller().Activate(true); GetActiveProject()->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Centered);
// Pop up the button // Pop up the button
SetButton(false, button); SetButton(false, button);

View File

@ -165,9 +165,12 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
// BG: Scroll screen if option is set // BG: Scroll screen if option is set
// msmeyer: But only if not playing looped or in one-second mode // msmeyer: But only if not playing looped or in one-second mode
// PRL: and not scrolling with play/record head fixed right
if (viewInfo.bUpdateTrackIndicator && if (viewInfo.bUpdateTrackIndicator &&
mProject->mLastPlayMode != PlayMode::loopedPlay && mProject->mLastPlayMode != PlayMode::loopedPlay &&
mProject->mLastPlayMode != PlayMode::oneSecondPlay && mProject->mLastPlayMode != PlayMode::oneSecondPlay &&
mProject->GetPlaybackScroller().GetMode() !=
AudacityProject::PlaybackScroller::Mode::Right &&
playPos >= 0 && playPos >= 0 &&
!onScreen && !onScreen &&
!gAudioIO->IsPaused()) !gAudioIO->IsPaused())

View File

@ -331,7 +331,9 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis(); mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis();
if (IsScrubbing()) { if (IsScrubbing()) {
mProject->GetPlaybackScroller().Activate(mSmoothScrollingScrub); using Mode = AudacityProject::PlaybackScroller::Mode;
mProject->GetPlaybackScroller().Activate
(mSmoothScrollingScrub ? Mode::Centered : Mode::Off);
mScrubHasFocus = true; mScrubHasFocus = true;
mLastScrubPosition = xx; mLastScrubPosition = xx;
@ -423,7 +425,8 @@ void Scrubber::StopScrubbing()
UncheckAllMenuItems(); UncheckAllMenuItems();
mScrubStartPosition = -1; mScrubStartPosition = -1;
mProject->GetPlaybackScroller().Activate(false); mProject->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Off);
mDragging = false; mDragging = false;
if (!IsScrubbing()) if (!IsScrubbing())
@ -706,7 +709,9 @@ void Scrubber::DoScrub(bool scroll, bool seek)
} }
else if(!match) { else if(!match) {
mSmoothScrollingScrub = scroll; mSmoothScrollingScrub = scroll;
mProject->GetPlaybackScroller().Activate(scroll); using Mode = AudacityProject::PlaybackScroller::Mode;
mProject->GetPlaybackScroller().Activate
(scroll ? Mode::Centered : Mode::Off);
mAlwaysSeeking = seek; mAlwaysSeeking = seek;
UncheckAllMenuItems(); UncheckAllMenuItems();
CheckMenuItem(); CheckMenuItem();

View File

@ -2533,7 +2533,8 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
void AdornedRulerPanel::HandleQPDoubleClick(wxMouseEvent &evt, wxCoord mousePosX) void AdornedRulerPanel::HandleQPDoubleClick(wxMouseEvent &evt, wxCoord mousePosX)
{ {
mProject->GetPlaybackScroller().Activate(true); mProject->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Centered);
} }
void AdornedRulerPanel::HandleQPClick(wxMouseEvent &evt, wxCoord mousePosX) void AdornedRulerPanel::HandleQPClick(wxMouseEvent &evt, wxCoord mousePosX)