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

Bug1156, fix inconsistencies in mapping pixel heights to track vertical scales

This commit is contained in:
Paul Licameli 2015-08-21 11:04:30 -04:00
parent 49ff3ae78f
commit bc5aed7465
3 changed files with 38 additions and 35 deletions

View File

@ -241,10 +241,14 @@ public:
case nstErb:
case nstUndertone:
return Iterator
(mType, (mValue1 - mValue0) / nPositions, mValue0, mUnit);
(mType,
nPositions == 1 ? 0 : (mValue1 - mValue0) / (nPositions - 1),
mValue0, mUnit);
case nstLogarithmic:
return Iterator
(mType, exp((mValue1 - mValue0) / nPositions), exp(mValue0), mUnit);
(mType,
nPositions == 1 ? 1 : exp((mValue1 - mValue0) / (nPositions - 1)),
exp(mValue0), mUnit);
}
}

View File

@ -571,8 +571,8 @@ void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & rect)
bev.height--;
dc->DrawRectangle(bev);
rect.y += 2;
rect.height -= 2;
rect.y += 1;
rect.height -= 1;
//int bottom = GetBottom((NoteTrack *) t, rect);
NoteTrack *track = (NoteTrack *) t;
@ -671,7 +671,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
min = tt->GetRangeLower() * 100.0;
max = tt->GetRangeUpper() * 100.0;
vruler->SetBounds(rect.x, rect.y+1, rect.x + rect.width, rect.y + rect.height-1);
vruler->SetBounds(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height-1);
vruler->SetOrientation(wxVERTICAL);
vruler->SetRange(max, min);
vruler->SetFormat((tt->GetDisplayLog()) ? Ruler::RealLogFormat : Ruler::RealFormat);
@ -720,7 +720,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
wt->SetDisplayBounds(min, max);
}
vruler->SetBounds(rect.x, rect.y + 1, rect.x + rect.width, rect.y + rect.height - 1);
vruler->SetBounds(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height - 1);
vruler->SetOrientation(wxVERTICAL);
vruler->SetRange(max, min);
vruler->SetFormat(Ruler::RealFormat);
@ -782,7 +782,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
botval = -((1 - min) * dBRange);
}
vruler->SetBounds(rect.x, rect.y + top + 1, rect.x + rect.width, rect.y + bot - 1);
vruler->SetBounds(rect.x, rect.y + top, rect.x + rect.width, rect.y + bot - 1);
vruler->SetOrientation(wxVERTICAL);
vruler->SetRange(topval, botval);
}
@ -815,7 +815,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
we will use Hz if maxFreq is < 2000, otherwise we represent kHz,
and append to the numbers a "k"
*/
vruler->SetBounds(rect.x, rect.y + 1, rect.x + rect.width, rect.y + rect.height - 1);
vruler->SetBounds(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height - 1);
vruler->SetOrientation(wxVERTICAL);
vruler->SetFormat(Ruler::RealFormat);
vruler->SetLabelEdges(true);
@ -853,7 +853,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
we will use Hz if maxFreq is < 2000, otherwise we represent kHz,
and append to the numbers a "k"
*/
vruler->SetBounds(rect.x, rect.y + 1, rect.x + rect.width, rect.y + rect.height - 1);
vruler->SetBounds(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height - 1);
vruler->SetOrientation(wxVERTICAL);
vruler->SetFormat(Ruler::IntFormat);
vruler->SetLabelEdges(true);
@ -873,7 +873,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
// The note track isn't drawing a ruler at all!
// But it needs to!
else if (t->GetKind() == Track::Note) {
vruler->SetBounds(rect.x, rect.y+1, rect.x + 1, rect.y + rect.height-1);
vruler->SetBounds(rect.x, rect.y, rect.x + 1, rect.y + rect.height-1);
vruler->SetOrientation(wxVERTICAL);
}
#endif // USE_MIDI
@ -946,7 +946,10 @@ float ValueOfPixel(int yy, int height, bool offset,
bool dB, double dBRange, float zoomMin, float zoomMax)
{
wxASSERT(height > 0);
float v = zoomMax - (yy / (float)height) * (zoomMax - zoomMin);
// Map 0 to max and height - 1 (not height) to min
float v =
height == 1 ? (zoomMin + zoomMax) / 2 :
zoomMax - (yy / (float)(height - 1)) * (zoomMax - zoomMin);
if (offset) {
if (v > 0.0)
v += .5;

View File

@ -2540,6 +2540,8 @@ void TrackPanel::SelectionHandleClick(wxMouseEvent & event,
{
Track *rightTrack = NULL;
mCapturedTrack = pTrack;
rect.y += kTopMargin;
rect.height -= kTopMargin + kBottomMargin;
mCapturedRect = rect;
mMouseCapture=IsSelecting;
@ -3414,9 +3416,11 @@ void TrackPanel::SelectionHandleDrag(wxMouseEvent & event, Track *clickedTrack)
wxRect rect = mCapturedRect;
Track *pTrack = mCapturedTrack;
// AS: Note that FindTrack will replace rect's value.
if (!pTrack)
if (!pTrack) {
pTrack = FindTrack(event.m_x, event.m_y, false, false, &rect);
rect.y += kTopMargin;
rect.height -= kTopMargin + kBottomMargin;
}
// Also fuhggeddaboudit if not in a track.
if (!pTrack)
@ -3705,8 +3709,8 @@ void TrackPanel::HandleEnvelope(wxMouseEvent & event)
}
mCapturedRect = rect;
mCapturedRect.y += kTopInset;
mCapturedRect.height -= kTopInset;
mCapturedRect.y += kTopMargin;
mCapturedRect.height -= kTopMargin + kBottomMargin;
}
// AS: if there's actually a selected track, then forward all of the
// mouse events to its envelope.
@ -3732,8 +3736,6 @@ void TrackPanel::ForwardEventToTimeTrackEnvelope(wxMouseEvent & event)
Envelope *pspeedenvelope = ptimetrack->GetEnvelope();
wxRect envRect = mCapturedRect;
envRect.y++;
envRect.height -= 2;
double lower = ptimetrack->GetRangeLower(), upper = ptimetrack->GetRangeUpper();
const double dBRange = mViewInfo->dBr;
if (ptimetrack->GetDisplayLog()) {
@ -3775,8 +3777,6 @@ void TrackPanel::ForwardEventToWaveTrackEnvelope(wxMouseEvent & event)
// AS: Then forward our mouse event to the envelope.
// It'll recalculate and then tell us whether or not to redraw.
wxRect envRect = mCapturedRect;
envRect.y++;
envRect.height -= 2;
float zoomMin, zoomMax;
pwavetrack->GetDisplayBounds(&zoomMin, &zoomMax);
needUpdate = penvelope->MouseEvent(
@ -3794,8 +3794,6 @@ void TrackPanel::ForwardEventToWaveTrackEnvelope(wxMouseEvent & event)
bool updateNeeded = false;
if (e2) {
wxRect envRect = mCapturedRect;
envRect.y++;
envRect.height -= 2;
float zoomMin, zoomMax;
pwavetrack->GetDisplayBounds(&zoomMin, &zoomMax);
updateNeeded = e2->MouseEvent(event, envRect,
@ -3808,8 +3806,6 @@ void TrackPanel::ForwardEventToWaveTrackEnvelope(wxMouseEvent & event)
if( (e2 = link->GetActiveEnvelope()) != 0 ) // search for any active DragPoint
{
wxRect envRect = mCapturedRect;
envRect.y++;
envRect.height -= 2;
float zoomMin, zoomMax;
pwavetrack->GetDisplayBounds(&zoomMin, &zoomMax);
needUpdate |= e2->MouseEvent(event, envRect,
@ -4663,8 +4659,8 @@ void TrackPanel::HandleWaveTrackVZoom
bool fixedMousePoint)
{
WaveTrack *const partner = static_cast<WaveTrack *>(tracks->GetLink(track));
int height = track->GetHeight();
int ypos = rect.y;
int height = track->GetHeight() - (kTopMargin + kBottomMargin);
int ypos = rect.y + kBorderThickness;
// Ensure start and end are in order (swap if not).
if (zoomEnd < zoomStart)
@ -4955,7 +4951,7 @@ float TrackPanel::FindSampleEditingLevel(wxMouseEvent &event, double dBRange, do
mDrawingTrack->GetDisplayBounds(&zoomMin, &zoomMax);
const int y = event.m_y - mDrawingTrackTop;
const int height = mDrawingTrack->GetHeight();
const int height = mDrawingTrack->GetHeight() - (kTopMargin + kBottomMargin);
const bool dB = !mDrawingTrack->GetWaveformSettings().isLinear();
float newLevel =
::ValueOfPixel(y, height, false, dB, dBRange, zoomMin, zoomMax);
@ -4996,7 +4992,7 @@ void TrackPanel::HandleSampleEditingClick( wxMouseEvent & event )
/// \todo Should mCapturedTrack take the place of mDrawingTrack??
mDrawingTrack = static_cast<WaveTrack*>(t);
mDrawingTrackTop=rect.y;
mDrawingTrackTop=rect.y + kTopMargin;
//If we are still around, we are drawing in earnest. Set some member data structures up:
//First, calculate the starting sample. To get this, we need the time
@ -7395,9 +7391,9 @@ void TrackPanel::DrawEverythingElse(wxDC * dc,
if (region.Contains(0, trackRect.y, GetLeftOffset(), trackRect.height)) {
wxRect rect = trackRect;
rect.x += GetVRulerOffset();
rect.y += kTopInset;
rect.y += kTopMargin;
rect.width = GetVRulerWidth();
rect.height -= (kTopInset + 2);
rect.height -= (kTopMargin + kBottomMargin);
mTrackArtist->DrawVRuler(t, dc, rect);
}
@ -7408,9 +7404,9 @@ void TrackPanel::DrawEverythingElse(wxDC * dc,
if (region.Contains(0, trackRect.y, GetLeftOffset(), trackRect.height)) {
wxRect rect = trackRect;
rect.x += GetVRulerOffset();
rect.y += kTopInset;
rect.y += kTopMargin;
rect.width = GetVRulerWidth();
rect.height -= (kTopInset + 2);
rect.height -= (kTopMargin + kBottomMargin);
mTrackArtist->DrawVRuler(t, dc, rect);
}
}
@ -7953,20 +7949,20 @@ void TrackPanel::UpdateTrackVRuler(Track *t)
return;
wxRect rect(GetVRulerOffset(),
kTopInset,
kTopMargin,
GetVRulerWidth(),
t->GetHeight() - (kTopInset + 2));
t->GetHeight() - (kTopMargin + kBottomMargin));
mTrackArtist->UpdateVRuler(t, rect);
Track *l = t->GetLink();
if (l)
{
rect.height = l->GetHeight() - (kTopInset + 2);
rect.height = l->GetHeight() - (kTopMargin + kBottomMargin);
mTrackArtist->UpdateVRuler(l, rect);
}
#ifdef EXPERIMENTAL_OUTPUT_DISPLAY
else if(MONO_WAVE_PAN(t)){
rect.height = t->GetHeight(true) - (kTopInset + 2);
rect.height = t->GetHeight(true) - (kTopMargin + kBottomMargin);
mTrackArtist->UpdateVRuler(t, rect);
}
#endif