Fixed behavior of deleting and joining lines on subtitles grid

Originally committed to SVN as r90.
This commit is contained in:
Rodrigo Braz Monteiro 2006-02-21 02:01:42 +00:00
parent 6eae67a95e
commit a82f60fe72
5 changed files with 60 additions and 4 deletions

View file

@ -750,3 +750,49 @@ bool BaseGrid::IsDisplayed(AssDialogue *line) {
if (f1 <= video->frame_n && f2 >= video->frame_n) return true;
return false;
}
///////////////
// Update maps
void BaseGrid::UpdateMaps() {
// Store old
int len = diagMap.size();
std::vector<AssDialogue *> tmpDiagPtrMap;
std::vector<bool> tmpSelMap;
for (int i=0;i<len;i++) {
tmpDiagPtrMap.push_back(diagPtrMap[i]);
tmpSelMap.push_back(selMap[i]);
}
// Clear old
diagPtrMap.clear();
diagMap.clear();
selMap.clear();
// Re-generate lines
int n = 0;
AssDialogue *curdiag;
for (entryIter cur=AssFile::top->Line.begin();cur != AssFile::top->Line.end();cur++) {
curdiag = AssEntry::GetAsDialogue(*cur);
if (curdiag) {
// Find old pos
bool sel = false;
for (int i=0;i<len;i++) {
if (tmpDiagPtrMap[i] == curdiag) {
sel = tmpSelMap[i];
break;
}
}
// Add new
diagMap.push_back(cur);
diagPtrMap.push_back(curdiag);
selMap.push_back(sel);
n++;
}
}
// Refresh
Refresh(false);
}

View file

@ -87,6 +87,7 @@ public:
bool byFrame;
std::vector<entryIter> diagMap;
std::vector<AssDialogue *> diagPtrMap;
std::vector<bool> selMap;
void SetColumnWidths();
@ -99,6 +100,7 @@ public:
bool IsInSelection(int row, int col) const;
bool IsDisplayed(AssDialogue *line);
int GetNumberSelection();
void UpdateMaps();
int GetRows() const;
int GetNumberRows() const { return GetRows(); }

View file

@ -37,6 +37,7 @@ Please visit http://aegisub.net to download latest version
- Rows colliding with the currently active one will now be highlighted in grid (AMZ)
- Selected comments are now highlighted in a different color (AMZ)
- Added a volume slider bar to audio mode (AMZ)
- Fixed behavior of deleting and joining lines on subtitles grid (AMZ)
= 1.09 beta - 2006.01.16 ===========================

View file

@ -259,7 +259,8 @@ void DialogShiftTimes::OnOK(wxCommandEvent &event) {
Options.Save();
// End dialog
grid->LoadFromAss(NULL,true);
//grid->LoadFromAss(NULL,true);
grid->UpdateMaps();
EndModal(0);
}

View file

@ -809,6 +809,7 @@ void SubtitlesGrid::LoadDefault (AssFile *_ass) {
void SubtitlesGrid::Clear () {
//if (GetNumberRows() > 0) DeleteRows(0,GetNumberRows());
diagMap.clear();
diagPtrMap.clear();
selMap.clear();
yPos = 0;
AdjustScrollbar();
@ -845,8 +846,9 @@ void SubtitlesGrid::LoadFromAss (AssFile *_ass,bool keepSelection,bool dontModif
curdiag = AssEntry::GetAsDialogue(*cur);
if (curdiag) {
//AppendRows(1);
SetRowToLine(n,curdiag);
//SetRowToLine(n,curdiag);
diagMap.push_back(cur);
diagPtrMap.push_back(curdiag);
selMap.push_back(false);
n++;
}
@ -866,8 +868,9 @@ void SubtitlesGrid::LoadFromAss (AssFile *_ass,bool keepSelection,bool dontModif
}
// Finish setting layout
EndBatch();
AdjustScrollbar();
SetColumnWidths();
EndBatch();
// Commit
if (!AssFile::Popping) {
@ -1080,7 +1083,10 @@ void SubtitlesGrid::DeleteLines(int n1,int n2,bool sel) {
}
// Update
LoadFromAss();
UpdateMaps();
AdjustScrollbar();
ass->FlagAsModified();
CommitChanges();
}