forked from mia/Aegisub
A few more tweaks, fixes and clean-ups
Originally committed to SVN as r108.
This commit is contained in:
parent
25d5516d77
commit
0b862d1727
9 changed files with 92 additions and 101 deletions
|
@ -96,27 +96,14 @@ BaseGrid::~BaseGrid() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
////////////////
|
||||
// Select a row
|
||||
void BaseGrid::SelectRow(int row, bool addToSelected, bool select) {
|
||||
if (!addToSelected) ClearSelection();
|
||||
try {
|
||||
bool cur = selMap.at(row);
|
||||
if (select != cur) {
|
||||
selMap.at(row) = select;
|
||||
|
||||
if (!addToSelected) Refresh(false);
|
||||
|
||||
else {
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
GetClientSize(&w,&h);
|
||||
RefreshRect(wxRect(0,(row+1-yPos)*lineHeight,w,lineHeight),false);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {}
|
||||
///////////////
|
||||
// Clears grid
|
||||
void BaseGrid::Clear () {
|
||||
diagMap.clear();
|
||||
diagPtrMap.clear();
|
||||
selMap.clear();
|
||||
yPos = 0;
|
||||
AdjustScrollbar();
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,6 +149,49 @@ void BaseGrid::MakeCellVisible(int row, int col,bool center) {
|
|||
}
|
||||
|
||||
|
||||
////////////////
|
||||
// Select a row
|
||||
void BaseGrid::SelectRow(int row, bool addToSelected, bool select) {
|
||||
if (!addToSelected) ClearSelection();
|
||||
try {
|
||||
bool cur = selMap.at(row);
|
||||
if (select != cur) {
|
||||
selMap.at(row) = select;
|
||||
|
||||
if (!addToSelected) Refresh(false);
|
||||
|
||||
else {
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
GetClientSize(&w,&h);
|
||||
RefreshRect(wxRect(0,(row+1-yPos)*lineHeight,w,lineHeight),false);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// Selects visible lines
|
||||
void BaseGrid::SelectVisible() {
|
||||
int rows = GetRows();
|
||||
bool selectedOne = false;
|
||||
for (int i=0;i<rows;i++) {
|
||||
if (IsDisplayed(GetDialogue(i))) {
|
||||
if (!selectedOne) {
|
||||
SelectRow(i,false);
|
||||
MakeCellVisible(i,0);
|
||||
selectedOne = true;
|
||||
}
|
||||
else {
|
||||
SelectRow(i,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
// Unselects all cells
|
||||
void BaseGrid::ClearSelection() {
|
||||
|
@ -242,15 +272,6 @@ int BaseGrid::GetRows() const {
|
|||
}
|
||||
|
||||
|
||||
/////////////////////
|
||||
// Auto size columns
|
||||
void BaseGrid::AutoSizeColumn(int col, bool setAsMin) {
|
||||
(void) col;
|
||||
(void) setAsMin;
|
||||
SetColumnWidths();
|
||||
}
|
||||
|
||||
|
||||
///////////////
|
||||
// Event table
|
||||
BEGIN_EVENT_TABLE(BaseGrid,wxWindow)
|
||||
|
@ -721,44 +742,60 @@ void BaseGrid::SetColumnWidths() {
|
|||
if (!byFrame) {
|
||||
AssTime time;
|
||||
dc.GetTextExtent(time.GetASSFormated(), &fw, &fh, NULL, NULL, &font);
|
||||
startLen = fw;
|
||||
endLen = fw;
|
||||
startLen = fw + 10;
|
||||
endLen = fw + 10;
|
||||
}
|
||||
|
||||
// O(n) widths
|
||||
int layerLen = 0;
|
||||
int actorLen = 0;
|
||||
int effectLen = 0;
|
||||
int maxLayer = 0;
|
||||
int maxStart = 0;
|
||||
int maxEnd = 0;
|
||||
AssDialogue *curDiag;
|
||||
for (int i=0;i<GetRows();i++) {
|
||||
curDiag = GetDialogue(i);
|
||||
if (curDiag) {
|
||||
// Layer
|
||||
dc.GetTextExtent(wxString::Format(_T("%i"),curDiag->Layer), &fw, &fh, NULL, NULL, &font);
|
||||
if (fw > layerLen) layerLen = fw;
|
||||
if (curDiag->Layer > maxLayer) maxLayer = curDiag->Layer;
|
||||
|
||||
// Actor
|
||||
dc.GetTextExtent(curDiag->Actor, &fw, &fh, NULL, NULL, &font);
|
||||
if (fw > actorLen) actorLen = fw;
|
||||
if (!curDiag->Actor.IsEmpty()) {
|
||||
dc.GetTextExtent(curDiag->Actor, &fw, &fh, NULL, NULL, &font);
|
||||
if (fw > actorLen) actorLen = fw;
|
||||
}
|
||||
|
||||
// Effect
|
||||
dc.GetTextExtent(curDiag->Effect, &fw, &fh, NULL, NULL, &font);
|
||||
if (fw > effectLen) effectLen = fw;
|
||||
if (!curDiag->Effect.IsEmpty()) {
|
||||
dc.GetTextExtent(curDiag->Effect, &fw, &fh, NULL, NULL, &font);
|
||||
if (fw > effectLen) effectLen = fw;
|
||||
}
|
||||
|
||||
// Times
|
||||
if (byFrame) {
|
||||
dc.GetTextExtent(wxString::Format(_T("%i"),VFR_Output.CorrectFrameAtTime(curDiag->Start.GetMS(),true)), &fw, &fh, NULL, NULL, &font);
|
||||
if (fw > startLen) startLen = fw;
|
||||
dc.GetTextExtent(wxString::Format(_T("%i"),VFR_Output.CorrectFrameAtTime(curDiag->End.GetMS(),true)), &fw, &fh, NULL, NULL, &font);
|
||||
if (fw > endLen) endLen = fw;
|
||||
int tmp = VFR_Output.CorrectFrameAtTime(curDiag->Start.GetMS(),true);
|
||||
if (tmp > maxStart) maxStart = tmp;
|
||||
tmp = VFR_Output.CorrectFrameAtTime(curDiag->End.GetMS(),true);
|
||||
if (tmp > maxEnd) maxEnd = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
layerLen += 10;
|
||||
|
||||
// Finish layer
|
||||
dc.GetTextExtent(wxString::Format(_T("%i"),maxLayer), &fw, &fh, NULL, NULL, &font);
|
||||
int layerLen = fw + 10;
|
||||
|
||||
// Finish times
|
||||
if (byFrame) {
|
||||
dc.GetTextExtent(wxString::Format(_T("%i"),maxStart), &fw, &fh, NULL, NULL, &font);
|
||||
startLen = fw + 10;
|
||||
dc.GetTextExtent(wxString::Format(_T("%i"),maxEnd), &fw, &fh, NULL, NULL, &font);
|
||||
endLen = fw + 10;
|
||||
}
|
||||
|
||||
// Finish actor/effect
|
||||
if (actorLen) actorLen += 10;
|
||||
if (effectLen) effectLen += 10;
|
||||
startLen += 10;
|
||||
endLen += 10;
|
||||
|
||||
// Style length
|
||||
int styleLen = 0;
|
||||
|
|
|
@ -103,14 +103,16 @@ public:
|
|||
bool IsDisplayed(AssDialogue *line);
|
||||
int GetNumberSelection();
|
||||
int GetFirstSelRow();
|
||||
void SelectVisible();
|
||||
wxArrayInt GetSelection(bool *continuous=NULL);
|
||||
|
||||
void Clear();
|
||||
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);
|
||||
|
||||
BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr);
|
||||
|
|
|
@ -225,7 +225,8 @@ void DialogResample::OnResample (wxCommandEvent &event) {
|
|||
subs->SetScriptInfo(_T("PlayResY"),wxString::Format(_T("%i"),y2));
|
||||
|
||||
// Flag as modified
|
||||
grid->LoadFromAss();
|
||||
subs->FlagAsModified();
|
||||
grid->CommitChanges();;
|
||||
EndModal(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,6 @@ void DialogShiftTimes::OnOK(wxCommandEvent &event) {
|
|||
Options.Save();
|
||||
|
||||
// End dialog
|
||||
//grid->LoadFromAss(NULL,true);
|
||||
grid->UpdateMaps();
|
||||
EndModal(0);
|
||||
}
|
||||
|
|
|
@ -511,7 +511,6 @@ void DialogTimingProcessor::Process() {
|
|||
}
|
||||
|
||||
// Update grid
|
||||
//grid->ass->FlagAsModified();
|
||||
//grid->CommitChanges();
|
||||
grid->LoadFromAss(NULL,true,false);
|
||||
grid->ass->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
}
|
||||
|
|
|
@ -910,7 +910,7 @@ void FrameMain::LoadVFR(wxString filename) {
|
|||
if (filename != _T("")) {
|
||||
try {
|
||||
VFR_Output.Load(filename);
|
||||
SubsBox->LoadFromAss(NULL,true,true);
|
||||
SubsBox->Refresh(false);
|
||||
}
|
||||
// Fail
|
||||
catch (wchar_t *error) {
|
||||
|
|
|
@ -579,7 +579,6 @@ void SubsEditBox::OnStyleChange(wxCommandEvent &event) {
|
|||
cur->UpdateData();
|
||||
}
|
||||
}
|
||||
grid->AutoSizeColumn(3);
|
||||
grid->ass->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
grid->EndBatch();
|
||||
|
@ -611,7 +610,6 @@ void SubsEditBox::OnActorChange(wxCommandEvent &event) {
|
|||
}
|
||||
|
||||
// Update grid
|
||||
grid->AutoSizeColumn(4);
|
||||
grid->ass->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
grid->EndBatch();
|
||||
|
@ -635,7 +633,6 @@ void SubsEditBox::OnLayerChange(wxCommandEvent &event) {
|
|||
cur->UpdateData();
|
||||
}
|
||||
}
|
||||
grid->AutoSizeColumn(0);
|
||||
grid->ass->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
grid->EndBatch();
|
||||
|
|
|
@ -728,18 +728,6 @@ void SubtitlesGrid::LoadDefault (AssFile *_ass) {
|
|||
}
|
||||
|
||||
|
||||
///////////////
|
||||
// Clears grid
|
||||
void SubtitlesGrid::Clear () {
|
||||
//if (GetNumberRows() > 0) DeleteRows(0,GetNumberRows());
|
||||
diagMap.clear();
|
||||
diagPtrMap.clear();
|
||||
selMap.clear();
|
||||
yPos = 0;
|
||||
AdjustScrollbar();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Read data from ASS file structure
|
||||
void SubtitlesGrid::LoadFromAss (AssFile *_ass,bool keepSelection,bool dontModify) {
|
||||
|
@ -769,8 +757,6 @@ void SubtitlesGrid::LoadFromAss (AssFile *_ass,bool keepSelection,bool dontModif
|
|||
for (entryIter cur=ass->Line.begin();cur != ass->Line.end();cur++) {
|
||||
curdiag = AssEntry::GetAsDialogue(*cur);
|
||||
if (curdiag) {
|
||||
//AppendRows(1);
|
||||
//SetRowToLine(n,curdiag);
|
||||
diagMap.push_back(cur);
|
||||
diagPtrMap.push_back(curdiag);
|
||||
selMap.push_back(false);
|
||||
|
@ -793,7 +779,6 @@ void SubtitlesGrid::LoadFromAss (AssFile *_ass,bool keepSelection,bool dontModif
|
|||
|
||||
// Finish setting layout
|
||||
AdjustScrollbar();
|
||||
SetColumnWidths();
|
||||
EndBatch();
|
||||
|
||||
// Commit
|
||||
|
@ -924,11 +909,6 @@ void SubtitlesGrid::PasteLines(int n) {
|
|||
curdata.Trim(false);
|
||||
try {
|
||||
AssDialogue *curdiag = new AssDialogue(curdata);
|
||||
//AssDialogue *curdiag = new AssDialogue;
|
||||
//curdiag->data = curdata;
|
||||
//curdiag->Parse();
|
||||
//curdiag->UpdateData();
|
||||
//InsertLine(curdiag,n,true,false);
|
||||
InsertLine(curdiag,n+inserted,false,false);
|
||||
inserted++;
|
||||
}
|
||||
|
@ -1212,8 +1192,6 @@ void SubtitlesGrid::SplitLine(int n,int pos,int mode) {
|
|||
wxString orig = n1->Text;
|
||||
n1->Text = orig.Left(pos);
|
||||
n2->Text = orig.Mid(pos);
|
||||
//n1->ParseASSTags();
|
||||
//n2->ParseASSTags();
|
||||
|
||||
// Modify time
|
||||
if (mode == 1) {
|
||||
|
@ -1260,6 +1238,7 @@ void SubtitlesGrid::CommitChanges(bool force) {
|
|||
if (playing) video->Play();
|
||||
}
|
||||
parentFrame->UpdateTitle();
|
||||
SetColumnWidths();
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
|
@ -1275,26 +1254,6 @@ wxString SubtitlesGrid::GetTempWorkFile () {
|
|||
}
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// Selects visible lines
|
||||
void SubtitlesGrid::SelectVisible() {
|
||||
int rows = GetRows();
|
||||
bool selectedOne = false;
|
||||
for (int i=0;i<rows;i++) {
|
||||
if (IsDisplayed(GetDialogue(i))) {
|
||||
if (!selectedOne) {
|
||||
SelectRow(i,false);
|
||||
MakeCellVisible(i,0);
|
||||
selectedOne = true;
|
||||
}
|
||||
else {
|
||||
SelectRow(i,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////
|
||||
// Set start to video pos
|
||||
void SubtitlesGrid::SetSubsToVideo(bool start) {
|
||||
|
|
|
@ -109,9 +109,6 @@ public:
|
|||
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue