From f0c149b89058922d58bf3b3bb7b9d925c1b019a9 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 6 Jun 2017 21:40:58 -0400 Subject: [PATCH] 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