From 57a253004de40f4d8d68d7170012f8ff4e3c026b Mon Sep 17 00:00:00 2001
From: Thomas Goyne <plorkyeran@aegisub.org>
Date: Tue, 2 Oct 2012 08:09:33 -0700
Subject: [PATCH] Scroll the audio display after a click near an edge

When auto scrolling is enabled, scroll the audio display after a click
near an edge to mimic the effect of scrolling to show the new audio
selection (as 2.1.9 did), but hopefully without all the weird
undesirable cases that had.
---
 aegisub/src/audio_display.cpp | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/aegisub/src/audio_display.cpp b/aegisub/src/audio_display.cpp
index 151611467..39f27a818 100644
--- a/aegisub/src/audio_display.cpp
+++ b/aegisub/src/audio_display.cpp
@@ -1010,11 +1010,23 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
 	if (event.IsButton())
 		SetFocus();
 
+	const int mouse_x = event.GetPosition().x;
+
+	// Scroll the display after a mouse-up near one of the edges
+	if ((event.LeftUp() || event.RightUp()) && OPT_GET("Audio/Auto/Scroll")->GetBool())
+	{
+		const int width = GetClientSize().GetWidth();
+		if (mouse_x < width / 20) {
+			ScrollBy(-width / 3);
+		}
+		else if (width - mouse_x < width / 20) {
+			ScrollBy(width / 3);
+		}
+	}
+
 	if (ForwardMouseEvent(event))
 		return;
 
-	const int mouse_x = event.GetPosition().x;
-
 	if (event.MiddleIsDown())
 	{
 		context->videoController->JumpToTime(TimeFromRelativeX(mouse_x), agi::vfr::EXACT);
-- 
GitLab