Make the duration field not completely wrong in frame mode
This commit is contained in:
parent
780c93ed4d
commit
3528e49286
2 changed files with 20 additions and 7 deletions
|
@ -313,7 +313,7 @@ void SubsEditBox::OnCommit(int type) {
|
||||||
if (type & AssFile::COMMIT_DIAG_TIME) {
|
if (type & AssFile::COMMIT_DIAG_TIME) {
|
||||||
start_time->SetTime(line->Start);
|
start_time->SetTime(line->Start);
|
||||||
end_time->SetTime(line->End);
|
end_time->SetTime(line->End);
|
||||||
duration->SetTime(line->End - line->Start);
|
SetDurationField();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type & AssFile::COMMIT_DIAG_TEXT) {
|
if (type & AssFile::COMMIT_DIAG_TEXT) {
|
||||||
|
@ -468,7 +468,7 @@ void SubsEditBox::CommitTimes(TimeField field) {
|
||||||
|
|
||||||
case TIME_DURATION:
|
case TIME_DURATION:
|
||||||
if (by_frame->GetValue())
|
if (by_frame->GetValue())
|
||||||
d->End = c->videoController->TimeAtFrame(c->videoController->FrameAtTime(d->Start, agi::vfr::START) + duration->GetFrame(), agi::vfr::END);
|
d->End = c->videoController->TimeAtFrame(c->videoController->FrameAtTime(d->Start, agi::vfr::START) + duration->GetFrame() - 1, agi::vfr::END);
|
||||||
else
|
else
|
||||||
d->End = d->Start + duration->GetTime();
|
d->End = d->Start + duration->GetTime();
|
||||||
initial_times[d].second = d->End;
|
initial_times[d].second = d->End;
|
||||||
|
@ -479,10 +479,8 @@ void SubsEditBox::CommitTimes(TimeField field) {
|
||||||
start_time->SetTime(line->Start);
|
start_time->SetTime(line->Start);
|
||||||
end_time->SetTime(line->End);
|
end_time->SetTime(line->End);
|
||||||
|
|
||||||
if (by_frame->GetValue())
|
if (field != TIME_DURATION)
|
||||||
duration->SetFrame(end_time->GetFrame() - start_time->GetFrame() + 1);
|
SetDurationField();
|
||||||
else
|
|
||||||
duration->SetTime(end_time->GetTime() - start_time->GetTime());
|
|
||||||
|
|
||||||
if (field != last_time_commit_type)
|
if (field != last_time_commit_type)
|
||||||
commit_id = -1;
|
commit_id = -1;
|
||||||
|
@ -493,6 +491,16 @@ void SubsEditBox::CommitTimes(TimeField field) {
|
||||||
file_changed_slot.Unblock();
|
file_changed_slot.Unblock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SubsEditBox::SetDurationField() {
|
||||||
|
// With VFR, the frame count calculated from the duration in time can be
|
||||||
|
// completely wrong (since the duration is calculated as if it were a start
|
||||||
|
// time), so we need to explicitly set it with the correct units.
|
||||||
|
if (by_frame->GetValue())
|
||||||
|
duration->SetFrame(end_time->GetFrame() - start_time->GetFrame() + 1);
|
||||||
|
else
|
||||||
|
duration->SetTime(end_time->GetTime() - start_time->GetTime());
|
||||||
|
}
|
||||||
|
|
||||||
void SubsEditBox::OnSize(wxSizeEvent &evt) {
|
void SubsEditBox::OnSize(wxSizeEvent &evt) {
|
||||||
int availableWidth = GetVirtualSize().GetWidth();
|
int availableWidth = GetVirtualSize().GetWidth();
|
||||||
int midMin = middle_left_sizer->GetMinSize().GetWidth();
|
int midMin = middle_left_sizer->GetMinSize().GetWidth();
|
||||||
|
@ -517,12 +525,15 @@ void SubsEditBox::OnSize(wxSizeEvent &evt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsEditBox::OnFrameTimeRadio(wxCommandEvent &event) {
|
void SubsEditBox::OnFrameTimeRadio(wxCommandEvent &event) {
|
||||||
|
event.Skip();
|
||||||
|
|
||||||
bool byFrame = by_frame->GetValue();
|
bool byFrame = by_frame->GetValue();
|
||||||
start_time->SetByFrame(byFrame);
|
start_time->SetByFrame(byFrame);
|
||||||
end_time->SetByFrame(byFrame);
|
end_time->SetByFrame(byFrame);
|
||||||
duration->SetByFrame(byFrame);
|
duration->SetByFrame(byFrame);
|
||||||
c->subsGrid->SetByFrame(byFrame);
|
c->subsGrid->SetByFrame(byFrame);
|
||||||
event.Skip();
|
|
||||||
|
SetDurationField();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsEditBox::SetControlsState(bool state) {
|
void SubsEditBox::SetControlsState(bool state) {
|
||||||
|
|
|
@ -195,6 +195,8 @@ class SubsEditBox final : public wxPanel {
|
||||||
/// Call a command the restore focus to the edit box
|
/// Call a command the restore focus to the edit box
|
||||||
void CallCommand(const char *cmd_name);
|
void CallCommand(const char *cmd_name);
|
||||||
|
|
||||||
|
void SetDurationField();
|
||||||
|
|
||||||
SubsTextEditCtrl *edit_ctrl;
|
SubsTextEditCtrl *edit_ctrl;
|
||||||
wxTextCtrl *secondary_editor;
|
wxTextCtrl *secondary_editor;
|
||||||
std::unique_ptr<TextSelectionController> textSelectionController;
|
std::unique_ptr<TextSelectionController> textSelectionController;
|
||||||
|
|
Loading…
Reference in a new issue