diff --git a/src/NoteTrack.cpp b/src/NoteTrack.cpp index 0b461ecd8..ac5cf8129 100644 --- a/src/NoteTrack.cpp +++ b/src/NoteTrack.cpp @@ -36,6 +36,8 @@ #include "InconsistencyException.h" +#include "TrackPanel.h" // For TrackInfo + #ifdef SONIFY #include "../lib-src/portmidi/pm_common/portmidi.h" @@ -110,6 +112,8 @@ NoteTrack::NoteTrack(const std::shared_ptr &projDirManager) SetDefaultName(_("Note Track")); SetName(GetDefaultName()); + SetHeight( TrackInfo::DefaultNoteTrackHeight() ); + mSeq = NULL; mSerializationLength = 0; diff --git a/src/Track.cpp b/src/Track.cpp index c8424e508..406795387 100644 --- a/src/Track.cpp +++ b/src/Track.cpp @@ -52,7 +52,7 @@ Track::Track(const std::shared_ptr &projDirManager) mLinked = false; mY = 0; - mHeight = 150; + mHeight = DefaultHeight; mIndex = 0; #ifdef EXPERIMENTAL_OUTPUT_DISPLAY mYv = mHeight; diff --git a/src/Track.h b/src/Track.h index da9614f32..8bb36a51b 100644 --- a/src/Track.h +++ b/src/Track.h @@ -167,6 +167,8 @@ class AUDACITY_DLL_API Track /* not final */ : public XMLTagHandler All }; + enum : unsigned { DefaultHeight = 150 }; + Track(const std::shared_ptr &projDirManager); Track(const Track &orig); diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 2f1e8e19b..c32a756e1 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -5246,19 +5246,31 @@ const TCPLine waveTrackTCPLines[] = { COMMON_ITEMS(2) STATUS_ITEMS MUTE_SOLO_ITEMS(2) - { kItemGain, kTrackInfoSliderHeight, 5 }, - { kItemPan, kTrackInfoSliderHeight, 5 }, + { kItemGain, kTrackInfoSliderHeight, kTrackInfoSliderExtra }, + { kItemPan, kTrackInfoSliderHeight, kTrackInfoSliderExtra }, { 0, 0, 0 } }; const TCPLine noteTrackTCPLines[] = { COMMON_ITEMS(0) +#ifdef EXPERIMENTAL_MIDI_OUT MUTE_SOLO_ITEMS(0) { kItemMidiControlsRect, kMidiCellHeight * 4, 0 }, - { kItemVelocity, kTrackInfoSliderHeight, 5 }, + { kItemVelocity, kTrackInfoSliderHeight, kTrackInfoSliderExtra }, +#endif { 0, 0, 0 } }; +int totalTCPLines( const TCPLine *pLines ) +{ + int total = 0; + while ( pLines->items ) { + total += pLines->height + pLines->extraSpace; + ++pLines; + } + return total; +} + const TCPLine *getTCPLines( const Track &track ) { #ifdef USE_MIDI @@ -5306,12 +5318,13 @@ std::pair< int, int > CalcBottomItemY return { y - (pLines->height + pLines->extraSpace ), pLines->height }; } -bool HideTopItem( const wxRect &rect, const wxRect &subRect ) { +bool HideTopItem( const wxRect &rect, const wxRect &subRect, + int allowance = 0 ) { auto limit = CalcBottomItemY ( commonTrackTCPBottomLines, kHighestBottomItem, rect.height).first; // Return true if the rectangle is even touching the limit // without an overlap. That was the behavior as of 2.1.3. - return subRect.y + subRect.height >= rect.y + limit; + return subRect.y + subRect.height - allowance >= rect.y + limit; } } @@ -5375,7 +5388,6 @@ void TrackPanel::HandleLabelClick(wxMouseEvent & event) if (isleft && VelocityFunc(t, rect, event, event.m_x, event.m_y)) return; -#endif wxRect midiRect; mTrackInfo.GetMidiControlsRect(rect, midiRect); @@ -5388,6 +5400,7 @@ void TrackPanel::HandleLabelClick(wxMouseEvent & event) Refresh(false); return; } +#endif } #endif // USE_MIDI @@ -5519,7 +5532,7 @@ bool TrackPanel::GainFunc(Track * t, wxRect rect, wxMouseEvent &event, { wxRect sliderRect; mTrackInfo.GetGainRect(rect.GetTopLeft(), sliderRect); - if ( HideTopItem( rect, sliderRect ) ) + if ( HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) ) return false; if (!sliderRect.Contains(x, y)) return false; @@ -5536,7 +5549,7 @@ bool TrackPanel::PanFunc(Track * t, wxRect rect, wxMouseEvent &event, { wxRect sliderRect; mTrackInfo.GetPanRect(rect.GetTopLeft(), sliderRect); - if ( HideTopItem( rect, sliderRect ) ) + if ( HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) ) return false; if (!sliderRect.Contains(x, y)) return false; @@ -5554,7 +5567,7 @@ bool TrackPanel::VelocityFunc(Track * t, wxRect rect, wxMouseEvent &event, { wxRect sliderRect; mTrackInfo.GetVelocityRect(rect.GetTopLeft(), sliderRect); - if ( HideTopItem( rect, sliderRect ) ) + if ( HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) ) return false; if (!sliderRect.Contains(x, y)) return false; @@ -9746,11 +9759,11 @@ void TrackInfo::DrawSliders(wxDC *dc, WaveTrack *t, wxRect rect, bool captured) wxRect sliderRect; GetGainRect(rect.GetTopLeft(), sliderRect); - if ( !HideTopItem( rect, sliderRect ) ) + if ( !HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) ) GainSlider(t, captured)->OnPaint(*dc); GetPanRect(rect.GetTopLeft(), sliderRect); - if ( !HideTopItem( rect, sliderRect ) ) + if ( !HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) ) PanSlider(t, captured)->OnPaint(*dc); } @@ -9759,13 +9772,35 @@ void TrackInfo::DrawVelocitySlider(wxDC *dc, NoteTrack *t, wxRect rect, bool cap { wxRect sliderRect; - GetVelocityRect(rect.GetTopLeft(), sliderRect); - if ( !HideTopItem( rect, sliderRect ) ) { + GetVelocityRect( rect.GetTopLeft(), sliderRect ); + if ( !HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) ) { VelocitySlider(t, captured)->OnPaint(*dc); } } #endif +unsigned TrackInfo::DefaultNoteTrackHeight() +{ + // Just high enough that the velocity slider is just above the Minimize + // button, as for default sized Wave track + int needed = + kTopMargin + kBottomMargin + + totalTCPLines( noteTrackTCPLines ) + + totalTCPLines( commonTrackTCPBottomLines ) - + kTrackInfoSliderExtra; + return (unsigned) std::max( needed, (int) Track::DefaultHeight ); +} + +unsigned TrackInfo::DefaultWaveTrackHeight() +{ + int needed = + kTopMargin + kBottomMargin + + totalTCPLines( waveTrackTCPLines ) + + totalTCPLines( commonTrackTCPBottomLines ) - + kTrackInfoSliderExtra; + return (unsigned) std::max( needed, (int) Track::DefaultHeight ); +} + LWSlider * TrackInfo::GainSlider(WaveTrack *t, bool captured) const { wxPoint topLeft{ diff --git a/src/TrackPanel.h b/src/TrackPanel.h index a8244299d..18420d8be 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -118,6 +118,9 @@ private: #endif public: + static unsigned DefaultNoteTrackHeight(); + static unsigned DefaultWaveTrackHeight(); + LWSlider * GainSlider(WaveTrack *t, bool captured = false) const; LWSlider * PanSlider(WaveTrack *t, bool captured = false) const; @@ -919,6 +922,8 @@ enum : int { kTrackInfoBtnSize = 18, // widely used dimension, usually height kTrackInfoSliderHeight = 25, kTrackInfoSliderWidth = 84, + kTrackInfoSliderAllowance = 5, + kTrackInfoSliderExtra = 5, }; #ifdef USE_MIDI diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 9de1ffaa2..a65baa86b 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -59,6 +59,8 @@ Track classes. #include "Experimental.h" +#include "TrackPanel.h" // for TrackInfo + using std::max; #ifdef EXPERIMENTAL_OUTPUT_DISPLAY @@ -113,6 +115,8 @@ WaveTrack::WaveTrack(const std::shared_ptr &projDirManager, sampleFo mLastScaleType = -1; mLastdBRange = -1; mAutoSaveIdent = 0; + + SetHeight( TrackInfo::DefaultWaveTrackHeight() ); } WaveTrack::WaveTrack(const WaveTrack &orig):