1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-05 06:39:26 +02:00

Added Space-Saver meters. These are now the default.

Fixed ResetToolbars so that SpectralSelectionBar is not shown after a reset.
This commit is contained in:
james.k.crook@gmail.com 2014-11-09 15:47:09 +00:00
parent 0880d1777a
commit 7ee3c47441
9 changed files with 126 additions and 22 deletions

View File

@ -92,7 +92,7 @@ void MeterToolBar::Populate()
wxID_ANY,
true,
wxDefaultPosition,
wxSize( 260, 55 ) );
wxSize( 260, 28 ) );
/* i18n-hint: (noun) The meter that shows the loudness of the audio being recorded.*/
mRecordMeter->SetName( _("Record Meter"));
/* i18n-hint: (noun) The meter that shows the loudness of the audio being recorded.
@ -107,14 +107,14 @@ void MeterToolBar::Populate()
wxID_ANY,
false,
wxDefaultPosition,
wxSize( 260, 55 ) );
wxSize( 260, 28 ) );
/* i18n-hint: (noun) The meter that shows the loudness of the audio playing.*/
mPlayMeter->SetName( _("Play Meter"));
/* i18n-hint: (noun) The meter that shows the loudness of the audio playing.
This is the name used in screen reader software, where having 'Meter' first
apparently is helpful to partially sighted people. */
mPlayMeter->SetLabel( _("Meter-Play"));
mSizer->Add( mPlayMeter, wxGBPosition( 0, 1 ), wxDefaultSpan, wxEXPAND );
mSizer->Add( mPlayMeter, wxGBPosition( (mWhichMeters & kWithRecordMeter)?1:0, 0 ), wxDefaultSpan, wxEXPAND );
}
if( IsVisible() )
MeterToolBars::AddMeters( mPlayMeter, mRecordMeter );
@ -220,7 +220,20 @@ bool MeterToolBar::Expose( bool show )
return ToolBar::Expose( show );
}
wxSize MeterToolBar::GetDockedSize()
{
const int tbs = toolbarSingle + toolbarGap;
wxSize sz = GetSize();
wxSize sz2 = GetMinSize();
sz.x = wxMax( sz.x, sz2.x );
sz.y = wxMax( sz.y, sz2.y );
// 50 is the size where we switch from expanded to compact.
if( sz.y < 55 )
sz.y = tbs-1;
else
sz.y = 2 * tbs -1;
return sz;
}
// Locally defined - we can change implementation easily later.
namespace MeterToolBars {

View File

@ -49,6 +49,7 @@ class MeterToolBar:public ToolBar {
int GetInitialWidth() {return (mWhichMeters ==
(kWithRecordMeter + kWithPlayMeter)) ? 338 : 460;} // Separate bars used to be smaller.
int GetMinToolbarWidth() { return 100; }
wxSize GetDockedSize();
private:
void OnMeterPrefsUpdated(wxCommandEvent & evt);

View File

@ -273,13 +273,17 @@ void ToolBar::ReCreateButtons()
// Recalculate the height to be a multiple of toolbarSingle
const int tbs = toolbarSingle + toolbarGap;
wxSize sz = GetSize();
sz.y = ( ( ( sz.y + tbs ) / tbs ) * tbs ) - 1;
sz.y = ( ( ( sz.y + tbs -1) / tbs ) * tbs ) - 1;
// Set the true AND minimum sizes and do final layout
if(IsResizable())
{
sz.SetWidth(GetMinToolbarWidth());
SetMinSize(sz);
// JKC we're going to allow all resizable toolbars to be resized
// to 1 unit high!
wxSize sz2 = sz;
sz2.y = tbs -1;
SetMinSize(sz2);
sz.SetWidth(GetInitialWidth());
SetSize(sz);
}

View File

@ -63,12 +63,12 @@ enum
NoBarID = -1,
TransportBarID,
ToolsBarID,
MixerBarID,
TranscriptionBarID,
EditBarID,
MeterBarID,
RecordMeterBarID,
PlayMeterBarID,
MixerBarID,
EditBarID,
TranscriptionBarID,
DeviceBarID,
SelectionBarID,
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
@ -110,10 +110,10 @@ class ToolBar:public wxPanel
void SetVisible( bool bVisible );
void SetPositioned(){ mPositioned = true;};
/// Resizable toolbars should implement this.
virtual int GetInitialWidth() {return -1;}
virtual int GetMinToolbarWidth() {return GetInitialWidth();}
virtual wxSize GetDockedSize(){ return GetMinSize();}
protected:
AButton *MakeButton(teBmps eUp,

View File

@ -130,7 +130,7 @@ void ToolDock::Dock( ToolBar *bar, int before )
mBars[ bar->GetId() ] = bar;
// Reset height
bar->SetSize( bar->GetSize().x, bar->GetMinSize().y );
bar->SetSize( bar->GetSize().x, bar->GetDockedSize().y );
// Park the new bar in the correct berth
if( before >= 0 && before < (int)mDockedBars.GetCount() )
@ -264,6 +264,7 @@ void ToolDock::LayoutToolBars()
//
// Determine the location and bar before which a new bar would be placed
//
// 'rect' will be the rectangle for the dock marker.
int ToolDock::PositionBar( ToolBar *t, wxPoint & pos, wxRect & rect )
{
struct
@ -306,7 +307,7 @@ int ToolDock::PositionBar( ToolBar *t, wxPoint & pos, wxRect & rect )
{
// Add the new bars' dimensions to the mix
tinfo[ct].rect = t->GetRect();
tinfo[ct].min = t->GetMinSize();
tinfo[ct].min = t->GetDockedSize();
tindx = ct;
}
}
@ -336,7 +337,7 @@ int ToolDock::PositionBar( ToolBar *t, wxPoint & pos, wxRect & rect )
{
// Add the new bars' dimensions to the mix
tinfo[ct].rect = t->GetRect();
tinfo[ct].min = t->GetMinSize();
tinfo[ct].min = t->GetDockedSize();
tindx = ct;
ndx--;
}

View File

@ -130,7 +130,7 @@ class ToolFrame:public wxFrame
width += sizerW;
}
SetSize( width + 2, bar->GetMinSize().y + 2 );
SetSize( width + 2, bar->GetDockedSize().y + 2 );
// Attach the sizer and resize the window to fit
SetSizer( s );
@ -490,18 +490,18 @@ void ToolManager::Reset()
floater = bar->GetParent();
}
if (ndx == SelectionBarID
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|| ndx == SpectralSelectionBarID
#endif
)
if (ndx == SelectionBarID )
{
dock = mBotDock;
wxCommandEvent e;
bar->GetEventHandler()->ProcessEvent(e);
}
else if( ndx == MeterBarID )
else if( ndx == MeterBarID
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|| ndx == SpectralSelectionBarID
#endif
)
{
dock = NULL;
}
@ -650,6 +650,13 @@ void ToolManager::ReadConfig()
bar->Create( mBotDock );
}
// Set the width and height
if( width[ ndx ] != -1 && height[ ndx ] != -1 )
{
wxSize sz( width[ ndx ], height[ ndx ] );
bar->SetSize( sz );
}
#ifdef EXPERIMENTAL_SYNC_LOCK
// Set the width
if( width[ ndx ] >= bar->GetSize().x )

View File

@ -351,6 +351,7 @@ void Meter::UpdatePrefs()
mStyle = gPrefs->Read(wxT("/Meter/MeterStyle"), wxT("HorizontalStereo")) == wxT("HorizontalStereo") ?
HorizontalStereo :
VerticalStereo;
mGradient = gPrefs->Read(wxT("/Meter/MeterBars"), wxT("Gradient")) == wxT("Gradient");
mDB = gPrefs->Read(wxT("/Meter/MeterType"), wxT("dB")) == wxT("dB");
@ -820,12 +821,20 @@ void Meter::HandleLayout(wxDC &dc)
int left = 0, top = 0;
int right, bottom;
int barw, barh;
int rulerHeight;
int i;
mRuler.SetFlip(true);
mRuler.SetLabelEdges(true);
switch(mStyle) {
// How many pixels between items?
const int iSpacer = 2;
Meter::Style AdjustedMeterStyle = mStyle;
if( (mStyle == HorizontalStereo) && (height < 50 ) )
AdjustedMeterStyle = HorizontalStereoCompact;
switch(AdjustedMeterStyle) {
default:
wxPrintf(wxT("Style not handled yet!\n"));
break;
@ -940,6 +949,66 @@ void Meter::HandleLayout(wxDC &dc)
}
mRuler.OfflimitsPixels(0, mMenuRect.x+mMenuRect.width-4);
break;
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;
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;
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);
{
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,
mBar[1].r.x + mBar[1].r.width,
BarMid + RulerHeight / 2 +TextDownBy);
}
if (mDB) {
mRuler.SetRange(-mDBRange, 0);
mRuler.SetFormat(Ruler::LinearDBFormat);
}
else {
mRuler.SetRange(0, 1);
mRuler.SetFormat(Ruler::RealFormat);
}
mRuler.OfflimitsPixels(0,0);
break;
case Waveform:
mNumBars = 0;
break;
@ -1118,6 +1187,9 @@ void Meter::HandlePaint(wxDC &destDC)
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);
}
}
@ -1139,6 +1211,9 @@ void Meter::RepaintBarsNow()
{
DrawMeterBar(*dc, &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(*dc);
}
}

View File

@ -97,7 +97,8 @@ class Meter : public wxPanel
VerticalMulti,
Equalizer,
Waveform,
MixerTrackCluster // Doesn't show menu, icon, or L/R labels, but otherwise like VerticalStereo.
MixerTrackCluster, // Doesn't show menu, icon, or L/R labels, but otherwise like VerticalStereo.
HorizontalStereoCompact // Thinner.
};

View File

@ -294,6 +294,8 @@ void Ruler::OfflimitsPixels(int start, int end)
mLength = mRight-mLeft;
else
mLength = mBottom-mTop;
if( mLength < 0 )
return;
mUserBits = new int[mLength+1];
for(i=0; i<=mLength; i++)
mUserBits[i] = 0;