mirror of https://github.com/odrling/Aegisub
Merged the three "Recombine" functions into a single one that autodetects the correct type.
Originally committed to SVN as r663.
This commit is contained in:
parent
280b9acf61
commit
f0938ca9f9
|
@ -62,6 +62,7 @@ Please visit http://aegisub.net to download latest version
|
|||
- Added a "Selection Onward" option to the Shift Times dialogue. (AMZ)
|
||||
- Main menu was completely re-designed, including several new options. (AMZ)
|
||||
- Added Medusa-style (numpad) global timing shortcuts, that can be enabled with the button under the audio display. This is disabled by default. (AMZ)
|
||||
- Merged the three "Recombine" functions into a single one that autodetects the correct type. (AMZ)
|
||||
|
||||
|
||||
= 1.10 beta - 2006.08.07 ===========================
|
||||
|
|
|
@ -272,32 +272,26 @@ void FrameMain::InitMenu() {
|
|||
wxMenu *InsertMenu = new wxMenu;
|
||||
wxMenuItem *InsertParent = new wxMenuItem(subtitlesMenu,Menu_Subtitles_Insert,_("&Insert Lines"),_T(""),wxITEM_NORMAL,InsertMenu);
|
||||
InsertParent->SetBitmap(wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_BEFORE,_("&Before Current"),_T("Inserts a line before current"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_AFTER,_("&After Current"),_T("Inserts a line after current"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_BEFORE_VIDEO,_("Before Current, at Video Time"),_T("Inserts a line before current, starting at video time"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_AFTER_VIDEO,_("After Current, at Video Time"),_T("Inserts a line after current, starting at video time"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_BEFORE,_("&Before Current"),_("Inserts a line before current"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_AFTER,_("&After Current"),_("Inserts a line after current"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_BEFORE_VIDEO,_("Before Current, at Video Time"),_("Inserts a line before current, starting at video time"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_AFTER_VIDEO,_("After Current, at Video Time"),_("Inserts a line after current, starting at video time"),wxBITMAP(blank_button));
|
||||
subtitlesMenu->Append(InsertParent);
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_DUPLICATE,wxString(_("&Duplicate Lines")) + _T("\t") + Hotkeys.GetText(_T("Grid duplicate rows")),_T("Duplicate the selected lines"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_DUPLICATE_NEXT_FRAME,wxString(_("&Duplicate and shift by 1 frame")) + _T("\t") + Hotkeys.GetText(_T("Grid duplicate and shift one frame")),_T("Duplicate lines and shift by one frame"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_DELETE,wxString(_("Delete Lines")) + _T("\t") + Hotkeys.GetText(_T("Grid delete rows")),_T("Delete currently selected lines"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_DUPLICATE,wxString(_("&Duplicate Lines")) + _T("\t") + Hotkeys.GetText(_T("Grid duplicate rows")),_("Duplicate the selected lines"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_DUPLICATE_NEXT_FRAME,wxString(_("&Duplicate and shift by 1 frame")) + _T("\t") + Hotkeys.GetText(_T("Grid duplicate and shift one frame")),_("Duplicate lines and shift by one frame"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_DELETE,wxString(_("Delete Lines")) + _T("\t") + Hotkeys.GetText(_T("Grid delete rows")),_("Delete currently selected lines"),wxBITMAP(blank_button));
|
||||
subtitlesMenu->AppendSeparator();
|
||||
wxMenu *JoinMenu = new wxMenu;
|
||||
wxMenuItem *JoinParent = new wxMenuItem(subtitlesMenu,Menu_Subtitles_Join,_("Join Lines"),_T(""),wxITEM_NORMAL,JoinMenu);
|
||||
JoinParent->SetBitmap(wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(JoinMenu,MENU_JOIN_CONCAT,_("&Concatenate"),_T("Joins selected lines in a single one, concatenating text together"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(JoinMenu,MENU_JOIN_REPLACE,_("Keep &First"),_T("Joins selected lines in a single one, keeping text of first and discarding remaining"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(JoinMenu,MENU_JOIN_AS_KARAOKE,_("As &Karaoke"),_T("Joins selected lines in a single one, as karaoke"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(JoinMenu,MENU_JOIN_CONCAT,_("&Concatenate"),_("Joins selected lines in a single one, concatenating text together"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(JoinMenu,MENU_JOIN_REPLACE,_("Keep &First"),_("Joins selected lines in a single one, keeping text of first and discarding remaining"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(JoinMenu,MENU_JOIN_AS_KARAOKE,_("As &Karaoke"),_("Joins selected lines in a single one, as karaoke"),wxBITMAP(blank_button));
|
||||
subtitlesMenu->Append(JoinParent);
|
||||
wxMenu *RecombineMenu = new wxMenu;
|
||||
wxMenuItem *RecombineParent = new wxMenuItem(subtitlesMenu,Menu_Subtitles_Recombine,_("Recombine"),_T(""),wxITEM_NORMAL,RecombineMenu);
|
||||
RecombineParent->SetBitmap(wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(RecombineMenu,MENU_1_12_RECOMBINE,_("Lines (1, 1+2) into (1, 2)"),_T("Recombine subtitles when first one is actually first plus second"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(RecombineMenu,MENU_12_2_RECOMBINE,_("Lines (1+2, 2) into (1, 2)"),_T("Recombine subtitles when second one is actually first plus second"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(RecombineMenu,MENU_1_12_2_RECOMBINE,_("Lines (1, 1+2, 2) into (1, 2)"),_T("Recombine subtitles when middle one is actually first plus second"),wxBITMAP(blank_button));
|
||||
subtitlesMenu->Append(RecombineParent);
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_SPLIT_BY_KARAOKE,_("Split Lines (by karaoke)"),_T("Uses karaoke timing to split line into multiple smaller lines"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_RECOMBINE,_("Recombine Lines"),_("Recombine subtitles when they have been split and merged"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_SPLIT_BY_KARAOKE,_("Split Lines (by karaoke)"),_("Uses karaoke timing to split line into multiple smaller lines"),wxBITMAP(blank_button));
|
||||
subtitlesMenu->AppendSeparator();
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_SWAP,_("Swap Lines"),_T("Swaps the two selected lines"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_SWAP,_("Swap Lines"),_("Swaps the two selected lines"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem (subtitlesMenu,Menu_Edit_Select, _("Select Lines...\t") + Hotkeys.GetText(_T("Select lines")), _("Selects lines based on defined criterea"),wxBITMAP(blank_button));
|
||||
subtitlesMenu->AppendSeparator();
|
||||
AppendBitmapMenuItem (subtitlesMenu,Menu_Tools_Styles_Manager, _("&Styles Manager..."), _("Open styles manager"), wxBITMAP(style_toolbutton));
|
||||
|
@ -324,8 +318,8 @@ void FrameMain::InitMenu() {
|
|||
wxMenu *ContinuousMenu = new wxMenu;
|
||||
wxMenuItem *ContinuousParent = new wxMenuItem(subtitlesMenu,-1,_("Make Times Continuous"),_T(""),wxITEM_NORMAL,ContinuousMenu);
|
||||
ContinuousParent->SetBitmap(wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(ContinuousMenu,MENU_ADJOIN,_("Change &Start"),_T("Changes times of subs so start times begin on previous's end time"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(ContinuousMenu,MENU_ADJOIN2,_("Change &End"),_T("Changes times of subs so end times begin on next's start time"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(ContinuousMenu,MENU_ADJOIN,_("Change &Start"),_("Changes times of subs so start times begin on previous's end time"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(ContinuousMenu,MENU_ADJOIN2,_("Change &End"),_("Changes times of subs so end times begin on next's start time"),wxBITMAP(blank_button));
|
||||
timingMenu->Append(ContinuousParent);
|
||||
MenuBar->Append(timingMenu, _("&Timing"));
|
||||
|
||||
|
|
|
@ -449,12 +449,8 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
|
|||
MenuBar->Enable(MENU_JOIN_REPLACE,state);
|
||||
MenuBar->Enable(MENU_JOIN_AS_KARAOKE,state);
|
||||
MenuBar->Enable(Menu_Subtitles_Join,state);
|
||||
state = count == 2 && continuous;
|
||||
MenuBar->Enable(MENU_1_12_RECOMBINE,state);
|
||||
MenuBar->Enable(MENU_12_2_RECOMBINE,state);
|
||||
state2 = count == 3 && continuous;
|
||||
MenuBar->Enable(MENU_1_12_2_RECOMBINE,state2);
|
||||
MenuBar->Enable(Menu_Subtitles_Recombine,state || state2);
|
||||
state = (count == 2 || count == 3) && continuous;
|
||||
MenuBar->Enable(MENU_RECOMBINE,state);
|
||||
}
|
||||
|
||||
// Timing menu
|
||||
|
|
|
@ -80,9 +80,7 @@ BEGIN_EVENT_TABLE(SubtitlesGrid, BaseGrid)
|
|||
EVT_MENU(MENU_SET_VIDEO_TO_END,SubtitlesGrid::OnSetVideoToEnd)
|
||||
EVT_MENU(MENU_JOIN_AS_KARAOKE,SubtitlesGrid::OnJoinAsKaraoke)
|
||||
EVT_MENU(MENU_SPLIT_BY_KARAOKE,SubtitlesGrid::OnSplitByKaraoke)
|
||||
EVT_MENU(MENU_1_12_2_RECOMBINE,SubtitlesGrid::On1122Recombine)
|
||||
EVT_MENU(MENU_12_2_RECOMBINE,SubtitlesGrid::On122Recombine)
|
||||
EVT_MENU(MENU_1_12_RECOMBINE,SubtitlesGrid::On112Recombine)
|
||||
EVT_MENU(MENU_RECOMBINE,SubtitlesGrid::OnRecombine)
|
||||
EVT_MENU_RANGE(MENU_SHOW_COL,MENU_SHOW_COL+15,SubtitlesGrid::OnShowColMenu)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
@ -176,18 +174,15 @@ void SubtitlesGrid::OnPopupMenu(bool alternate) {
|
|||
menu.Append(MENU_JOIN_CONCAT,_("&Join (concatenate)"),_T("Joins selected lines in a single one, concatenating text together"))->Enable(state);
|
||||
menu.Append(MENU_JOIN_REPLACE,_("Join (keep first)"),_T("Joins selected lines in a single one, keeping text of first and discarding remaining"))->Enable(state);
|
||||
menu.Append(MENU_JOIN_AS_KARAOKE,_("Join (as Karaoke)"),_T(""))->Enable(state);
|
||||
menu.AppendSeparator();
|
||||
|
||||
// Adjoin selection
|
||||
menu.Append(MENU_ADJOIN,_("&Make times continuous (change start)"),_T("Changes times of subs so start times begin on previous's end time"))->Enable(state);
|
||||
menu.Append(MENU_ADJOIN2,_("&Make times continuous (change end)"),_T("Changes times of subs so end times begin on next's start time"))->Enable(state);
|
||||
menu.AppendSeparator();
|
||||
|
||||
// Recombine selection
|
||||
state = (sels == 2 && continuous);
|
||||
menu.Append(MENU_1_12_RECOMBINE,_("Recombine (1, 1+2) into (1, 2)"),_T("Recombine subtitles when first one is actually first plus second"))->Enable(state);
|
||||
menu.Append(MENU_12_2_RECOMBINE,_("Recombine (1+2, 2) into (1, 2)"),_T("Recombine subtitles when second one is actually first plus second"))->Enable(state);
|
||||
state = (sels == 3 && continuous);
|
||||
menu.Append(MENU_1_12_2_RECOMBINE,_("Recombine (1, 1+2, 2) into (1, 2)"),_T("Recombine subtitles when middle one is actually first plus second"))->Enable(state);
|
||||
state = (sels == 2 || sels == 3) && continuous;
|
||||
menu.Append(MENU_RECOMBINE,_("Recombine Lines"),_T("Recombine subtitles when they have been split and merged"))->Enable(state);
|
||||
menu.AppendSeparator();
|
||||
|
||||
// Copy/cut/paste
|
||||
|
@ -566,112 +561,72 @@ void SubtitlesGrid::OnSetVideoToEnd(wxCommandEvent &event) {
|
|||
}
|
||||
|
||||
|
||||
/////////////////////
|
||||
// 1,1+2,2 Recombine
|
||||
void SubtitlesGrid::On1122Recombine(wxCommandEvent &event) {
|
||||
BeginBatch();
|
||||
//////////////
|
||||
// Recombine
|
||||
void SubtitlesGrid::OnRecombine(wxCommandEvent &event) {
|
||||
// Get selection
|
||||
bool cont;
|
||||
wxArrayInt sel = GetSelection(&cont);
|
||||
if (sel.Count() != 3 || !cont) throw _T("Invalid number of selections");
|
||||
int nSel = sel.Count();
|
||||
if ((nSel != 2 && nSel != 3) || !cont) throw _T("Invalid selection");
|
||||
int n = sel[0];
|
||||
|
||||
// Update
|
||||
// Get dialogues
|
||||
AssDialogue *n1,*n2,*n3;
|
||||
n1 = GetDialogue(n);
|
||||
n2 = GetDialogue(n+1);
|
||||
|
||||
// 1,1+2,2 -> 1,2
|
||||
if (nSel == 3) {
|
||||
n3 = GetDialogue(n+2);
|
||||
n1->End = n2->End;
|
||||
n3->Start = n2->Start;
|
||||
n1->UpdateData();
|
||||
n3->UpdateData();
|
||||
|
||||
// Delete middle
|
||||
DeleteLines(GetRangeArray(n+1,n+1));
|
||||
}
|
||||
|
||||
EndBatch();
|
||||
}
|
||||
|
||||
|
||||
///////////////////
|
||||
// 1+2,2 Recombine
|
||||
void SubtitlesGrid::On122Recombine(wxCommandEvent &event) {
|
||||
BeginBatch();
|
||||
|
||||
// Get selection
|
||||
bool cont;
|
||||
wxArrayInt sel = GetSelection(&cont);
|
||||
if (sel.Count() != 2 || !cont) throw _T("Invalid number of selections");
|
||||
int n = sel[0];
|
||||
|
||||
// Update
|
||||
AssDialogue *n1,*n2;
|
||||
n1 = GetDialogue(n);
|
||||
n2 = GetDialogue(n+1);
|
||||
// 2 Line recombine
|
||||
else {
|
||||
// Trim dialogues
|
||||
n1->Text.Trim(true).Trim(false);
|
||||
n2->Text.Trim(true).Trim(false);
|
||||
|
||||
// Check if n2 is a suffix of n1
|
||||
if (n1->Text.Right(n2->Text.Length()) == n2->Text) {
|
||||
// Detect type
|
||||
int type = -1;
|
||||
if (n1->Text.Right(n2->Text.Length()) == n2->Text) type = 0;
|
||||
else if (n2->Text.Left(n1->Text.Length()) == n1->Text) type = 1;
|
||||
else {
|
||||
// Unknown type
|
||||
parentFrame->StatusTimeout(_T("Unable to recombine: Neither line is a suffix of the other one."));
|
||||
return;
|
||||
}
|
||||
|
||||
// 1+2,2 -> 1,2
|
||||
if (type == 0) {
|
||||
n1->Text = n1->Text.SubString(0, n1->Text.Length() - n2->Text.Length() - 1).Trim(true).Trim(false);
|
||||
while (n1->Text.Left(2) == _T("\\N") || n1->Text.Left(2) == _T("\\n"))
|
||||
n1->Text = n1->Text.Mid(2);
|
||||
while (n1->Text.Right(2) == _T("\\N") || n1->Text.Right(2) == _T("\\n"))
|
||||
n1->Text = n1->Text.Mid(0,n1->Text.Length()-2);
|
||||
while (n1->Text.Left(2) == _T("\\N") || n1->Text.Left(2) == _T("\\n")) n1->Text = n1->Text.Mid(2);
|
||||
while (n1->Text.Right(2) == _T("\\N") || n1->Text.Right(2) == _T("\\n")) n1->Text = n1->Text.Mid(0,n1->Text.Length()-2);
|
||||
n2->Start = n1->Start;
|
||||
//n1->ParseASSTags();
|
||||
n1->UpdateData();
|
||||
n2->UpdateData();
|
||||
|
||||
// Commit
|
||||
ass->FlagAsModified();
|
||||
CommitChanges();
|
||||
} else {
|
||||
parentFrame->StatusTimeout(_T("Unable to recombine: Second line is not a suffix of first one."));
|
||||
}
|
||||
|
||||
EndBatch();
|
||||
}
|
||||
|
||||
|
||||
///////////////////
|
||||
// 1,1+2 Recombine
|
||||
void SubtitlesGrid::On112Recombine(wxCommandEvent &event) {
|
||||
BeginBatch();
|
||||
|
||||
// Get selection
|
||||
bool cont;
|
||||
wxArrayInt sel = GetSelection(&cont);
|
||||
if (sel.Count() != 2 || !cont) throw _T("Invalid number of selections");
|
||||
int n = sel[0];
|
||||
|
||||
// Update
|
||||
AssDialogue *n1,*n2;
|
||||
n1 = GetDialogue(n);
|
||||
n2 = GetDialogue(n+1);
|
||||
n1->Text.Trim(true).Trim(false);
|
||||
n2->Text.Trim(true).Trim(false);
|
||||
|
||||
// Check if n1 is a prefix of n2 and recombine
|
||||
if (n2->Text.Left(n1->Text.Length()) == n1->Text) {
|
||||
// 1,1+2, -> 1,2
|
||||
else {
|
||||
n2->Text = n2->Text.Mid(n1->Text.Length()).Trim(true).Trim(false);
|
||||
while (n2->Text.Left(2) == _T("\\N") || n2->Text.Left(2) == _T("\\n"))
|
||||
n2->Text = n2->Text.Mid(2);
|
||||
while (n2->Text.Right(2) == _T("\\N") || n2->Text.Right(2) == _T("\\n"))
|
||||
n2->Text = n2->Text.Mid(0,n2->Text.Length()-2);
|
||||
while (n2->Text.Left(2) == _T("\\N") || n2->Text.Left(2) == _T("\\n")) n2->Text = n2->Text.Mid(2);
|
||||
while (n2->Text.Right(2) == _T("\\N") || n2->Text.Right(2) == _T("\\n")) n2->Text = n2->Text.Mid(0,n2->Text.Length()-2);
|
||||
n1->End = n2->End;
|
||||
//n2->ParseASSTags();
|
||||
n1->UpdateData();
|
||||
n2->UpdateData();
|
||||
|
||||
// Commit
|
||||
ass->FlagAsModified();
|
||||
CommitChanges();
|
||||
} else {
|
||||
parentFrame->StatusTimeout(_T("Unable to recombine: First line is not a prefix of second one."));
|
||||
}
|
||||
|
||||
EndBatch();
|
||||
// Commit
|
||||
n1->UpdateData();
|
||||
n2->UpdateData();
|
||||
ass->FlagAsModified();
|
||||
CommitChanges();
|
||||
}
|
||||
|
||||
// Adjus scrollbar
|
||||
AdjustScrollbar();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -92,9 +92,7 @@ private:
|
|||
void OnSetVideoToEnd(wxCommandEvent &event);
|
||||
void OnJoinAsKaraoke(wxCommandEvent &event);
|
||||
void OnSplitByKaraoke(wxCommandEvent &event);
|
||||
void On1122Recombine(wxCommandEvent &event);
|
||||
void On122Recombine(wxCommandEvent &event);
|
||||
void On112Recombine(wxCommandEvent &event);
|
||||
void OnRecombine(wxCommandEvent &event);
|
||||
void OnShowColMenu(wxCommandEvent &event);
|
||||
|
||||
public:
|
||||
|
@ -155,9 +153,7 @@ enum {
|
|||
MENU_ADJOIN,
|
||||
MENU_ADJOIN2,
|
||||
MENU_JOIN_AS_KARAOKE,
|
||||
MENU_1_12_2_RECOMBINE,
|
||||
MENU_1_12_RECOMBINE,
|
||||
MENU_12_2_RECOMBINE,
|
||||
MENU_RECOMBINE,
|
||||
MENU_SET_START_TO_VIDEO,
|
||||
MENU_SET_END_TO_VIDEO,
|
||||
MENU_SET_VIDEO_TO_START,
|
||||
|
|
Loading…
Reference in New Issue