Independent meters with combined menu/icon

Many other changes including:

1)  Independent preferences
2)  Automatic layout separated from vertical/horizontal orientation choices 
3)  Combined menu and icon which saves space
4)  Click to start monitoring label no longer covers peak hold line completely
5)  Click to start monitoring label now adjusts label based on available width
6)  Click to start monitoring label now appears on vertical meter (not sure about this one...)
7)  Reduced width of vertical meter by moving icon to left of meters
8)  Includes a compact vertical meter now
9)  Clipping indicator is easier to see
10) All 1-off drawing issues resolved (99.9% sure...I challenge you to find some ;-))
11) Bevels around meters are no longer overlaid by meter updates
12) "Old" menu handling code removed
13) Though not perfect since some non-English characters are taller/wider than the meters, non-English text is now handled better
14) Clicking play meter resets indicators as appropriate
15) Indicators on meters now stick around until the meter is clicked
16) Ugly flashing while resizing is now gone
17) There should be NO magic numbers in the code.  Every +1 or -2 is explained in comments...
18) Size of L/R labels are recalculated now when preferences are updated (to pull in locale changes)
This commit is contained in:
lllucius 2014-12-28 03:18:00 +00:00
parent 7c1535fdfd
commit 6a3ef5565c
7 changed files with 1035 additions and 825 deletions

40
images/MicMenu.xpm Normal file
View File

@ -0,0 +1,40 @@
/* XPM */
static const char * MicMenu_xpm[] = {
"24 19 18 1",
" c None",
". c #000000",
"+ c #DCDCDC",
"@ c #B5B5B5",
"# c #8C8C8C",
"$ c #D6D6D6",
"% c #9C9C9C",
"& c #6B6B6B",
"* c #EFEFEF",
"= c #C6C6C6",
"- c #737373",
"; c #4A4A4A",
"> c #DEDEDE",
", c #424242",
"' c #212121",
") c #ADADAD",
"! c #848484",
"~ c #636363",
" .... ",
" .+@+#. ",
" ..$+%+&. ",
" .+*.=+-+;. ",
" .>+*.%+,+. ",
" .+=+=.'+'. ",
" ..+)+;.... ",
" ..%+-+'.. ",
" .+..!~;.. ",
" .+....... ",
" .+... ",
" .+... ",
" .+... ",
" .+... ",
" .... .....",
" .... ",
" .. .....",
" . ... ",
". . "};

36
images/SpeakerMenu.xpm Normal file
View File

@ -0,0 +1,36 @@
/* XPM */
static const char * SpeakerMenu_xpm[] = {
"24 19 14 1",
" c None",
". c #C1C1C1",
"+ c #2F2F2F",
"@ c #707070",
"# c #4B4B4B",
"$ c #000000",
"% c #090909",
"& c #383838",
"* c #838383",
"= c #7A7A7A",
"- c #414141",
"; c #8C8C8C",
"> c #131313",
", c #676767",
" ",
" ",
" . ",
" + ",
" @ #@ ",
" $ % ",
" &$ & *& ",
" ===$$ -= $ ",
" $$$$$ $ $ ",
" $$$$$ $ $ ",
" &&&$$ *& $ ",
" $$ % $ ",
" @$ @ #@ ",
" + ;+ ",
" . >. $$$$$",
" , ",
" $$$$$",
" $$$ ",
" $ "};

View File

@ -44,7 +44,6 @@ IMPLEMENT_CLASS(MeterToolBar, ToolBar);
BEGIN_EVENT_TABLE( MeterToolBar, ToolBar )
EVT_SIZE( MeterToolBar::OnSize )
EVT_COMMAND(wxID_ANY, EVT_METER_PREFERENCES_CHANGED, MeterToolBar::OnMeterPrefsUpdated)
END_EVENT_TABLE()
//Standard contructor
@ -127,9 +126,16 @@ void MeterToolBar::Populate()
void MeterToolBar::UpdatePrefs()
{
if( mPlayMeter )
{
mPlayMeter->UpdatePrefs();
mPlayMeter->Refresh();
}
if( mRecordMeter )
{
mRecordMeter->UpdatePrefs();
mRecordMeter->Refresh();
}
RegenerateTooltips();
@ -150,13 +156,9 @@ void MeterToolBar::RegenerateTooltips()
#endif
}
void MeterToolBar::OnMeterPrefsUpdated(wxCommandEvent & WXUNUSED(evt))
{
UpdatePrefs();
}
void MeterToolBar::OnSize( wxSizeEvent & WXUNUSED(event) )
void MeterToolBar::OnSize( wxSizeEvent & event) //WXUNUSED(event) )
{
event.Skip();
int width, height;
// We can be resized before populating...protect against it
@ -192,20 +194,10 @@ void MeterToolBar::OnSize( wxSizeEvent & WXUNUSED(event) )
}
if( mRecordMeter ) {
mRecordMeter->SetStyle(bHorizontal ? Meter::HorizontalStereo : Meter::VerticalStereo);
mRecordMeter->SetMinSize( wxSize( width, height ));
Meter *play = mProject->GetPlaybackMeter();
if( play ) {
play->SetStyle(bHorizontal ? Meter::HorizontalStereo : Meter::VerticalStereo);
}
}
if( mPlayMeter ) {
mPlayMeter->SetStyle(bHorizontal ? Meter::HorizontalStereo : Meter::VerticalStereo);
mPlayMeter->SetMinSize( wxSize( width, height ));
Meter *record = mProject->GetCaptureMeter();
if( record ) {
record->SetStyle(bHorizontal ? Meter::HorizontalStereo : Meter::VerticalStereo);
}
mSizer->SetItemPosition( mPlayMeter, pos );
}
@ -220,18 +212,10 @@ bool MeterToolBar::Expose( bool show )
Meter *meter;
if( mPlayMeter ) {
mProject->SetPlaybackMeter( mPlayMeter );
meter = mProject->GetCaptureMeter();
if( meter ) {
meter->SetStyle( mPlayMeter->GetStyle() );
}
}
if( mRecordMeter ) {
mProject->SetCaptureMeter( mRecordMeter );
meter = mProject->GetPlaybackMeter();
if( meter ) {
meter->SetStyle( mRecordMeter->GetStyle() );
}
}
} else {
if( mPlayMeter && mProject->GetPlaybackMeter() == mPlayMeter ) {

View File

@ -48,11 +48,10 @@ class MeterToolBar:public ToolBar {
int GetInitialWidth() {return (mWhichMeters ==
(kWithRecordMeter + kWithPlayMeter)) ? 338 : 460;} // Separate bars used to be smaller.
int GetMinToolbarWidth() { return 100; }
int GetMinToolbarWidth() { return 50; }
wxSize GetDockedSize();
private:
void OnMeterPrefsUpdated(wxCommandEvent & evt);
void RegenerateTooltips();
AudacityProject *mProject;

View File

@ -387,7 +387,7 @@ bool ToolBar::Expose( bool show )
bool was = mVisible;
SetVisible( show );
if( IsDocked() )
{
Show( show );

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,8 @@ const int kMaxMeterBars = 2;
struct MeterBar {
bool vert;
wxRect r;
wxRect b; // Bevel around bar
wxRect r; // True bar drawing area
float peak;
float rms;
float peakHold;
@ -92,13 +93,12 @@ class Meter : public wxPanel
// These should be kept in the same order as they appear
// in the menu
enum Style {
AutomaticStereo,
HorizontalStereo,
VerticalStereo,
VerticalMulti,
Equalizer,
Waveform,
MixerTrackCluster, // Doesn't show menu, icon, or L/R labels, but otherwise like VerticalStereo.
HorizontalStereoCompact // Thinner.
HorizontalStereoCompact, // Thinner.
VerticalStereoCompact, // Narrower.
};
@ -115,7 +115,8 @@ class Meter : public wxPanel
void UpdatePrefs();
void Clear();
Style GetStyle() { return mStyle; }
Style GetStyle() const { return mStyle; }
Style GetDesiredStyle() const { return mDesiredStyle; }
void SetStyle(Style newStyle);
/** \brief
@ -149,6 +150,7 @@ class Meter : public wxPanel
*/
void UpdateDisplay(int numChannels,
int numFrames, float *sampleData);
// Vaughan, 2010-11-29: This not currently used. See comments in MixerTrackCluster::UpdateMeter().
//void UpdateDisplay(int numChannels, int numFrames,
// // Need to make these double-indexed max and min arrays if we handle more than 2 channels.
@ -161,13 +163,11 @@ class Meter : public wxPanel
* This method is thread-safe! Feel free to call from a
* different thread (like from an audio I/O callback).
*/
bool IsMeterDisabled();
bool IsMeterDisabled() const;
float GetMaxPeak();
float GetMaxPeak() const;
double ToLinearIfDB(double value);
bool IsClipping();
bool IsClipping() const;
void StartMonitoring();
@ -184,34 +184,23 @@ class Meter : public wxPanel
void OnMeterUpdate(wxTimerEvent &evt);
void HandlePaint(wxDC &dc);
void HandleLayout(wxDC &dc);
void SetActiveStyle(Style style);
void SetBarAndClip(int iBar, bool vert);
void DrawMeterBar(wxDC &dc, MeterBar *meterBar);
void ResetBar(MeterBar *bar, bool resetClipping);
void RepaintBarsNow();
wxFont GetFont() const;
//
// Pop-up menu handlers
//
void OnDisableMeter(wxCommandEvent &evt);
void OnHorizontal(wxCommandEvent &evt);
void OnVertical(wxCommandEvent &evt);
void OnMulti(wxCommandEvent &evt);
void OnEqualizer(wxCommandEvent &evt);
void OnWaveform(wxCommandEvent &evt);
void OnLinear(wxCommandEvent &evt);
void OnDB(wxCommandEvent &evt);
void OnClip(wxCommandEvent &evt);
void OnMonitor(wxCommandEvent &evt);
#ifdef AUTOMATED_INPUT_LEVEL_ADJUSTMENT
void OnAutomatedInputLevelAdjustment(wxCommandEvent &evt);
#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();
void CreateIcon(int aquaOffset);
wxFont GetFont();
void OnMeterPrefsUpdated(wxCommandEvent &evt);
wxString Key(const wxString & key) const;
AudacityProject *mProject;
MeterUpdateQueue mQueue;
@ -220,9 +209,13 @@ class Meter : public wxPanel
int mWidth;
int mHeight;
int mRulerWidth;
int mRulerHeight;
bool mIsInput;
Style mStyle, mSavedStyle;
Style mStyle;
Style mDesiredStyle;
bool mGradient;
bool mDB;
int mDBRange;
@ -246,8 +239,7 @@ class Meter : public wxPanel
bool mLayoutValid;
wxBitmap *mBitmap;
wxRect mMenuRect;
wxPoint mIconPos;
wxRect mIconRect;
wxPoint mLeftTextPos;
wxPoint mRightTextPos;
wxSize mLeftSize;
@ -261,7 +253,6 @@ class Meter : public wxPanel
wxBrush mClipBrush;
wxBrush mBkgndBrush;
wxBrush mDisabledBkgndBrush;
wxRect mAllBarsRect;
Ruler mRuler;
wxString mLeftText;
wxString mRightText;