Minor bugs fixed

Originally committed to SVN as r67.
This commit is contained in:
Rodrigo Braz Monteiro 2006-02-19 00:54:35 +00:00
parent 6edfa51c21
commit ff278ee099
5 changed files with 50 additions and 127 deletions

View File

@ -48,6 +48,7 @@
#include "vfr.h"
#include "subs_edit_box.h"
#include "frame_main.h"
#include "video_display.h"
///////////////
@ -266,9 +267,17 @@ void BaseGrid::DrawImage(wxDC &dc) {
// Row colors
std::vector<wxBrush> rowColors;
rowColors.push_back(wxBrush(wxColour(255,255,255)));
rowColors.push_back(wxBrush(wxColour(165,207,231)));
rowColors.push_back(wxBrush(Options.AsColour(_T("Grid selection background"))));
std::vector<wxBrush> foreColors;
rowColors.push_back(wxBrush(wxColour(255,255,255))); // 0 = Standard
foreColors.push_back(wxBrush(wxColour(0,0,0)));
rowColors.push_back(wxBrush(wxColour(165,207,231))); // 1 = Header
foreColors.push_back(wxBrush(wxColour(0,0,0)));
rowColors.push_back(wxBrush(Options.AsColour(_T("Grid selection background")))); // 2 = Selected
foreColors.push_back(wxBrush(Options.AsColour(_T("Grid selection foreground"))));
rowColors.push_back(wxBrush(Options.AsColour(_T("Grid comment background")))); // 3 = Commented
foreColors.push_back(wxBrush(Options.AsColour(_T("Grid selection foreground"))));
rowColors.push_back(wxBrush(Options.AsColour(_T("Grid inframe background")))); // 4 = Video Highlighted
foreColors.push_back(wxBrush(Options.AsColour(_T("Grid selection foreground"))));
// First grid row
bool drawGrid = true;
@ -314,8 +323,14 @@ void BaseGrid::DrawImage(wxDC &dc) {
// Set fields
strings.Add(wxString::Format(_T("%i"),curRow+1));
strings.Add(wxString::Format(_T("%i"),curDiag->Layer));
strings.Add(curDiag->Start.GetASSFormated());
strings.Add(curDiag->End.GetASSFormated());
if (byFrame) {
strings.Add(wxString::Format(_T("%i"),VFR_Output.CorrectFrameAtTime(curDiag->Start.GetMS(),true)));
strings.Add(wxString::Format(_T("%i"),VFR_Output.CorrectFrameAtTime(curDiag->End.GetMS(),true)));
}
else {
strings.Add(curDiag->Start.GetASSFormated());
strings.Add(curDiag->End.GetASSFormated());
}
strings.Add(curDiag->Style);
strings.Add(curDiag->Actor);
strings.Add(curDiag->Effect);
@ -350,12 +365,14 @@ void BaseGrid::DrawImage(wxDC &dc) {
else value = curDiag->Text;
// Cap length and set text
if (value.Length() > 128) value = value.Left(128) + _T("...");
if (value.Length() > 512) value = value.Left(512) + _T("...");
strings.Add(value);
// Set color
curColor = 0;
if (IsInSelection(curRow,0)) curColor = 2;
else if (curDiag->Comment) curColor = 3;
else if (Options.AsBool(_T("Highlight subs in frame")) && IsDisplayed(curDiag)) curColor = 4;
}
else {
@ -490,14 +507,15 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
// Toggle selected
if (click && ctrl && !shift) {
SelectRow(row,true,!IsInSelection(row,0));
parentFrame->SetSelectionFlag(GetNumberSelection());
return;
}
// Normal click
if (click && !shift && !ctrl && !alt) {
editBox->SetToLine(row);
parentFrame->SetSelectionFlag(validRow);
SelectRow(row,false);
parentFrame->SetSelectionFlag(GetNumberSelection());
lastRow = row;
return;
}
@ -520,6 +538,7 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
SelectRow(i,notFirst,true);
notFirst = true;
}
parentFrame->SetSelectionFlag(GetNumberSelection());
}
return;
}
@ -553,7 +572,7 @@ void BaseGrid::AdjustScrollbar() {
GetClientSize(&w,&h);
scrollBar->Freeze();
scrollBar->GetSize(&sw,&sh);
scrollBar->SetSize(w-sw-4,0,sw,h-4);
scrollBar->SetSize(w-sw,0,sw,h);
// Set parameters
int drawPerScreen = h/lineHeight;
@ -670,3 +689,14 @@ AssDialogue *BaseGrid::GetDialogue(int n) {
return NULL;
}
}
////////////////////////////////////
// Check if line is being displayed
bool BaseGrid::IsDisplayed(AssDialogue *line) {
if (!video->loaded) return false;
int f1 = VFR_Output.CorrectFrameAtTime(line->Start.GetMS(),true);
int f2 = VFR_Output.CorrectFrameAtTime(line->End.GetMS(),false);
if (f1 <= video->frame_n && f2 >= video->frame_n) return true;
return false;
}

View File

@ -51,6 +51,7 @@ class AssEntry;
class AssDialogue;
class SubsEditBox;
class FrameMain;
class VideoDisplay;
typedef std::list<AssEntry*>::iterator entryIter;
@ -73,7 +74,6 @@ private:
void OnMouseEvent(wxMouseEvent &event);
void AdjustScrollbar();
void SetColumnWidths();
void DrawImage(wxDC &dc);
protected:
@ -82,10 +82,13 @@ protected:
public:
SubsEditBox *editBox;
VideoDisplay *video;
bool byFrame;
std::vector<entryIter> diagMap;
std::vector<bool> selMap;
void SetColumnWidths();
void BeginBatch();
void EndBatch();
void MakeCellVisible(int row, int col);
@ -93,6 +96,8 @@ public:
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();
int GetRows() const;
int GetNumberRows() const { return GetRows(); }

View File

@ -177,6 +177,7 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren
// HACK: Fix colour of bg of editbox
origBgColour = TextEdit->GetBackgroundColour();
disabledBgColour = GetBackgroundColour();
Update();
}

View File

@ -924,100 +924,21 @@ 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) {
//BeginBatch();
//// Times
//if (byFrame) {
// SetCellValue(n,1,wxString::Format(_T("%i"),VFR_Output.CorrectFrameAtTime(line->Start.GetMS(),true)));
// SetCellValue(n,2,wxString::Format(_T("%i"),VFR_Output.CorrectFrameAtTime(line->End.GetMS(),false)));
//}
//else {
// SetCellValue(n,1,line->Start.GetASSFormated());
// SetCellValue(n,2,line->End.GetASSFormated());
//}
//// Fields
//SetCellValue(n,0,wxString::Format(_T("%d"),line->Layer));
//SetCellValue(n,3,line->Style);
//SetCellValue(n,4,line->Actor);
//SetCellValue(n,5,line->Effect);
//SetCellValue(n,6,wxString::Format(_T("%04d"),line->MarginL));
//SetCellValue(n,7,wxString::Format(_T("%04d"),line->MarginR));
//SetCellValue(n,8,wxString::Format(_T("%04d"),line->MarginV));
//// Text
//int mode = Options.AsInt(_T("Grid Hide Overrides"));
//wxString value = _T("");
//// Hid overrides
//if (mode == 1 || mode == 2) {
// wxString replaceWith = Options.AsText(_T("Grid hide overrides char"));
// line->ParseASSTags();
// size_t n = line->Blocks.size();
// for (size_t i=0;i<n;i++) {
// AssDialogueBlock *block = line->Blocks.at(i);
// AssDialogueBlockPlain *plain = AssDialogueBlock::GetAsPlain(block);
// if (plain) {
// value += plain->GetText();
// }
// else {
// if (mode == 1) {
// value += replaceWith;
// }
// }
// }
//}
//// Show overrides
//else value = line->Text;
//// Cap length and set text
//if (value.Length() > 128) value = value.Left(128) + _T("...");
//SetCellValue(n,9,value);
//// Colour
//SetRowColour(n,line);
//// Size
//SetRowSize(n,RowHeight);
//EndBatch();
Refresh(false);
}
//////////////////
// Sets row color
void SubtitlesGrid::SetRowColour(int n,AssDialogue *line) {
// Get line
if (!line) line = GetDialogue(n);
if (!line) return;
wxGridCellAttr* attr = new wxGridCellAttr;
// Comment
if (line->Comment) {
attr->SetTextColour(Options.AsColour(_T("Grid selection foreground")));
attr->SetBackgroundColour(Options.AsColour(_T("Grid comment background")));
}
// In video
else if (Options.AsBool(_T("Highlight subs in frame")) && IsDisplayed(line)) {
attr->SetTextColour(Options.AsColour(_T("Grid selection foreground")));
attr->SetBackgroundColour(Options.AsColour(_T("Grid inframe background")));
}
// Set
//SetRowAttr(n,attr);
Refresh(false);
}
//////////////////////
// Update row colours
void SubtitlesGrid::UpdateRowColours() {
BeginBatch();
int rows = GetRows();
for (int i=0;i<rows;i++) {
//SetRowColour(i);
}
EndBatch();
Refresh(false);
}
@ -1505,29 +1426,8 @@ void SubtitlesGrid::SetByFrame (bool state) {
// Check if it's already the same
if (byFrame == state) return;
byFrame = state;
//// Update rows
//BeginBatch();
//int nrows = GetRows();
//AssDialogue *line;
//for (int i=0;i<nrows;i++) {
// line = GetDialogue(i);
// if (byFrame) {
// SetCellValue(i,1,wxString::Format(_T("%i"),VFR_Output.CorrectFrameAtTime(line->Start.GetMS(),true)));
// SetCellValue(i,2,wxString::Format(_T("%i"),VFR_Output.CorrectFrameAtTime(line->End.GetMS(),false)));
// }
// else {
// SetCellValue(i,1,line->Start.GetASSFormated());
// SetCellValue(i,2,line->End.GetASSFormated());
// }
//}
//// Update columns
////AutoSizeColumn(1,false);
////AutoSizeColumn(2,false);
//AutoSizeColumns();
//FitColumns();
//EndBatch();
SetColumnWidths();
Refresh(false);
}
@ -1542,17 +1442,6 @@ wxString SubtitlesGrid::GetTempWorkFile () {
}
////////////////////////////////////
// Check if line is being displayed
bool SubtitlesGrid::IsDisplayed(AssDialogue *line) {
if (!video->loaded) return false;
int f1 = VFR_Output.CorrectFrameAtTime(line->Start.GetMS(),true);
int f2 = VFR_Output.CorrectFrameAtTime(line->End.GetMS(),false);
if (f1 <= video->frame_n && f2 >= video->frame_n) return true;
return false;
}
/////////////////////////
// Selects visible lines
void SubtitlesGrid::SelectVisible() {

View File

@ -73,7 +73,6 @@ private:
public:
AssFile *ass;
VideoDisplay *video;
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();
@ -114,7 +113,6 @@ public:
void SetRowColour(int n,AssDialogue *line=NULL);
void UpdateRowColours();
void SelectVisible();
bool IsDisplayed(AssDialogue *line);
void SetRowToLine(int n,AssDialogue *line);
void LoadFromAss(AssFile *ass=NULL,bool keepSelection=false,bool dontModify=false);
void CommitChanges(bool force=false);