mirror of https://github.com/odrling/Aegisub
Add function to calculate the end time for a subtitle line.
Originally committed to SVN as r5581.
This commit is contained in:
parent
2c6bee6d19
commit
7867aa9f30
|
@ -409,6 +409,8 @@ void FrameMain::InitMenu() {
|
||||||
AppendBitmapMenuItem(timingMenu,Menu_Subs_Snap_End_To_Video, MakeHotkeyText(_("Snap End to Video"), _T("Set End to Video")), _("Set end of selected subtitles to current video frame"), wxBITMAP(subend_to_video));
|
AppendBitmapMenuItem(timingMenu,Menu_Subs_Snap_End_To_Video, MakeHotkeyText(_("Snap End to Video"), _T("Set End to Video")), _("Set end of selected subtitles to current video frame"), wxBITMAP(subend_to_video));
|
||||||
AppendBitmapMenuItem(timingMenu,Menu_Video_Snap_To_Scene, MakeHotkeyText(_("Snap to Scene"), _T("Snap to Scene")), _("Set start and end of subtitles to the keyframes around current video frame"), wxBITMAP(snap_subs_to_scene));
|
AppendBitmapMenuItem(timingMenu,Menu_Video_Snap_To_Scene, MakeHotkeyText(_("Snap to Scene"), _T("Snap to Scene")), _("Set start and end of subtitles to the keyframes around current video frame"), wxBITMAP(snap_subs_to_scene));
|
||||||
AppendBitmapMenuItem(timingMenu,Menu_Video_Shift_To_Frame, MakeHotkeyText(_("Shift to Current Frame"), _T("Shift by Current Time")), _("Shift selection so first selected line starts at current frame"), wxBITMAP(shift_to_frame));
|
AppendBitmapMenuItem(timingMenu,Menu_Video_Shift_To_Frame, MakeHotkeyText(_("Shift to Current Frame"), _T("Shift by Current Time")), _("Shift selection so first selected line starts at current frame"), wxBITMAP(shift_to_frame));
|
||||||
|
timingMenu->Append(Menu_Subs_Calculate_End_Time, _("Calculate End Time for Frame(s)"), _("Calculate end time based on reading speed of 14 chars per second"));
|
||||||
|
|
||||||
timingMenu->AppendSeparator();
|
timingMenu->AppendSeparator();
|
||||||
wxMenu *ContinuousMenu = new wxMenu;
|
wxMenu *ContinuousMenu = new wxMenu;
|
||||||
wxMenuItem *ContinuousParent = new wxMenuItem(subtitlesMenu,-1,_("Make Times Continuous"),_T(""),wxITEM_NORMAL,ContinuousMenu);
|
wxMenuItem *ContinuousParent = new wxMenuItem(subtitlesMenu,-1,_("Make Times Continuous"),_T(""),wxITEM_NORMAL,ContinuousMenu);
|
||||||
|
|
|
@ -227,6 +227,8 @@ private:
|
||||||
void OnOpenVideoDetails (wxCommandEvent &event);
|
void OnOpenVideoDetails (wxCommandEvent &event);
|
||||||
void OnOpenASSDraw (wxCommandEvent &event);
|
void OnOpenASSDraw (wxCommandEvent &event);
|
||||||
|
|
||||||
|
void OnCalculateEndTime (wxCommandEvent &event);
|
||||||
|
|
||||||
void OnOpenOptions (wxCommandEvent &event);
|
void OnOpenOptions (wxCommandEvent &event);
|
||||||
void OnOpenLog (wxCommandEvent &event);
|
void OnOpenLog (wxCommandEvent &event);
|
||||||
void OnGridEvent (wxCommandEvent &event);
|
void OnGridEvent (wxCommandEvent &event);
|
||||||
|
@ -415,6 +417,7 @@ enum {
|
||||||
Menu_Subs_Snap_End_To_Video,
|
Menu_Subs_Snap_End_To_Video,
|
||||||
Menu_Subs_Snap_Video_To_Start,
|
Menu_Subs_Snap_Video_To_Start,
|
||||||
Menu_Subs_Snap_Video_To_End,
|
Menu_Subs_Snap_Video_To_End,
|
||||||
|
Menu_Subs_Calculate_End_Time,
|
||||||
Menu_Video_Snap_To_Scene,
|
Menu_Video_Snap_To_Scene,
|
||||||
Menu_Video_Shift_To_Frame,
|
Menu_Video_Shift_To_Frame,
|
||||||
|
|
||||||
|
|
|
@ -191,6 +191,7 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
|
||||||
EVT_MENU(Menu_Subs_Snap_End_To_Video, FrameMain::OnSnapSubsEndToVid)
|
EVT_MENU(Menu_Subs_Snap_End_To_Video, FrameMain::OnSnapSubsEndToVid)
|
||||||
EVT_MENU(Menu_Subs_Snap_Video_To_Start, FrameMain::OnSnapVidToSubsStart)
|
EVT_MENU(Menu_Subs_Snap_Video_To_Start, FrameMain::OnSnapVidToSubsStart)
|
||||||
EVT_MENU(Menu_Subs_Snap_Video_To_End, FrameMain::OnSnapVidToSubsEnd)
|
EVT_MENU(Menu_Subs_Snap_Video_To_End, FrameMain::OnSnapVidToSubsEnd)
|
||||||
|
EVT_MENU(Menu_Subs_Calculate_End_Time, FrameMain::OnCalculateEndTime)
|
||||||
EVT_MENU(Menu_Video_Snap_To_Scene, FrameMain::OnSnapToScene)
|
EVT_MENU(Menu_Video_Snap_To_Scene, FrameMain::OnSnapToScene)
|
||||||
EVT_MENU(Menu_Video_Shift_To_Frame, FrameMain::OnShiftToFrame)
|
EVT_MENU(Menu_Video_Shift_To_Frame, FrameMain::OnShiftToFrame)
|
||||||
|
|
||||||
|
@ -1205,6 +1206,13 @@ void FrameMain::OnSnapVidToSubsEnd (wxCommandEvent &event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Handler for menu event to calculate the end times of subtitles
|
||||||
|
/// @param event
|
||||||
|
///
|
||||||
|
void FrameMain::OnCalculateEndTime (wxCommandEvent &event) {
|
||||||
|
if (SubsBox)
|
||||||
|
SubsBox->CalculateEndTimeForLines(SubsBox->GetSelection());
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
// Snap to scene
|
// Snap to scene
|
||||||
|
|
|
@ -1024,6 +1024,28 @@ void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
|
||||||
EndBatch();
|
EndBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Calculate the end time for a given set of subtitle strings
|
||||||
|
/// @param lines
|
||||||
|
///
|
||||||
|
void SubtitlesGrid::CalculateEndTimeForLines(wxArrayInt lines)
|
||||||
|
{
|
||||||
|
AssDialogue *cur;
|
||||||
|
int nrows = lines.Count();
|
||||||
|
float charsPerSecond = 14.0;
|
||||||
|
for (int i=0;i<nrows;i++) {
|
||||||
|
int row = lines[i];
|
||||||
|
cur = GetDialogue(row);
|
||||||
|
int start = cur->Start.GetMS();
|
||||||
|
wxString text = cur->GetStrippedText();
|
||||||
|
float seconds = (float)text.Length() / charsPerSecond;
|
||||||
|
int lenms = seconds * 1000;
|
||||||
|
// make sure very short subtitles stay on for at least a second
|
||||||
|
if (lenms < 1000)
|
||||||
|
lenms = 1000;
|
||||||
|
cur->End.SetMS(start + lenms);
|
||||||
|
}
|
||||||
|
CommitChanges();
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Delete selected lines
|
// Delete selected lines
|
||||||
|
|
|
@ -134,6 +134,8 @@ public:
|
||||||
void CutLines(wxArrayInt lines);
|
void CutLines(wxArrayInt lines);
|
||||||
void PasteLines(int pos,bool over=false);
|
void PasteLines(int pos,bool over=false);
|
||||||
|
|
||||||
|
void CalculateEndTimeForLines(wxArrayInt lines);
|
||||||
|
|
||||||
std::vector<int> GetAbsoluteSelection();
|
std::vector<int> GetAbsoluteSelection();
|
||||||
void SetSelectionFromAbsolute(std::vector<int> &selection);
|
void SetSelectionFromAbsolute(std::vector<int> &selection);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue