1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-14 15:48:21 +02:00

No disabled state for meters. Monitoring can be on or off. Input meter now has prompt when monitoring off.

I haven't got rid of the preferences for disabled/enabled.
This commit is contained in:
james.k.crook@gmail.com 2014-11-29 21:10:44 +00:00
parent f9863a1400
commit 94c243cb2e
3 changed files with 62 additions and 69 deletions

View File

@ -143,11 +143,7 @@ void MeterToolBar::RegenerateTooltips()
if( mPlayMeter ) if( mPlayMeter )
mPlayMeter->SetToolTip( _("Playback Level.") ); mPlayMeter->SetToolTip( _("Playback Level.") );
if( mRecordMeter ) if( mRecordMeter )
mRecordMeter->SetToolTip( mRecordMeter->SetToolTip( _("Recording Level.") );
!gAudioIO->IsMonitoring() ?
_("Recording Level. (Click to monitor).") :
_("Recording Level. (Click to turn monitoring off).")
);
#endif #endif
} }

View File

@ -252,35 +252,28 @@ Meter::Meter(wxWindow* parent, wxWindowID id,
mRightSize = wxSize(0, 0); mRightSize = wxSize(0, 0);
if (mIsInput) { if (mIsInput) {
if (mStyle != MixerTrackCluster)
mMeterDisabled = 1L;// Monitoring off by default.
mPen = wxPen( theTheme.Colour( clrMeterInputPen ), 1, wxSOLID); mPen = wxPen( theTheme.Colour( clrMeterInputPen ), 1, wxSOLID);
mBrush = wxBrush( theTheme.Colour( clrMeterInputBrush ), wxSOLID); mBrush = wxBrush( theTheme.Colour( clrMeterInputBrush ), wxSOLID);
mRMSBrush = wxBrush( theTheme.Colour( clrMeterInputRMSBrush ), wxSOLID); mRMSBrush = wxBrush( theTheme.Colour( clrMeterInputRMSBrush ), wxSOLID);
mClipBrush = wxBrush( theTheme.Colour( clrMeterInputClipBrush ), wxSOLID); mClipBrush = wxBrush( theTheme.Colour( clrMeterInputClipBrush ), wxSOLID);
mLightPen = wxPen( theTheme.Colour( clrMeterInputLightPen ), 1, wxSOLID); // mLightPen = wxPen( theTheme.Colour( clrMeterInputLightPen ), 1, wxSOLID);
mDarkPen = wxPen( theTheme.Colour( clrMeterInputDarkPen ), 1, wxSOLID); // mDarkPen = wxPen( theTheme.Colour( clrMeterInputDarkPen ), 1, wxSOLID);
} }
else { else {
mPen = wxPen( theTheme.Colour( clrMeterOutputPen ), 1, wxSOLID); mPen = wxPen( theTheme.Colour( clrMeterOutputPen ), 1, wxSOLID);
mBrush = wxBrush( theTheme.Colour( clrMeterOutputBrush ), wxSOLID); mBrush = wxBrush( theTheme.Colour( clrMeterOutputBrush ), wxSOLID);
mRMSBrush = wxBrush( theTheme.Colour( clrMeterOutputRMSBrush ), wxSOLID); mRMSBrush = wxBrush( theTheme.Colour( clrMeterOutputRMSBrush ), wxSOLID);
mClipBrush = wxBrush( theTheme.Colour( clrMeterOutputClipBrush ), wxSOLID); mClipBrush = wxBrush( theTheme.Colour( clrMeterOutputClipBrush ), wxSOLID);
mLightPen = wxPen( theTheme.Colour( clrMeterOutputLightPen ), 1, wxSOLID); // mLightPen = wxPen( theTheme.Colour( clrMeterOutputLightPen ), 1, wxSOLID);
mDarkPen = wxPen( theTheme.Colour( clrMeterOutputDarkPen ), 1, wxSOLID); // mDarkPen = wxPen( theTheme.Colour( clrMeterOutputDarkPen ), 1, wxSOLID);
} }
mDisabledBkgndBrush = wxBrush(theTheme.Colour( clrMeterDisabledBrush), wxSOLID); // mDisabledBkgndBrush = wxBrush(theTheme.Colour( clrMeterDisabledBrush), wxSOLID);
// mDisabledBkgndBrush = wxBrush( // No longer show a difference in the background colour when not monitoring.
// wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW), wxSOLID); // We have the tip instead.
// wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), wxSOLID); mDisabledBkgndBrush = mBkgndBrush;
if (mMeterDisabled) {
mSavedBkgndBrush = mBkgndBrush;
mSavedBrush = mBrush;
mSavedRMSBrush = mRMSBrush;
mBkgndBrush = mDisabledBkgndBrush;
mBrush = mDisabledBkgndBrush;
mRMSBrush = mDisabledBkgndBrush;
}
// MixerTrackCluster style has no menu, so disallows SetStyle, so never needs icon. // MixerTrackCluster style has no menu, so disallows SetStyle, so never needs icon.
if (mStyle != MixerTrackCluster) if (mStyle != MixerTrackCluster)
@ -357,7 +350,8 @@ void Meter::UpdatePrefs()
if (mIsInput) if (mIsInput)
{ {
mMeterDisabled = gPrefs->Read(wxT("/Meter/MeterInputDisabled"), (long)0); // Default is disabled i.e. monitoring off when we start.
mMeterDisabled = gPrefs->Read(wxT("/Meter/MeterInputDisabled"), (long)1);
} }
else else
{ {
@ -415,10 +409,6 @@ void Meter::OnMouse(wxMouseEvent &evt)
{ {
wxMenu *menu = new wxMenu(); wxMenu *menu = new wxMenu();
// Note: these should be kept in the same order as the enum // Note: these should be kept in the same order as the enum
if (mMeterDisabled)
menu->Append(OnDisableMeterID, _("Enable Meter"));
else
menu->Append(OnDisableMeterID, _("Disable Meter"));
if (mIsInput) { if (mIsInput) {
if (gAudioIO->IsMonitoring()) if (gAudioIO->IsMonitoring())
menu->Append(OnMonitorID, _("Stop Monitoring")); menu->Append(OnMonitorID, _("Stop Monitoring"));
@ -438,7 +428,7 @@ void Meter::OnMouse(wxMouseEvent &evt)
#endif #endif
} }
menu->AppendSeparator(); //menu->AppendSeparator();
//menu->Append(OnHorizontalID, _("Horizontal Stereo")); //menu->Append(OnHorizontalID, _("Horizontal Stereo"));
//menu->Append(OnVerticalID, _("Vertical Stereo")); //menu->Append(OnVerticalID, _("Vertical Stereo"));
@ -1186,14 +1176,41 @@ void Meter::HandlePaint(wxDC &destDC)
dc.SelectObject(wxNullBitmap); dc.SelectObject(wxNullBitmap);
} }
// Go draw the meter bars using current levels // Go draw the meter bars, Left & Right channels using current levels
for (int i = 0; i < mNumBars; i++) for (int i = 0; i < mNumBars; i++)
{ {
DrawMeterBar(destDC, &mBar[i]); DrawMeterBar(destDC, &mBar[i]);
}
// We can have numbers over the bars, in which case we have to draw them each time. // We can have numbers over the bars, in which case we have to draw them each time.
if( mRuler.mRect.Intersects( mBar[0].r ) ) if( mRuler.mRect.Intersects( mBar[0].r ) )
{
mRuler.Draw(destDC); mRuler.Draw(destDC);
} }
// And for the case of horizontal meter we tell the user they can click to monitor.
// It's a nice extra, not an essential, as they have a start monitoring menu item.
if( mMeterDisabled && !mBar[0].vert)
{
destDC.SetBrush( mBkgndBrush );
destDC.SetPen( *wxTRANSPARENT_PEN );
//destDC.SetFont(wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
destDC.SetFont( GetFont() );
wxString Text = _("Click to Start Monitoring");
Text = wxT(" ") + Text + wxT(" ");
wxSize Siz = destDC.GetTextExtent( Text );
// We shouldn't need fudge factors to adjust the rectangle, but seems we do.
const int widthFudge = 2;
const int xFudge = 1;
wxRect BigRect( mBar[0].r.x + xFudge, mBar[0].r.y, mBar[0].r.width + widthFudge, mBar[1].r.y-mBar[0].r.y + mBar[1].r.height );
wxPoint TextPos(
BigRect.x + 0.5*(BigRect.width-Siz.x),
BigRect.y + 0.5*(BigRect.height-Siz.y));
destDC.DrawRectangle( BigRect );
destDC.SetBackgroundMode( wxTRANSPARENT );
destDC.DrawText( Text, TextPos );
}
} }
void Meter::RepaintBarsNow() void Meter::RepaintBarsNow()
@ -1217,6 +1234,8 @@ void Meter::RepaintBarsNow()
// We can have numbers over the bars, in which case we have to draw them each time. // We can have numbers over the bars, in which case we have to draw them each time.
if( mRuler.mRect.Intersects( mBar[0].r ) ) if( mRuler.mRect.Intersects( mBar[0].r ) )
mRuler.Draw(*dc); mRuler.Draw(*dc);
} }
} }
@ -1235,7 +1254,7 @@ void Meter::DrawMeterBar(wxDC &dc, MeterBar *meterBar)
// Setup for erasing the background // Setup for erasing the background
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(mBkgndBrush); dc.SetBrush(mMeterDisabled ? mDisabledBkgndBrush : mBkgndBrush);
int ht; int ht;
int wd; int wd;
@ -1364,9 +1383,9 @@ void Meter::DrawMeterBar(wxDC &dc, MeterBar *meterBar)
// Draw the peak and rms levels // Draw the peak and rms levels
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(mBrush); dc.SetBrush( mMeterDisabled ? mDisabledBkgndBrush : mBrush);
dc.DrawRectangle(r); dc.DrawRectangle(r);
dc.SetBrush(mRMSBrush); dc.SetBrush( mMeterDisabled ? mDisabledBkgndBrush : mRMSBrush);
dc.DrawRectangle(rRMS); dc.DrawRectangle(rRMS);
} }
@ -1381,7 +1400,7 @@ void Meter::DrawMeterBar(wxDC &dc, MeterBar *meterBar)
} }
else else
{ {
dc.SetBrush(mBkgndBrush); dc.SetBrush(mMeterDisabled ? mDisabledBkgndBrush : mBkgndBrush);
} }
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(meterBar->rClip); dc.DrawRectangle(meterBar->rClip);
@ -1389,6 +1408,8 @@ void Meter::DrawMeterBar(wxDC &dc, MeterBar *meterBar)
AColor::Bevel(dc, false, meterBar->rClip); AColor::Bevel(dc, false, meterBar->rClip);
} }
// No longer need the source DC, so unselect the predrawn bitmap // No longer need the source DC, so unselect the predrawn bitmap
srcDC.SelectObject(wxNullBitmap); srcDC.SelectObject(wxNullBitmap);
} }
@ -1401,9 +1422,13 @@ bool Meter::IsMeterDisabled()
void Meter::StartMonitoring() void Meter::StartMonitoring()
{ {
if (gAudioIO->IsMonitoring()) if (gAudioIO->IsMonitoring()){
gAudioIO->StopStream(); gAudioIO->StopStream();
else { if (!mMeterDisabled){
wxCommandEvent dummy;
OnDisableMeter(dummy);
}
} else {
if (mMeterDisabled){ if (mMeterDisabled){
wxCommandEvent dummy; wxCommandEvent dummy;
OnDisableMeter(dummy); OnDisableMeter(dummy);
@ -1431,17 +1456,8 @@ void Meter::OnDisableMeter(wxCommandEvent & WXUNUSED(event))
{ {
if (mMeterDisabled) //Enable if (mMeterDisabled) //Enable
{ {
mLightPen = mSavedLightPen;
mDarkPen = mSavedDarkPen;
mBkgndBrush = mSavedBkgndBrush;
mBrush = mSavedBrush;
mRMSBrush = mSavedRMSBrush;
mBkgndBrush = mSavedBkgndBrush;
mLightPen = mSavedLightPen;
Refresh(false);
mMeterDisabled = false; mMeterDisabled = false;
Refresh(false);
} }
else else
{ {
@ -1451,22 +1467,10 @@ void Meter::OnDisableMeter(wxCommandEvent & WXUNUSED(event))
{ {
gAudioIO->StopStream(); gAudioIO->StopStream();
} }
mMeterDisabled = true;
} }
mSavedLightPen = mLightPen;
mSavedDarkPen = mDarkPen;
mSavedBkgndBrush = mBkgndBrush;
mSavedBrush = mBrush;
mSavedRMSBrush = mRMSBrush;
mLightPen = mDisabledPen;
mDarkPen = mDisabledPen;
mBkgndBrush = mDisabledBkgndBrush;
mBrush = mDisabledBkgndBrush;
mRMSBrush = mDisabledBkgndBrush;
mLayoutValid = false; mLayoutValid = false;
Refresh(false); Refresh(false);
mMeterDisabled = true;
} }
if (mIsInput) if (mIsInput)
{ {

View File

@ -246,19 +246,12 @@ class Meter : public wxPanel
wxSize mRightSize; wxSize mRightSize;
wxBitmap *mIcon; wxBitmap *mIcon;
wxPen mPen; wxPen mPen;
wxPen mLightPen;
wxPen mSavedLightPen;
wxPen mDarkPen;
wxPen mSavedDarkPen;
wxPen mDisabledPen; wxPen mDisabledPen;
wxPen mPeakPeakPen; wxPen mPeakPeakPen;
wxBrush mBrush; wxBrush mBrush;
wxBrush mRMSBrush; wxBrush mRMSBrush;
wxBrush mClipBrush; wxBrush mClipBrush;
wxBrush mBkgndBrush; wxBrush mBkgndBrush;
wxBrush mSavedBkgndBrush;
wxBrush mSavedBrush;
wxBrush mSavedRMSBrush;
wxBrush mDisabledBkgndBrush; wxBrush mDisabledBkgndBrush;
wxRect mAllBarsRect; wxRect mAllBarsRect;
Ruler mRuler; Ruler mRuler;