Update the time relative to frame box when the subtitle file is changed to reflect timing changes immediately

Originally committed to SVN as r4816.
This commit is contained in:
Thomas Goyne 2010-10-16 20:11:53 +00:00
parent 9083776b9c
commit a278901e13
2 changed files with 27 additions and 16 deletions

View File

@ -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) {

View File

@ -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);