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

Norm C's patch for zooming, with a few mods from me. Allows more zooming-in and gives shift-right-click to return to 'normal' zoom on platforms that support it.

I note a number of 'zooming' bugs do still exist, but are ancient.
This commit is contained in:
martynshaw99 2013-11-28 01:11:09 +00:00
parent 127a8cc92e
commit f32e4918c0

View File

@ -221,6 +221,8 @@ is time to refresh some aspect of the screen.
#include <wx/arrimpl.cpp> #include <wx/arrimpl.cpp>
#define ZOOMLIMIT 0.001
WX_DEFINE_OBJARRAY(TrackClipArray); WX_DEFINE_OBJARRAY(TrackClipArray);
//This loads the appropriate set of cursors, depending on platform. //This loads the appropriate set of cursors, depending on platform.
@ -3490,10 +3492,11 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event )
} }
} }
else { else {
if (max - min < 0.2) { // Waveform view - allow zooming down to a range of ZOOMLIMIT
c = (min+max)/2; if (max - min < ZOOMLIMIT) { // if user attempts to go smaller...
min = c-0.1; c = (min+max)/2; // ...set centre of view to centre of dragged area and top/bottom to ZOOMLIMIT/2 above/below
max = c+0.1; min = c - ZOOMLIMIT/2.0;
max = c + ZOOMLIMIT/2.0;
} }
} }
} }
@ -3504,6 +3507,13 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event )
// then, if they click again, allow one more // then, if they click again, allow one more
// zoom out. // zoom out.
if(spectrum) { if(spectrum) {
if (event.ShiftDown() && event.RightUp()) {
// Zoom out full
min = 0.0;
max = rate/2.;
}
else {
// Zoom out
c = 0.5*(min+max); c = 0.5*(min+max);
l = (c - min); l = (c - min);
if(c - 2*l <= 0) { if(c - 2*l <= 0) {
@ -3515,9 +3525,16 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event )
max = wxMin( rate/2., c + 2*l); max = wxMin( rate/2., c + 2*l);
} }
} }
}
else { else {
if(spectrumLog) if(spectrumLog) {
{ if (event.ShiftDown() && event.RightUp()) {
// Zoom out full
min = 1.0;
max = rate/2.;
}
else {
// Zoom out
float p1; float p1;
p1 = (mZoomStart - ypos) / (float)height; p1 = (mZoomStart - ypos) / (float)height;
c = 1.0-p1; c = 1.0-p1;
@ -3528,7 +3545,15 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event )
min = wxMax(1,pow(10, xmin*d+lmin)); min = wxMax(1,pow(10, xmin*d+lmin));
max = wxMin(rate/2., pow(10, xmax*d+lmin)); max = wxMin(rate/2., pow(10, xmax*d+lmin));
} }
}
else { else {
if (event.ShiftDown() && event.RightUp()) {
// Zoom out full
min = -1.0;
max = 1.0;
}
else {
// Zoom out
if (min <= -1.0 && max >= 1.0) { if (min <= -1.0 && max >= 1.0) {
min = -2.0; min = -2.0;
max = 2.0; max = 2.0;
@ -3536,12 +3561,13 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event )
else { else {
c = 0.5*(min+max); c = 0.5*(min+max);
l = (c - min); l = (c - min);
min = wxMax( -1.0, c - 2*l); min = wxMax( -1.0, c - 2*l); // limit to +/-1 range
max = wxMin( 1.0, c + 2*l); max = wxMin( 1.0, c + 2*l);
} }
} }
} }
} }
}
else { else {
// Zoom IN // Zoom IN
float p1; float p1;
@ -3583,7 +3609,7 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event )
else { else {
c = 0.5*(min+max); c = 0.5*(min+max);
// Enforce maximum vertical zoom // Enforce maximum vertical zoom
l = wxMax( 0.1, (c - min)); l = wxMax( ZOOMLIMIT, (c - min));
p1 = (mZoomStart - ypos) / (float)height; p1 = (mZoomStart - ypos) / (float)height;
c = (max * (1.0-p1) + min * p1); c = (max * (1.0-p1) + min * p1);