1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-06 14:52:34 +02:00

P & R recording: change color of pin button, as for play indicator

This commit is contained in:
Paul Licameli 2018-08-11 00:09:26 -04:00
parent 0d9972b3e0
commit 3f1d9ab8c1
4 changed files with 24 additions and 5 deletions

View File

@ -5583,7 +5583,8 @@ double AudioIO::RecordingSchedule::ToDiscard() const
bool AudioIO::IsCapturing() const
{
// Includes a test of mTime, used in the main thread
return GetNumCaptureChannels() > 0 &&
return IsStreamActive() &&
GetNumCaptureChannels() > 0 &&
mPlaybackSchedule.GetTrackTime() >=
mPlaybackSchedule.mT0 + mRecordingSchedule.mPreRoll;
}

View File

@ -50,10 +50,11 @@ std::pair<wxRect, bool> PlayIndicatorOverlayBase::DoGetRectangle(wxSize size)
// May be excessive height, but little matter
wxRect rect(mLastIndicatorX - width / 2, 0, width, size.GetHeight());
return std::make_pair(
return {
rect,
mLastIndicatorX != mNewIndicatorX
);
(mLastIndicatorX != mNewIndicatorX
|| mLastIsCapturing != mNewIsCapturing)
};
}
@ -62,6 +63,17 @@ void PlayIndicatorOverlayBase::Draw(OverlayPanel &panel, wxDC &dc)
// Set play/record color
bool rec = gAudioIO->IsCapturing();
AColor::IndicatorColor(&dc, !rec);
if (mIsMaster
&& mLastIsCapturing != mNewIsCapturing) {
// Detect transition to recording during punch and roll; make ruler
// change its button color too
const auto ruler = mProject->GetRulerPanel();
ruler->UpdateButtonStates();
ruler->Refresh();
}
mLastIsCapturing = mNewIsCapturing;
mLastIndicatorX = mNewIndicatorX;
if (!between_incexc(0, mLastIndicatorX, dc.GetSize().GetWidth()))
return;
@ -136,6 +148,7 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
if (!mProject->IsAudioActive()) {
mNewIndicatorX = -1;
mNewIsCapturing = false;
const auto &scrubber = mProject->GetScrubber();
if (scrubber.HasMark()) {
auto position = scrubber.GetScrubStartPosition();
@ -195,6 +208,8 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
mNewIndicatorX = viewInfo.TimeToPosition(playPos, trackPanel->GetLeftOffset());
else
mNewIndicatorX = -1;
mNewIsCapturing = gAudioIO->IsCapturing();
}
if(mPartner)

View File

@ -37,6 +37,8 @@ protected:
const bool mIsMaster;
int mLastIndicatorX { -1 };
int mNewIndicatorX { -1 };
bool mNewIsCapturing { false };
bool mLastIsCapturing { false };
};
// Master object for track panel, creates the other object for the ruler

View File

@ -3287,7 +3287,8 @@ void AdornedRulerPanel::UpdateButtonStates()
pinButton->PopUp();
else
pinButton->PushDown();
pinButton->SetAlternateIdx((mIsRecording ? 2 : 0) + (state ? 0 : 1));
pinButton->SetAlternateIdx(
(gAudioIO->IsCapturing() ? 2 : 0) + (state ? 0 : 1));
// Bug 1584: Toltip now shows what clicking will do.
const auto label = state
? _("Click to unpin")