Factor out the options lookups from BaseGrid::GetRowStrings so that they aren't pointlessly checked every row
Originally committed to SVN as r6393.
This commit is contained in:
parent
1af19fb42e
commit
aa49a4eb0f
2 changed files with 10 additions and 10 deletions
|
@ -510,6 +510,11 @@ void BaseGrid::DrawImage(wxDC &dc, bool paint_columns[]) {
|
||||||
_("Effect"), _("Left"), _("Right"), _("Vert"), _("Text")
|
_("Effect"), _("Left"), _("Right"), _("Vert"), _("Text")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int override_mode = OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt();
|
||||||
|
wxString replace_char;
|
||||||
|
if (override_mode == 1)
|
||||||
|
replace_char = lagi_wxString(OPT_GET("Subtitle/Grid/Hide Overrides Char")->GetString());
|
||||||
|
|
||||||
for (int i = 0; i < nDraw + 1; i++) {
|
for (int i = 0; i < nDraw + 1; i++) {
|
||||||
int curRow = i + yPos - 1;
|
int curRow = i + yPos - 1;
|
||||||
RowColor curColor = COLOR_DEFAULT;
|
RowColor curColor = COLOR_DEFAULT;
|
||||||
|
@ -521,7 +526,7 @@ void BaseGrid::DrawImage(wxDC &dc, bool paint_columns[]) {
|
||||||
}
|
}
|
||||||
// Lines
|
// Lines
|
||||||
else if (AssDialogue *curDiag = GetDialogue(curRow)) {
|
else if (AssDialogue *curDiag = GetDialogue(curRow)) {
|
||||||
GetRowStrings(curRow, curDiag, paint_columns, strings);
|
GetRowStrings(curRow, curDiag, paint_columns, strings, !!override_mode, replace_char);
|
||||||
|
|
||||||
bool inSel = !!selection.count(curDiag);
|
bool inSel = !!selection.count(curDiag);
|
||||||
if (inSel && curDiag->Comment)
|
if (inSel && curDiag->Comment)
|
||||||
|
@ -600,7 +605,7 @@ void BaseGrid::DrawImage(wxDC &dc, bool paint_columns[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseGrid::GetRowStrings(int row, AssDialogue *line, bool *paint_columns, wxString *strings) const {
|
void BaseGrid::GetRowStrings(int row, AssDialogue *line, bool *paint_columns, wxString *strings, bool replace, wxString const& rep_char) const {
|
||||||
if (paint_columns[0]) strings[0] = wxString::Format("%d", row + 1);
|
if (paint_columns[0]) strings[0] = wxString::Format("%d", row + 1);
|
||||||
if (paint_columns[1]) strings[1] = wxString::Format("%d", line->Layer);
|
if (paint_columns[1]) strings[1] = wxString::Format("%d", line->Layer);
|
||||||
if (byFrame) {
|
if (byFrame) {
|
||||||
|
@ -620,19 +625,14 @@ void BaseGrid::GetRowStrings(int row, AssDialogue *line, bool *paint_columns, wx
|
||||||
|
|
||||||
if (paint_columns[10]) {
|
if (paint_columns[10]) {
|
||||||
strings[10].clear();
|
strings[10].clear();
|
||||||
int mode = OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt();
|
|
||||||
|
|
||||||
// Hidden overrides
|
// Hidden overrides
|
||||||
if (mode == 1 || mode == 2) {
|
if (replace) {
|
||||||
wxString replaceWith;
|
|
||||||
if (mode == 1)
|
|
||||||
replaceWith = lagi_wxString(OPT_GET("Subtitle/Grid/Hide Overrides Char")->GetString());
|
|
||||||
|
|
||||||
strings[10].reserve(line->Text.size());
|
strings[10].reserve(line->Text.size());
|
||||||
size_t start = 0, pos;
|
size_t start = 0, pos;
|
||||||
while ((pos = line->Text.find('{', start)) != wxString::npos) {
|
while ((pos = line->Text.find('{', start)) != wxString::npos) {
|
||||||
strings[10] += line->Text.Mid(start, pos - start);
|
strings[10] += line->Text.Mid(start, pos - start);
|
||||||
strings[10] += replaceWith;
|
strings[10] += rep_char;
|
||||||
start = line->Text.find('}', pos);
|
start = line->Text.find('}', pos);
|
||||||
if (start != wxString::npos) ++start;
|
if (start != wxString::npos) ++start;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ class BaseGrid : public wxWindow, public BaseSelectionController<AssDialogue> {
|
||||||
void OnSubtitlesSave();
|
void OnSubtitlesSave();
|
||||||
|
|
||||||
void DrawImage(wxDC &dc, bool paint_columns[]);
|
void DrawImage(wxDC &dc, bool paint_columns[]);
|
||||||
void GetRowStrings(int row, AssDialogue *line, bool *paint_columns, wxString *strings) const;
|
void GetRowStrings(int row, AssDialogue *line, bool *paint_columns, wxString *strings, bool replace, wxString const& rep_char) const;
|
||||||
|
|
||||||
void ScrollTo(int y);
|
void ScrollTo(int y);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue