forked from mia/Aegisub
Some clean up of grid classes
Originally committed to SVN as r107.
This commit is contained in:
parent
82bfd00da8
commit
25d5516d77
13 changed files with 148 additions and 243 deletions
|
@ -995,7 +995,6 @@ void AudioDisplay::CommitChanges () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update grid
|
// Update grid
|
||||||
grid->SetRowToLine(line_n,dialogue);
|
|
||||||
grid->editBox->Update(!karaoke->enabled);
|
grid->editBox->Update(!karaoke->enabled);
|
||||||
grid->ass->FlagAsModified();
|
grid->ass->FlagAsModified();
|
||||||
grid->CommitChanges();
|
grid->CommitChanges();
|
||||||
|
|
|
@ -198,6 +198,43 @@ int BaseGrid::GetNumberSelection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////
|
||||||
|
// Gets first selected row
|
||||||
|
int BaseGrid::GetFirstSelRow() {
|
||||||
|
int nrows = GetRows();
|
||||||
|
for (int i=0;i<nrows;i++) {
|
||||||
|
if (IsInSelection(i,0)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////
|
||||||
|
// Gets all selected rows
|
||||||
|
wxArrayInt BaseGrid::GetSelection(bool *cont) {
|
||||||
|
// Prepare
|
||||||
|
int nrows = GetRows();
|
||||||
|
int last = -1;
|
||||||
|
bool continuous = true;
|
||||||
|
wxArrayInt selections;
|
||||||
|
|
||||||
|
// Scan
|
||||||
|
for (int i=0;i<nrows;i++) {
|
||||||
|
if (IsInSelection(i,0)) {
|
||||||
|
selections.Add(i);
|
||||||
|
if (last != -1 && i != last+1) continuous = false;
|
||||||
|
last = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return
|
||||||
|
if (cont) *cont = continuous;
|
||||||
|
return selections;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// Get number of rows
|
// Get number of rows
|
||||||
int BaseGrid::GetRows() const {
|
int BaseGrid::GetRows() const {
|
||||||
|
@ -928,3 +965,15 @@ void BaseGrid::OnKeyPress(wxKeyEvent &event) {
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// Sets display by frame or not
|
||||||
|
void BaseGrid::SetByFrame (bool state) {
|
||||||
|
// Check if it's already the same
|
||||||
|
if (byFrame == state) return;
|
||||||
|
byFrame = state;
|
||||||
|
SetColumnWidths();
|
||||||
|
Refresh(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,17 +95,20 @@ public:
|
||||||
void SetColumnWidths();
|
void SetColumnWidths();
|
||||||
void BeginBatch();
|
void BeginBatch();
|
||||||
void EndBatch();
|
void EndBatch();
|
||||||
void MakeCellVisible(int row, int col,bool center=true);
|
void SetByFrame (bool state);
|
||||||
|
|
||||||
void SelectRow(int row, bool addToSelected = false, bool select=true);
|
void SelectRow(int row, bool addToSelected = false, bool select=true);
|
||||||
void ClearSelection();
|
void ClearSelection();
|
||||||
bool IsInSelection(int row, int col) const;
|
bool IsInSelection(int row, int col) const;
|
||||||
bool IsDisplayed(AssDialogue *line);
|
bool IsDisplayed(AssDialogue *line);
|
||||||
int GetNumberSelection();
|
int GetNumberSelection();
|
||||||
void UpdateMaps();
|
int GetFirstSelRow();
|
||||||
|
wxArrayInt GetSelection(bool *continuous=NULL);
|
||||||
|
|
||||||
|
void UpdateMaps();
|
||||||
int GetRows() const;
|
int GetRows() const;
|
||||||
int GetNumberRows() const { return GetRows(); }
|
int GetNumberRows() const { return GetRows(); }
|
||||||
|
void MakeCellVisible(int row, int col,bool center=true);
|
||||||
|
|
||||||
void AutoSizeColumn(int col, bool setAsMin = true);
|
void AutoSizeColumn(int col, bool setAsMin = true);
|
||||||
AssDialogue *GetDialogue(int n);
|
AssDialogue *GetDialogue(int n);
|
||||||
|
|
|
@ -367,7 +367,6 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
|
|
||||||
// Commit
|
// Commit
|
||||||
grid->SetRowToLine(curLine,cur);
|
|
||||||
grid->ass->FlagAsModified();
|
grid->ass->FlagAsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,8 +386,7 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
|
||||||
// Update video
|
// Update video
|
||||||
if (updateVideo) {
|
if (updateVideo) {
|
||||||
grid->CommitChanges();
|
grid->CommitChanges();
|
||||||
wxCommandEvent dummy;
|
grid->SetVideoToSubs(true);
|
||||||
grid->OnSetVideoToStart(dummy);
|
|
||||||
}
|
}
|
||||||
else if (DoReplace) Modified = true;
|
else if (DoReplace) Modified = true;
|
||||||
|
|
||||||
|
@ -455,7 +453,6 @@ void SearchReplaceEngine::ReplaceAll() {
|
||||||
AssDialogue *cur = grid->GetDialogue(i);
|
AssDialogue *cur = grid->GetDialogue(i);
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
//cur->ParseASSTags();
|
//cur->ParseASSTags();
|
||||||
grid->SetRowToLine(i,cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -571,8 +571,8 @@ void DialogSpellCheck::BlockStore() {
|
||||||
curPlain->text = current_block;
|
curPlain->text = current_block;
|
||||||
current_line->UpdateText();
|
current_line->UpdateText();
|
||||||
current_line->UpdateData();
|
current_line->UpdateData();
|
||||||
grid->SetRowToLine(curLineNumber,current_line);
|
|
||||||
subs->FlagAsModified();
|
subs->FlagAsModified();
|
||||||
|
grid->CommitChanges();
|
||||||
}
|
}
|
||||||
curPlain = 0;
|
curPlain = 0;
|
||||||
current_line->ClearBlocks();
|
current_line->ClearBlocks();
|
||||||
|
|
|
@ -215,7 +215,7 @@ void DialogStyling::SetStyle (wxString curName, bool jump) {
|
||||||
line->UpdateData();
|
line->UpdateData();
|
||||||
|
|
||||||
// Update grid/subs
|
// Update grid/subs
|
||||||
grid->SetRowToLine(linen,line);
|
grid->Refresh(false);
|
||||||
if (PreviewCheck->IsChecked()) {
|
if (PreviewCheck->IsChecked()) {
|
||||||
grid->ass->FlagAsModified();
|
grid->ass->FlagAsModified();
|
||||||
grid->CommitChanges();
|
grid->CommitChanges();
|
||||||
|
|
|
@ -314,7 +314,6 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
||||||
cur->UpdateText();
|
cur->UpdateText();
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
cur->ClearBlocks();
|
cur->ClearBlocks();
|
||||||
grid->SetRowToLine(curline,cur);
|
|
||||||
subs->FlagAsModified();
|
subs->FlagAsModified();
|
||||||
grid->CommitChanges();
|
grid->CommitChanges();
|
||||||
((FrameMain*)main)->UpdateTitle();
|
((FrameMain*)main)->UpdateTitle();
|
||||||
|
|
|
@ -729,9 +729,7 @@ void FrameMain::OnSnapSubsStartToVid (wxCommandEvent &event) {
|
||||||
wxArrayInt sel = SubsBox->GetSelection();
|
wxArrayInt sel = SubsBox->GetSelection();
|
||||||
if (sel.Count() > 0) {
|
if (sel.Count() > 0) {
|
||||||
wxCommandEvent dummy;
|
wxCommandEvent dummy;
|
||||||
SubsBox->OnSetStartToVideo(dummy);
|
SubsBox->SetSubsToVideo(true);
|
||||||
//SubsBox->ass->FlagAsModified();
|
|
||||||
//SubsBox->CommitChanges();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -741,9 +739,7 @@ void FrameMain::OnSnapSubsEndToVid (wxCommandEvent &event) {
|
||||||
wxArrayInt sel = SubsBox->GetSelection();
|
wxArrayInt sel = SubsBox->GetSelection();
|
||||||
if (sel.Count() > 0) {
|
if (sel.Count() > 0) {
|
||||||
wxCommandEvent dummy;
|
wxCommandEvent dummy;
|
||||||
SubsBox->OnSetEndToVideo(dummy);
|
SubsBox->SetSubsToVideo(false);
|
||||||
//SubsBox->ass->FlagAsModified();
|
|
||||||
//SubsBox->CommitChanges();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -756,7 +752,7 @@ void FrameMain::OnSnapVidToSubsStart (wxCommandEvent &event) {
|
||||||
wxArrayInt sel = SubsBox->GetSelection();
|
wxArrayInt sel = SubsBox->GetSelection();
|
||||||
if (sel.Count() > 0) {
|
if (sel.Count() > 0) {
|
||||||
wxCommandEvent dummy;
|
wxCommandEvent dummy;
|
||||||
SubsBox->OnSetVideoToStart(dummy);
|
SubsBox->SetVideoToSubs(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -766,7 +762,7 @@ void FrameMain::OnSnapVidToSubsEnd (wxCommandEvent &event) {
|
||||||
wxArrayInt sel = SubsBox->GetSelection();
|
wxArrayInt sel = SubsBox->GetSelection();
|
||||||
if (sel.Count() > 0) {
|
if (sel.Count() > 0) {
|
||||||
wxCommandEvent dummy;
|
wxCommandEvent dummy;
|
||||||
SubsBox->OnSetVideoToEnd(dummy);
|
SubsBox->SetVideoToSubs(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -822,7 +818,6 @@ void FrameMain::OnSnapToScene (wxCommandEvent &event) {
|
||||||
cur->Start.SetMS(start_ms);
|
cur->Start.SetMS(start_ms);
|
||||||
cur->End.SetMS(end_ms);
|
cur->End.SetMS(end_ms);
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
SubsBox->SetRowToLine(sel[i],cur);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit
|
// Commit
|
||||||
|
@ -853,7 +848,6 @@ void FrameMain::OnShiftToFrame (wxCommandEvent &event) {
|
||||||
cur->Start.SetMS(cur->Start.GetMS()+shiftBy);
|
cur->Start.SetMS(cur->Start.GetMS()+shiftBy);
|
||||||
cur->End.SetMS(cur->End.GetMS()+shiftBy);
|
cur->End.SetMS(cur->End.GetMS()+shiftBy);
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
SubsBox->SetRowToLine(sels[i],cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,18 +956,15 @@ void FrameMain::OnCloseWindow (wxCloseEvent &event) {
|
||||||
//////////////////
|
//////////////////
|
||||||
// Cut/copy/paste
|
// Cut/copy/paste
|
||||||
void FrameMain::OnCut (wxCommandEvent &event) {
|
void FrameMain::OnCut (wxCommandEvent &event) {
|
||||||
wxCommandEvent dummy;
|
SubsBox->CutLines();
|
||||||
SubsBox->OnCutLines(dummy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameMain::OnCopy (wxCommandEvent &event) {
|
void FrameMain::OnCopy (wxCommandEvent &event) {
|
||||||
wxCommandEvent dummy;
|
SubsBox->CopyLines();
|
||||||
SubsBox->OnCopyLines(dummy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameMain::OnPaste (wxCommandEvent &event) {
|
void FrameMain::OnPaste (wxCommandEvent &event) {
|
||||||
wxCommandEvent dummy;
|
SubsBox->PasteLines(SubsBox->GetFirstSelRow());
|
||||||
SubsBox->OnPasteLines(dummy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -577,7 +577,6 @@ void SubsEditBox::OnStyleChange(wxCommandEvent &event) {
|
||||||
if (cur) {
|
if (cur) {
|
||||||
cur->Style = StyleBox->GetValue();
|
cur->Style = StyleBox->GetValue();
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
grid->SetRowToLine(sel[i],cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
grid->AutoSizeColumn(3);
|
grid->AutoSizeColumn(3);
|
||||||
|
@ -602,7 +601,6 @@ void SubsEditBox::OnActorChange(wxCommandEvent &event) {
|
||||||
if (cur) {
|
if (cur) {
|
||||||
cur->Actor = actor;
|
cur->Actor = actor;
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
grid->SetRowToLine(sel[i],cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,7 +633,6 @@ void SubsEditBox::OnLayerChange(wxCommandEvent &event) {
|
||||||
Layer->GetValue().ToLong(&temp);
|
Layer->GetValue().ToLong(&temp);
|
||||||
cur->Layer = temp;
|
cur->Layer = temp;
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
grid->SetRowToLine(sel[i],cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
grid->AutoSizeColumn(0);
|
grid->AutoSizeColumn(0);
|
||||||
|
@ -704,7 +701,6 @@ void SubsEditBox::CommitTimes(bool start,bool end,bool fromStart) {
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
grid->SetRowToLine(sel[i],cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +726,6 @@ void SubsEditBox::OnMarginLChange(wxCommandEvent &event) {
|
||||||
if (cur) {
|
if (cur) {
|
||||||
cur->SetMarginString(MarginL->GetValue(),1);
|
cur->SetMarginString(MarginL->GetValue(),1);
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
grid->SetRowToLine(sel[i],cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MarginL->SetValue(cur->GetMarginString(1));
|
MarginL->SetValue(cur->GetMarginString(1));
|
||||||
|
@ -753,7 +748,6 @@ void SubsEditBox::OnMarginRChange(wxCommandEvent &event) {
|
||||||
if (cur) {
|
if (cur) {
|
||||||
cur->SetMarginString(MarginR->GetValue(),2);
|
cur->SetMarginString(MarginR->GetValue(),2);
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
grid->SetRowToLine(sel[i],cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MarginR->SetValue(cur->GetMarginString(2));
|
MarginR->SetValue(cur->GetMarginString(2));
|
||||||
|
@ -776,7 +770,6 @@ void SubsEditBox::OnMarginVChange(wxCommandEvent &event) {
|
||||||
if (cur) {
|
if (cur) {
|
||||||
cur->SetMarginString(MarginV->GetValue(),3);
|
cur->SetMarginString(MarginV->GetValue(),3);
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
grid->SetRowToLine(sel[i],cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MarginV->SetValue(cur->GetMarginString(3));
|
MarginV->SetValue(cur->GetMarginString(3));
|
||||||
|
@ -798,7 +791,6 @@ void SubsEditBox::OnCommentChange(wxCommandEvent &event) {
|
||||||
if (cur) {
|
if (cur) {
|
||||||
cur->Comment = CommentBox->GetValue();
|
cur->Comment = CommentBox->GetValue();
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
grid->SetRowToLine(sel[i],cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
grid->ass->FlagAsModified();
|
grid->ass->FlagAsModified();
|
||||||
|
@ -876,7 +868,7 @@ void SubsEditBox::CommitText() {
|
||||||
cur->Text = TextEdit->GetValue();
|
cur->Text = TextEdit->GetValue();
|
||||||
//cur->ParseASSTags();
|
//cur->ParseASSTags();
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
grid->SetRowToLine(linen,cur);
|
grid->Refresh(false);
|
||||||
audio->SetDialogue(grid,cur,linen);
|
audio->SetDialogue(grid,cur,linen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,8 +79,6 @@ BEGIN_EVENT_TABLE(SubtitlesGrid, BaseGrid)
|
||||||
EVT_MENU(MENU_1_12_2_RECOMBINE,SubtitlesGrid::On1122Recombine)
|
EVT_MENU(MENU_1_12_2_RECOMBINE,SubtitlesGrid::On1122Recombine)
|
||||||
EVT_MENU(MENU_12_2_RECOMBINE,SubtitlesGrid::On122Recombine)
|
EVT_MENU(MENU_12_2_RECOMBINE,SubtitlesGrid::On122Recombine)
|
||||||
EVT_MENU(MENU_1_12_RECOMBINE,SubtitlesGrid::On112Recombine)
|
EVT_MENU(MENU_1_12_RECOMBINE,SubtitlesGrid::On112Recombine)
|
||||||
|
|
||||||
EVT_ERASE_BACKGROUND(SubtitlesGrid::OnEraseBackground)
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,22 +88,11 @@ SubtitlesGrid::SubtitlesGrid(FrameMain* parentFr, wxWindow *parent, wxWindowID i
|
||||||
: BaseGrid(parent,id,pos,size,style,name)
|
: BaseGrid(parent,id,pos,size,style,name)
|
||||||
{
|
{
|
||||||
// Vars
|
// Vars
|
||||||
changingCol = false;
|
|
||||||
byFrame = false;
|
byFrame = false;
|
||||||
ass = NULL;
|
ass = NULL;
|
||||||
video = _video;
|
video = _video;
|
||||||
editBox = NULL;
|
editBox = NULL;
|
||||||
parentFrame = parentFr;
|
parentFrame = parentFr;
|
||||||
|
|
||||||
// Font size
|
|
||||||
int fontSize = Options.AsInt(_T("Grid font size"));
|
|
||||||
wxFont font;
|
|
||||||
font.SetPointSize(fontSize);
|
|
||||||
wxClientDC dc(this);
|
|
||||||
dc.SetFont(font);
|
|
||||||
int w,h;
|
|
||||||
dc.GetTextExtent(_T("#TWFfgGhH"), &w, &h, NULL, NULL, &font);
|
|
||||||
RowHeight = h+4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -586,24 +573,14 @@ void SubtitlesGrid::OnCopyLines (wxCommandEvent &WXUNUSED(&event)) {
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// Cuts selection to clipboard
|
// Cuts selection to clipboard
|
||||||
void SubtitlesGrid::OnCutLines (wxCommandEvent &WXUNUSED(&event)) {
|
void SubtitlesGrid::OnCutLines (wxCommandEvent &WXUNUSED(&event)) {
|
||||||
CopyLines();
|
CutLines();
|
||||||
DeleteLines(-1,-1,true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Paste from clipboard
|
// Paste from clipboard
|
||||||
void SubtitlesGrid::OnPasteLines (wxCommandEvent &WXUNUSED(&event)) {
|
void SubtitlesGrid::OnPasteLines (wxCommandEvent &WXUNUSED(&event)) {
|
||||||
int n;
|
PasteLines(GetFirstSelRow());
|
||||||
int nrows = GetRows();
|
|
||||||
for (int i=0;i<nrows;i++) {
|
|
||||||
if (IsInSelection(i,0)) {
|
|
||||||
n = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PasteLines(n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -617,85 +594,28 @@ void SubtitlesGrid::OnDeleteLines (wxCommandEvent &WXUNUSED(&event)) {
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
// Set start to video pos
|
// Set start to video pos
|
||||||
void SubtitlesGrid::OnSetStartToVideo(wxCommandEvent &event) {
|
void SubtitlesGrid::OnSetStartToVideo(wxCommandEvent &event) {
|
||||||
// Check if it's OK to do it
|
SetSubsToVideo(true);
|
||||||
if (!VFR_Output.loaded) return;
|
|
||||||
|
|
||||||
// Get new time
|
|
||||||
int ms = VFR_Output.CorrectTimeAtFrame(video->frame_n,true);
|
|
||||||
|
|
||||||
// Update selection
|
|
||||||
wxArrayInt sel = GetSelection();
|
|
||||||
AssDialogue *cur;
|
|
||||||
int modified =0;
|
|
||||||
for (size_t i=0;i<sel.Count();i++) {
|
|
||||||
cur = GetDialogue(sel[i]);
|
|
||||||
if (cur) {
|
|
||||||
modified++;
|
|
||||||
cur->Start.SetMS(ms);
|
|
||||||
cur->UpdateData();
|
|
||||||
SetRowToLine(sel[i],cur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commit
|
|
||||||
if (modified) {
|
|
||||||
ass->FlagAsModified();
|
|
||||||
CommitChanges();
|
|
||||||
editBox->Update();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Set end to video pos
|
// Set end to video pos
|
||||||
void SubtitlesGrid::OnSetEndToVideo(wxCommandEvent &event) {
|
void SubtitlesGrid::OnSetEndToVideo(wxCommandEvent &event) {
|
||||||
// Check if it's OK to do it
|
SetSubsToVideo(false);
|
||||||
if (!VFR_Output.loaded) return;
|
|
||||||
|
|
||||||
// Get new time
|
|
||||||
int ms = VFR_Output.CorrectTimeAtFrame(video->frame_n,false);
|
|
||||||
|
|
||||||
// Update selection
|
|
||||||
wxArrayInt sel = GetSelection();
|
|
||||||
AssDialogue *cur;
|
|
||||||
int modified = 0;
|
|
||||||
for (size_t i=0;i<sel.Count();i++) {
|
|
||||||
cur = GetDialogue(sel[i]);
|
|
||||||
if (cur) {
|
|
||||||
cur->End.SetMS(ms);
|
|
||||||
cur->UpdateData();
|
|
||||||
modified++;
|
|
||||||
SetRowToLine(sel[i],cur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commit
|
|
||||||
if (modified) {
|
|
||||||
ass->FlagAsModified();
|
|
||||||
CommitChanges();
|
|
||||||
editBox->Update();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
// Set video pos to start
|
// Set video pos to start
|
||||||
void SubtitlesGrid::OnSetVideoToStart(wxCommandEvent &event) {
|
void SubtitlesGrid::OnSetVideoToStart(wxCommandEvent &event) {
|
||||||
wxArrayInt sel = GetSelection();
|
SetVideoToSubs(true);
|
||||||
if (sel.Count() == 0) return;
|
|
||||||
AssDialogue *cur = GetDialogue(sel[0]);
|
|
||||||
if (cur) video->JumpToFrame(VFR_Output.CorrectFrameAtTime(cur->Start.GetMS(),true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Set video pos to end
|
// Set video pos to end
|
||||||
void SubtitlesGrid::OnSetVideoToEnd(wxCommandEvent &event) {
|
void SubtitlesGrid::OnSetVideoToEnd(wxCommandEvent &event) {
|
||||||
wxArrayInt sel = GetSelection();
|
SetVideoToSubs(false);
|
||||||
if (sel.Count() == 0) return;
|
|
||||||
AssDialogue *cur = GetDialogue(sel[0]);
|
|
||||||
//if (cur) video->JumpToTime(cur->End.GetMS());
|
|
||||||
if (cur) video->JumpToFrame(VFR_Output.CorrectFrameAtTime(cur->End.GetMS(),false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -752,8 +672,6 @@ void SubtitlesGrid::On122Recombine(wxCommandEvent &event) {
|
||||||
n2->UpdateData();
|
n2->UpdateData();
|
||||||
|
|
||||||
// Commit
|
// Commit
|
||||||
SetRowToLine(n,n1);
|
|
||||||
SetRowToLine(n+1,n2);
|
|
||||||
ass->FlagAsModified();
|
ass->FlagAsModified();
|
||||||
CommitChanges();
|
CommitChanges();
|
||||||
} else {
|
} else {
|
||||||
|
@ -791,8 +709,6 @@ void SubtitlesGrid::On112Recombine(wxCommandEvent &event) {
|
||||||
n2->UpdateData();
|
n2->UpdateData();
|
||||||
|
|
||||||
// Commit
|
// Commit
|
||||||
SetRowToLine(n,n1);
|
|
||||||
SetRowToLine(n+1,n2);
|
|
||||||
ass->FlagAsModified();
|
ass->FlagAsModified();
|
||||||
CommitChanges();
|
CommitChanges();
|
||||||
} else {
|
} else {
|
||||||
|
@ -903,27 +819,6 @@ void SubtitlesGrid::LoadFromAss (AssFile *_ass,bool keepSelection,bool dontModif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////
|
|
||||||
// Sets one line to a line from the subs
|
|
||||||
void SubtitlesGrid::SetRowToLine(int n,AssDialogue *line) {
|
|
||||||
Refresh(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////
|
|
||||||
// Sets row color
|
|
||||||
void SubtitlesGrid::SetRowColour(int n,AssDialogue *line) {
|
|
||||||
Refresh(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////
|
|
||||||
// Update row colours
|
|
||||||
void SubtitlesGrid::UpdateRowColours() {
|
|
||||||
Refresh(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// Swaps two lines
|
// Swaps two lines
|
||||||
void SubtitlesGrid::SwapLines(int n1,int n2) {
|
void SubtitlesGrid::SwapLines(int n1,int n2) {
|
||||||
|
@ -936,10 +831,6 @@ void SubtitlesGrid::SwapLines(int n1,int n2) {
|
||||||
// Swaps
|
// Swaps
|
||||||
iter_swap(src1,src2);
|
iter_swap(src1,src2);
|
||||||
|
|
||||||
// Update display
|
|
||||||
SetRowToLine(n1,AssEntry::GetAsDialogue(*src1));
|
|
||||||
SetRowToLine(n2,AssEntry::GetAsDialogue(*src2));
|
|
||||||
|
|
||||||
// Update mapping
|
// Update mapping
|
||||||
diagMap[n1] = src1;
|
diagMap[n1] = src1;
|
||||||
diagMap[n2] = src2;
|
diagMap[n2] = src2;
|
||||||
|
@ -999,6 +890,14 @@ void SubtitlesGrid::CopyLines() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////
|
||||||
|
// Cut to clipboard
|
||||||
|
void SubtitlesGrid::CutLines() {
|
||||||
|
CopyLines();
|
||||||
|
DeleteLines(-1,-1,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// Paste lines from clipboard
|
// Paste lines from clipboard
|
||||||
void SubtitlesGrid::PasteLines(int n) {
|
void SubtitlesGrid::PasteLines(int n) {
|
||||||
|
@ -1151,7 +1050,6 @@ void SubtitlesGrid::AdjoinLines(int n1,int n2,bool setStart) {
|
||||||
if (!cur) return;
|
if (!cur) return;
|
||||||
cur->Start = prev->End;
|
cur->Start = prev->End;
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
SetRowToLine(i,cur);
|
|
||||||
prev = cur;
|
prev = cur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1165,7 +1063,6 @@ void SubtitlesGrid::AdjoinLines(int n1,int n2,bool setStart) {
|
||||||
if (!next) return;
|
if (!next) return;
|
||||||
cur->End = next->Start;
|
cur->End = next->Start;
|
||||||
cur->UpdateData();
|
cur->UpdateData();
|
||||||
SetRowToLine(i,cur);
|
|
||||||
cur = next;
|
cur = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1329,8 +1226,6 @@ void SubtitlesGrid::SplitLine(int n,int pos,int mode) {
|
||||||
// Update data
|
// Update data
|
||||||
n1->UpdateData();
|
n1->UpdateData();
|
||||||
n2->UpdateData();
|
n2->UpdateData();
|
||||||
SetRowToLine(n,n1);
|
|
||||||
SetRowToLine(n+1,n2);
|
|
||||||
|
|
||||||
// Update editbox and audio
|
// Update editbox and audio
|
||||||
editBox->SetToLine(n);
|
editBox->SetToLine(n);
|
||||||
|
@ -1365,53 +1260,6 @@ void SubtitlesGrid::CommitChanges(bool force) {
|
||||||
if (playing) video->Play();
|
if (playing) video->Play();
|
||||||
}
|
}
|
||||||
parentFrame->UpdateTitle();
|
parentFrame->UpdateTitle();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////
|
|
||||||
// Gets first selected row
|
|
||||||
int SubtitlesGrid::GetFirstSelRow() {
|
|
||||||
int nrows = GetRows();
|
|
||||||
for (int i=0;i<nrows;i++) {
|
|
||||||
if (IsInSelection(i,0)) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////
|
|
||||||
// Gets all selected rows
|
|
||||||
wxArrayInt SubtitlesGrid::GetSelection(bool *cont) {
|
|
||||||
// Prepare
|
|
||||||
int nrows = GetRows();
|
|
||||||
int last = -1;
|
|
||||||
bool continuous = true;
|
|
||||||
wxArrayInt selections;
|
|
||||||
|
|
||||||
// Scan
|
|
||||||
for (int i=0;i<nrows;i++) {
|
|
||||||
if (IsInSelection(i,0)) {
|
|
||||||
selections.Add(i);
|
|
||||||
if (last != -1 && i != last+1) continuous = false;
|
|
||||||
last = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return
|
|
||||||
if (cont) *cont = continuous;
|
|
||||||
return selections;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
// Sets display by frame or not
|
|
||||||
void SubtitlesGrid::SetByFrame (bool state) {
|
|
||||||
// Check if it's already the same
|
|
||||||
if (byFrame == state) return;
|
|
||||||
byFrame = state;
|
|
||||||
SetColumnWidths();
|
|
||||||
Refresh(false);
|
Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1445,3 +1293,48 @@ void SubtitlesGrid::SelectVisible() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////
|
||||||
|
// Set start to video pos
|
||||||
|
void SubtitlesGrid::SetSubsToVideo(bool start) {
|
||||||
|
// Check if it's OK to do it
|
||||||
|
if (!VFR_Output.loaded) return;
|
||||||
|
|
||||||
|
// Get new time
|
||||||
|
int ms = VFR_Output.CorrectTimeAtFrame(video->frame_n,true);
|
||||||
|
|
||||||
|
// Update selection
|
||||||
|
wxArrayInt sel = GetSelection();
|
||||||
|
AssDialogue *cur;
|
||||||
|
int modified =0;
|
||||||
|
for (size_t i=0;i<sel.Count();i++) {
|
||||||
|
cur = GetDialogue(sel[i]);
|
||||||
|
if (cur) {
|
||||||
|
modified++;
|
||||||
|
if (start) cur->Start.SetMS(ms);
|
||||||
|
else cur->End.SetMS(ms);
|
||||||
|
cur->UpdateData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit
|
||||||
|
if (modified) {
|
||||||
|
ass->FlagAsModified();
|
||||||
|
CommitChanges();
|
||||||
|
editBox->Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// Set video pos to start/end
|
||||||
|
void SubtitlesGrid::SetVideoToSubs(bool start) {
|
||||||
|
wxArrayInt sel = GetSelection();
|
||||||
|
if (sel.Count() == 0) return;
|
||||||
|
AssDialogue *cur = GetDialogue(sel[0]);
|
||||||
|
if (cur) {
|
||||||
|
if (start) video->JumpToFrame(VFR_Output.CorrectFrameAtTime(cur->Start.GetMS(),true));
|
||||||
|
else video->JumpToFrame(VFR_Output.CorrectFrameAtTime(cur->End.GetMS(),false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -67,17 +67,8 @@ typedef std::list<AssEntry*>::iterator entryIter;
|
||||||
class SubtitlesGrid: public BaseGrid {
|
class SubtitlesGrid: public BaseGrid {
|
||||||
private:
|
private:
|
||||||
wxString tempfile;
|
wxString tempfile;
|
||||||
bool changingCol;
|
|
||||||
bool ready;
|
bool ready;
|
||||||
int RowHeight;
|
|
||||||
|
|
||||||
public:
|
|
||||||
AssFile *ass;
|
|
||||||
|
|
||||||
SubtitlesGrid(FrameMain* parentFrame,wxWindow *parent, wxWindowID id, VideoDisplay* video, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr);
|
|
||||||
~SubtitlesGrid();
|
|
||||||
|
|
||||||
void OnEraseBackground(wxEraseEvent& event) {}
|
|
||||||
void OnCellLeftClick(wxGridEvent &event);
|
void OnCellLeftClick(wxGridEvent &event);
|
||||||
void OnCellChange(wxGridEvent &event);
|
void OnCellChange(wxGridEvent &event);
|
||||||
void OnSelectCell(wxGridEvent &event);
|
void OnSelectCell(wxGridEvent &event);
|
||||||
|
@ -108,30 +99,37 @@ public:
|
||||||
void On122Recombine(wxCommandEvent &event);
|
void On122Recombine(wxCommandEvent &event);
|
||||||
void On112Recombine(wxCommandEvent &event);
|
void On112Recombine(wxCommandEvent &event);
|
||||||
|
|
||||||
|
public:
|
||||||
|
AssFile *ass;
|
||||||
|
|
||||||
|
SubtitlesGrid(FrameMain* parentFrame,wxWindow *parent, wxWindowID id, VideoDisplay* video, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr);
|
||||||
|
~SubtitlesGrid();
|
||||||
|
|
||||||
void LoadDefault(AssFile *ass=NULL);
|
void LoadDefault(AssFile *ass=NULL);
|
||||||
void Clear();
|
|
||||||
void SetRowColour(int n,AssDialogue *line=NULL);
|
|
||||||
void UpdateRowColours();
|
|
||||||
void SelectVisible();
|
|
||||||
void SetRowToLine(int n,AssDialogue *line);
|
|
||||||
void LoadFromAss(AssFile *ass=NULL,bool keepSelection=false,bool dontModify=false);
|
void LoadFromAss(AssFile *ass=NULL,bool keepSelection=false,bool dontModify=false);
|
||||||
void CommitChanges(bool force=false);
|
void CommitChanges(bool force=false);
|
||||||
|
|
||||||
|
void Clear();
|
||||||
|
void SelectVisible();
|
||||||
|
|
||||||
|
void SetVideoToSubs(bool start);
|
||||||
|
void SetSubsToVideo(bool start);
|
||||||
|
|
||||||
void SwapLines(int n1,int n2);
|
void SwapLines(int n1,int n2);
|
||||||
void CopyLines();
|
|
||||||
void DuplicateLines(int n1,int n2,bool nextFrame=false);
|
void DuplicateLines(int n1,int n2,bool nextFrame=false);
|
||||||
void PasteLines(int n);
|
|
||||||
void DeleteLines(int n1,int n2,bool sel);
|
void DeleteLines(int n1,int n2,bool sel);
|
||||||
void JoinLines(int n1,int n2,bool concat=true);
|
void JoinLines(int n1,int n2,bool concat=true);
|
||||||
|
void JoinAsKaraoke(int n1,int n2);
|
||||||
void AdjoinLines(int n1,int n2,bool setStart);
|
void AdjoinLines(int n1,int n2,bool setStart);
|
||||||
void InsertLine(AssDialogue *line,int n,bool after,bool update=true);
|
void InsertLine(AssDialogue *line,int n,bool after,bool update=true);
|
||||||
void ShiftLineByTime(int n,int len,int type);
|
void ShiftLineByTime(int n,int len,int type);
|
||||||
void ShiftLineByFrames(int n,int len,int type);
|
void ShiftLineByFrames(int n,int len,int type);
|
||||||
void JoinAsKaraoke(int n1,int n2);
|
|
||||||
void SplitLine(int n,int pos,int mode);
|
void SplitLine(int n,int pos,int mode);
|
||||||
int GetFirstSelRow();
|
|
||||||
wxArrayInt GetSelection(bool *continuous=NULL);
|
|
||||||
|
|
||||||
void SetByFrame (bool state);
|
void CopyLines();
|
||||||
|
void CutLines();
|
||||||
|
void PasteLines(int n);
|
||||||
|
|
||||||
wxString GetTempWorkFile ();
|
wxString GetTempWorkFile ();
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
|
@ -411,7 +411,7 @@ void VideoDisplay::JumpToFrame(int n) {
|
||||||
ControlSlider->SetValue(n);
|
ControlSlider->SetValue(n);
|
||||||
|
|
||||||
// Update grid
|
// Update grid
|
||||||
if (!IsPlaying && Options.AsBool(_T("Highlight subs in frame"))) grid->UpdateRowColours();
|
if (!IsPlaying && Options.AsBool(_T("Highlight subs in frame"))) grid->Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -288,9 +288,6 @@ void VideoSlider::OnKeyDown(wxKeyEvent &event) {
|
||||||
|
|
||||||
// Jump to next sub boundary
|
// Jump to next sub boundary
|
||||||
if (direction != 0) {
|
if (direction != 0) {
|
||||||
wxCommandEvent dummy;
|
|
||||||
//int target1 = VFR_Output.GetFrameAtTime(curDiag->Start.GetMS()+1)+1;
|
|
||||||
//int target2 = VFR_Output.GetFrameAtTime(curDiag->End.GetMS());
|
|
||||||
int target1 = VFR_Output.CorrectFrameAtTime(curDiag->Start.GetMS(),true);
|
int target1 = VFR_Output.CorrectFrameAtTime(curDiag->Start.GetMS(),true);
|
||||||
int target2 = VFR_Output.CorrectFrameAtTime(curDiag->End.GetMS(),false);
|
int target2 = VFR_Output.CorrectFrameAtTime(curDiag->End.GetMS(),false);
|
||||||
bool drawn = false;
|
bool drawn = false;
|
||||||
|
@ -301,12 +298,11 @@ void VideoSlider::OnKeyDown(wxKeyEvent &event) {
|
||||||
else if (Display->frame_n < target2) Display->JumpToFrame(target2);
|
else if (Display->frame_n < target2) Display->JumpToFrame(target2);
|
||||||
else {
|
else {
|
||||||
if (cur+1 >= grid->GetRows()) return;
|
if (cur+1 >= grid->GetRows()) return;
|
||||||
grid->BeginBatch();
|
|
||||||
grid->editBox->SetToLine(cur+1);
|
grid->editBox->SetToLine(cur+1);
|
||||||
grid->SelectRow(cur+1);
|
grid->SelectRow(cur+1);
|
||||||
grid->MakeCellVisible(cur+1,0);
|
grid->MakeCellVisible(cur+1,0);
|
||||||
grid->OnSetVideoToStart(dummy);
|
grid->SetVideoToSubs(true);
|
||||||
grid->EndBatch();
|
grid->Refresh(false);
|
||||||
drawn = true;
|
drawn = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -318,27 +314,15 @@ void VideoSlider::OnKeyDown(wxKeyEvent &event) {
|
||||||
else if (Display->frame_n > target1) Display->JumpToFrame(target1);
|
else if (Display->frame_n > target1) Display->JumpToFrame(target1);
|
||||||
else {
|
else {
|
||||||
if (cur-1 < 0) return;
|
if (cur-1 < 0) return;
|
||||||
grid->BeginBatch();
|
|
||||||
grid->editBox->SetToLine(cur-1);
|
grid->editBox->SetToLine(cur-1);
|
||||||
grid->SelectRow(cur-1);
|
grid->SelectRow(cur-1);
|
||||||
grid->MakeCellVisible(cur-1,0);
|
grid->MakeCellVisible(cur-1,0);
|
||||||
grid->OnSetVideoToEnd(dummy);
|
grid->SetVideoToSubs(false);
|
||||||
grid->EndBatch();
|
grid->Refresh(false);
|
||||||
drawn = true;
|
drawn = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text
|
|
||||||
/*
|
|
||||||
if (drawn) {
|
|
||||||
wxMemoryDC dc;
|
|
||||||
dc.SelectObject(*Display->curFrame);
|
|
||||||
dc.BeginDrawing();
|
|
||||||
dc.DrawText(_T("Hello world!"),10,10);
|
|
||||||
dc.EndDrawing();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue