Fix waveform height calculation being 2x too high (but set default vertical zoom to 2.0 to keep the same effective look). Now you can zoom out vertically to 1.0 to see the correct height.

Increase maximum vertical zoom factor to compensate for the height correction.
Allow vertical zoom to be changed with control + shift + scroll wheel.
This commit is contained in:
J.D. Purcell 2015-09-13 02:22:15 -04:00
parent 0defc6b5e9
commit f6014d7dc8
2 changed files with 26 additions and 6 deletions

View File

@ -133,8 +133,8 @@ namespace Nikse.SubtitleEdit.Controls
}
public const double VerticalZoomMinimum = 1.0;
public const double VerticalZoomMaximum = 20.0;
private double _verticalZoomFactor = 1.0; // 1.0=no zoom
public const double VerticalZoomMaximum = 40.0;
private double _verticalZoomFactor = 2.0; // 1.0=no zoom
public double VerticalZoomFactor
{
get
@ -404,7 +404,7 @@ namespace Nikse.SubtitleEdit.Controls
private static int CalculateHeight(double value, int imageHeight, int maxHeight)
{
double percentage = value / maxHeight;
var result = (int)Math.Round((percentage * imageHeight) + (imageHeight / 2.0));
var result = (int)Math.Round((percentage / 2.0 + 0.5) * imageHeight);
return imageHeight - result;
}
@ -1690,18 +1690,28 @@ namespace Nikse.SubtitleEdit.Controls
public void ZoomIn()
{
ZoomFactor = ZoomFactor + 0.1;
ZoomFactor += 0.1;
if (OnZoomedChanged != null)
OnZoomedChanged.Invoke(this, null);
}
public void ZoomOut()
{
ZoomFactor = ZoomFactor - 0.1;
ZoomFactor -= 0.1;
if (OnZoomedChanged != null)
OnZoomedChanged.Invoke(this, null);
}
private void VerticalZoomIn()
{
VerticalZoomFactor *= 1.1;
}
private void VerticalZoomOut()
{
VerticalZoomFactor /= 1.1;
}
private void WaveformMouseWheel(object sender, MouseEventArgs e)
{
// The scroll wheel could work in theory without the waveform loaded (it would be
@ -1720,6 +1730,16 @@ namespace Nikse.SubtitleEdit.Controls
return;
}
if (ModifierKeys == (Keys.Control | Keys.Shift))
{
if (e.Delta > 0)
VerticalZoomIn();
else
VerticalZoomOut();
return;
}
int delta = e.Delta;
if (!MouseWheelScrollUpIsForward)
delta = delta * -1;

View File

@ -4450,7 +4450,7 @@
this.audioVisualizer.TextBold = true;
this.audioVisualizer.TextColor = System.Drawing.Color.Gray;
this.audioVisualizer.TextSize = 9F;
this.audioVisualizer.VerticalZoomFactor = 1D;
this.audioVisualizer.VerticalZoomFactor = 2D;
this.audioVisualizer.WaveformNotLoadedText = "Click to add waveform";
this.audioVisualizer.WavePeaks = null;
this.audioVisualizer.ZoomFactor = 1D;