1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-24 16:01:16 +02:00

NoteTrack, extreme vertical zoom-in: limit top & bottom margin height

This commit is contained in:
Paul Licameli 2017-07-19 11:28:14 -04:00
parent 60405eb7fe
commit d256bfedd2
2 changed files with 7 additions and 6 deletions

View File

@ -133,13 +133,14 @@ class AUDACITY_DLL_API NoteTrack final
/// If center is true, the result will be centered at y.
void Zoom(const wxRect &rect, int y, int amount, bool center);
void ZoomTo(const wxRect &rect, int start, int end);
int GetNoteMargin() const { return (mPitchHeight + 1) / 2; }
int GetNoteMargin(int height) const
{ return std::min(height / 3, (mPitchHeight + 1) / 2); }
int GetOctaveHeight() const { return mPitchHeight * 12 + 2; }
// call this once before a series of calls to IPitchToY(). It
// sets mBottom to offset of octave 0 so that mBottomNote
// is located at r.y + r.height - (GetNoteMargin() + 1 + mPitchHeight)
void PrepareIPitchToY(const wxRect &r) const {
mBottom = r.y + r.height - GetNoteMargin() - 1 - mPitchHeight +
mBottom = r.y + r.height - GetNoteMargin(r.height) - 1 - mPitchHeight +
(mBottomNote / 12) * GetOctaveHeight() +
GetNotePos(mBottomNote % 12);
}

View File

@ -619,7 +619,7 @@ void TrackArtist::DrawVRuler
int octave = 0;
int obottom = track->GetOctaveBottom(octave);
int marg = track->GetNoteMargin();
int marg = track->GetNoteMargin(rect.height);
//IPITCH_TO_Y(octave * 12) + PITCH_HEIGHT + 1;
while (obottom >= rect.y) {
dc->SetPen(*wxBLACK_PEN);
@ -2826,9 +2826,9 @@ void TrackArtist::DrawNoteBackground(const NoteTrack *track, wxDC &dc,
// eOffset is for the line between E and F; there's another line
// between B and C, hence the offset of 2 for two line thicknesses
int eOffset = track->GetPitchHeight() * 5 + 2;
while (obottom > rect.y + track->GetNoteMargin() + 3) {
while (obottom > rect.y + track->GetNoteMargin(rect.height) + 3) {
// draw a black line separating octaves if this octave botton is visible
if (obottom < rect.y + rect.height - track->GetNoteMargin()) {
if (obottom < rect.y + rect.height - track->GetNoteMargin(rect.height)) {
dc.SetPen(*wxBLACK_PEN);
// obottom - 1 because obottom is at the bottom of the line
AColor::Line(dc, left, obottom - 1, right, obottom - 1);
@ -2970,7 +2970,7 @@ void TrackArtist::DrawNoteTrack(const NoteTrack *track,
selectedBarLinePen);
SonifyEndNoteBackground();
SonifyBeginNoteForeground();
int marg = track->GetNoteMargin();
int marg = track->GetNoteMargin(rect.height);
// NOTE: it would be better to put this in some global initialization
// function rather than do lookups every time.