From 8279adc7979dfdc48ec209b1d85fe68425bba268 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 19 Jul 2017 14:44:42 -0400 Subject: [PATCH] Changing NoteTrack height, keep # of piano keys (roughly) constant... This fix is imperfect, but quick and easy --- src/NoteTrack.cpp | 12 ++++++++++++ src/NoteTrack.h | 2 ++ src/Track.h | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/NoteTrack.cpp b/src/NoteTrack.cpp index 5aeb2447f..8e2d1052b 100644 --- a/src/NoteTrack.cpp +++ b/src/NoteTrack.cpp @@ -210,6 +210,18 @@ double NoteTrack::GetEndTime() const return GetStartTime() + GetSeq().get_real_dur(); } +void NoteTrack::SetHeight(int h) +{ + auto oldHeight = GetHeight(); + Track::SetHeight(h); + Zoom( + wxRect{ 0, 0, 1, h }, // only height matters + h - 1, // preserve bottom note + (float)h / std::max(1, oldHeight), + false + ); +} + void NoteTrack::WarpAndTransposeNotes(double t0, double t1, const TimeWarper &warper, diff --git a/src/NoteTrack.h b/src/NoteTrack.h index 9a50fc9c7..090a71f14 100644 --- a/src/NoteTrack.h +++ b/src/NoteTrack.h @@ -84,6 +84,8 @@ class AUDACITY_DLL_API NoteTrack final double GetStartTime() const override; double GetEndTime() const override; + void SetHeight(int h) override; + Alg_seq &GetSeq() const; void WarpAndTransposeNotes(double t0, double t1, diff --git a/src/Track.h b/src/Track.h index 9cee366f4..f8459db35 100644 --- a/src/Track.h +++ b/src/Track.h @@ -184,7 +184,7 @@ class AUDACITY_DLL_API Track /* not final */ int GetY() const; void SetY(int y); int GetHeight() const; - void SetHeight(int h); + virtual void SetHeight(int h); #endif bool GetMinimized() const; void SetMinimized(bool isMinimized);