From a00a45125e6d4b9517cae05994121b8a7bd17060 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sun, 5 Mar 2006 23:41:00 +0000 Subject: [PATCH] Audio display now follows the play cursor Originally committed to SVN as r211. --- core/audio_display.cpp | 39 +++++++++++++++++++++++++++++++-------- core/changelog.txt | 2 +- core/options.cpp | 1 + 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/core/audio_display.cpp b/core/audio_display.cpp index 425294a46..ac9ee86fd 100644 --- a/core/audio_display.cpp +++ b/core/audio_display.cpp @@ -1479,19 +1479,42 @@ void AudioDisplay::OnUpdateTimer(wxTimerEvent &event) { if (curPos > player->GetStartPosition() && curPos < player->GetEndPosition()) { // Scroll if needed int posX = GetXAtSample(curPos); - if (posX > w-80) { - UpdatePosition(curPos - samples/2 - 80,true); - UpdateImage(); - Refresh(true); + bool fullDraw = false; + bool centerLock = Options.AsBool(_T("Audio lock scroll on cursor")); + if (centerLock) { + int goTo = MAX(0,curPos - w*samples/2); + if (goTo >= 0) { + UpdatePosition(goTo,true); + UpdateImage(); + fullDraw = true; + } + } + else { + if (posX < 80 || posX > w-80) { + int goTo = MAX(0,curPos - 80*samples); + if (goTo >= 0) { + UpdatePosition(goTo,true); + UpdateImage(); + fullDraw = true; + } + } } // Draw cursor wxMemoryDC src; - src.SelectObject(*origImage); - dc.Blit(oldCurPos,0,1,h,&src,oldCurPos,0); - dc.SetPen(wxPen(Options.AsColour(_T("Audio Play cursor")))); curpos = GetXAtSample(curPos); - dc.DrawLine(curpos,0,curpos,h); + dc.SetPen(wxPen(Options.AsColour(_T("Audio Play cursor")))); + src.SelectObject(*origImage); + if (fullDraw) { + //dc.Blit(0,0,w,h,&src,0,0); + dc.DrawLine(curpos,0,curpos,h); + //dc.Blit(0,0,curpos-10,h,&src,0,0); + //dc.Blit(curpos+10,0,w-curpos-10,h,&src,curpos+10,0); + } + else { + dc.Blit(oldCurPos,0,1,h,&src,oldCurPos,0); + dc.DrawLine(curpos,0,curpos,h); + } } else { if (curPos > player->GetEndPosition() + 8192) { diff --git a/core/changelog.txt b/core/changelog.txt index f769d2287..9e03067bf 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -63,7 +63,7 @@ Please visit http://aegisub.net to download latest version - Select lines dialog now has an option on how to deal with comment lines. (Pomyk) - Last folder for all the file selection dialogs are now remembered in config.dat. (Pomyk) - Audio current play position cursor will now always be visible. (AMZ) -- Removed video frame/subtitles time sync controls from the grid context menu. +- Removed video frame/subtitles time sync controls from the grid context menu. (AMZ) = 1.09 beta - 2006.01.16 =========================== diff --git a/core/options.cpp b/core/options.cpp index 0b57a39f7..9d66b21b8 100644 --- a/core/options.cpp +++ b/core/options.cpp @@ -174,6 +174,7 @@ void OptionsManager::LoadDefaults() { SetInt(_T("Audio Display Height"),100); SetInt(_T("Timing Default Duration"), 2000); SetBool(_T("Audio Wheel Default To Zoom"),false); + SetBool(_T("Audio lock scroll on cursor"),false); SetBool(_T("Audio Spectrum"),false); SetInt(_T("Audio Spectrum Cutoff"),32);