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
|
||||
grid->SetRowToLine(line_n,dialogue);
|
||||
grid->editBox->Update(!karaoke->enabled);
|
||||
grid->ass->FlagAsModified();
|
||||
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
|
||||
int BaseGrid::GetRows() const {
|
||||
|
@ -928,3 +965,15 @@ void BaseGrid::OnKeyPress(wxKeyEvent &event) {
|
|||
|
||||
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 BeginBatch();
|
||||
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 ClearSelection();
|
||||
bool IsInSelection(int row, int col) const;
|
||||
bool IsDisplayed(AssDialogue *line);
|
||||
int GetNumberSelection();
|
||||
void UpdateMaps();
|
||||
int GetFirstSelRow();
|
||||
wxArrayInt GetSelection(bool *continuous=NULL);
|
||||
|
||||
void UpdateMaps();
|
||||
int GetRows() const;
|
||||
int GetNumberRows() const { return GetRows(); }
|
||||
void MakeCellVisible(int row, int col,bool center=true);
|
||||
|
||||
void AutoSizeColumn(int col, bool setAsMin = true);
|
||||
AssDialogue *GetDialogue(int n);
|
||||
|
|
|
@ -367,7 +367,6 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
|
|||
cur->UpdateData();
|
||||
|
||||
// Commit
|
||||
grid->SetRowToLine(curLine,cur);
|
||||
grid->ass->FlagAsModified();
|
||||
}
|
||||
|
||||
|
@ -387,8 +386,7 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
|
|||
// Update video
|
||||
if (updateVideo) {
|
||||
grid->CommitChanges();
|
||||
wxCommandEvent dummy;
|
||||
grid->OnSetVideoToStart(dummy);
|
||||
grid->SetVideoToSubs(true);
|
||||
}
|
||||
else if (DoReplace) Modified = true;
|
||||
|
||||
|
@ -455,7 +453,6 @@ void SearchReplaceEngine::ReplaceAll() {
|
|||
AssDialogue *cur = grid->GetDialogue(i);
|
||||
cur->UpdateData();
|
||||
//cur->ParseASSTags();
|
||||
grid->SetRowToLine(i,cur);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -571,8 +571,8 @@ void DialogSpellCheck::BlockStore() {
|
|||
curPlain->text = current_block;
|
||||
current_line->UpdateText();
|
||||
current_line->UpdateData();
|
||||
grid->SetRowToLine(curLineNumber,current_line);
|
||||
subs->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
}
|
||||
curPlain = 0;
|
||||
current_line->ClearBlocks();
|
||||
|
|
|
@ -215,7 +215,7 @@ void DialogStyling::SetStyle (wxString curName, bool jump) {
|
|||
line->UpdateData();
|
||||
|
||||
// Update grid/subs
|
||||
grid->SetRowToLine(linen,line);
|
||||
grid->Refresh(false);
|
||||
if (PreviewCheck->IsChecked()) {
|
||||
grid->ass->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
|
|
|
@ -314,7 +314,6 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
|||
cur->UpdateText();
|
||||
cur->UpdateData();
|
||||
cur->ClearBlocks();
|
||||
grid->SetRowToLine(curline,cur);
|
||||
subs->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
((FrameMain*)main)->UpdateTitle();
|
||||
|
|
|
@ -729,9 +729,7 @@ void FrameMain::OnSnapSubsStartToVid (wxCommandEvent &event) {
|
|||
wxArrayInt sel = SubsBox->GetSelection();
|
||||
if (sel.Count() > 0) {
|
||||
wxCommandEvent dummy;
|
||||
SubsBox->OnSetStartToVideo(dummy);
|
||||
//SubsBox->ass->FlagAsModified();
|
||||
//SubsBox->CommitChanges();
|
||||
SubsBox->SetSubsToVideo(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -741,9 +739,7 @@ void FrameMain::OnSnapSubsEndToVid (wxCommandEvent &event) {
|
|||
wxArrayInt sel = SubsBox->GetSelection();
|
||||
if (sel.Count() > 0) {
|
||||
wxCommandEvent dummy;
|
||||
SubsBox->OnSetEndToVideo(dummy);
|
||||
//SubsBox->ass->FlagAsModified();
|
||||
//SubsBox->CommitChanges();
|
||||
SubsBox->SetSubsToVideo(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -756,7 +752,7 @@ void FrameMain::OnSnapVidToSubsStart (wxCommandEvent &event) {
|
|||
wxArrayInt sel = SubsBox->GetSelection();
|
||||
if (sel.Count() > 0) {
|
||||
wxCommandEvent dummy;
|
||||
SubsBox->OnSetVideoToStart(dummy);
|
||||
SubsBox->SetVideoToSubs(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -766,7 +762,7 @@ void FrameMain::OnSnapVidToSubsEnd (wxCommandEvent &event) {
|
|||
wxArrayInt sel = SubsBox->GetSelection();
|
||||
if (sel.Count() > 0) {
|
||||
wxCommandEvent dummy;
|
||||
SubsBox->OnSetVideoToEnd(dummy);
|
||||
SubsBox->SetVideoToSubs(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -822,7 +818,6 @@ void FrameMain::OnSnapToScene (wxCommandEvent &event) {
|
|||
cur->Start.SetMS(start_ms);
|
||||
cur->End.SetMS(end_ms);
|
||||
cur->UpdateData();
|
||||
SubsBox->SetRowToLine(sel[i],cur);
|
||||
}
|
||||
|
||||
// Commit
|
||||
|
@ -853,7 +848,6 @@ void FrameMain::OnShiftToFrame (wxCommandEvent &event) {
|
|||
cur->Start.SetMS(cur->Start.GetMS()+shiftBy);
|
||||
cur->End.SetMS(cur->End.GetMS()+shiftBy);
|
||||
cur->UpdateData();
|
||||
SubsBox->SetRowToLine(sels[i],cur);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -962,18 +956,15 @@ void FrameMain::OnCloseWindow (wxCloseEvent &event) {
|
|||
//////////////////
|
||||
// Cut/copy/paste
|
||||
void FrameMain::OnCut (wxCommandEvent &event) {
|
||||
wxCommandEvent dummy;
|
||||
SubsBox->OnCutLines(dummy);
|
||||
SubsBox->CutLines();
|
||||
}
|
||||
|
||||
void FrameMain::OnCopy (wxCommandEvent &event) {
|
||||
wxCommandEvent dummy;
|
||||
SubsBox->OnCopyLines(dummy);
|
||||
SubsBox->CopyLines();
|
||||
}
|
||||
|
||||
void FrameMain::OnPaste (wxCommandEvent &event) {
|
||||
wxCommandEvent dummy;
|
||||
SubsBox->OnPasteLines(dummy);
|
||||
SubsBox->PasteLines(SubsBox->GetFirstSelRow());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -577,7 +577,6 @@ void SubsEditBox::OnStyleChange(wxCommandEvent &event) {
|
|||
if (cur) {
|
||||
cur->Style = StyleBox->GetValue();
|
||||
cur->UpdateData();
|
||||
grid->SetRowToLine(sel[i],cur);
|
||||
}
|
||||
}
|
||||
grid->AutoSizeColumn(3);
|
||||
|
@ -602,7 +601,6 @@ void SubsEditBox::OnActorChange(wxCommandEvent &event) {
|
|||
if (cur) {
|
||||
cur->Actor = actor;
|
||||
cur->UpdateData();
|
||||
grid->SetRowToLine(sel[i],cur);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -635,7 +633,6 @@ void SubsEditBox::OnLayerChange(wxCommandEvent &event) {
|
|||
Layer->GetValue().ToLong(&temp);
|
||||
cur->Layer = temp;
|
||||
cur->UpdateData();
|
||||
grid->SetRowToLine(sel[i],cur);
|
||||
}
|
||||
}
|
||||
grid->AutoSizeColumn(0);
|
||||
|
@ -704,7 +701,6 @@ void SubsEditBox::CommitTimes(bool start,bool end,bool fromStart) {
|
|||
|
||||
// Update
|
||||
cur->UpdateData();
|
||||
grid->SetRowToLine(sel[i],cur);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -730,7 +726,6 @@ void SubsEditBox::OnMarginLChange(wxCommandEvent &event) {
|
|||
if (cur) {
|
||||
cur->SetMarginString(MarginL->GetValue(),1);
|
||||
cur->UpdateData();
|
||||
grid->SetRowToLine(sel[i],cur);
|
||||
}
|
||||
}
|
||||
MarginL->SetValue(cur->GetMarginString(1));
|
||||
|
@ -753,7 +748,6 @@ void SubsEditBox::OnMarginRChange(wxCommandEvent &event) {
|
|||
if (cur) {
|
||||
cur->SetMarginString(MarginR->GetValue(),2);
|
||||
cur->UpdateData();
|
||||
grid->SetRowToLine(sel[i],cur);
|
||||
}
|
||||
}
|
||||
MarginR->SetValue(cur->GetMarginString(2));
|
||||
|
@ -776,7 +770,6 @@ void SubsEditBox::OnMarginVChange(wxCommandEvent &event) {
|
|||
if (cur) {
|
||||
cur->SetMarginString(MarginV->GetValue(),3);
|
||||
cur->UpdateData();
|
||||
grid->SetRowToLine(sel[i],cur);
|
||||
}
|
||||
}
|
||||
MarginV->SetValue(cur->GetMarginString(3));
|
||||
|
@ -798,7 +791,6 @@ void SubsEditBox::OnCommentChange(wxCommandEvent &event) {
|
|||
if (cur) {
|
||||
cur->Comment = CommentBox->GetValue();
|
||||
cur->UpdateData();
|
||||
grid->SetRowToLine(sel[i],cur);
|
||||
}
|
||||
}
|
||||
grid->ass->FlagAsModified();
|
||||
|
@ -876,7 +868,7 @@ void SubsEditBox::CommitText() {
|
|||
cur->Text = TextEdit->GetValue();
|
||||
//cur->ParseASSTags();
|
||||
cur->UpdateData();
|
||||
grid->SetRowToLine(linen,cur);
|
||||
grid->Refresh(false);
|
||||
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_12_2_RECOMBINE,SubtitlesGrid::On122Recombine)
|
||||
EVT_MENU(MENU_1_12_RECOMBINE,SubtitlesGrid::On112Recombine)
|
||||
|
||||
EVT_ERASE_BACKGROUND(SubtitlesGrid::OnEraseBackground)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
@ -90,22 +88,11 @@ SubtitlesGrid::SubtitlesGrid(FrameMain* parentFr, wxWindow *parent, wxWindowID i
|
|||
: BaseGrid(parent,id,pos,size,style,name)
|
||||
{
|
||||
// Vars
|
||||
changingCol = false;
|
||||
byFrame = false;
|
||||
ass = NULL;
|
||||
video = _video;
|
||||
editBox = NULL;
|
||||
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
|
||||
void SubtitlesGrid::OnCutLines (wxCommandEvent &WXUNUSED(&event)) {
|
||||
CopyLines();
|
||||
DeleteLines(-1,-1,true);
|
||||
CutLines();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////
|
||||
// Paste from clipboard
|
||||
void SubtitlesGrid::OnPasteLines (wxCommandEvent &WXUNUSED(&event)) {
|
||||
int n;
|
||||
int nrows = GetRows();
|
||||
for (int i=0;i<nrows;i++) {
|
||||
if (IsInSelection(i,0)) {
|
||||
n = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PasteLines(n);
|
||||
PasteLines(GetFirstSelRow());
|
||||
}
|
||||
|
||||
|
||||
|
@ -617,85 +594,28 @@ void SubtitlesGrid::OnDeleteLines (wxCommandEvent &WXUNUSED(&event)) {
|
|||
//////////////////////////
|
||||
// Set start to video pos
|
||||
void SubtitlesGrid::OnSetStartToVideo(wxCommandEvent &event) {
|
||||
// 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++;
|
||||
cur->Start.SetMS(ms);
|
||||
cur->UpdateData();
|
||||
SetRowToLine(sel[i],cur);
|
||||
}
|
||||
}
|
||||
|
||||
// Commit
|
||||
if (modified) {
|
||||
ass->FlagAsModified();
|
||||
CommitChanges();
|
||||
editBox->Update();
|
||||
}
|
||||
SetSubsToVideo(true);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////
|
||||
// Set end to video pos
|
||||
void SubtitlesGrid::OnSetEndToVideo(wxCommandEvent &event) {
|
||||
// Check if it's OK to do it
|
||||
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();
|
||||
}
|
||||
SetSubsToVideo(false);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////
|
||||
// Set video pos to start
|
||||
void SubtitlesGrid::OnSetVideoToStart(wxCommandEvent &event) {
|
||||
wxArrayInt sel = GetSelection();
|
||||
if (sel.Count() == 0) return;
|
||||
AssDialogue *cur = GetDialogue(sel[0]);
|
||||
if (cur) video->JumpToFrame(VFR_Output.CorrectFrameAtTime(cur->Start.GetMS(),true));
|
||||
SetVideoToSubs(true);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////
|
||||
// Set video pos to end
|
||||
void SubtitlesGrid::OnSetVideoToEnd(wxCommandEvent &event) {
|
||||
wxArrayInt sel = GetSelection();
|
||||
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));
|
||||
SetVideoToSubs(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -752,8 +672,6 @@ void SubtitlesGrid::On122Recombine(wxCommandEvent &event) {
|
|||
n2->UpdateData();
|
||||
|
||||
// Commit
|
||||
SetRowToLine(n,n1);
|
||||
SetRowToLine(n+1,n2);
|
||||
ass->FlagAsModified();
|
||||
CommitChanges();
|
||||
} else {
|
||||
|
@ -791,8 +709,6 @@ void SubtitlesGrid::On112Recombine(wxCommandEvent &event) {
|
|||
n2->UpdateData();
|
||||
|
||||
// Commit
|
||||
SetRowToLine(n,n1);
|
||||
SetRowToLine(n+1,n2);
|
||||
ass->FlagAsModified();
|
||||
CommitChanges();
|
||||
} 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
|
||||
void SubtitlesGrid::SwapLines(int n1,int n2) {
|
||||
|
@ -936,10 +831,6 @@ void SubtitlesGrid::SwapLines(int n1,int n2) {
|
|||
// Swaps
|
||||
iter_swap(src1,src2);
|
||||
|
||||
// Update display
|
||||
SetRowToLine(n1,AssEntry::GetAsDialogue(*src1));
|
||||
SetRowToLine(n2,AssEntry::GetAsDialogue(*src2));
|
||||
|
||||
// Update mapping
|
||||
diagMap[n1] = src1;
|
||||
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
|
||||
void SubtitlesGrid::PasteLines(int n) {
|
||||
|
@ -1151,7 +1050,6 @@ void SubtitlesGrid::AdjoinLines(int n1,int n2,bool setStart) {
|
|||
if (!cur) return;
|
||||
cur->Start = prev->End;
|
||||
cur->UpdateData();
|
||||
SetRowToLine(i,cur);
|
||||
prev = cur;
|
||||
}
|
||||
}
|
||||
|
@ -1165,7 +1063,6 @@ void SubtitlesGrid::AdjoinLines(int n1,int n2,bool setStart) {
|
|||
if (!next) return;
|
||||
cur->End = next->Start;
|
||||
cur->UpdateData();
|
||||
SetRowToLine(i,cur);
|
||||
cur = next;
|
||||
}
|
||||
}
|
||||
|
@ -1329,8 +1226,6 @@ void SubtitlesGrid::SplitLine(int n,int pos,int mode) {
|
|||
// Update data
|
||||
n1->UpdateData();
|
||||
n2->UpdateData();
|
||||
SetRowToLine(n,n1);
|
||||
SetRowToLine(n+1,n2);
|
||||
|
||||
// Update editbox and audio
|
||||
editBox->SetToLine(n);
|
||||
|
@ -1365,53 +1260,6 @@ void SubtitlesGrid::CommitChanges(bool force) {
|
|||
if (playing) video->Play();
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
private:
|
||||
wxString tempfile;
|
||||
bool changingCol;
|
||||
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 OnCellChange(wxGridEvent &event);
|
||||
void OnSelectCell(wxGridEvent &event);
|
||||
|
@ -107,31 +98,38 @@ public:
|
|||
void On1122Recombine(wxCommandEvent &event);
|
||||
void On122Recombine(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 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 CommitChanges(bool force=false);
|
||||
|
||||
void Clear();
|
||||
void SelectVisible();
|
||||
|
||||
void SetVideoToSubs(bool start);
|
||||
void SetSubsToVideo(bool start);
|
||||
|
||||
void SwapLines(int n1,int n2);
|
||||
void CopyLines();
|
||||
void DuplicateLines(int n1,int n2,bool nextFrame=false);
|
||||
void PasteLines(int n);
|
||||
void DeleteLines(int n1,int n2,bool sel);
|
||||
void JoinLines(int n1,int n2,bool concat=true);
|
||||
void JoinAsKaraoke(int n1,int n2);
|
||||
void AdjoinLines(int n1,int n2,bool setStart);
|
||||
void InsertLine(AssDialogue *line,int n,bool after,bool update=true);
|
||||
void ShiftLineByTime(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);
|
||||
int GetFirstSelRow();
|
||||
wxArrayInt GetSelection(bool *continuous=NULL);
|
||||
|
||||
void SetByFrame (bool state);
|
||||
void CopyLines();
|
||||
void CutLines();
|
||||
void PasteLines(int n);
|
||||
|
||||
wxString GetTempWorkFile ();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
|
|
@ -411,7 +411,7 @@ void VideoDisplay::JumpToFrame(int n) {
|
|||
ControlSlider->SetValue(n);
|
||||
|
||||
// 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
|
||||
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 target2 = VFR_Output.CorrectFrameAtTime(curDiag->End.GetMS(),false);
|
||||
bool drawn = false;
|
||||
|
@ -301,12 +298,11 @@ void VideoSlider::OnKeyDown(wxKeyEvent &event) {
|
|||
else if (Display->frame_n < target2) Display->JumpToFrame(target2);
|
||||
else {
|
||||
if (cur+1 >= grid->GetRows()) return;
|
||||
grid->BeginBatch();
|
||||
grid->editBox->SetToLine(cur+1);
|
||||
grid->SelectRow(cur+1);
|
||||
grid->MakeCellVisible(cur+1,0);
|
||||
grid->OnSetVideoToStart(dummy);
|
||||
grid->EndBatch();
|
||||
grid->SetVideoToSubs(true);
|
||||
grid->Refresh(false);
|
||||
drawn = true;
|
||||
}
|
||||
return;
|
||||
|
@ -318,27 +314,15 @@ void VideoSlider::OnKeyDown(wxKeyEvent &event) {
|
|||
else if (Display->frame_n > target1) Display->JumpToFrame(target1);
|
||||
else {
|
||||
if (cur-1 < 0) return;
|
||||
grid->BeginBatch();
|
||||
grid->editBox->SetToLine(cur-1);
|
||||
grid->SelectRow(cur-1);
|
||||
grid->MakeCellVisible(cur-1,0);
|
||||
grid->OnSetVideoToEnd(dummy);
|
||||
grid->EndBatch();
|
||||
grid->SetVideoToSubs(false);
|
||||
grid->Refresh(false);
|
||||
drawn = true;
|
||||
}
|
||||
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