1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-21 14:50:06 +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 )
mPlayMeter->SetToolTip( _("Playback Level.") );
if( mRecordMeter )
mRecordMeter->SetToolTip(
!gAudioIO->IsMonitoring() ?
_("Recording Level. (Click to monitor).") :
_("Recording Level. (Click to turn monitoring off).")
);
mRecordMeter->SetToolTip( _("Recording Level.") );
#endif
}

View File

@ -252,36 +252,29 @@ Meter::Meter(wxWindow* parent, wxWindowID id,
mRightSize = wxSize(0, 0);
if (mIsInput) {
if (mStyle != MixerTrackCluster)
mMeterDisabled = 1L;// Monitoring off by default.
mPen = wxPen( theTheme.Colour( clrMeterInputPen ), 1, wxSOLID);
mBrush = wxBrush( theTheme.Colour( clrMeterInputBrush ), wxSOLID);
mRMSBrush = wxBrush( theTheme.Colour( clrMeterInputRMSBrush ), wxSOLID);
mClipBrush = wxBrush( theTheme.Colour( clrMeterInputClipBrush ), wxSOLID);
mLightPen = wxPen( theTheme.Colour( clrMeterInputLightPen ), 1, wxSOLID);
mDarkPen = wxPen( theTheme.Colour( clrMeterInputDarkPen ), 1, wxSOLID);
// mLightPen = wxPen( theTheme.Colour( clrMeterInputLightPen ), 1, wxSOLID);
// mDarkPen = wxPen( theTheme.Colour( clrMeterInputDarkPen ), 1, wxSOLID);
}
else {
mPen = wxPen( theTheme.Colour( clrMeterOutputPen ), 1, wxSOLID);
mBrush = wxBrush( theTheme.Colour( clrMeterOutputBrush ), wxSOLID);
mRMSBrush = wxBrush( theTheme.Colour( clrMeterOutputRMSBrush ), wxSOLID);
mClipBrush = wxBrush( theTheme.Colour( clrMeterOutputClipBrush ), wxSOLID);
mLightPen = wxPen( theTheme.Colour( clrMeterOutputLightPen ), 1, wxSOLID);
mDarkPen = wxPen( theTheme.Colour( clrMeterOutputDarkPen ), 1, wxSOLID);
}
mDisabledBkgndBrush = wxBrush(theTheme.Colour( clrMeterDisabledBrush), wxSOLID);
// mDisabledBkgndBrush = wxBrush(
// wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW), wxSOLID);
// wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), wxSOLID);
if (mMeterDisabled) {
mSavedBkgndBrush = mBkgndBrush;
mSavedBrush = mBrush;
mSavedRMSBrush = mRMSBrush;
mBkgndBrush = mDisabledBkgndBrush;
mBrush = mDisabledBkgndBrush;
mRMSBrush = mDisabledBkgndBrush;
// mLightPen = wxPen( theTheme.Colour( clrMeterOutputLightPen ), 1, wxSOLID);
// mDarkPen = wxPen( theTheme.Colour( clrMeterOutputDarkPen ), 1, wxSOLID);
}
// mDisabledBkgndBrush = wxBrush(theTheme.Colour( clrMeterDisabledBrush), wxSOLID);
// No longer show a difference in the background colour when not monitoring.
// We have the tip instead.
mDisabledBkgndBrush = mBkgndBrush;
// MixerTrackCluster style has no menu, so disallows SetStyle, so never needs icon.
if (mStyle != MixerTrackCluster)
CreateIcon(2);
@ -357,7 +350,8 @@ void Meter::UpdatePrefs()
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
{
@ -415,10 +409,6 @@ void Meter::OnMouse(wxMouseEvent &evt)
{
wxMenu *menu = new wxMenu();
// 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 (gAudioIO->IsMonitoring())
menu->Append(OnMonitorID, _("Stop Monitoring"));
@ -438,7 +428,7 @@ void Meter::OnMouse(wxMouseEvent &evt)
#endif
}
menu->AppendSeparator();
//menu->AppendSeparator();
//menu->Append(OnHorizontalID, _("Horizontal Stereo"));
//menu->Append(OnVerticalID, _("Vertical Stereo"));
@ -1186,14 +1176,41 @@ void Meter::HandlePaint(wxDC &destDC)
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++)
{
DrawMeterBar(destDC, &mBar[i]);
// We can have numbers over the bars, in which case we have to draw them each time.
if( mRuler.mRect.Intersects( mBar[0].r ) )
mRuler.Draw(destDC);
}
// We can have numbers over the bars, in which case we have to draw them each time.
if( mRuler.mRect.Intersects( mBar[0].r ) )
{
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()
@ -1217,6 +1234,8 @@ void Meter::RepaintBarsNow()
// We can have numbers over the bars, in which case we have to draw them each time.
if( mRuler.mRect.Intersects( mBar[0].r ) )
mRuler.Draw(*dc);
}
}
@ -1235,7 +1254,7 @@ void Meter::DrawMeterBar(wxDC &dc, MeterBar *meterBar)
// Setup for erasing the background
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(mBkgndBrush);
dc.SetBrush(mMeterDisabled ? mDisabledBkgndBrush : mBkgndBrush);
int ht;
int wd;
@ -1364,9 +1383,9 @@ void Meter::DrawMeterBar(wxDC &dc, MeterBar *meterBar)
// Draw the peak and rms levels
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(mBrush);
dc.SetBrush( mMeterDisabled ? mDisabledBkgndBrush : mBrush);
dc.DrawRectangle(r);
dc.SetBrush(mRMSBrush);
dc.SetBrush( mMeterDisabled ? mDisabledBkgndBrush : mRMSBrush);
dc.DrawRectangle(rRMS);
}
@ -1381,7 +1400,7 @@ void Meter::DrawMeterBar(wxDC &dc, MeterBar *meterBar)
}
else
{
dc.SetBrush(mBkgndBrush);
dc.SetBrush(mMeterDisabled ? mDisabledBkgndBrush : mBkgndBrush);
}
dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(meterBar->rClip);
@ -1389,6 +1408,8 @@ void Meter::DrawMeterBar(wxDC &dc, MeterBar *meterBar)
AColor::Bevel(dc, false, meterBar->rClip);
}
// No longer need the source DC, so unselect the predrawn bitmap
srcDC.SelectObject(wxNullBitmap);
}
@ -1401,9 +1422,13 @@ bool Meter::IsMeterDisabled()
void Meter::StartMonitoring()
{
if (gAudioIO->IsMonitoring())
if (gAudioIO->IsMonitoring()){
gAudioIO->StopStream();
else {
if (!mMeterDisabled){
wxCommandEvent dummy;
OnDisableMeter(dummy);
}
} else {
if (mMeterDisabled){
wxCommandEvent dummy;
OnDisableMeter(dummy);
@ -1431,17 +1456,8 @@ void Meter::OnDisableMeter(wxCommandEvent & WXUNUSED(event))
{
if (mMeterDisabled) //Enable
{
mLightPen = mSavedLightPen;
mDarkPen = mSavedDarkPen;
mBkgndBrush = mSavedBkgndBrush;
mBrush = mSavedBrush;
mRMSBrush = mSavedRMSBrush;
mBkgndBrush = mSavedBkgndBrush;
mLightPen = mSavedLightPen;
Refresh(false);
mMeterDisabled = false;
Refresh(false);
}
else
{
@ -1451,22 +1467,10 @@ void Meter::OnDisableMeter(wxCommandEvent & WXUNUSED(event))
{
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;
Refresh(false);
mMeterDisabled = true;
}
if (mIsInput)
{

View File

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