From 8d517bd3bd01ec592f26c90973eab4025bc1cc67 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 6 Jun 2017 21:47:13 -0400 Subject: [PATCH 1/4] EXPERIMENTAL_MIDI_OUT off -- then no invisible channel buttons... ... They were still clickable before this commit. --- src/TrackPanel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 2f1e8e19b..23fca60d7 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -5253,9 +5253,11 @@ const TCPLine waveTrackTCPLines[] = { const TCPLine noteTrackTCPLines[] = { COMMON_ITEMS(0) +#ifdef EXPERIMENTAL_MIDI_OUT MUTE_SOLO_ITEMS(0) { kItemMidiControlsRect, kMidiCellHeight * 4, 0 }, { kItemVelocity, kTrackInfoSliderHeight, 5 }, +#endif { 0, 0, 0 } }; @@ -5375,7 +5377,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 +5389,7 @@ void TrackPanel::HandleLabelClick(wxMouseEvent & event) Refresh(false); return; } +#endif } #endif // USE_MIDI From 0204cd80c5b95983539a7007125e0279c675e4ce Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 6 Jun 2017 21:19:57 -0400 Subject: [PATCH 2/4] Make gain slider again visible in default sized WaveTrack --- src/TrackPanel.cpp | 13 +++++++------ src/TrackPanel.h | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 23fca60d7..2f16148a2 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -5308,12 +5308,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; } } @@ -5521,7 +5522,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; @@ -5538,7 +5539,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; @@ -9748,11 +9749,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); } diff --git a/src/TrackPanel.h b/src/TrackPanel.h index a8244299d..7d2bcb7e7 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -919,6 +919,7 @@ enum : int { kTrackInfoBtnSize = 18, // widely used dimension, usually height kTrackInfoSliderHeight = 25, kTrackInfoSliderWidth = 84, + kTrackInfoSliderAllowance = 5, }; #ifdef USE_MIDI From f0c149b89058922d58bf3b3bb7b9d925c1b019a9 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 6 Jun 2017 21:40:58 -0400 Subject: [PATCH 3/4] Default MIDI track height is enough to display velocity slider... ... It is computed from the layout table, and in fact comes to 158 pixels, versus 150 for other tracks. --- src/NoteTrack.cpp | 4 ++++ src/Track.cpp | 2 +- src/Track.h | 2 ++ src/TrackPanel.cpp | 34 ++++++++++++++++++++++++++++------ src/TrackPanel.h | 3 +++ 5 files changed, 38 insertions(+), 7 deletions(-) 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 2f16148a2..c44dfd721 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -5246,8 +5246,8 @@ 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 } }; @@ -5256,11 +5256,21 @@ const TCPLine noteTrackTCPLines[] = { #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 @@ -5557,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; @@ -9762,13 +9772,25 @@ 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 ); +} + LWSlider * TrackInfo::GainSlider(WaveTrack *t, bool captured) const { wxPoint topLeft{ diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 7d2bcb7e7..5c8544d01 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -118,6 +118,8 @@ private: #endif public: + static unsigned DefaultNoteTrackHeight(); + LWSlider * GainSlider(WaveTrack *t, bool captured = false) const; LWSlider * PanSlider(WaveTrack *t, bool captured = false) const; @@ -920,6 +922,7 @@ enum : int { kTrackInfoSliderHeight = 25, kTrackInfoSliderWidth = 84, kTrackInfoSliderAllowance = 5, + kTrackInfoSliderExtra = 5, }; #ifdef USE_MIDI From 84b5fd6075f3b2f98390b37c73c7490130960d53 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 6 Jun 2017 22:37:24 -0400 Subject: [PATCH 4/4] Compute default WaveTrack height analogously to NoteTrack... ... though in fact this comes to the same 150 pixels as before, given the present layout table. --- src/TrackPanel.cpp | 10 ++++++++++ src/TrackPanel.h | 1 + src/WaveTrack.cpp | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index c44dfd721..c32a756e1 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -9791,6 +9791,16 @@ unsigned TrackInfo::DefaultNoteTrackHeight() 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 5c8544d01..18420d8be 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -119,6 +119,7 @@ private: public: static unsigned DefaultNoteTrackHeight(); + static unsigned DefaultWaveTrackHeight(); LWSlider * GainSlider(WaveTrack *t, bool captured = false) const; LWSlider * PanSlider(WaveTrack *t, bool captured = false) const; 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):