diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index 4fee8b1d5..6db9358e6 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -182,6 +182,27 @@ void VideoDisplay::ShowCursor(bool show) { SetCursor(cursor); } } + +void VideoDisplay::UpdateRelativeTimes(int time) { + wxString startSign; + wxString endSign; + int startOff = 0; + int endOff = 0; + + if (AssDialogue *curLine = VideoContext::Get()->grid->GetActiveLine()) { + startOff = time - curLine->Start.GetMS(); + endOff = time - curLine->End.GetMS(); + } + + // Positive signs + if (startOff > 0) startSign = L"+"; + if (endOff > 0) endSign = L"+"; + + // Set the text box for time relative to active subtitle line + SubsPosition->SetValue(wxString::Format(L"%s%ims; %s%ims", startSign.c_str(), startOff, endSign.c_str(), endOff)); +} + + void VideoDisplay::SetFrame(int frameNumber) { VideoContext *context = VideoContext::Get(); ControlSlider->SetValue(frameNumber); @@ -208,22 +229,7 @@ void VideoDisplay::SetFrame(int frameNumber) { PositionDisplay->SetForegroundColour(wxNullColour); } - wxString startSign; - wxString endSign; - int startOff = 0; - int endOff = 0; - - if (AssDialogue *curLine = context->grid->GetActiveLine()) { - startOff = time - curLine->Start.GetMS(); - endOff = time - curLine->End.GetMS(); - } - - // Positive signs - if (startOff > 0) startSign = L"+"; - if (endOff > 0) endSign = L"+"; - - // Set the text box for time relative to active subtitle line - SubsPosition->SetValue(wxString::Format(L"%s%ims; %s%ims", startSign.c_str(), startOff, endSign.c_str(), endOff)); + UpdateRelativeTimes(time); } // Render the new frame @@ -261,6 +267,7 @@ void VideoDisplay::Refresh() { if (!InitContext()) return; VideoContext::Get()->GetFrameAsync(currentFrame); tool->Refresh(); + UpdateRelativeTimes(VideoContext::Get()->TimeAtFrame(currentFrame, agi::vfr::EXACT)); } void VideoDisplay::SetFrameRange(int from, int to) { diff --git a/aegisub/src/video_display.h b/aegisub/src/video_display.h index 036dd3ad7..d72d34c12 100644 --- a/aegisub/src/video_display.h +++ b/aegisub/src/video_display.h @@ -155,6 +155,10 @@ class VideoDisplay : public wxGLCanvas { /// @return Could the context be set? bool InitContext(); + /// @brief Update the time relative to current subtitle line box + /// @param time Currently displayed frame's time + void UpdateRelativeTimes(int time); + void OnMode(const wxCommandEvent &event); void SetMode(int mode);