diff --git a/core/base_grid.cpp b/core/base_grid.cpp index aa582ee27..9b3c76599 100644 --- a/core/base_grid.cpp +++ b/core/base_grid.cpp @@ -252,7 +252,7 @@ wxArrayInt BaseGrid::GetSelection(bool *cont) { // Scan for (int i=0;iCutLines(); + SubsBox->CutLines(SubsBox->GetSelection()); } void FrameMain::OnCopy (wxCommandEvent &event) { - SubsBox->CopyLines(); + SubsBox->CopyLines(SubsBox->GetSelection()); } void FrameMain::OnPaste (wxCommandEvent &event) { diff --git a/core/subs_grid.cpp b/core/subs_grid.cpp index 3eaa10554..2e4a855a3 100644 --- a/core/subs_grid.cpp +++ b/core/subs_grid.cpp @@ -99,8 +99,6 @@ SubtitlesGrid::SubtitlesGrid(FrameMain* parentFr, wxWindow *parent, wxWindowID i ////////////// // Destructor SubtitlesGrid::~SubtitlesGrid() { - wxRemoveFile(tempfile); - tempfile = _T(""); } @@ -267,178 +265,61 @@ void SubtitlesGrid::OnKeyDown(wxKeyEvent &event) { /////////////////////// // Duplicate selection void SubtitlesGrid::OnDuplicate (wxCommandEvent &WXUNUSED(&event)) { - int n1 = -1; - int n2 = -1; - bool gotfirst = false; - int nrows = GetRows(); - for (int i=0;idata; - } + if (!first) data += _T("\r\n"); + first = false; + cur = GetDialogue(target[i]); + data += cur->data; } // Send to clipboard @@ -880,9 +732,9 @@ void SubtitlesGrid::CopyLines() { //////////////////// // Cut to clipboard -void SubtitlesGrid::CutLines() { - CopyLines(); - DeleteLines(GetSelection()); +void SubtitlesGrid::CutLines(wxArrayInt target) { + CopyLines(target); + DeleteLines(target); } @@ -942,31 +794,6 @@ void SubtitlesGrid::DeleteLines(wxArrayInt target) { // Check if it's wiping file int deleted = 0; - //// Range - //if (!sel) { - // // Deallocate lines - // for (int i=n1;i<=n2;i++) { - // delete GetDialogue(i); - // } - - // // Remove from AssFile - // if (n1 != n2) ass->Line.erase(diagMap.at(n1),++diagMap.at(n2)); - // else ass->Line.erase(diagMap.at(n1)); - // deleted = n2-n1+1; - //} - - //// Selection - //else { - // int nlines = GetRows(); - // for (int i=0;iLine.erase(diagMap.at(i)); - // deleted++; - // } - // } - //} - // Delete lines int size = target.Count(); for (int i=0;iGetTempWorkFile(); ass->Export(workfile); if (video->loaded) @@ -1255,17 +1082,6 @@ void SubtitlesGrid::CommitChanges(bool force) { } -////////////////////////////// -// Get name of temp work file -wxString SubtitlesGrid::GetTempWorkFile () { - if (tempfile.IsEmpty()) { - tempfile = wxFileName::CreateTempFileName(_T("aegisub")); - tempfile += _T(".ass"); - } - return tempfile; -} - - ////////////////////////// // Set start to video pos void SubtitlesGrid::SetSubsToVideo(bool start) { diff --git a/core/subs_grid.h b/core/subs_grid.h index 00e7c3338..8bd3fb63c 100644 --- a/core/subs_grid.h +++ b/core/subs_grid.h @@ -66,12 +66,8 @@ typedef std::list::iterator entryIter; // Main class class SubtitlesGrid: public BaseGrid { private: - wxString tempfile; bool ready; - void OnCellLeftClick(wxGridEvent &event); - void OnCellChange(wxGridEvent &event); - void OnSelectCell(wxGridEvent &event); void OnPopupMenu(); void OnKeyDown(wxKeyEvent &event); @@ -112,22 +108,22 @@ public: void SetVideoToSubs(bool start); void SetSubsToVideo(bool start); - void SwapLines(int n1,int n2); - void DuplicateLines(int n1,int n2,bool nextFrame=false); + void JoinLines(int first,int last,bool concat=true); + void JoinAsKaraoke(int first,int last); + void AdjoinLines(int first,int last,bool setStart); + void SplitLine(int lineNumber,int splitPosition,int mode); + void DuplicateLines(int first,int last,bool nextFrame=false); + + void SwapLines(int line1,int line2); + void ShiftLineByTime(int lineNumber,int len,int type); + void ShiftLineByFrames(int lineNumber,int len,int type); + + void InsertLine(AssDialogue *line,int position,bool insertAfter,bool update=true); void DeleteLines(wxArrayInt lines); - 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 SplitLine(int n,int pos,int mode); - void CopyLines(); - void CutLines(); - void PasteLines(int n); - - wxString GetTempWorkFile (); + void CopyLines(wxArrayInt lines); + void CutLines(wxArrayInt lines); + void PasteLines(int pos); DECLARE_EVENT_TABLE() }; diff --git a/core/video_display.cpp b/core/video_display.cpp index ae855572b..6c4a03d63 100644 --- a/core/video_display.cpp +++ b/core/video_display.cpp @@ -115,6 +115,8 @@ VideoDisplay::VideoDisplay(wxWindow* parent, wxWindowID id, const wxPoint& pos, ////////////// // Destructor VideoDisplay::~VideoDisplay () { + wxRemoveFile(tempfile); + tempfile = _T(""); SetVideo(_T("")); delete backbuffer; } @@ -154,7 +156,7 @@ void VideoDisplay::SetVideo(const wxString &filename) { bool usedDirectshow; - provider = new VideoProvider(filename,grid->GetTempWorkFile(),zoomValue,usedDirectshow,true); + provider = new VideoProvider(filename,GetTempWorkFile(),zoomValue,usedDirectshow,true); // Set keyframes if (filename.Right(4).Lower() == _T(".avi")) @@ -844,3 +846,14 @@ void VideoDisplay::OnPlayTimer(wxTimerEvent &event) { audio->provider->realPlayPos = audPos; } } + + +////////////////////////////// +// Get name of temp work file +wxString VideoDisplay::GetTempWorkFile () { + if (tempfile.IsEmpty()) { + tempfile = wxFileName::CreateTempFileName(_T("aegisub")); + tempfile += _T(".ass"); + } + return tempfile; +} diff --git a/core/video_display.h b/core/video_display.h index ba8f6b55e..2108455dc 100644 --- a/core/video_display.h +++ b/core/video_display.h @@ -61,6 +61,8 @@ class VideoDisplay: public wxWindow { friend class AudioProvider; private: + wxString tempfile; + int mouse_x,mouse_y; wxBitmap *backbuffer; @@ -136,6 +138,7 @@ public: void SetZoomPos(int pos); void UpdateSubsRelativeTime(); void GetScriptSize(int &w,int &h); + wxString GetTempWorkFile (); void Play(); void PlayLine();