Don't use the ms time value of the Duration time edit control when in frame mode, as with vfr this may not actually represent a consisten number of frames

Originally committed to SVN as r6132.
This commit is contained in:
Thomas Goyne 2011-12-22 21:30:22 +00:00
parent 2c324de29c
commit e5707ca6eb
3 changed files with 33 additions and 8 deletions

View file

@ -519,21 +519,30 @@ void SubsEditBox::CommitText(wxString desc) {
}
void SubsEditBox::CommitTimes(TimeField field) {
if (ByFrame->GetValue())
Duration->SetFrame(EndTime->GetFrame() - StartTime->GetFrame() + 1);
else
Duration->SetTime(EndTime->GetTime() - StartTime->GetTime());
// Update lines
for (Selection::iterator cur = sel.begin(); cur != sel.end(); ++cur) {
AssDialogue *d = *cur;
switch (field) {
case TIME_START:
(*cur)->Start = StartTime->GetTime();
if ((*cur)->Start > (*cur)->End) (*cur)->End = (*cur)->Start;
d->Start = StartTime->GetTime();
if (d->Start > d->End)
d->End = d->Start;
break;
case TIME_END:
(*cur)->End = EndTime->GetTime();
if ((*cur)->Start > (*cur)->End) (*cur)->Start = (*cur)->End;
d->End = EndTime->GetTime();
if (d->Start > d->End)
d->Start = d->End;
break;
case TIME_DURATION:
(*cur)->End = (*cur)->Start + Duration->GetTime();
if (ByFrame->GetValue())
d->End = c->videoController->TimeAtFrame(c->videoController->FrameAtTime(d->Start, agi::vfr::START) + Duration->GetFrame(), agi::vfr::END);
else
d->End = d->Start + Duration->GetTime();
break;
}
}
@ -643,6 +652,9 @@ void SubsEditBox::OnEndTimeChange(wxCommandEvent &) {
}
void SubsEditBox::OnDurationChange(wxCommandEvent &) {
if (ByFrame->GetValue())
EndTime->SetFrame(StartTime->GetFrame() + Duration->GetFrame() - 1);
else
EndTime->SetTime(StartTime->GetTime() + Duration->GetTime());
CommitTimes(TIME_DURATION);
}

View file

@ -104,6 +104,14 @@ void TimeEdit::SetTime(AssTime new_time) {
}
}
int TimeEdit::GetFrame() const {
return c->videoController->FrameAtTime(time, isEnd ? agi::vfr::END : agi::vfr::START);
}
void TimeEdit::SetFrame(int fn) {
SetTime(c->videoController->TimeAtFrame(fn, isEnd ? agi::vfr::END : agi::vfr::START));
}
void TimeEdit::SetByFrame(bool enableByFrame) {
if (enableByFrame == byFrame) return;

View file

@ -78,6 +78,11 @@ public:
/// Set the time
void SetTime(AssTime time);
/// Get the current time as a frame number, or 0 if timecodes are unavailable
int GetFrame() const;
/// Set the time to a frame number. Does nothing if timecodes are unavailable
void SetFrame(int fn);
/// Set whether the time is displayed as a time or the corresponding frame number
/// @param enableByFrame If true, frame numbers are displayed
void SetByFrame(bool enableByFrame);