From 4e417a6dae4c6578d07c880396b3eebe09e22fac Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Thu, 14 May 2009 22:12:05 +0000 Subject: [PATCH] Change audio autoscroll behaviour: * In karaoke mode, instead of scrolling start to end of active line into view, scroll start of selection to end of line into view. This gives sensible results when horizontal zoom is great enough that the entire line isn't visible at once and the syllable is too far from the start of the line. This fixes #677. * If the line is too long to fit in the display, always left-align it instead of sometimes left-aligning and sometimes centering. (I think the old behaviour depended on the actual scroll position.) Originally committed to SVN as r2928. --- aegisub/src/audio_display.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/aegisub/src/audio_display.cpp b/aegisub/src/audio_display.cpp index 9aca2a280..c15424427 100644 --- a/aegisub/src/audio_display.cpp +++ b/aegisub/src/audio_display.cpp @@ -725,20 +725,22 @@ void AudioDisplay::RecreateImage() { void AudioDisplay::MakeDialogueVisible(bool force) { wxLogDebug(_T("AudioDisplay::MakeDialogueVisible(force=%d)"), force?1:0); // Variables - int temp1=0,temp2=0; + int startShow=0, endShow=0; if (karaoke->enabled) { - // In karaoke mode the entire dialogue line should be visible instead of just the selected syllable - GetTimesDialogue(temp1, temp2); + // In karaoke mode the syllable and as much as possible towards the end of the line should be shown + int dummy = 0; + GetTimesSelection(startShow, dummy); + GetTimesDialogue(dummy, endShow); } else { - GetTimesSelection(temp1,temp2); + GetTimesSelection(startShow,endShow); } - int startPos = GetSampleAtMS(temp1); - int endPos = GetSampleAtMS(temp2); - int startX = GetXAtMS(temp1); - int endX = GetXAtMS(temp2); + int startPos = GetSampleAtMS(startShow); + int endPos = GetSampleAtMS(endShow); + int startX = GetXAtMS(startShow); + int endX = GetXAtMS(endShow); if (force || startX < 50 || endX > w-50) { - if (startX < 50) { + if (startX < 50 || endX - startX >= w) { // Make sure the left edge of the selection is at least 50 pixels from the edge of the display UpdatePosition(startPos - 50*samples, true); } else {