mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-18 17:10:05 +02:00
Tidy up of code. Moved preferences menu to end of meter. Fixed memory leaks on some bitmaps.
This commit is contained in:
parent
8bd3891561
commit
24a636d6ea
@ -60,6 +60,8 @@ END_EVENT_TABLE()
|
||||
DeviceToolBar::DeviceToolBar()
|
||||
: ToolBar(DeviceBarID, _("Device"), wxT("Device"), true)
|
||||
{
|
||||
mPlayBitmap = NULL;
|
||||
mRecordBitmap = NULL;
|
||||
}
|
||||
|
||||
DeviceToolBar::~DeviceToolBar()
|
||||
@ -111,7 +113,8 @@ void DeviceToolBar::Populate()
|
||||
Add(mHost, 0, wxALIGN_CENTER);
|
||||
|
||||
// Input device
|
||||
mRecordBitmap = new wxBitmap(theTheme.Bitmap(bmpMic));
|
||||
if( mRecordBitmap == NULL )
|
||||
mRecordBitmap = new wxBitmap(theTheme.Bitmap(bmpMic));
|
||||
|
||||
Add(new wxStaticBitmap(this,
|
||||
wxID_ANY,
|
||||
@ -133,7 +136,8 @@ void DeviceToolBar::Populate()
|
||||
Add(mInputChannels, 0, wxALIGN_CENTER);
|
||||
|
||||
// Output device
|
||||
mPlayBitmap = new wxBitmap(theTheme.Bitmap(bmpSpeaker));
|
||||
if( mPlayBitmap == NULL )
|
||||
mPlayBitmap = new wxBitmap(theTheme.Bitmap(bmpSpeaker));
|
||||
Add(new wxStaticBitmap(this,
|
||||
wxID_ANY,
|
||||
*mPlayBitmap), 0, wxALIGN_CENTER);
|
||||
|
@ -58,6 +58,8 @@ END_EVENT_TABLE()
|
||||
MixerToolBar::MixerToolBar()
|
||||
: ToolBar(MixerBarID, _("Mixer"), wxT("Mixer"))
|
||||
{
|
||||
mPlayBitmap = NULL;
|
||||
mRecordBitmap = NULL;
|
||||
mInputSliderVolume = 0.0;
|
||||
mOutputSliderVolume = 0.0;
|
||||
}
|
||||
@ -82,7 +84,8 @@ void MixerToolBar::RecreateTipWindows()
|
||||
|
||||
void MixerToolBar::Populate()
|
||||
{
|
||||
mRecordBitmap = new wxBitmap(theTheme.Bitmap(bmpMic));
|
||||
if( mRecordBitmap == NULL )
|
||||
mRecordBitmap = new wxBitmap(theTheme.Bitmap(bmpMic));
|
||||
|
||||
Add(new wxStaticBitmap(this,
|
||||
wxID_ANY,
|
||||
@ -94,7 +97,8 @@ void MixerToolBar::Populate()
|
||||
mInputSlider->SetName(_("Slider Recording"));
|
||||
Add(mInputSlider, 0, wxALIGN_CENTER);
|
||||
|
||||
mPlayBitmap = new wxBitmap(theTheme.Bitmap(bmpSpeaker));
|
||||
if( mPlayBitmap == NULL )
|
||||
mPlayBitmap = new wxBitmap(theTheme.Bitmap(bmpSpeaker));
|
||||
|
||||
Add(new wxStaticBitmap(this,
|
||||
wxID_ANY,
|
||||
|
@ -779,6 +779,18 @@ bool Meter::IsClipping()
|
||||
return false;
|
||||
}
|
||||
|
||||
void Meter::SetBarClip( int iBar )
|
||||
{
|
||||
mBar[iBar].vert = false;
|
||||
ResetBar(&mBar[iBar], false);
|
||||
if (!mClip)
|
||||
return;
|
||||
mBar[iBar].rClip = mBar[iBar].r;
|
||||
mBar[iBar].rClip.x += mBar[iBar].rClip.width-3;
|
||||
mBar[iBar].rClip.width = 3;
|
||||
mBar[iBar].r.width -= 4;
|
||||
}
|
||||
|
||||
void Meter::HandleLayout(wxDC &dc)
|
||||
{
|
||||
// Refresh to reflect any language changes
|
||||
@ -916,24 +928,11 @@ void Meter::HandleLayout(wxDC &dc)
|
||||
barw = width - 4;
|
||||
barh = (height-2)/2;
|
||||
mNumBars = 2;
|
||||
mBar[0].vert = false;
|
||||
ResetBar(&mBar[0], false);
|
||||
mBar[0].r = wxRect(left+2, height/2 - barh - 1, barw, barh);
|
||||
if (mClip) {
|
||||
mBar[0].rClip = mBar[0].r;
|
||||
mBar[0].rClip.x += mBar[0].rClip.width-3;
|
||||
mBar[0].rClip.width = 3;
|
||||
mBar[0].r.width -= 4;
|
||||
}
|
||||
mBar[1].vert = false;
|
||||
ResetBar(&mBar[1], false);
|
||||
SetBarClip( 0 );
|
||||
mBar[1].r = wxRect(left+2, height/2 + 1, barw, barh);
|
||||
if (mClip) {
|
||||
mBar[1].rClip = mBar[1].r;
|
||||
mBar[1].rClip.x += mBar[1].rClip.width-3;
|
||||
mBar[1].rClip.width = 3;
|
||||
mBar[1].r.width -= 4;
|
||||
}
|
||||
SetBarClip( 1 );
|
||||
|
||||
mRuler.SetOrientation(wxHORIZONTAL);
|
||||
mRuler.SetBounds(mBar[1].r.x,
|
||||
mBar[1].r.y + mBar[1].r.height + 1,
|
||||
@ -952,52 +951,34 @@ void Meter::HandleLayout(wxDC &dc)
|
||||
case HorizontalStereoCompact:
|
||||
left = iSpacer;
|
||||
mIconPos = wxPoint(left, (height-iconHeight)/2);
|
||||
left += iconWidth + iSpacer;
|
||||
mMenuRect = wxRect(left, (height-menuHeight)/2, menuWidth, menuHeight);
|
||||
left += menuWidth + 2 * iSpacer;
|
||||
left += iconWidth + 2 *iSpacer;
|
||||
mLeftTextPos = wxPoint(left, (height)/4 - mLeftSize.y/2);
|
||||
mRightTextPos = wxPoint(left, (height*3)/4 - mLeftSize.y/2);
|
||||
left += intmax(mLeftSize.x, mRightSize.x) + iSpacer;
|
||||
|
||||
// The proportion to use for ruler is chosen to give a good ruler at
|
||||
// two tb height.
|
||||
rulerHeight = intmin( height*0.35, 24 );
|
||||
// Below 12 pixels height, the ruler is pointless.
|
||||
if( rulerHeight < 12 )
|
||||
rulerHeight = 0;
|
||||
rulerHeight = 0;
|
||||
width -= left;
|
||||
barw = width - 4;
|
||||
barh = (height-2-rulerHeight)/2;
|
||||
barw = width - 4 - menuWidth - 3* iSpacer;
|
||||
barh = (height-2)/2;
|
||||
mNumBars = 2;
|
||||
mBar[0].vert = false;
|
||||
ResetBar(&mBar[0], false);
|
||||
mBar[0].r = wxRect(left+2, 0, barw, barh);
|
||||
if (mClip) {
|
||||
mBar[0].rClip = mBar[0].r;
|
||||
mBar[0].rClip.x += mBar[0].rClip.width-3;
|
||||
mBar[0].rClip.width = 3;
|
||||
mBar[0].r.width -= 4;
|
||||
}
|
||||
mBar[1].vert = false;
|
||||
ResetBar(&mBar[1], false);
|
||||
mBar[1].r = wxRect(left+2, 2 + barh, barw, barh);
|
||||
if (mClip) {
|
||||
mBar[1].rClip = mBar[1].r;
|
||||
mBar[1].rClip.x += mBar[1].rClip.width-3;
|
||||
mBar[1].rClip.width = 3;
|
||||
mBar[1].r.width -= 4;
|
||||
}
|
||||
mRuler.SetOrientation(wxHORIZONTAL);
|
||||
mBar[0].r = wxRect(left, 0, barw, barh);
|
||||
SetBarClip( 0 );
|
||||
mBar[1].r = wxRect(left, 2 + barh, barw, barh);
|
||||
SetBarClip( 1 );
|
||||
|
||||
left += barw + 2* iSpacer;
|
||||
mMenuRect = wxRect(left, (height-menuHeight)/2, menuWidth, menuHeight);
|
||||
left += menuWidth + 2* iSpacer;
|
||||
|
||||
|
||||
mRuler.SetOrientation(wxHORIZONTAL);
|
||||
{
|
||||
int BarMid = (mBar[0].r.y + mBar[1].r.y + mBar[1].r.height ) / 2;
|
||||
const int RulerHeight = 24;
|
||||
const int TextDownBy = 2;
|
||||
mRuler.SetBounds(mBar[0].r.x,
|
||||
BarMid - RulerHeight / 2 +TextDownBy,
|
||||
BarMid +TextDownBy,
|
||||
mBar[1].r.x + mBar[1].r.width,
|
||||
BarMid + RulerHeight / 2 +TextDownBy);
|
||||
BarMid +TextDownBy);
|
||||
}
|
||||
if (mDB) {
|
||||
mRuler.SetRange(-mDBRange, 0);
|
||||
|
@ -203,7 +203,7 @@ class Meter : public wxPanel
|
||||
#endif
|
||||
void OnFloat(wxCommandEvent &evt);
|
||||
void OnPreferences(wxCommandEvent &evt);
|
||||
|
||||
void SetBarClip( int iBar );
|
||||
void DrawMeterBar(wxDC &dc, MeterBar *meterBar);
|
||||
void ResetBar(MeterBar *bar, bool resetClipping);
|
||||
void RepaintBarsNow();
|
||||
|
Loading…
x
Reference in New Issue
Block a user