Use range-based for loops in a bunch of places
This commit is contained in:
parent
8af78a6a61
commit
67df64e879
81 changed files with 585 additions and 682 deletions
|
@ -235,10 +235,9 @@ std::vector<AssDialogueBlock*> AssDialogue::ParseTags() const {
|
|||
Blocks.push_back(block);
|
||||
|
||||
// Look for \p in block
|
||||
std::vector<AssOverrideTag*>::iterator curTag;
|
||||
for (curTag = block->Tags.begin(); curTag != block->Tags.end(); ++curTag) {
|
||||
if ((*curTag)->Name == "\\p") {
|
||||
drawingLevel = (*curTag)->Params[0]->Get<int>(0);
|
||||
for (auto tag : block->Tags) {
|
||||
if (tag->Name == "\\p") {
|
||||
drawingLevel = tag->Params[0]->Get<int>(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -284,17 +283,17 @@ void AssDialogue::StripTag (wxString tagName) {
|
|||
wxString final;
|
||||
|
||||
// Look for blocks
|
||||
for (std::vector<AssDialogueBlock*>::iterator cur = Blocks.begin(); cur != Blocks.end(); ++cur) {
|
||||
if ((*cur)->GetType() != BLOCK_OVERRIDE) {
|
||||
final += (*cur)->GetText();
|
||||
for (auto block : Blocks) {
|
||||
if (block->GetType() != BLOCK_OVERRIDE) {
|
||||
final += block->GetText();
|
||||
continue;
|
||||
}
|
||||
|
||||
AssDialogueBlockOverride *over = static_cast<AssDialogueBlockOverride*>(*cur);
|
||||
AssDialogueBlockOverride *over = static_cast<AssDialogueBlockOverride*>(block);
|
||||
wxString temp;
|
||||
for (size_t i = 0; i < over->Tags.size(); ++i) {
|
||||
if (over->Tags[i]->Name != tagName)
|
||||
temp += *over->Tags[i];
|
||||
for (auto tag : over->Tags) {
|
||||
if (tag->Name != tagName)
|
||||
temp += *tag;
|
||||
}
|
||||
|
||||
if (!temp.empty())
|
||||
|
@ -308,13 +307,13 @@ void AssDialogue::StripTag (wxString tagName) {
|
|||
void AssDialogue::UpdateText () {
|
||||
if (Blocks.empty()) return;
|
||||
Text.clear();
|
||||
for (std::vector<AssDialogueBlock*>::iterator cur = Blocks.begin(); cur != Blocks.end(); ++cur) {
|
||||
if ((*cur)->GetType() == BLOCK_OVERRIDE) {
|
||||
for (auto block : Blocks) {
|
||||
if (block->GetType() == BLOCK_OVERRIDE) {
|
||||
Text += "{";
|
||||
Text += (*cur)->GetText();
|
||||
Text += block->GetText();
|
||||
Text += "}";
|
||||
}
|
||||
else Text += (*cur)->GetText();
|
||||
else Text += block->GetText();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,9 +344,9 @@ wxString AssDialogue::GetMarginString(int which, bool pad) const {
|
|||
|
||||
void AssDialogue::ProcessParameters(AssDialogueBlockOverride::ProcessParametersCallback callback,void *userData) {
|
||||
// Apply for all override blocks
|
||||
for (std::vector<AssDialogueBlock*>::iterator cur = Blocks.begin(); cur != Blocks.end(); ++cur) {
|
||||
if ((*cur)->GetType() == BLOCK_OVERRIDE) {
|
||||
static_cast<AssDialogueBlockOverride*>(*cur)->ProcessParameters(callback, userData);
|
||||
for (auto block : Blocks) {
|
||||
if (block->GetType() == BLOCK_OVERRIDE) {
|
||||
static_cast<AssDialogueBlockOverride*>(block)->ProcessParameters(callback, userData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,9 +89,9 @@ void AssExportFilterChain::Clear() {
|
|||
}
|
||||
|
||||
AssExportFilter *AssExportFilterChain::GetFilter(wxString const& name) {
|
||||
for (FilterList::iterator it = filters()->begin(); it != filters()->end(); ++it) {
|
||||
if ((*it)->name == name)
|
||||
return *it;
|
||||
for (auto filter : *filters()) {
|
||||
if (filter->name == name)
|
||||
return filter;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -64,16 +64,16 @@ AssExporter::~AssExporter () {
|
|||
|
||||
void AssExporter::DrawSettings(wxWindow *parent, wxSizer *target_sizer) {
|
||||
is_default = false;
|
||||
for (filter_iterator cur = filter_list_begin(); cur != filter_list_end(); ++cur) {
|
||||
for (auto filter : *AssExportFilterChain::GetFilterList()) {
|
||||
// Make sure to construct static box sizer first, so it won't overlap
|
||||
// the controls on wxMac.
|
||||
wxSizer *box = new wxStaticBoxSizer(wxVERTICAL, parent, (*cur)->GetName());
|
||||
wxWindow *window = (*cur)->GetConfigDialogWindow(parent, c);
|
||||
wxSizer *box = new wxStaticBoxSizer(wxVERTICAL, parent, filter->GetName());
|
||||
wxWindow *window = filter->GetConfigDialogWindow(parent, c);
|
||||
if (window) {
|
||||
box->Add(window, 0, wxEXPAND, 0);
|
||||
target_sizer->Add(box, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
||||
target_sizer->Show(box, false);
|
||||
Sizers[(*cur)->GetName()] = box;
|
||||
Sizers[filter->GetName()] = box;
|
||||
}
|
||||
else {
|
||||
delete box;
|
||||
|
@ -90,9 +90,9 @@ void AssExporter::AddFilter(wxString const& name) {
|
|||
}
|
||||
|
||||
void AssExporter::AddAutoFilters() {
|
||||
for (filter_iterator it = filter_list_begin(); it != filter_list_end(); ++it) {
|
||||
if ((*it)->GetAutoApply())
|
||||
filters.push_back(*it);
|
||||
for (auto filter : *AssExportFilterChain::GetFilterList()) {
|
||||
if (filter->GetAutoApply())
|
||||
filters.push_back(filter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,9 +106,9 @@ wxArrayString AssExporter::GetAllFilterNames() const {
|
|||
AssFile *AssExporter::ExportTransform(wxWindow *export_dialog, bool copy) {
|
||||
AssFile *subs = copy ? new AssFile(*c->ass) : c->ass;
|
||||
|
||||
for (filter_iterator cur = filters.begin(); cur != filters.end(); ++cur) {
|
||||
(*cur)->LoadSettings(is_default, c);
|
||||
(*cur)->ProcessSubs(subs, export_dialog);
|
||||
for (auto filter : filters) {
|
||||
filter->LoadSettings(is_default, c);
|
||||
filter->ProcessSubs(subs, export_dialog);
|
||||
}
|
||||
|
||||
return subs;
|
||||
|
|
|
@ -87,8 +87,8 @@ void AssFile::Load(const wxString &_filename, wxString const& charset) {
|
|||
bool found_dialogue = false;
|
||||
|
||||
// Check if the file has at least one style and at least one dialogue line
|
||||
for (entryIter it = temp.Line.begin(); it != temp.Line.end(); ++it) {
|
||||
AssEntryType type = it->GetType();
|
||||
for (auto const& line : temp.Line) {
|
||||
AssEntryType type = line.GetType();
|
||||
if (type == ENTRY_STYLE) found_style = true;
|
||||
if (type == ENTRY_DIALOGUE) found_dialogue = true;
|
||||
if (found_style && found_dialogue) break;
|
||||
|
@ -180,8 +180,8 @@ void AssFile::SaveMemory(std::vector<char> &dst) {
|
|||
dst.reserve(0x4000);
|
||||
|
||||
// Write file
|
||||
for (entryIter cur = Line.begin(); cur != Line.end(); ++cur) {
|
||||
wxCharBuffer buffer = (cur->GetEntryData() + "\r\n").utf8_str();
|
||||
for (auto const& line : Line) {
|
||||
wxCharBuffer buffer = (line.GetEntryData() + "\r\n").utf8_str();
|
||||
copy(buffer.data(), buffer.data() + buffer.length(), back_inserter(dst));
|
||||
}
|
||||
}
|
||||
|
@ -318,10 +318,10 @@ wxString AssFile::GetScriptInfo(wxString key) const {
|
|||
key += ":";
|
||||
bool GotIn = false;
|
||||
|
||||
for (constEntryIter cur = Line.begin(); cur != Line.end(); ++cur) {
|
||||
if (cur->group == "[Script Info]") {
|
||||
for (auto const& line : Line) {
|
||||
if (line.group == "[Script Info]") {
|
||||
GotIn = true;
|
||||
wxString curText = cur->GetEntryData();
|
||||
wxString curText = line.GetEntryData();
|
||||
if (curText.Lower().StartsWith(key))
|
||||
return curText.Mid(key.size()).Trim(true).Trim(false);
|
||||
}
|
||||
|
@ -343,22 +343,19 @@ void AssFile::SetScriptInfo(wxString const& key, wxString const& value) {
|
|||
entryIter script_info_end;
|
||||
bool found_script_info = false;
|
||||
|
||||
for (entryIter cur = Line.begin(); cur != Line.end(); ++cur) {
|
||||
if (cur->group == "[Script Info]") {
|
||||
for (auto& line : Line) {
|
||||
if (line.group == "[Script Info]") {
|
||||
found_script_info = true;
|
||||
wxString cur_text = cur->GetEntryData().Left(key_size).Lower();
|
||||
wxString cur_text = line.GetEntryData().Left(key_size).Lower();
|
||||
|
||||
if (cur_text == search_key) {
|
||||
if (value.empty()) {
|
||||
delete &*cur;
|
||||
Line.erase(cur);
|
||||
}
|
||||
else {
|
||||
cur->SetEntryData(key + ": " + value);
|
||||
}
|
||||
if (value.empty())
|
||||
delete &line;
|
||||
else
|
||||
line.SetEntryData(key + ": " + value);
|
||||
return;
|
||||
}
|
||||
script_info_end = cur;
|
||||
script_info_end = Line.iterator_to(line);
|
||||
}
|
||||
else if (found_script_info) {
|
||||
if (value.size())
|
||||
|
@ -402,16 +399,16 @@ void AssFile::GetResolution(int &sw,int &sh) const {
|
|||
|
||||
wxArrayString AssFile::GetStyles() const {
|
||||
wxArrayString styles;
|
||||
for (constEntryIter cur = Line.begin(); cur != Line.end(); ++cur) {
|
||||
if (const AssStyle *curstyle = dynamic_cast<const AssStyle*>(&*cur))
|
||||
for (auto const& line : Line) {
|
||||
if (const AssStyle *curstyle = dynamic_cast<const AssStyle*>(&line))
|
||||
styles.Add(curstyle->name);
|
||||
}
|
||||
return styles;
|
||||
}
|
||||
|
||||
AssStyle *AssFile::GetStyle(wxString const& name) {
|
||||
for (entryIter cur = Line.begin(); cur != Line.end(); ++cur) {
|
||||
AssStyle *curstyle = dynamic_cast<AssStyle*>(&*cur);
|
||||
for (auto& line : Line) {
|
||||
AssStyle *curstyle = dynamic_cast<AssStyle*>(&line);
|
||||
if (curstyle && curstyle->name == name)
|
||||
return curstyle;
|
||||
}
|
||||
|
|
|
@ -41,10 +41,10 @@ wxString AssKaraoke::Syllable::GetText(bool k_tag) const {
|
|||
ret = wxString::Format("{%s%d}", tag_type, (duration + 5) / 10);
|
||||
|
||||
size_t idx = 0;
|
||||
for (std::map<size_t, wxString>::const_iterator ovr = ovr_tags.begin(); ovr != ovr_tags.end(); ++ovr) {
|
||||
ret += text.Mid(idx, ovr->first - idx);
|
||||
ret += ovr->second;
|
||||
idx = ovr->first;
|
||||
for (auto const& ovr : ovr_tags) {
|
||||
ret += text.Mid(idx, ovr.first - idx);
|
||||
ret += ovr.second;
|
||||
idx = ovr.first;
|
||||
}
|
||||
ret += text.Mid(idx);
|
||||
return ret;
|
||||
|
@ -67,8 +67,7 @@ void AssKaraoke::SetLine(AssDialogue *line, bool auto_split, bool normalize) {
|
|||
syl.duration = 0;
|
||||
syl.tag_type = "\\k";
|
||||
|
||||
for (size_t i = 0; i < line->Blocks.size(); ++i) {
|
||||
AssDialogueBlock *block = line->Blocks[i];
|
||||
for (auto block : line->Blocks) {
|
||||
wxString text = block->GetText();
|
||||
|
||||
if (dynamic_cast<AssDialogueBlockPlain*>(block)) {
|
||||
|
@ -85,9 +84,7 @@ void AssKaraoke::SetLine(AssDialogue *line, bool auto_split, bool normalize) {
|
|||
}
|
||||
else if (AssDialogueBlockOverride *ovr = dynamic_cast<AssDialogueBlockOverride*>(block)) {
|
||||
bool in_tag = false;
|
||||
for (size_t j = 0; j < ovr->Tags.size(); ++j) {
|
||||
AssOverrideTag *tag = ovr->Tags[j];
|
||||
|
||||
for (auto tag : ovr->Tags) {
|
||||
if (tag->IsValid() && tag->Name.Left(2).Lower() == "\\k") {
|
||||
if (in_tag) {
|
||||
syl.ovr_tags[syl.text.size()] += "}";
|
||||
|
@ -112,7 +109,7 @@ void AssKaraoke::SetLine(AssDialogue *line, bool auto_split, bool normalize) {
|
|||
else {
|
||||
wxString& otext = syl.ovr_tags[syl.text.size()];
|
||||
// Merge adjacent override tags
|
||||
if (j == 0 && otext.size())
|
||||
if (otext.size() && otext.Last() == '}')
|
||||
otext.RemoveLast();
|
||||
else if (!in_tag)
|
||||
otext += "{";
|
||||
|
@ -142,13 +139,13 @@ void AssKaraoke::SetLine(AssDialogue *line, bool auto_split, bool normalize) {
|
|||
syls.back().duration += end_time - last_end;
|
||||
else if (last_end > end_time) {
|
||||
// Truncate any syllables that extend past the end of the line
|
||||
for (size_t i = 0; i < size(); ++i) {
|
||||
if (syls[i].start_time > end_time) {
|
||||
syls[i].start_time = end_time;
|
||||
syls[i].duration = 0;
|
||||
for (auto& syl : syls) {
|
||||
if (syl.start_time > end_time) {
|
||||
syl.start_time = end_time;
|
||||
syl.duration = 0;
|
||||
}
|
||||
else {
|
||||
syls[i].duration = std::min(syls[i].duration, end_time - syls[i].start_time);
|
||||
syl.duration = std::min(syl.duration, end_time - syl.start_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,9 +167,8 @@ wxString AssKaraoke::GetText() const {
|
|||
wxString text;
|
||||
text.reserve(size() * 10);
|
||||
|
||||
for (iterator it = begin(); it != end(); ++it) {
|
||||
text += it->GetText(true);
|
||||
}
|
||||
for (auto const& syl : syls)
|
||||
text += syl.GetText(true);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
@ -182,9 +178,8 @@ wxString AssKaraoke::GetTagType() const {
|
|||
}
|
||||
|
||||
void AssKaraoke::SetTagType(wxString const& new_type) {
|
||||
for (size_t i = 0; i < size(); ++i) {
|
||||
syls[i].tag_type = new_type;
|
||||
}
|
||||
for (auto& syl : syls)
|
||||
syl.tag_type = new_type;
|
||||
}
|
||||
|
||||
void AssKaraoke::AddSplit(size_t syl_idx, size_t pos) {
|
||||
|
|
|
@ -95,16 +95,13 @@ void AssDialogueBlockOverride::AddTag(wxString const& tag) {
|
|||
|
||||
wxString AssDialogueBlockOverride::GetText() {
|
||||
text.clear();
|
||||
for (std::vector<AssOverrideTag*>::iterator cur = Tags.begin(); cur != Tags.end(); ++cur) {
|
||||
text += **cur;
|
||||
}
|
||||
for (auto tag : Tags)
|
||||
text += *tag;
|
||||
return text;
|
||||
}
|
||||
|
||||
void AssDialogueBlockOverride::ProcessParameters(AssDialogueBlockOverride::ProcessParametersCallback callback,void *userData) {
|
||||
for (std::vector<AssOverrideTag*>::iterator cur = Tags.begin(); cur != Tags.end(); ++cur) {
|
||||
AssOverrideTag *curTag = *cur;
|
||||
|
||||
for (auto curTag : Tags) {
|
||||
// Find parameters
|
||||
for (size_t n = 0; n < curTag->Params.size(); ++n) {
|
||||
AssOverrideParameter *curPar = curTag->Params[n];
|
||||
|
@ -371,16 +368,14 @@ void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto::
|
|||
}
|
||||
|
||||
unsigned curPar = 0;
|
||||
for (size_t n = 0; n < proto_it->params.size(); n++) {
|
||||
AssOverrideParamProto *curproto = &proto_it->params[n];
|
||||
|
||||
for (auto& curproto : proto_it->params) {
|
||||
// Create parameter
|
||||
AssOverrideParameter *newparam = new AssOverrideParameter;
|
||||
newparam->classification = curproto->classification;
|
||||
newparam->classification = curproto.classification;
|
||||
Params.push_back(newparam);
|
||||
|
||||
// Check if it's optional and not present
|
||||
if (!(curproto->optional & parsFlag) || curPar >= totalPars) {
|
||||
if (!(curproto.optional & parsFlag) || curPar >= totalPars) {
|
||||
newparam->omitted = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -393,42 +388,42 @@ void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto::
|
|||
}
|
||||
|
||||
wxChar firstChar = curtok[0];
|
||||
bool auto4 = (firstChar == '!' || firstChar == '$' || firstChar == '%') && curproto->type != VARDATA_BLOCK;
|
||||
bool auto4 = (firstChar == '!' || firstChar == '$' || firstChar == '%') && curproto.type != VARDATA_BLOCK;
|
||||
if (auto4) {
|
||||
newparam->Set(curtok);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
switch (curproto->type) {
|
||||
case VARDATA_INT: {
|
||||
long temp;
|
||||
curtok.ToLong(&temp);
|
||||
newparam->Set<int>(temp);
|
||||
break;
|
||||
}
|
||||
case VARDATA_FLOAT: {
|
||||
double temp;
|
||||
curtok.ToDouble(&temp);
|
||||
newparam->Set(temp);
|
||||
break;
|
||||
}
|
||||
case VARDATA_TEXT:
|
||||
newparam->Set(curtok);
|
||||
break;
|
||||
case VARDATA_BOOL: {
|
||||
long temp;
|
||||
curtok.ToLong(&temp);
|
||||
newparam->Set<bool>(temp != 0);
|
||||
break;
|
||||
}
|
||||
case VARDATA_BLOCK: {
|
||||
AssDialogueBlockOverride *temp = new AssDialogueBlockOverride(curtok);
|
||||
temp->ParseTags();
|
||||
newparam->Set(temp);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
switch (curproto.type) {
|
||||
case VARDATA_INT: {
|
||||
long temp;
|
||||
curtok.ToLong(&temp);
|
||||
newparam->Set<int>(temp);
|
||||
break;
|
||||
}
|
||||
case VARDATA_FLOAT: {
|
||||
double temp;
|
||||
curtok.ToDouble(&temp);
|
||||
newparam->Set(temp);
|
||||
break;
|
||||
}
|
||||
case VARDATA_TEXT:
|
||||
newparam->Set(curtok);
|
||||
break;
|
||||
case VARDATA_BOOL: {
|
||||
long temp;
|
||||
curtok.ToLong(&temp);
|
||||
newparam->Set<bool>(temp != 0);
|
||||
break;
|
||||
}
|
||||
case VARDATA_BLOCK: {
|
||||
AssDialogueBlockOverride *temp = new AssDialogueBlockOverride(curtok);
|
||||
temp->ParseTags();
|
||||
newparam->Set(temp);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -450,14 +445,14 @@ AssOverrideTag::operator wxString() const {
|
|||
|
||||
// Add parameters
|
||||
bool any = false;
|
||||
for (std::vector<AssOverrideParameter*>::const_iterator cur = Params.begin(); cur != Params.end(); ++cur) {
|
||||
if ((*cur)->GetType() != VARDATA_NONE && !(*cur)->omitted) {
|
||||
result += (*cur)->Get<wxString>();
|
||||
for (auto param : Params) {
|
||||
if (param->GetType() != VARDATA_NONE && !param->omitted) {
|
||||
result += param->Get<wxString>();
|
||||
result += ",";
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
if (any) result = result.Left(result.Length()-1);
|
||||
if (any) result.resize(result.size() - 1);
|
||||
|
||||
if (parentheses) result += ")";
|
||||
return result;
|
||||
|
|
|
@ -41,8 +41,8 @@ void AssParser::ParseAttachmentLine(wxString const& data) {
|
|||
bool is_filename = data.StartsWith("fontname: ") || data.StartsWith("filename: ");
|
||||
|
||||
bool valid_data = data.size() > 0 && data.size() <= 80;
|
||||
for (size_t i = 0; i < data.size(); ++i) {
|
||||
if (data[i] < 33 || data[i] >= 97) {
|
||||
for (auto byte : data) {
|
||||
if (byte < 33 || byte >= 97) {
|
||||
valid_data = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ void AssStyleStorage::Save() const {
|
|||
throw "Failed creating directory for style catalogs";
|
||||
|
||||
TextFileWriter file(StandardPaths::DecodePath("?user/catalog/" + storage_name + ".sty"), "UTF-8");
|
||||
for (const_iterator cur = begin(); cur != end(); ++cur)
|
||||
file.WriteLineToFile((*cur)->GetEntryData());
|
||||
for (const AssStyle *cur : style)
|
||||
file.WriteLineToFile(cur->GetEntryData());
|
||||
}
|
||||
|
||||
void AssStyleStorage::Load(wxString const& name) {
|
||||
|
@ -96,15 +96,15 @@ void AssStyleStorage::Delete(int idx) {
|
|||
|
||||
wxArrayString AssStyleStorage::GetNames() {
|
||||
wxArrayString names;
|
||||
for (iterator cur = begin(); cur != end(); ++cur)
|
||||
names.Add((*cur)->name);
|
||||
for (const AssStyle *cur : style)
|
||||
names.Add(cur->name);
|
||||
return names;
|
||||
}
|
||||
|
||||
AssStyle *AssStyleStorage::GetStyle(wxString const& name) {
|
||||
for (iterator cur = begin(); cur != end(); ++cur) {
|
||||
if ((*cur)->name.CmpNoCase(name) == 0)
|
||||
return *cur;
|
||||
for (AssStyle *cur : style) {
|
||||
if (cur->name.CmpNoCase(name) == 0)
|
||||
return cur;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -835,9 +835,8 @@ void AudioDisplay::PaintMarkers(wxDC &dc, TimeRange updtime)
|
|||
|
||||
wxDCPenChanger pen_retainer(dc, wxPen());
|
||||
wxDCBrushChanger brush_retainer(dc, wxBrush());
|
||||
for (AudioMarkerVector::iterator marker_i = markers.begin(); marker_i != markers.end(); ++marker_i)
|
||||
for (const auto marker : markers)
|
||||
{
|
||||
const AudioMarker *marker = *marker_i;
|
||||
int marker_x = RelativeXFromTime(marker->GetPosition());
|
||||
|
||||
dc.SetPen(marker->GetStyle());
|
||||
|
@ -874,23 +873,23 @@ void AudioDisplay::PaintLabels(wxDC &dc, TimeRange updtime)
|
|||
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
dc.SetFont(font);
|
||||
dc.SetTextForeground(*wxWHITE);
|
||||
for (size_t i = 0; i < labels.size(); ++i)
|
||||
for (auto const& label : labels)
|
||||
{
|
||||
wxSize extent = dc.GetTextExtent(labels[i].text);
|
||||
int left = RelativeXFromTime(labels[i].range.begin());
|
||||
int width = AbsoluteXFromTime(labels[i].range.length());
|
||||
wxSize extent = dc.GetTextExtent(label.text);
|
||||
int left = RelativeXFromTime(label.range.begin());
|
||||
int width = AbsoluteXFromTime(label.range.length());
|
||||
|
||||
// If it doesn't fit, truncate
|
||||
if (width < extent.GetWidth())
|
||||
{
|
||||
dc.SetClippingRegion(left, audio_top + 4, width, extent.GetHeight());
|
||||
dc.DrawText(labels[i].text, left, audio_top + 4);
|
||||
dc.DrawText(label.text, left, audio_top + 4);
|
||||
dc.DestroyClippingRegion();
|
||||
}
|
||||
// Otherwise center in the range
|
||||
else
|
||||
{
|
||||
dc.DrawText(labels[i].text, left + (width - extent.GetWidth()) / 2, audio_top + 4);
|
||||
dc.DrawText(label.text, left + (width - extent.GetWidth()) / 2, audio_top + 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,9 +360,9 @@ void AudioKaraoke::SetDisplayText() {
|
|||
spaced_text.clear();
|
||||
syl_start_points.clear();
|
||||
syl_start_points.reserve(kara->size());
|
||||
for (AssKaraoke::iterator it = kara->begin(); it != kara->end(); ++it) {
|
||||
for (auto const& syl : *kara) {
|
||||
syl_start_points.push_back(spaced_text.size());
|
||||
spaced_text += " " + it->text;
|
||||
spaced_text += " " + syl.text;
|
||||
}
|
||||
|
||||
// Get the x-coordinates of the right edge of each character
|
||||
|
|
|
@ -71,9 +71,8 @@ void AudioMarkerProviderKeyframes::Update() {
|
|||
|
||||
markers.clear();
|
||||
markers.reserve(keyframes.size());
|
||||
for (size_t i = 0; i < keyframes.size(); ++i) {
|
||||
markers.push_back(AudioMarkerKeyframe(style.get(), timecodes.TimeAtFrame(keyframes[i], agi::vfr::START)));
|
||||
}
|
||||
for (int frame : keyframes)
|
||||
markers.push_back(AudioMarkerKeyframe(style.get(), timecodes.TimeAtFrame(frame, agi::vfr::START)));
|
||||
AnnounceMarkerMoved();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,12 +57,12 @@ AudioPlayer* AudioPlayerFactory::GetAudioPlayer(AudioProvider *provider) {
|
|||
if (list.empty()) throw agi::NoAudioPlayersError("No audio players are available.", 0);
|
||||
|
||||
std::string error;
|
||||
for (size_t i = 0; i < list.size(); ++i) {
|
||||
for (auto const& factory_name : list) {
|
||||
try {
|
||||
return Create(list[i], provider);
|
||||
return Create(factory_name, provider);
|
||||
}
|
||||
catch (agi::AudioPlayerOpenError const& err) {
|
||||
error += list[i] + " factory: " + err.GetChainedMessage() + "\n";
|
||||
error += factory_name + " factory: " + err.GetChainedMessage() + "\n";
|
||||
}
|
||||
}
|
||||
throw agi::AudioPlayerOpenError(error, 0);
|
||||
|
|
|
@ -651,8 +651,7 @@ std::vector<AudioMarker*> AudioTimingControllerDialogue::OnLeftClick(int ms, boo
|
|||
{
|
||||
// The use of GetPosition here is important, as otherwise it'll start
|
||||
// after lines ending at the same time as the active line begins
|
||||
std::vector<DialogueTimingMarker*>::iterator it =
|
||||
lower_bound(markers.begin(), markers.end(), clicked->GetPosition(), marker_ptr_cmp());
|
||||
auto it = lower_bound(markers.begin(), markers.end(), clicked->GetPosition(), marker_ptr_cmp());
|
||||
for(; it != markers.end() && !(*clicked < **it); ++it)
|
||||
ret.push_back(*it);
|
||||
}
|
||||
|
@ -692,21 +691,20 @@ void AudioTimingControllerDialogue::SetMarkers(std::vector<AudioMarker*> const&
|
|||
// is effected.
|
||||
int min_ms = ms;
|
||||
int max_ms = ms;
|
||||
for (size_t i = 0; i < upd_markers.size(); ++i)
|
||||
for (AudioMarker *upd_marker : upd_markers)
|
||||
{
|
||||
DialogueTimingMarker *marker = static_cast<DialogueTimingMarker*>(upd_markers[i]);
|
||||
DialogueTimingMarker *marker = static_cast<DialogueTimingMarker*>(upd_marker);
|
||||
min_ms = std::min<int>(*marker, min_ms);
|
||||
max_ms = std::max<int>(*marker, max_ms);
|
||||
}
|
||||
|
||||
std::vector<DialogueTimingMarker*>::iterator
|
||||
begin = lower_bound(markers.begin(), markers.end(), min_ms, marker_ptr_cmp()),
|
||||
end = upper_bound(begin, markers.end(), max_ms, marker_ptr_cmp());
|
||||
auto begin = lower_bound(markers.begin(), markers.end(), min_ms, marker_ptr_cmp());
|
||||
auto end = upper_bound(begin, markers.end(), max_ms, marker_ptr_cmp());
|
||||
|
||||
// Update the markers
|
||||
for (size_t i = 0; i < upd_markers.size(); ++i)
|
||||
for (AudioMarker *upd_marker : upd_markers)
|
||||
{
|
||||
DialogueTimingMarker *marker = static_cast<DialogueTimingMarker*>(upd_markers[i]);
|
||||
DialogueTimingMarker *marker = static_cast<DialogueTimingMarker*>(upd_marker);
|
||||
marker->SetPosition(ms);
|
||||
modified_lines.insert(marker->GetLine());
|
||||
}
|
||||
|
@ -768,10 +766,10 @@ void AudioTimingControllerDialogue::RegenerateInactiveLines()
|
|||
case 3: // All inactive lines
|
||||
{
|
||||
AssDialogue *active_line = context->selectionController->GetActiveLine();
|
||||
for (entryIter it = context->ass->Line.begin(); it != context->ass->Line.end(); ++it)
|
||||
for (auto& line : context->ass->Line)
|
||||
{
|
||||
if (&*it != active_line && predicate(*it))
|
||||
AddInactiveLine(sel, static_cast<AssDialogue*>(&*it));
|
||||
if (&line != active_line && predicate(line))
|
||||
AddInactiveLine(sel, static_cast<AssDialogue*>(&line));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -803,12 +801,12 @@ void AudioTimingControllerDialogue::RegenerateSelectedLines()
|
|||
|
||||
AssDialogue *active = context->selectionController->GetActiveLine();
|
||||
SubtitleSelection sel = context->selectionController->GetSelectedSet();
|
||||
for (SubtitleSelection::iterator it = sel.begin(); it != sel.end(); ++it)
|
||||
for (auto line : sel)
|
||||
{
|
||||
if (*it == active) continue;
|
||||
if (line == active) continue;
|
||||
|
||||
selected_lines.push_back(TimeableLine(AudioStyle_Selected, &style_inactive, &style_inactive));
|
||||
selected_lines.back().SetLine(*it);
|
||||
selected_lines.back().SetLine(line);
|
||||
}
|
||||
|
||||
if (!selected_lines.empty() || !was_empty)
|
||||
|
@ -864,14 +862,14 @@ int AudioTimingControllerDialogue::SnapPosition(int position, int snap_range, st
|
|||
const AudioMarker *snap_marker = 0;
|
||||
AudioMarkerVector potential_snaps;
|
||||
GetMarkers(snap_time_range, potential_snaps);
|
||||
for (AudioMarkerVector::iterator mi = potential_snaps.begin(); mi != potential_snaps.end(); ++mi)
|
||||
for (auto marker : potential_snaps)
|
||||
{
|
||||
if ((*mi)->CanSnap() && find(exclude.begin(), exclude.end(), *mi) == exclude.end())
|
||||
if (marker->CanSnap() && find(exclude.begin(), exclude.end(), marker) == exclude.end())
|
||||
{
|
||||
if (!snap_marker)
|
||||
snap_marker = *mi;
|
||||
else if (tabs((*mi)->GetPosition() - position) < tabs(snap_marker->GetPosition() - position))
|
||||
snap_marker = *mi;
|
||||
snap_marker = marker;
|
||||
else if (tabs(marker->GetPosition() - position) < tabs(snap_marker->GetPosition() - position))
|
||||
snap_marker = marker;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -345,8 +345,8 @@ void AudioTimingControllerKaraoke::ModifyStart(int delta) {
|
|||
bool AudioTimingControllerKaraoke::IsNearbyMarker(int ms, int sensitivity) const {
|
||||
TimeRange range(ms - sensitivity, ms + sensitivity);
|
||||
|
||||
for (size_t i = 0; i < markers.size(); ++i)
|
||||
if (range.contains(markers[i]))
|
||||
for (auto const& marker : markers)
|
||||
if (range.contains(marker))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -424,8 +424,8 @@ void AudioTimingControllerKaraoke::OnMarkerDrag(std::vector<AudioMarker*> const&
|
|||
}
|
||||
|
||||
void AudioTimingControllerKaraoke::GetLabels(TimeRange const& range, std::vector<AudioLabel> &out) const {
|
||||
for (size_t i = 0; i < labels.size(); ++i) {
|
||||
if (range.overlaps(labels[i].range))
|
||||
out.push_back(labels[i]);
|
||||
for (auto const& label : labels) {
|
||||
if (range.overlaps(label.range))
|
||||
out.push_back(label);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ namespace Automation4 {
|
|||
|
||||
void ScriptManager::Remove(Script *script)
|
||||
{
|
||||
std::vector<Script*>::iterator i = find(scripts.begin(), scripts.end(), script);
|
||||
auto i = find(scripts.begin(), scripts.end(), script);
|
||||
if (i != scripts.end()) {
|
||||
delete *i;
|
||||
scripts.erase(i);
|
||||
|
@ -380,8 +380,8 @@ namespace Automation4 {
|
|||
const std::vector<cmd::Command*>& ScriptManager::GetMacros()
|
||||
{
|
||||
macros.clear();
|
||||
for (std::vector<Script*>::iterator i = scripts.begin(); i != scripts.end(); ++i) {
|
||||
std::vector<cmd::Command*> sfs = (*i)->GetMacros();
|
||||
for (auto script : scripts) {
|
||||
std::vector<cmd::Command*> sfs = script->GetMacros();
|
||||
copy(sfs.begin(), sfs.end(), back_inserter(macros));
|
||||
}
|
||||
return macros;
|
||||
|
@ -500,10 +500,8 @@ namespace Automation4 {
|
|||
wxString scripts_string;
|
||||
wxString autobasefn(lagi_wxString(OPT_GET("Path/Automation/Base")->GetString()));
|
||||
|
||||
for (size_t i = 0; i < GetScripts().size(); i++) {
|
||||
Script *script = GetScripts()[i];
|
||||
|
||||
if (i != 0)
|
||||
for (auto script : GetScripts()) {
|
||||
if (!scripts_string.empty())
|
||||
scripts_string += "|";
|
||||
|
||||
wxString autobase_rel, assfile_rel;
|
||||
|
@ -541,7 +539,7 @@ namespace Automation4 {
|
|||
|
||||
void ScriptFactory::Unregister(ScriptFactory *factory)
|
||||
{
|
||||
std::vector<ScriptFactory*>::iterator i = find(Factories().begin(), Factories().end(), factory);
|
||||
auto i = find(Factories().begin(), Factories().end(), factory);
|
||||
if (i != Factories().end()) {
|
||||
delete *i;
|
||||
Factories().erase(i);
|
||||
|
@ -550,8 +548,8 @@ namespace Automation4 {
|
|||
|
||||
Script* ScriptFactory::CreateFromFile(wxString const& filename, bool log_errors)
|
||||
{
|
||||
for (std::vector<ScriptFactory*>::iterator i = Factories().begin(); i != Factories().end(); ++i) {
|
||||
Script *s = (*i)->Produce(filename);
|
||||
for (auto factory : Factories()) {
|
||||
Script *s = factory->Produce(filename);
|
||||
if (s) {
|
||||
if (!s->GetLoadedState() && log_errors) {
|
||||
wxLogError(_("An Automation script failed to load. File name: '%s', error reported: %s"), filename, s->GetDescription());
|
||||
|
@ -590,8 +588,7 @@ namespace Automation4 {
|
|||
wxString ScriptFactory::GetWildcardStr()
|
||||
{
|
||||
wxString fnfilter, catchall;
|
||||
for (size_t i = 0; i < Factories().size(); ++i) {
|
||||
const ScriptFactory *fact = Factories()[i];
|
||||
for (auto fact : Factories()) {
|
||||
if (fact->GetEngineName().empty() || fact->GetFilenamePattern().empty())
|
||||
continue;
|
||||
|
||||
|
|
|
@ -408,8 +408,8 @@ namespace Automation4 {
|
|||
lua_pushstring(L, "path");
|
||||
lua_gettable(L, -3);
|
||||
|
||||
for (size_t i = 0; i < include_path.size(); ++i) {
|
||||
wxCharBuffer p = include_path[i].utf8_str();
|
||||
for (wxString const& path : include_path) {
|
||||
wxCharBuffer p = path.utf8_str();
|
||||
lua_pushfstring(L, ";%s/?.lua;%s/?/init.lua", p.data(), p.data());
|
||||
lua_concat(L, 2);
|
||||
}
|
||||
|
@ -527,8 +527,8 @@ namespace Automation4 {
|
|||
|
||||
void LuaScript::RegisterCommand(LuaCommand *command)
|
||||
{
|
||||
for (size_t i = 0; i < macros.size(); ++i) {
|
||||
if (macros[i]->name() == command->name()) {
|
||||
for (auto macro : macros) {
|
||||
if (macro->name() == command->name()) {
|
||||
luaL_error(L,
|
||||
"A macro named '%s' is already defined in script '%s'",
|
||||
command->StrDisplay(0).utf8_str().data(), name.utf8_str().data());
|
||||
|
@ -840,10 +840,11 @@ namespace Automation4 {
|
|||
lua_newtable(L);
|
||||
int active_idx = -1;
|
||||
|
||||
int row = 1;
|
||||
int row = 0;
|
||||
int idx = 1;
|
||||
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it, ++row) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it);
|
||||
for (auto& line : c->ass->Line) {
|
||||
++row;
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&line);
|
||||
if (!diag) continue;
|
||||
|
||||
if (diag == active_line) active_idx = row;
|
||||
|
|
|
@ -670,10 +670,10 @@ namespace Automation4 {
|
|||
void LuaAssFile::ProcessingComplete(wxString const& undo_description)
|
||||
{
|
||||
// Apply any pending commits
|
||||
for (std::deque<PendingCommit>::iterator it = pending_commits.begin(); it != pending_commits.end(); ++it) {
|
||||
for (auto const& pc : pending_commits) {
|
||||
ass->Line.clear();
|
||||
boost::push_back(ass->Line, it->lines | boost::adaptors::indirected);
|
||||
ass->Commit(it->mesage, it->modification_type);
|
||||
boost::push_back(ass->Line, pc.lines | boost::adaptors::indirected);
|
||||
ass->Commit(pc.mesage, pc.modification_type);
|
||||
}
|
||||
|
||||
// Commit any changes after the last undo point was set
|
||||
|
@ -704,8 +704,8 @@ namespace Automation4 {
|
|||
, modification_type(0)
|
||||
, references(2)
|
||||
{
|
||||
for (entryIter it = ass->Line.begin(); it != ass->Line.end(); ++it)
|
||||
lines.push_back(&*it);
|
||||
for (auto& line : ass->Line)
|
||||
lines.push_back(&line);
|
||||
|
||||
// prepare userdata object
|
||||
*static_cast<LuaAssFile**>(lua_newuserdata(L, sizeof(LuaAssFile*))) = this;
|
||||
|
|
|
@ -560,10 +560,8 @@ namespace Automation4 {
|
|||
window = new wxPanel(parent);
|
||||
wxGridBagSizer *s = new wxGridBagSizer(4, 4);
|
||||
|
||||
for (size_t i = 0; i < controls.size(); ++i) {
|
||||
LuaDialogControl *c = controls[i];
|
||||
for (auto c : controls)
|
||||
s->Add(c->Create(window), wxGBPosition(c->y, c->x), wxGBSpan(c->height, c->width), c->GetSizerFlags());
|
||||
}
|
||||
|
||||
if (use_buttons) {
|
||||
wxStdDialogButtonSizer *bs = new wxStdDialogButtonSizer();
|
||||
|
@ -616,9 +614,9 @@ namespace Automation4 {
|
|||
|
||||
// Then read controls back
|
||||
lua_newtable(L);
|
||||
for (size_t i = 0; i < controls.size(); ++i) {
|
||||
controls[i]->LuaReadBack(L);
|
||||
lua_setfield(L, -2, controls[i]->name.utf8_str());
|
||||
for (auto control : controls) {
|
||||
control->LuaReadBack(L);
|
||||
lua_setfield(L, -2, control->name.utf8_str());
|
||||
}
|
||||
|
||||
if (use_buttons) {
|
||||
|
@ -633,10 +631,10 @@ namespace Automation4 {
|
|||
wxString res;
|
||||
|
||||
// Format into "name1:value1|name2:value2|name3:value3|"
|
||||
for (size_t i = 0; i < controls.size(); ++i) {
|
||||
if (controls[i]->CanSerialiseValue()) {
|
||||
wxString sn = inline_string_encode(controls[i]->name);
|
||||
wxString sv = controls[i]->SerialiseValue();
|
||||
for (auto control : controls) {
|
||||
if (control->CanSerialiseValue()) {
|
||||
wxString sn = inline_string_encode(control->name);
|
||||
wxString sv = control->SerialiseValue();
|
||||
res += wxString::Format("%s:%s|", sn, sv);
|
||||
}
|
||||
}
|
||||
|
@ -659,10 +657,9 @@ namespace Automation4 {
|
|||
wxString value = pair.AfterFirst(':');
|
||||
|
||||
// Hand value to all controls matching name
|
||||
for (size_t i = 0; i < controls.size(); ++i) {
|
||||
if (controls[i]->name == name && controls[i]->CanSerialiseValue()) {
|
||||
controls[i]->UnserialiseValue(value);
|
||||
}
|
||||
for (auto control : controls) {
|
||||
if (control->name == name && control->CanSerialiseValue())
|
||||
control->UnserialiseValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -278,8 +278,8 @@ void BaseGrid::UpdateMaps(bool preserve_selected_rows) {
|
|||
index_line_map.clear();
|
||||
line_index_map.clear();
|
||||
|
||||
for (entryIter cur = context->ass->Line.begin(); cur != context->ass->Line.end(); ++cur) {
|
||||
if (AssDialogue *curdiag = dynamic_cast<AssDialogue*>(&*cur)) {
|
||||
for (auto& line : context->ass->Line) {
|
||||
if (AssDialogue *curdiag = dynamic_cast<AssDialogue*>(&line)) {
|
||||
line_index_map[curdiag] = (int)index_line_map.size();
|
||||
index_line_map.push_back(curdiag);
|
||||
}
|
||||
|
@ -290,15 +290,14 @@ void BaseGrid::UpdateMaps(bool preserve_selected_rows) {
|
|||
|
||||
// If the file shrank enough that no selected rows are left, select the
|
||||
// last row
|
||||
if (sel_rows.empty()) {
|
||||
if (sel_rows.empty())
|
||||
sel_rows.push_back(index_line_map.size() - 1);
|
||||
}
|
||||
else if (sel_rows[0] >= (int)index_line_map.size()) {
|
||||
else if (sel_rows[0] >= (int)index_line_map.size())
|
||||
sel_rows[0] = index_line_map.size() - 1;
|
||||
}
|
||||
for (size_t i = 0; i < sel_rows.size(); i++) {
|
||||
if (sel_rows[i] >= (int)index_line_map.size()) break;
|
||||
sel.insert(index_line_map[sel_rows[i]]);
|
||||
|
||||
for (int row : sel_rows) {
|
||||
if (row >= (int)index_line_map.size()) break;
|
||||
sel.insert(index_line_map[row]);
|
||||
}
|
||||
|
||||
SetSelectedSet(sel);
|
||||
|
|
|
@ -138,11 +138,10 @@ class DataBlockCache {
|
|||
if (mb.blocks.empty())
|
||||
return;
|
||||
|
||||
for (size_t bi = 0; bi < mb.blocks.size(); ++bi)
|
||||
for (auto block : mb.blocks)
|
||||
{
|
||||
BlockT *b = mb.blocks[bi];
|
||||
if (b)
|
||||
factory.DisposeBlock(b);
|
||||
if (block)
|
||||
factory.DisposeBlock(block);
|
||||
}
|
||||
|
||||
mb.blocks.clear();
|
||||
|
@ -205,10 +204,8 @@ public:
|
|||
// Quick way out: get rid of everything
|
||||
if (max_size == 0)
|
||||
{
|
||||
for (size_t mbi = 0; mbi < data.size(); ++mbi)
|
||||
{
|
||||
KillMacroBlock(data[mbi]);
|
||||
}
|
||||
for (auto& mb : data)
|
||||
KillMacroBlock(mb);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,34 +53,32 @@ namespace CharSetDetect {
|
|||
|
||||
wxString GetEncoding(wxString const& filename) {
|
||||
agi::charset::CharsetListDetected list;
|
||||
agi::charset::CharsetListDetected::const_iterator i_lst;
|
||||
|
||||
try {
|
||||
agi::charset::DetectAll(STD_STR(filename), list);
|
||||
agi::charset::DetectAll(from_wx(filename), list);
|
||||
} catch (const agi::charset::UnknownCharset&) {
|
||||
/// @todo If the charset is unknown we need to display a complete list of character sets.
|
||||
}
|
||||
|
||||
if (list.size() > 1) {
|
||||
// Get choice from user
|
||||
wxArrayString choices;
|
||||
|
||||
std::string log_choice;
|
||||
for (i_lst = list.begin(); i_lst != list.end(); ++i_lst) {
|
||||
choices.Add(lagi_wxString(i_lst->second));
|
||||
log_choice.append(" " + i_lst->second);
|
||||
}
|
||||
|
||||
LOG_I("charset/file") << filename << " (" << log_choice << ")";
|
||||
|
||||
int choice = wxGetSingleChoiceIndex(_("Aegisub could not narrow down the character set to a single one.\nPlease pick one below:"),_("Choose character set"),choices);
|
||||
if (choice == -1) throw "Canceled";
|
||||
return choices.Item(choice);
|
||||
if (list.size() == 1) {
|
||||
auto charset = list.begin();
|
||||
LOG_I("charset/file") << filename << " (" << charset->second << ")";
|
||||
return charset->second;
|
||||
}
|
||||
|
||||
i_lst = list.begin();
|
||||
LOG_I("charset/file") << filename << " (" << i_lst->second << ")";
|
||||
return i_lst->second;
|
||||
wxArrayString choices;
|
||||
std::string log_choice;
|
||||
|
||||
for (auto const& charset : list) {
|
||||
choices.push_back(to_wx(charset.second));
|
||||
log_choice.append(" " + charset.second);
|
||||
}
|
||||
|
||||
LOG_I("charset/file") << filename << " (" << log_choice << ")";
|
||||
|
||||
int choice = wxGetSingleChoiceIndex(_("Aegisub could not narrow down the character set to a single one.\nPlease pick one below:"),_("Choose character set"),choices);
|
||||
if (choice == -1) throw "Canceled";
|
||||
return choices[choice];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -220,9 +220,9 @@ struct audio_save_clip : public Command {
|
|||
if (sel.empty()) return;
|
||||
|
||||
AssTime start = INT_MAX, end = 0;
|
||||
for (SubtitleSelection::iterator it = sel.begin(); it != sel.end(); ++it) {
|
||||
start = std::min(start, (*it)->Start);
|
||||
end = std::max(end, (*it)->End);
|
||||
for (auto line : sel) {
|
||||
start = std::min(start, line->Start);
|
||||
end = std::max(end, line->End);
|
||||
}
|
||||
|
||||
c->audioController->SaveClip(
|
||||
|
|
|
@ -68,8 +68,8 @@ namespace cmd {
|
|||
std::vector<std::string> get_registered_commands() {
|
||||
std::vector<std::string> ret;
|
||||
ret.reserve(cmd_map.size());
|
||||
for (iterator it = cmd_map.begin(); it != cmd_map.end(); ++it)
|
||||
ret.push_back(it->first);
|
||||
for (auto const& it : cmd_map)
|
||||
ret.push_back(it.first);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -110,9 +110,8 @@ namespace cmd {
|
|||
}
|
||||
|
||||
void clear() {
|
||||
for (std::map<std::string, Command*>::iterator it = cmd_map.begin(); it != cmd_map.end(); ++it) {
|
||||
delete it->second;
|
||||
}
|
||||
for (auto& it : cmd_map)
|
||||
delete it.second;
|
||||
cmd_map.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -485,8 +485,8 @@ struct edit_find_replace : public Command {
|
|||
static void copy_lines(agi::Context *c) {
|
||||
wxString data;
|
||||
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
||||
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it);
|
||||
for (auto& line : c->ass->Line) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&line);
|
||||
if (diag && sel.count(diag)) {
|
||||
if (!data.empty())
|
||||
data += "\r\n";
|
||||
|
@ -505,8 +505,8 @@ static void delete_lines(agi::Context *c, wxString const& commit_message) {
|
|||
AssDialogue *new_active = 0;
|
||||
bool hit_active = false;
|
||||
|
||||
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it);
|
||||
for (auto& line : c->ass->Line) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&line);
|
||||
if (!diag) continue;
|
||||
|
||||
if (diag == active) {
|
||||
|
|
|
@ -71,8 +71,8 @@ namespace {
|
|||
if (sel.size() < 2) return false;
|
||||
|
||||
size_t found = 0;
|
||||
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it);
|
||||
for (auto& line : c->ass->Line) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&line);
|
||||
if (!diag) continue;
|
||||
|
||||
if (sel.count(diag)) {
|
||||
|
@ -137,9 +137,9 @@ struct time_frame_current : public validate_video_loaded {
|
|||
int target_start = std::max(0, c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START));
|
||||
int shift_by = target_start - active_line->Start;
|
||||
|
||||
for (SubtitleSelection::const_iterator it = sel.begin(); it != sel.end(); ++it) {
|
||||
(*it)->Start = (*it)->Start + shift_by;
|
||||
(*it)->End = (*it)->End + shift_by;
|
||||
for (auto line : sel) {
|
||||
line->Start = line->Start + shift_by;
|
||||
line->End = line->End + shift_by;
|
||||
}
|
||||
|
||||
c->ass->Commit(_("shift to frame"), AssFile::COMMIT_DIAG_TIME);
|
||||
|
@ -167,11 +167,11 @@ static void snap_subs_video(agi::Context *c, bool set_start) {
|
|||
int start = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START);
|
||||
int end = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::END);
|
||||
|
||||
for (SubtitleSelection::const_iterator it = sel.begin(); it != sel.end(); ++it) {
|
||||
if (set_start || (*it)->Start > start)
|
||||
(*it)->Start = start;
|
||||
if (!set_start || (*it)->End < end)
|
||||
(*it)->End = end;
|
||||
for (auto line : sel) {
|
||||
if (set_start || line->Start > start)
|
||||
line->Start = start;
|
||||
if (!set_start || line->End < end)
|
||||
line->End = end;
|
||||
}
|
||||
|
||||
c->ass->Commit(_("timing"), AssFile::COMMIT_DIAG_TIME);
|
||||
|
@ -201,7 +201,6 @@ struct time_snap_scene : public validate_video_loaded {
|
|||
if (!con->IsLoaded() || !con->KeyFramesLoaded()) return;
|
||||
|
||||
// Get frames
|
||||
wxArrayInt sel = c->subsGrid->GetSelection();
|
||||
int curFrame = con->GetFrameN();
|
||||
int prev = 0;
|
||||
int next = 0;
|
||||
|
@ -229,13 +228,11 @@ struct time_snap_scene : public validate_video_loaded {
|
|||
// Get times
|
||||
int start_ms = con->TimeAtFrame(prev,agi::vfr::START);
|
||||
int end_ms = con->TimeAtFrame(next-1,agi::vfr::END);
|
||||
AssDialogue *cur;
|
||||
|
||||
// Update rows
|
||||
for (size_t i=0;i<sel.Count();i++) {
|
||||
cur = c->subsGrid->GetDialogue(sel[i]);
|
||||
cur->Start = start_ms;
|
||||
cur->End = end_ms;
|
||||
for (auto line : c->selectionController->GetSelectedSet()) {
|
||||
line->Start = start_ms;
|
||||
line->End = end_ms;
|
||||
}
|
||||
|
||||
// Commit
|
||||
|
|
|
@ -102,9 +102,8 @@ void DialogAttachments::UpdateList() {
|
|||
listView->InsertColumn(2, _("Group"), wxLIST_FORMAT_LEFT, 100);
|
||||
|
||||
// Fill list
|
||||
for (entryIter cur = ass->Line.begin();cur != ass->Line.end();cur++) {
|
||||
if (AssAttachment *attach = dynamic_cast<AssAttachment*>(&*cur)) {
|
||||
// Add item
|
||||
for (auto& line : ass->Line) {
|
||||
if (AssAttachment *attach = dynamic_cast<AssAttachment*>(&line)) {
|
||||
int row = listView->GetItemCount();
|
||||
listView->InsertItem(row,attach->GetFileName(true));
|
||||
listView->SetItem(row,1,PrettySize(attach->GetSize()));
|
||||
|
|
|
@ -199,16 +199,16 @@ void DialogAutomation::OnAdd(wxCommandEvent &)
|
|||
wxArrayString fnames;
|
||||
diag.GetPaths(fnames);
|
||||
|
||||
for (size_t i = 0; i < fnames.size(); ++i) {
|
||||
wxFileName fnpath(fnames[i]);
|
||||
for (auto const& fname : fnames) {
|
||||
wxFileName fnpath(fname);
|
||||
OPT_SET("Path/Last/Automation")->SetString(STD_STR(fnpath.GetPath()));
|
||||
|
||||
if (has_file(local_manager->GetScripts(), fnpath) || has_file(global_manager->GetScripts(), fnpath)) {
|
||||
wxLogError("Script '%s' is already loaded", fnames[i]);
|
||||
wxLogError("Script '%s' is already loaded", fname);
|
||||
continue;
|
||||
}
|
||||
|
||||
local_manager->Add(Automation4::ScriptFactory::CreateFromFile(fnames[i], true));
|
||||
local_manager->Add(Automation4::ScriptFactory::CreateFromFile(fname, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ std::vector<agi::Color> ColorPickerRecent::Save() const
|
|||
|
||||
void ColorPickerRecent::AddColor(agi::Color color)
|
||||
{
|
||||
std::vector<agi::Color>::iterator existing = find(colors.begin(), colors.end(), color);
|
||||
auto existing = find(colors.begin(), colors.end(), color);
|
||||
if (existing != colors.end())
|
||||
rotate(colors.begin(), existing, existing + 1);
|
||||
else {
|
||||
|
|
|
@ -117,9 +117,9 @@ class FontsCollectorThread : public wxThread {
|
|||
|
||||
int64_t total_size = 0;
|
||||
bool allOk = true;
|
||||
for (std::vector<wxString>::iterator cur = paths.begin(); cur != paths.end(); ++cur) {
|
||||
for (wxString const& path : paths) {
|
||||
int ret = 0;
|
||||
wxFileName cur_fn(*cur);
|
||||
wxFileName cur_fn(path);
|
||||
total_size += cur_fn.GetSize().GetValue();
|
||||
|
||||
switch (oper) {
|
||||
|
@ -139,12 +139,12 @@ class FontsCollectorThread : public wxThread {
|
|||
}
|
||||
#endif
|
||||
else
|
||||
ret = wxCopyFile(*cur, dest, true);
|
||||
ret = wxCopyFile(path, dest, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case CopyToZip: {
|
||||
wxFFileInputStream in(*cur);
|
||||
wxFFileInputStream in(path);
|
||||
if (!in.IsOk())
|
||||
ret = false;
|
||||
else {
|
||||
|
@ -156,13 +156,13 @@ class FontsCollectorThread : public wxThread {
|
|||
}
|
||||
|
||||
if (ret == 1)
|
||||
AppendText(wxString::Format(_("* Copied %s.\n"), *cur), 1);
|
||||
AppendText(wxString::Format(_("* Copied %s.\n"), path), 1);
|
||||
else if (ret == 2)
|
||||
AppendText(wxString::Format(_("* %s already exists on destination.\n"), wxFileName(*cur).GetFullName()), 3);
|
||||
AppendText(wxString::Format(_("* %s already exists on destination.\n"), wxFileName(path).GetFullName()), 3);
|
||||
else if (ret == 3)
|
||||
AppendText(wxString::Format(_("* Symlinked %s.\n"), *cur), 1);
|
||||
AppendText(wxString::Format(_("* Symlinked %s.\n"), path), 1);
|
||||
else {
|
||||
AppendText(wxString::Format(_("* Failed to copy %s.\n"), *cur), 2);
|
||||
AppendText(wxString::Format(_("* Failed to copy %s.\n"), path), 2);
|
||||
allOk = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,9 +240,8 @@ void KaraokeLineMatchDisplay::OnPaint(wxPaintEvent &)
|
|||
// Draw matched groups
|
||||
int this_total_matchgroup_render_width = 0;
|
||||
bool scroll_arrows_drawn = false;
|
||||
for (size_t i = 0; i < matched_groups.size(); ++i)
|
||||
for (auto& grp : matched_groups)
|
||||
{
|
||||
MatchGroup &grp = matched_groups[i];
|
||||
int prev_x = next_x;
|
||||
|
||||
// Skip groups that would cause the input part to be too far right
|
||||
|
@ -273,10 +272,8 @@ void KaraokeLineMatchDisplay::OnPaint(wxPaintEvent &)
|
|||
|
||||
// Matched source syllables
|
||||
int syl_x = next_x;
|
||||
for (size_t j = 0; j < grp.src.size(); ++j)
|
||||
{
|
||||
syl_x += DrawBoxedText(dc, grp.src[j].text, syl_x, y_line1);
|
||||
}
|
||||
for (auto const& syl : grp.src)
|
||||
syl_x += DrawBoxedText(dc, syl.text, syl_x, y_line1);
|
||||
|
||||
// Matched destination text
|
||||
{
|
||||
|
@ -371,14 +368,11 @@ wxString KaraokeLineMatchDisplay::GetOutputLine() const
|
|||
{
|
||||
wxString res;
|
||||
|
||||
for (size_t i = 0; i < matched_groups.size(); ++i)
|
||||
for (auto const& match : matched_groups)
|
||||
{
|
||||
const MatchGroup &match = matched_groups[i];
|
||||
int duration = 0;
|
||||
for (size_t j = 0; j < match.src.size(); ++j)
|
||||
{
|
||||
duration += match.src[j].duration;
|
||||
}
|
||||
for (auto const& syl : match.src)
|
||||
duration += syl.duration;
|
||||
res = wxString::Format("%s{\\k%d}%s", res, duration / 10, match.dst);
|
||||
}
|
||||
|
||||
|
@ -539,12 +533,12 @@ void KaraokeLineMatchDisplay::AutoMatchJapanese()
|
|||
// For the magic number 5, see big comment block above
|
||||
int src_lookahead_max = (lookahead+1)*5;
|
||||
int src_lookahead_pos = 0;
|
||||
for (std::deque<MatchSyllable>::iterator ss = unmatched_source.begin(); ss != unmatched_source.end(); ++ss)
|
||||
for (auto const& syl : unmatched_source)
|
||||
{
|
||||
// Check if we've gone too far ahead in the source
|
||||
if (src_lookahead_pos++ >= src_lookahead_max) break;
|
||||
// Otherwise look for a match
|
||||
if (ss->text.StartsWith(matched_roma))
|
||||
if (syl.text.StartsWith(matched_roma))
|
||||
{
|
||||
// Yay! Time to interpolate.
|
||||
// Special case: If the last source syllable before the matching one is
|
||||
|
@ -725,9 +719,8 @@ END_EVENT_TABLE()
|
|||
void DialogKanjiTimer::OnClose(wxCommandEvent &) {
|
||||
OPT_SET("Tool/Kanji Timer/Interpolation")->SetBool(Interpolate->IsChecked());
|
||||
|
||||
for (size_t i = 0; i < LinesToChange.size(); ++i) {
|
||||
LinesToChange[i].first->Text = LinesToChange[i].second;
|
||||
}
|
||||
for (auto& line : LinesToChange)
|
||||
line.first->Text = line.second;
|
||||
|
||||
if (LinesToChange.size()) {
|
||||
subs->Commit(_("kanji timing"), AssFile::COMMIT_DIAG_TEXT);
|
||||
|
|
|
@ -106,9 +106,9 @@ public:
|
|||
}
|
||||
|
||||
~DialogManager() {
|
||||
for (DialogMap::iterator it = created_dialogs.begin(); it != created_dialogs.end(); ++it) {
|
||||
it->second->Unbind(wxEVT_CLOSE_WINDOW, &DialogManager::OnClose, this);
|
||||
it->second->Destroy();
|
||||
for (auto const& it : created_dialogs) {
|
||||
it.second->Unbind(wxEVT_CLOSE_WINDOW, &DialogManager::OnClose, this);
|
||||
it.second->Destroy();
|
||||
}
|
||||
created_dialogs.clear();
|
||||
}
|
||||
|
|
|
@ -144,8 +144,8 @@ void DialogProperties::AddProperty(wxSizer *sizer, wxString const& label, wxStri
|
|||
|
||||
void DialogProperties::OnOK(wxCommandEvent &) {
|
||||
int count = 0;
|
||||
for (size_t i = 0; i < properties.size(); ++i)
|
||||
count += SetInfoIfDifferent(properties[i].first, properties[i].second->GetValue());
|
||||
for (auto const& prop : properties)
|
||||
count += SetInfoIfDifferent(prop.first, prop.second->GetValue());
|
||||
|
||||
count += SetInfoIfDifferent("PlayResX", ResX->GetValue());
|
||||
count += SetInfoIfDifferent("PlayResY", ResY->GetValue());
|
||||
|
|
|
@ -206,9 +206,9 @@ namespace {
|
|||
diag->ParseAssTags();
|
||||
diag->ProcessParameters(resample_tags, state);
|
||||
|
||||
for (size_t i = 0; i < diag->Blocks.size(); ++i) {
|
||||
if (AssDialogueBlockDrawing *block = dynamic_cast<AssDialogueBlockDrawing*>(diag->Blocks[i]))
|
||||
block->TransformCoords(state->margin[LEFT], state->margin[TOP], state->rx, state->ry);
|
||||
for (auto block : diag->Blocks) {
|
||||
if (AssDialogueBlockDrawing *drawing = dynamic_cast<AssDialogueBlockDrawing*>(block))
|
||||
drawing->TransformCoords(state->margin[LEFT], state->margin[TOP], state->rx, state->ry);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 3; ++i)
|
||||
|
|
|
@ -379,8 +379,8 @@ void SearchReplaceEngine::ReplaceAll() {
|
|||
bool inSel = affect == 1;
|
||||
|
||||
// Scan
|
||||
for (entryIter it = context->ass->Line.begin(); it != context->ass->Line.end(); ++it) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it);
|
||||
for (auto& line : context->ass->Line) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&line);
|
||||
if (!diag) continue;
|
||||
|
||||
// Check if row is selected
|
||||
|
|
|
@ -113,8 +113,8 @@ static std::set<AssDialogue*> process(wxString match_text, bool match_case, int
|
|||
std::function<bool (wxString)> pred = get_predicate(mode, &re, match_case, match_text);
|
||||
|
||||
std::set<AssDialogue*> matches;
|
||||
for (entryIter it = ass->Line.begin(); it != ass->Line.end(); ++it) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it);
|
||||
for (auto& line : ass->Line) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&line);
|
||||
if (!diag) continue;
|
||||
if (diag->Comment && !comments) continue;
|
||||
if (!diag->Comment && !dialogue) continue;
|
||||
|
|
|
@ -308,8 +308,8 @@ void DialogShiftTimes::LoadHistory() {
|
|||
json::Reader::Read(root, *file);
|
||||
*history = root;
|
||||
|
||||
for (json::Array::iterator it = history->begin(); it != history->end(); ++it)
|
||||
history_box->Append(get_history_string(*it));
|
||||
for (auto& history_entry : *history)
|
||||
history_box->Append(get_history_string(history_entry));
|
||||
}
|
||||
catch (agi::FileSystemError const& e) {
|
||||
LOG_D("dialog_shift_times/load_history") << "Cannot load shift times history: " << e.GetChainedMessage();
|
||||
|
@ -352,8 +352,8 @@ void DialogShiftTimes::Process(wxCommandEvent &) {
|
|||
int block_start = 0;
|
||||
json::Array shifted_blocks;
|
||||
|
||||
for (entryIter it = context->ass->Line.begin(); it != context->ass->Line.end(); ++it) {
|
||||
AssDialogue *line = dynamic_cast<AssDialogue*>(&*it);
|
||||
for (auto& entry : context->ass->Line) {
|
||||
AssDialogue *line = dynamic_cast<AssDialogue*>(&entry);
|
||||
if (!line) continue;
|
||||
++row_number;
|
||||
|
||||
|
|
|
@ -251,10 +251,10 @@ bool DialogSpellChecker::CheckLine(AssDialogue *active_line, int start_pos, int
|
|||
GetWordBoundaries(active_line->Text, results);
|
||||
|
||||
int shift = 0;
|
||||
for (size_t j = 0; j < results.size(); ++j) {
|
||||
word_start = results[j].first + shift;
|
||||
for (auto const& result : results) {
|
||||
word_start = result.first + shift;
|
||||
if (word_start < start_pos) continue;
|
||||
word_end = results[j].second + shift;
|
||||
word_end = result.second + shift;
|
||||
wxString word = active_line->Text.Mid(word_start, word_end - word_start);
|
||||
|
||||
if (auto_ignore.count(word) || spellchecker->CheckWord(from_wx(word))) continue;
|
||||
|
|
|
@ -87,8 +87,8 @@ class StyleRenamer {
|
|||
found_any = false;
|
||||
do_replace = replace;
|
||||
|
||||
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it);
|
||||
for (auto& line : c->ass->Line) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&line);
|
||||
if (!diag) continue;
|
||||
|
||||
if (diag->Style == source_name) {
|
||||
|
@ -425,9 +425,9 @@ void DialogStyleEditor::Apply(bool apply, bool close) {
|
|||
wxArrayString styles = store ? store->GetNames() : c->ass->GetStyles();
|
||||
|
||||
// Check if style name is unique
|
||||
for (unsigned int i=0;i<styles.Count();i++) {
|
||||
if (newStyleName.CmpNoCase(styles[i]) == 0) {
|
||||
if ((store && store->GetStyle(styles[i]) != style) || (!store && c->ass->GetStyle(styles[i]) != style)) {
|
||||
for (auto const& style_name : styles) {
|
||||
if (newStyleName.CmpNoCase(style_name) == 0) {
|
||||
if ((store && store->GetStyle(style_name) != style) || (!store && c->ass->GetStyle(style_name) != style)) {
|
||||
wxMessageBox("There is already a style with this name. Please choose another name.", "Style name conflict.", wxOK | wxICON_ERROR | wxCENTER);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -274,8 +274,8 @@ void DialogStyleManager::LoadCurrentStyles(int commit_type) {
|
|||
CurrentList->Clear();
|
||||
styleMap.clear();
|
||||
|
||||
for (entryIter cur = c->ass->Line.begin(); cur != c->ass->Line.end(); ++cur) {
|
||||
if (AssStyle *style = dynamic_cast<AssStyle*>(&*cur)) {
|
||||
for (auto& line : c->ass->Line) {
|
||||
if (AssStyle *style = dynamic_cast<AssStyle*>(&line)) {
|
||||
CurrentList->Append(style->name);
|
||||
styleMap.push_back(style);
|
||||
}
|
||||
|
@ -306,8 +306,8 @@ void DialogStyleManager::UpdateStorage() {
|
|||
Store.Save();
|
||||
|
||||
StorageList->Clear();
|
||||
for (AssStyleStorage::iterator cur = Store.begin(); cur != Store.end(); ++cur)
|
||||
StorageList->Append((*cur)->name);
|
||||
for (auto style : Store)
|
||||
StorageList->Append(style->name);
|
||||
|
||||
UpdateButtons();
|
||||
}
|
||||
|
@ -360,9 +360,9 @@ void DialogStyleManager::OnCatalogNew() {
|
|||
// Remove bad characters from the name
|
||||
wxString badchars = wxFileName::GetForbiddenChars(wxPATH_DOS);
|
||||
int badchars_removed = 0;
|
||||
for (size_t i = 0; i < name.size(); ++i) {
|
||||
if (badchars.find(name[i]) != badchars.npos) {
|
||||
name[i] = '_';
|
||||
for (wxUniCharRef chr : name) {
|
||||
if (badchars.find(chr) != badchars.npos) {
|
||||
chr = '_';
|
||||
++badchars_removed;
|
||||
}
|
||||
}
|
||||
|
@ -420,8 +420,8 @@ void DialogStyleManager::OnCopyToStorage() {
|
|||
}
|
||||
|
||||
UpdateStorage();
|
||||
for (std::list<wxString>::iterator name = copied.begin(); name != copied.end(); ++name)
|
||||
StorageList->SetStringSelection(*name, true);
|
||||
for (auto const& style_name : copied)
|
||||
StorageList->SetStringSelection(style_name, true);
|
||||
|
||||
UpdateButtons();
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ void DialogStyleManager::OnCopyToCurrent() {
|
|||
wxString styleName = StorageList->GetString(selections[i]);
|
||||
bool addStyle = true;
|
||||
|
||||
for (std::vector<AssStyle *>::iterator style = styleMap.begin(); style != styleMap.end(); ++style) {
|
||||
for (auto style = styleMap.begin(); style != styleMap.end(); ++style) {
|
||||
if ((*style)->name.CmpNoCase(styleName) == 0) {
|
||||
addStyle = false;
|
||||
if (wxYES == wxMessageBox(wxString::Format(_("There is already a style with the name \"%s\" in the current script. Overwrite?"), styleName), _("Style name collision"), wxYES_NO)) {
|
||||
|
@ -453,8 +453,8 @@ void DialogStyleManager::OnCopyToCurrent() {
|
|||
c->ass->Commit(_("style copy"), AssFile::COMMIT_STYLES);
|
||||
|
||||
CurrentList->DeselectAll();
|
||||
for (std::list<wxString>::iterator name = copied.begin(); name != copied.end(); ++name)
|
||||
CurrentList->SetStringSelection(*name, true);
|
||||
for (auto const& style_name : copied)
|
||||
CurrentList->SetStringSelection(style_name, true);
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
|
@ -603,12 +603,12 @@ void DialogStyleManager::OnCurrentImport() {
|
|||
bool modified = false;
|
||||
|
||||
// Loop through selection
|
||||
for (size_t i = 0; i < selections.size(); ++i) {
|
||||
for (auto const& sel : selections) {
|
||||
// Check if there is already a style with that name
|
||||
int test = CurrentList->FindString(styles[selections[i]], false);
|
||||
int test = CurrentList->FindString(styles[sel], false);
|
||||
if (test != wxNOT_FOUND) {
|
||||
int answer = wxMessageBox(
|
||||
wxString::Format(_("There is already a style with the name \"%s\" in the current script. Overwrite?"), styles[selections[i]]),
|
||||
wxString::Format(_("There is already a style with the name \"%s\" in the current script. Overwrite?"), styles[sel]),
|
||||
_("Style name collision"),
|
||||
wxYES_NO);
|
||||
if (answer == wxYES) {
|
||||
|
@ -617,7 +617,7 @@ void DialogStyleManager::OnCurrentImport() {
|
|||
// The result of GetString is used rather than the name
|
||||
// itself to deal with that AssFile::GetStyle is
|
||||
// case-sensitive, but style names are case insensitive
|
||||
*c->ass->GetStyle(CurrentList->GetString(test)) = *temp.GetStyle(styles[selections[i]]);
|
||||
*c->ass->GetStyle(CurrentList->GetString(test)) = *temp.GetStyle(styles[sel]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ void DialogStyleManager::OnCurrentImport() {
|
|||
// Copy
|
||||
modified = true;
|
||||
AssStyle *tempStyle = new AssStyle;
|
||||
*tempStyle = *temp.GetStyle(styles[selections[i]]);
|
||||
*tempStyle = *temp.GetStyle(styles[sel]);
|
||||
c->ass->InsertStyle(tempStyle);
|
||||
}
|
||||
|
||||
|
|
|
@ -247,8 +247,8 @@ void DialogTranslation::UpdateDisplay() {
|
|||
original_text->SetReadOnly(false);
|
||||
original_text->ClearAll();
|
||||
|
||||
for (size_t i = 0; i < active_line->Blocks.size(); ++i) {
|
||||
AssDialogueBlock *block = active_line->Blocks[i];
|
||||
size_t i = 0;
|
||||
for (auto block : active_line->Blocks) {
|
||||
if (block->GetType() == BLOCK_PLAIN) {
|
||||
int cur_size = original_text->GetReverseUnicodePosition(original_text->GetLength());
|
||||
original_text->AppendText(block->GetText());
|
||||
|
@ -259,6 +259,7 @@ void DialogTranslation::UpdateDisplay() {
|
|||
}
|
||||
else if (block->GetType() == BLOCK_OVERRIDE)
|
||||
original_text->AppendText("{" + block->GetText() + "}");
|
||||
++i;
|
||||
}
|
||||
|
||||
original_text->SetReadOnly(true);
|
||||
|
|
|
@ -53,11 +53,10 @@ void AssFixStylesFilter::ProcessSubs(AssFile *subs, wxWindow *) {
|
|||
for_each(styles.begin(), styles.end(), std::mem_fun_ref(&wxString::MakeLower));
|
||||
styles.Sort();
|
||||
|
||||
for (entryIter cur=subs->Line.begin();cur!=subs->Line.end();cur++) {
|
||||
if (AssDialogue *diag = dynamic_cast<AssDialogue*>(&*cur)) {
|
||||
if (!std::binary_search(styles.begin(), styles.end(), diag->Style.Lower())) {
|
||||
for (auto& line : subs->Line) {
|
||||
if (AssDialogue *diag = dynamic_cast<AssDialogue*>(&line)) {
|
||||
if (!std::binary_search(styles.begin(), styles.end(), diag->Style.Lower()))
|
||||
diag->Style = "Default";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,24 +208,23 @@ void AssTransformFramerateFilter::TransformTimeTags(wxString name,int n,AssOverr
|
|||
|
||||
void AssTransformFramerateFilter::TransformFrameRate(AssFile *subs) {
|
||||
if (!Input->IsLoaded() || !Output->IsLoaded()) return;
|
||||
for (entryIter cur=subs->Line.begin();cur!=subs->Line.end();cur++) {
|
||||
AssDialogue *curDialogue = dynamic_cast<AssDialogue*>(&*cur);
|
||||
for (auto& entry : subs->Line) {
|
||||
AssDialogue *curDialogue = dynamic_cast<AssDialogue*>(&entry);
|
||||
if (!curDialogue) continue;
|
||||
|
||||
if (curDialogue) {
|
||||
line = curDialogue;
|
||||
newK = 0;
|
||||
oldK = 0;
|
||||
newStart = trunc_cs(ConvertTime(curDialogue->Start));
|
||||
newEnd = trunc_cs(ConvertTime(curDialogue->End) + 9);
|
||||
line = curDialogue;
|
||||
newK = 0;
|
||||
oldK = 0;
|
||||
newStart = trunc_cs(ConvertTime(curDialogue->Start));
|
||||
newEnd = trunc_cs(ConvertTime(curDialogue->End) + 9);
|
||||
|
||||
// Process stuff
|
||||
curDialogue->ParseAssTags();
|
||||
curDialogue->ProcessParameters(TransformTimeTags, this);
|
||||
curDialogue->Start = newStart;
|
||||
curDialogue->End = newEnd;
|
||||
curDialogue->UpdateText();
|
||||
curDialogue->ClearBlocks();
|
||||
}
|
||||
// Process stuff
|
||||
curDialogue->ParseAssTags();
|
||||
curDialogue->ProcessParameters(TransformTimeTags, this);
|
||||
curDialogue->Start = newStart;
|
||||
curDialogue->End = newEnd;
|
||||
curDialogue->UpdateText();
|
||||
curDialogue->ClearBlocks();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,9 +58,8 @@ protected:
|
|||
classes->insert(std::make_pair(name, std::make_pair(hide, function)));
|
||||
}
|
||||
else {
|
||||
for (size_t i = 0; i < subtypes.size(); i++) {
|
||||
classes->insert(std::make_pair(name + '/' + subtypes[i], std::make_pair(hide, function)));
|
||||
}
|
||||
for (auto const& subtype : subtypes)
|
||||
classes->insert(std::make_pair(name + '/' + subtype, std::make_pair(hide, function)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,11 +80,11 @@ public:
|
|||
if (!classes) return list;
|
||||
std::string cmp;
|
||||
std::transform(favourite.begin(), favourite.end(), favourite.begin(), ::tolower);
|
||||
for (iterator cur = classes->begin(); cur != classes->end(); ++cur) {
|
||||
for (auto const& cls : *classes) {
|
||||
cmp.clear();
|
||||
std::transform(cur->first.begin(), cur->first.end(), std::back_inserter(cmp), ::tolower);
|
||||
if (cmp == favourite) list.insert(list.begin(), cur->first);
|
||||
else if (!cur->second.first) list.push_back(cur->first);
|
||||
std::transform(cls.first.begin(), cls.first.end(), std::back_inserter(cmp), ::tolower);
|
||||
if (cmp == favourite) list.insert(list.begin(), cls.first);
|
||||
else if (!cls.second.first) list.push_back(cls.first);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -157,9 +157,9 @@ int FFmpegSourceProvider::AskForTrackSelection(const std::map<int,wxString> &Tra
|
|||
std::vector<int> TrackNumbers;
|
||||
wxArrayString Choices;
|
||||
|
||||
for (std::map<int,wxString>::const_iterator i = TrackList.begin(); i != TrackList.end(); i++) {
|
||||
Choices.Add(wxString::Format(_("Track %02d: %s"), i->first, i->second));
|
||||
TrackNumbers.push_back(i->first);
|
||||
for (auto const& track : TrackList) {
|
||||
Choices.Add(wxString::Format(_("Track %02d: %s"), track.first, track.second));
|
||||
TrackNumbers.push_back(track.first);
|
||||
}
|
||||
|
||||
int Choice = wxGetSingleChoiceIndex(
|
||||
|
|
|
@ -54,10 +54,9 @@ void FontCollector::ProcessDialogueLine(const AssDialogue *line, int index) {
|
|||
|
||||
bool overriden = false;
|
||||
|
||||
for (size_t i = 0; i < blocks.size(); ++i) {
|
||||
if (AssDialogueBlockOverride *ovr = dynamic_cast<AssDialogueBlockOverride *>(blocks[i])) {
|
||||
for (size_t j = 0; j < ovr->Tags.size(); ++j) {
|
||||
AssOverrideTag *tag = ovr->Tags[j];
|
||||
for (auto block : blocks) {
|
||||
if (AssDialogueBlockOverride *ovr = dynamic_cast<AssDialogueBlockOverride *>(block)) {
|
||||
for (auto tag : ovr->Tags) {
|
||||
wxString name = tag->Name;
|
||||
|
||||
if (name == "\\r") {
|
||||
|
@ -78,7 +77,7 @@ void FontCollector::ProcessDialogueLine(const AssDialogue *line, int index) {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (AssDialogueBlockPlain *txt = dynamic_cast<AssDialogueBlockPlain *>(blocks[i])) {
|
||||
else if (AssDialogueBlockPlain *txt = dynamic_cast<AssDialogueBlockPlain *>(block)) {
|
||||
wxString text = txt->GetText();
|
||||
|
||||
if (text.empty() || (text.size() >= 2 && text.StartsWith("{") && text.EndsWith("}")))
|
||||
|
@ -136,14 +135,14 @@ void FontCollector::ProcessChunk(std::pair<StyleInfo, UsageData> const& style) {
|
|||
void FontCollector::PrintUsage(UsageData const& data) {
|
||||
if (data.styles.size()) {
|
||||
status_callback(wxString::Format(_("Used in styles:\n")), 2);
|
||||
for (std::set<wxString>::const_iterator it = data.styles.begin(); it != data.styles.end(); ++it)
|
||||
status_callback(wxString::Format(" - %s\n", *it), 2);
|
||||
for (auto const& style : data.styles)
|
||||
status_callback(wxString::Format(" - %s\n", style), 2);
|
||||
}
|
||||
|
||||
if (data.lines.size()) {
|
||||
status_callback(wxString::Format(_("Used on lines:")), 2);
|
||||
for (std::set<int>::const_iterator it = data.lines.begin(); it != data.lines.end(); ++it)
|
||||
status_callback(wxString::Format(" %d", *it), 2);
|
||||
for (int line : data.lines)
|
||||
status_callback(wxString::Format(" %d", line), 2);
|
||||
status_callback("\n", 2);
|
||||
}
|
||||
status_callback("\n", 2);
|
||||
|
@ -156,15 +155,15 @@ std::vector<wxString> FontCollector::GetFontPaths(const AssFile *file) {
|
|||
status_callback(_("Parsing file\n"), 0);
|
||||
|
||||
int index = 0;
|
||||
for (constEntryIter cur = file->Line.begin(); cur != file->Line.end(); ++cur) {
|
||||
if (const AssStyle *style = dynamic_cast<const AssStyle*>(&*cur)) {
|
||||
for (auto const& line : file->Line) {
|
||||
if (const AssStyle *style = dynamic_cast<const AssStyle*>(&line)) {
|
||||
StyleInfo &info = styles[style->name];
|
||||
info.facename = style->font;
|
||||
info.bold = style->bold;
|
||||
info.italic = style->italic;
|
||||
used_styles[info].styles.insert(style->name);
|
||||
}
|
||||
else if (const AssDialogue *diag = dynamic_cast<const AssDialogue*>(&*cur))
|
||||
else if (const AssDialogue *diag = dynamic_cast<const AssDialogue*>(&line))
|
||||
ProcessDialogueLine(diag, ++index);
|
||||
}
|
||||
|
||||
|
|
|
@ -205,9 +205,9 @@ FontFileLister::CollectionResult FontConfigFontFileLister::GetFontPaths(wxString
|
|||
|
||||
FcCharSet *charset;
|
||||
if (FcPatternGetCharSet(rpat, FC_CHARSET, 0, &charset) == FcResultMatch) {
|
||||
for (std::set<wxUniChar>::const_iterator it = characters.begin(); it != characters.end(); ++it) {
|
||||
if (!FcCharSetHasChar(charset, *it))
|
||||
ret.missing += *it;
|
||||
for (wxUniChar chr : characters) {
|
||||
if (!FcCharSetHasChar(charset, chr))
|
||||
ret.missing += chr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -146,8 +146,7 @@ static void get_files_to_load(wxArrayString const& list, wxString &subs, wxStrin
|
|||
};
|
||||
|
||||
// Scan list
|
||||
for (size_t i = 0; i < list.size(); ++i) {
|
||||
wxFileName file(list[i]);
|
||||
for (wxFileName file : list) {
|
||||
if (file.IsRelative()) file.MakeAbsolute();
|
||||
if (!file.FileExists()) continue;
|
||||
|
||||
|
|
|
@ -156,13 +156,10 @@ void OpenGLText::Print(const wxString &text,int x,int y) {
|
|||
}
|
||||
|
||||
void OpenGLText::DrawString(const wxString &text,int x,int y) {
|
||||
size_t len = text.Length();
|
||||
lineHeight = 0;
|
||||
int dx=x,dy=y;
|
||||
|
||||
for (size_t i=0;i<len;i++) {
|
||||
int curChar = text[i];
|
||||
|
||||
for (int curChar : text) {
|
||||
// Handle carriage returns
|
||||
if (curChar == '\n') {
|
||||
dx = x;
|
||||
|
@ -180,17 +177,13 @@ void OpenGLText::DrawString(const wxString &text,int x,int y) {
|
|||
}
|
||||
|
||||
void OpenGLText::GetExtent(wxString const& text, int &w, int &h) {
|
||||
size_t len = text.Length();
|
||||
lineHeight = 0;
|
||||
int dx=0,dy=0;
|
||||
w = 0;
|
||||
h = 0;
|
||||
|
||||
// Simulate drawing of string
|
||||
for (size_t i=0;i<len;i++) {
|
||||
// Get current character
|
||||
int curChar = text[i];
|
||||
|
||||
for (int curChar : text) {
|
||||
// Handle carriage returns
|
||||
if (curChar == '\n') {
|
||||
if (dx > w) w = dx;
|
||||
|
@ -224,8 +217,8 @@ OpenGLTextGlyph const& OpenGLText::CreateGlyph(int n) {
|
|||
|
||||
// Insert into some texture
|
||||
bool ok = false;
|
||||
for (unsigned int i=0;i<textures.size();i++) {
|
||||
if (textures[i]->TryToInsert(glyph)) {
|
||||
for (auto texture : textures) {
|
||||
if (texture->TryToInsert(glyph)) {
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
|
@ -239,9 +232,6 @@ OpenGLTextGlyph const& OpenGLText::CreateGlyph(int n) {
|
|||
return glyph;
|
||||
}
|
||||
|
||||
/// @brief Texture constructor
|
||||
/// @param w
|
||||
/// @param h
|
||||
OpenGLTextTexture::OpenGLTextTexture(OpenGLTextGlyph &glyph) {
|
||||
x = y = nextY = 0;
|
||||
width = std::max(SmallestPowerOf2(glyph.w), 64);
|
||||
|
|
|
@ -101,9 +101,9 @@ namespace {
|
|||
name_map[renamed_commands[i][0]] = renamed_commands[i][1];
|
||||
|
||||
bool renamed_any = false;
|
||||
agi::hotkey::Hotkey::HotkeyMap hk_map = hotkey::inst->GetHotkeyMap();
|
||||
for (agi::hotkey::Hotkey::HotkeyMap::iterator it = hk_map.begin(); it != hk_map.end(); ) {
|
||||
std::map<std::string, const char *>::iterator ren = name_map.find(it->first);
|
||||
auto hk_map = hotkey::inst->GetHotkeyMap();
|
||||
for (auto it = hk_map.begin(); it != hk_map.end(); ) {
|
||||
auto ren = name_map.find(it->first);
|
||||
if (ren != name_map.end()) {
|
||||
hk_map.insert(make_pair(std::string(ren->second),
|
||||
agi::hotkey::Combo(it->second.Context(), ren->second, it->second.Get())));
|
||||
|
|
|
@ -117,8 +117,7 @@ public:
|
|||
wxArrayString toks = wxSplit(variant.GetString(), '-');
|
||||
std::vector<std::string> keys;
|
||||
keys.resize(toks.size());
|
||||
for (size_t i = 0; i < toks.size(); ++i)
|
||||
keys[i] = STD_STR(toks[i]);
|
||||
transform(toks.begin(), toks.end(), back_inserter(keys), (std::string(*)(wxString const&))&from_wx);
|
||||
combo = Combo(combo.Context(), combo.CmdName(), keys);
|
||||
cmd_str = combo.Str();
|
||||
return true;
|
||||
|
@ -155,7 +154,7 @@ public:
|
|||
}
|
||||
|
||||
void Delete(wxDataViewItem const& item) {
|
||||
for (std::list<HotkeyModelCombo>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
for (auto it = children.begin(); it != children.end(); ++it) {
|
||||
if (&*it == item.GetID()) {
|
||||
model->ItemDeleted(wxDataViewItem(this), wxDataViewItem((void*)&*it));
|
||||
children.erase(it);
|
||||
|
@ -165,30 +164,30 @@ public:
|
|||
}
|
||||
|
||||
void Apply(Hotkey::HotkeyMap *hk_map) {
|
||||
for_each(children.begin(), children.end(),
|
||||
bind(&HotkeyModelCombo::Apply, std::placeholders::_1, hk_map));
|
||||
for (auto& combo : children)
|
||||
combo.Apply(hk_map);
|
||||
}
|
||||
|
||||
void SetFilter(wxRegEx const& new_filter) {
|
||||
std::set<HotkeyModelCombo*> old_visible;
|
||||
for (size_t i = 0; i < visible_items.size(); ++i)
|
||||
old_visible.insert(static_cast<HotkeyModelCombo*>(visible_items[i].GetID()));
|
||||
for (auto item : visible_items)
|
||||
old_visible.insert(static_cast<HotkeyModelCombo*>(item.GetID()));
|
||||
|
||||
visible_items.clear();
|
||||
|
||||
wxDataViewItemArray added;
|
||||
wxDataViewItemArray removed;
|
||||
|
||||
for (std::list<HotkeyModelCombo>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
bool was_visible = old_visible.count(&*it) > 0;
|
||||
bool is_visible = it->IsVisible(new_filter);
|
||||
for (auto& combo : children) {
|
||||
bool was_visible = old_visible.count(&combo) > 0;
|
||||
bool is_visible = combo.IsVisible(new_filter);
|
||||
|
||||
if (is_visible)
|
||||
visible_items.push_back(wxDataViewItem(&*it));
|
||||
visible_items.push_back(wxDataViewItem(&combo));
|
||||
if (was_visible && !is_visible)
|
||||
removed.push_back(wxDataViewItem(&*it));
|
||||
removed.push_back(wxDataViewItem(&combo));
|
||||
if (is_visible && !was_visible)
|
||||
added.push_back(wxDataViewItem(&*it));
|
||||
added.push_back(wxDataViewItem(&combo));
|
||||
}
|
||||
|
||||
if (!added.empty())
|
||||
|
@ -222,10 +221,10 @@ public:
|
|||
Hotkey::HotkeyMap const& hk_map = hotkey::inst->GetHotkeyMap();
|
||||
std::map<std::string, HotkeyModelCategory*> cat_map;
|
||||
|
||||
for (Hotkey::HotkeyMap::const_iterator it = hk_map.begin(); it != hk_map.end(); ++it) {
|
||||
std::string cat_name = it->second.Context();
|
||||
for (auto const& category : hk_map) {
|
||||
std::string cat_name = category.second.Context();
|
||||
HotkeyModelCategory *cat;
|
||||
std::map<std::string, HotkeyModelCategory*>::iterator cat_it = cat_map.find(cat_name);
|
||||
auto cat_it = cat_map.find(cat_name);
|
||||
if (cat_it != cat_map.end())
|
||||
cat = cat_it->second;
|
||||
else {
|
||||
|
@ -233,7 +232,7 @@ public:
|
|||
cat = cat_map[cat_name] = &categories.back();
|
||||
}
|
||||
|
||||
cat->AddChild(it->second);
|
||||
cat->AddChild(category.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,8 +259,8 @@ public:
|
|||
|
||||
unsigned int GetChildren(wxDataViewItemArray &out) const {
|
||||
out.reserve(categories.size());
|
||||
for (std::list<HotkeyModelCategory>::const_iterator it = categories.begin(); it != categories.end(); ++it)
|
||||
out.push_back(wxDataViewItem((void*)&*it));
|
||||
for (auto const& category : categories)
|
||||
out.push_back(wxDataViewItem((void*)&category));
|
||||
return out.size();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -255,9 +255,8 @@ bool AegisubApp::OnInit() {
|
|||
// Get parameter subs
|
||||
StartupLog("Parse command line");
|
||||
wxArrayString subs;
|
||||
for (int i=1;i<argc;i++) {
|
||||
subs.Add(argv[i]);
|
||||
}
|
||||
for (int i = 1; i < argc; ++i)
|
||||
subs.push_back(argv[i]);
|
||||
|
||||
// Open main frame
|
||||
StartupLog("Create main window");
|
||||
|
@ -475,12 +474,7 @@ int AegisubApp::OnRun() {
|
|||
file << std::endl << timeStr.mb_str(csConvLocal);
|
||||
file << "\nVER - " << GetAegisubLongVersionString();
|
||||
file << "\nEXC - Aegisub has crashed with unhandled exception \"" << error.mb_str(csConvLocal) <<"\".\n";
|
||||
int formatLen = timeStr.Length();
|
||||
char dashes[1024];
|
||||
int i = 0;
|
||||
for (i=0;i<formatLen;i++) dashes[i] = '-';
|
||||
dashes[i] = 0;
|
||||
file << dashes;
|
||||
file << wxString('-', timeStr.size());
|
||||
file << "\n";
|
||||
file.close();
|
||||
}
|
||||
|
|
|
@ -98,10 +98,7 @@ public:
|
|||
}
|
||||
|
||||
int i = 0;
|
||||
for (agi::MRUManager::MRUListMap::const_iterator it = mru->begin();
|
||||
it != mru->end();
|
||||
++it, ++i)
|
||||
{
|
||||
for (auto it = mru->begin(); it != mru->end(); ++it, ++i) {
|
||||
items[i]->SetItemLabel(wxString::Format("%s%d %s",
|
||||
i <= 9 ? "&" : "", i + 1,
|
||||
wxFileName(lagi_wxString(*it)).GetFullName()));
|
||||
|
@ -209,8 +206,7 @@ public:
|
|||
|
||||
/// Unregister a dynamic menu item
|
||||
void Remove(wxMenuItem *item) {
|
||||
std::deque<std::pair<std::string, wxMenuItem*> >::iterator it =
|
||||
find_if(dynamic_items.begin(), dynamic_items.end(), menu_item_cmp(item));
|
||||
auto it = find_if(dynamic_items.begin(), dynamic_items.end(), menu_item_cmp(item));
|
||||
if (it != dynamic_items.end())
|
||||
dynamic_items.erase(it);
|
||||
it = find_if(static_items.begin(), static_items.end(), menu_item_cmp(item));
|
||||
|
@ -442,17 +438,17 @@ namespace menu {
|
|||
menu_items const& items = get_menu(name);
|
||||
|
||||
std::auto_ptr<CommandMenuBar> menu(new CommandMenuBar(c));
|
||||
for (menu_items::const_iterator it = items.begin(); it != items.end(); ++it) {
|
||||
for (auto const& item : items) {
|
||||
std::string submenu, disp;
|
||||
read_entry(*it, "submenu", &submenu);
|
||||
read_entry(*it, "text", &disp);
|
||||
read_entry(item, "submenu", &submenu);
|
||||
read_entry(item, "text", &disp);
|
||||
if (!submenu.empty()) {
|
||||
menu->Append(build_menu(submenu, c, &menu->cm), _(lagi_wxString(disp)));
|
||||
menu->Append(build_menu(submenu, c, &menu->cm), _(to_wx(disp)));
|
||||
}
|
||||
else {
|
||||
read_entry(*it, "special", &submenu);
|
||||
read_entry(item, "special", &submenu);
|
||||
if (submenu == "automation")
|
||||
menu->Append(new AutomationMenu(c, &menu->cm), _(lagi_wxString(disp)));
|
||||
menu->Append(new AutomationMenu(c, &menu->cm), _(to_wx(disp)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,8 +133,8 @@ static void read_subtitles(agi::ProgressSink *ps, MatroskaFile *file, MkvStdIO *
|
|||
delete[] readBuf;
|
||||
|
||||
// Insert into file
|
||||
for (std::map<int, wxString>::iterator it = subList.begin(); it != subList.end(); ++it) {
|
||||
parser->AddLine(it->second);
|
||||
for (auto order_value_pair : subList) {
|
||||
parser->AddLine(order_value_pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -449,8 +449,8 @@ void Interface_Hotkeys::OnUpdateFilter(wxCommandEvent&) {
|
|||
if (!quick_search->GetValue().empty()) {
|
||||
wxDataViewItemArray contexts;
|
||||
model->GetChildren(wxDataViewItem(0), contexts);
|
||||
for (size_t i = 0; i < contexts.size(); ++i)
|
||||
dvc->Expand(contexts[i]);
|
||||
for (auto const& context : contexts)
|
||||
dvc->Expand(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -635,14 +635,14 @@ void Preferences::OnOK(wxCommandEvent &event) {
|
|||
}
|
||||
|
||||
void Preferences::OnApply(wxCommandEvent &) {
|
||||
for (std::map<std::string, agi::OptionValue*>::iterator cur = pending_changes.begin(); cur != pending_changes.end(); ++cur) {
|
||||
OPT_SET(cur->first)->Set(cur->second);
|
||||
delete cur->second;
|
||||
for (auto const& change : pending_changes) {
|
||||
OPT_SET(change.first)->Set(change.second);
|
||||
delete change.second;
|
||||
}
|
||||
pending_changes.clear();
|
||||
|
||||
for (std::deque<Thunk>::iterator it = pending_callbacks.begin(); it != pending_callbacks.end(); ++it)
|
||||
(*it)();
|
||||
for (auto const& thunk : pending_callbacks)
|
||||
thunk();
|
||||
pending_callbacks.clear();
|
||||
|
||||
applyButton->Enable(false);
|
||||
|
@ -653,8 +653,8 @@ void Preferences::OnResetDefault(wxCommandEvent&) {
|
|||
if (wxYES != wxMessageBox(_("Are you sure that you want to restore the defaults? All your settings will be overridden."), _("Restore defaults?"), wxYES_NO))
|
||||
return;
|
||||
|
||||
for (std::deque<std::string>::iterator it = option_names.begin(); it != option_names.end(); ++it) {
|
||||
agi::OptionValue *opt = OPT_SET(*it);
|
||||
for (auto const& opt_name : option_names) {
|
||||
agi::OptionValue *opt = OPT_SET(opt_name);
|
||||
if (!opt->IsDefault())
|
||||
opt->Reset();
|
||||
}
|
||||
|
@ -719,7 +719,6 @@ Preferences::Preferences(wxWindow *parent): wxDialog(parent, -1, _("Preferences"
|
|||
}
|
||||
|
||||
Preferences::~Preferences() {
|
||||
for (std::map<std::string, agi::OptionValue*>::iterator cur = pending_changes.begin(); cur != pending_changes.end(); ++cur) {
|
||||
delete cur->second;
|
||||
}
|
||||
for (auto& change : pending_changes)
|
||||
delete change.second;
|
||||
}
|
||||
|
|
|
@ -88,10 +88,10 @@ void ScintillaTextCtrl::GetBoundsOfWordAtPosition(int pos,int &start,int &end) {
|
|||
GetWordBoundaries(GetText(), results);
|
||||
|
||||
// Get boundaries
|
||||
for (size_t i = 0; i < results.size(); i++) {
|
||||
if (results[i].first <= pos && results[i].second >= pos) {
|
||||
start = results[i].first;
|
||||
end = results[i].second;
|
||||
for (auto const& result : results) {
|
||||
if (result.first <= pos && result.second >= pos) {
|
||||
start = result.first;
|
||||
end = result.second;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,14 +48,14 @@ agi::SpellChecker *SpellCheckerFactory::GetSpellChecker() {
|
|||
|
||||
// Get provider
|
||||
wxString error;
|
||||
for (unsigned int i=0;i<list.size();i++) {
|
||||
for (auto const& name : list) {
|
||||
try {
|
||||
agi::SpellChecker *checker = Create(list[i]);
|
||||
agi::SpellChecker *checker = Create(name);
|
||||
if (checker) return checker;
|
||||
}
|
||||
catch (wxString const& err) { error += list[i] + " factory: " + err + "\n"; }
|
||||
catch (const char *err) { error += list[i] + " factory: " + wxString(err) + "\n"; }
|
||||
catch (...) { error += list[i] + " factory: Unknown error\n"; }
|
||||
catch (wxString const& err) { error += name + " factory: " + err + "\n"; }
|
||||
catch (const char *err) { error += name + " factory: " + wxString(err) + "\n"; }
|
||||
catch (...) { error += name + " factory: Unknown error\n"; }
|
||||
}
|
||||
|
||||
throw error;
|
||||
|
|
|
@ -315,8 +315,8 @@ void SubsEditBox::PopulateList(wxComboBox *combo, wxString AssDialogue::*field)
|
|||
wxEventBlocker blocker(this);
|
||||
|
||||
std::set<wxString> values;
|
||||
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
||||
if (AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it))
|
||||
for (auto& line : c->ass->Line) {
|
||||
if (AssDialogue *diag = dynamic_cast<AssDialogue*>(&line))
|
||||
values.insert(diag->*field);
|
||||
}
|
||||
values.erase("");
|
||||
|
@ -412,9 +412,7 @@ void SubsEditBox::CommitText(wxString const& desc) {
|
|||
}
|
||||
|
||||
void SubsEditBox::CommitTimes(TimeField field) {
|
||||
for (SubtitleSelection::iterator cur = sel.begin(); cur != sel.end(); ++cur) {
|
||||
AssDialogue *d = *cur;
|
||||
|
||||
for (AssDialogue *d : sel) {
|
||||
if (!initialTimes.count(d))
|
||||
initialTimes[d] = std::make_pair(d->Start, d->End);
|
||||
|
||||
|
|
|
@ -281,11 +281,9 @@ void SubsTextEditCtrl::UpdateStyle() {
|
|||
AssDialogue *diag = context ? context->selectionController->GetActiveLine() : 0;
|
||||
bool template_line = diag && diag->Comment && diag->Effect.Lower().StartsWith("template");
|
||||
|
||||
std::vector<agi::ass::DialogueToken> tokens = agi::ass::TokenizeDialogueBody(text);
|
||||
std::vector<agi::ass::DialogueToken> style_ranges = agi::ass::SyntaxHighlight(text, tokens, template_line, spellchecker.get());
|
||||
for (size_t i = 0; i < style_ranges.size(); ++i) {
|
||||
SetStyling(style_ranges[i].length, style_ranges[i].type);
|
||||
}
|
||||
auto tokens = agi::ass::TokenizeDialogueBody(text);
|
||||
for (auto const& style_range : agi::ass::SyntaxHighlight(text, tokens, template_line, spellchecker.get()))
|
||||
SetStyling(style_range.length, style_range.type);
|
||||
}
|
||||
|
||||
/// @brief Update call tip
|
||||
|
@ -611,32 +609,32 @@ void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) {
|
|||
if (!thesaurus)
|
||||
thesaurus.reset(new Thesaurus);
|
||||
|
||||
std::vector<Thesaurus::Entry> result;
|
||||
thesaurus->Lookup(currentWord, &result);
|
||||
std::vector<Thesaurus::Entry> results;
|
||||
thesaurus->Lookup(currentWord, &results);
|
||||
|
||||
thesSugs.clear();
|
||||
|
||||
if (result.size()) {
|
||||
if (results.size()) {
|
||||
wxMenu *thesMenu = new wxMenu;
|
||||
|
||||
int curThesEntry = 0;
|
||||
for (size_t i = 0; i < result.size(); ++i) {
|
||||
for (auto const& result : results) {
|
||||
// Single word, insert directly
|
||||
if (result[i].second.size() == 1) {
|
||||
thesMenu->Append(EDIT_MENU_THESAURUS_SUGS+curThesEntry, lagi_wxString(result[i].first));
|
||||
thesSugs.push_back(result[i].first);
|
||||
if (result.second.size() == 1) {
|
||||
thesMenu->Append(EDIT_MENU_THESAURUS_SUGS+curThesEntry, lagi_wxString(result.first));
|
||||
thesSugs.push_back(result.first);
|
||||
++curThesEntry;
|
||||
}
|
||||
// Multiple, create submenu
|
||||
else {
|
||||
wxMenu *subMenu = new wxMenu;
|
||||
for (size_t j = 0; j < result[i].second.size(); ++j) {
|
||||
subMenu->Append(EDIT_MENU_THESAURUS_SUGS+curThesEntry, lagi_wxString(result[i].second[j]));
|
||||
thesSugs.push_back(result[i].second[j]);
|
||||
for (auto const& sug : result.second) {
|
||||
subMenu->Append(EDIT_MENU_THESAURUS_SUGS+curThesEntry, to_wx(sug));
|
||||
thesSugs.push_back(sug);
|
||||
++curThesEntry;
|
||||
}
|
||||
|
||||
thesMenu->Append(-1, lagi_wxString(result[i].first), subMenu);
|
||||
thesMenu->Append(-1, to_wx(result.first), subMenu);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,18 +79,18 @@ bool SubtitleFormat::CanWriteFile(wxString const& filename) const {
|
|||
|
||||
bool SubtitleFormat::CanSave(const AssFile *subs) const {
|
||||
AssStyle defstyle;
|
||||
for (constEntryIter cur = subs->Line.begin(); cur != subs->Line.end(); ++cur) {
|
||||
for (auto const& line : subs->Line) {
|
||||
// Check style, if anything non-default is found, return false
|
||||
if (const AssStyle *curstyle = dynamic_cast<const AssStyle*>(&*cur)) {
|
||||
if (const AssStyle *curstyle = dynamic_cast<const AssStyle*>(&line)) {
|
||||
if (curstyle->GetEntryData() != defstyle.GetEntryData())
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for attachments, if any is found, return false
|
||||
if (dynamic_cast<const AssAttachment*>(&*cur)) return false;
|
||||
if (dynamic_cast<const AssAttachment*>(&line)) return false;
|
||||
|
||||
// Check dialog
|
||||
if (const AssDialogue *curdiag = dynamic_cast<const AssDialogue*>(&*cur)) {
|
||||
if (const AssDialogue *curdiag = dynamic_cast<const AssDialogue*>(&line)) {
|
||||
if (curdiag->GetStrippedText() != curdiag->Text)
|
||||
return false;
|
||||
}
|
||||
|
@ -164,16 +164,16 @@ agi::vfr::Framerate SubtitleFormat::AskForFPS(bool allow_vfr, bool show_smpte) {
|
|||
}
|
||||
|
||||
void SubtitleFormat::StripTags(AssFile &file) {
|
||||
for (entryIter cur = file.Line.begin(); cur != file.Line.end(); ++cur) {
|
||||
if (AssDialogue *current = dynamic_cast<AssDialogue*>(&*cur)) {
|
||||
for (auto &line : file.Line) {
|
||||
if (AssDialogue *current = dynamic_cast<AssDialogue*>(&line)) {
|
||||
current->StripTags();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SubtitleFormat::ConvertNewlines(AssFile &file, wxString const& newline, bool mergeLineBreaks) {
|
||||
for (entryIter cur = file.Line.begin(); cur != file.Line.end(); ++cur) {
|
||||
if (AssDialogue *current = dynamic_cast<AssDialogue*>(&*cur)) {
|
||||
for (auto &line : file.Line) {
|
||||
if (AssDialogue *current = dynamic_cast<AssDialogue*>(&line)) {
|
||||
current->Text.Replace("\\h", " ");
|
||||
current->Text.Replace("\\n", newline);
|
||||
current->Text.Replace("\\N", newline);
|
||||
|
@ -321,13 +321,13 @@ void SubtitleFormat::LoadFormats() {
|
|||
}
|
||||
|
||||
void SubtitleFormat::DestroyFormats() {
|
||||
for (std::list<SubtitleFormat*>::iterator it = formats.begin(); it != formats.end(); )
|
||||
for (auto it = formats.begin(); it != formats.end(); )
|
||||
delete *it++;
|
||||
}
|
||||
|
||||
template<class Cont, class Pred>
|
||||
SubtitleFormat *find_or_throw(Cont &container, Pred pred) {
|
||||
typename Cont::iterator it = find_if(container.begin(), container.end(), pred);
|
||||
auto it = find_if(container.begin(), container.end(), pred);
|
||||
if (it == container.end())
|
||||
throw UnknownSubtitleFormatError("Subtitle format for extension not found", 0);
|
||||
return *it;
|
||||
|
@ -349,9 +349,7 @@ wxString SubtitleFormat::GetWildcards(int mode) {
|
|||
wxArrayString all;
|
||||
wxString final;
|
||||
|
||||
std::list<SubtitleFormat*>::iterator curIter;
|
||||
for (curIter=formats.begin();curIter!=formats.end();curIter++) {
|
||||
SubtitleFormat *format = *curIter;
|
||||
for (auto format : formats) {
|
||||
wxArrayString cur = mode == 0 ? format->GetReadWildcards() : format->GetWriteWildcards();
|
||||
if (cur.empty()) continue;
|
||||
|
||||
|
|
|
@ -92,13 +92,13 @@ void AssSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename,
|
|||
bool ssa = filename.Right(4).Lower() == ".ssa";
|
||||
|
||||
wxString group = src->Line.front().group;
|
||||
for (constEntryIter cur = src->Line.begin(); cur != src->Line.end(); ++cur) {
|
||||
for (auto const& line : src->Line) {
|
||||
// Add a blank line between each group
|
||||
if (cur->group != group) {
|
||||
if (line.group != group) {
|
||||
file.WriteLineToFile("");
|
||||
group = cur->group;
|
||||
group = line.group;
|
||||
}
|
||||
|
||||
file.WriteLineToFile(ssa ? cur->GetSSAText() : cur->GetEntryData(), true);
|
||||
file.WriteLineToFile(ssa ? line.GetSSAText() : line.GetEntryData(), true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,9 +123,8 @@ namespace
|
|||
{
|
||||
void ProcessOverrides(AssDialogueBlockOverride *ob, bool &underline, bool &italic, int &align, bool style_underline, bool style_italic)
|
||||
{
|
||||
for (std::vector<AssOverrideTag*>::iterator tag = ob->Tags.begin(); tag != ob->Tags.end(); ++tag)
|
||||
for (auto t : ob->Tags)
|
||||
{
|
||||
AssOverrideTag *t = *tag;
|
||||
if (t->Name == "\\u")
|
||||
underline = t->Params[0]->Get<bool>(style_underline);
|
||||
else if (t->Name == "\\i")
|
||||
|
@ -203,15 +202,15 @@ namespace
|
|||
std::vector<EbuTextRow> new_text;
|
||||
new_text.reserve(text_rows.size());
|
||||
|
||||
for (std::vector<EbuTextRow>::iterator row = text_rows.begin(); row != text_rows.end(); ++row)
|
||||
for (auto const& row : text_rows)
|
||||
{
|
||||
// Get lengths of each word
|
||||
std::vector<size_t> word_lengths;
|
||||
for (EbuTextRow::iterator cur_block = row->begin(); cur_block != row->end(); ++cur_block)
|
||||
for (auto const& cur_block : row)
|
||||
{
|
||||
if (cur_block->word_start)
|
||||
if (cur_block.word_start)
|
||||
word_lengths.push_back(0);
|
||||
word_lengths.back() += cur_block->text.size();
|
||||
word_lengths.back() += cur_block.text.size();
|
||||
}
|
||||
|
||||
std::vector<size_t> split_points = agi::get_wrap_points(word_lengths, (size_t)max_width, (agi::WrapMode)split_type);
|
||||
|
@ -219,7 +218,7 @@ namespace
|
|||
if (split_points.empty())
|
||||
{
|
||||
// Line doesn't need splitting, so copy straight over
|
||||
new_text.push_back(*row);
|
||||
new_text.push_back(row);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -227,9 +226,9 @@ namespace
|
|||
new_text.push_back(EbuTextRow());
|
||||
size_t cur_word = 0;
|
||||
size_t split_point = 0;
|
||||
for (EbuTextRow::iterator cur_block = row->begin(); cur_block != row->end(); ++cur_block)
|
||||
for (auto const& cur_block : row)
|
||||
{
|
||||
if (cur_block->word_start && split_point < split_points.size())
|
||||
if (cur_block.word_start && split_point < split_points.size())
|
||||
{
|
||||
if (split_points[split_point] == cur_word)
|
||||
{
|
||||
|
@ -239,7 +238,7 @@ namespace
|
|||
++cur_word;
|
||||
}
|
||||
|
||||
new_text.back().push_back(*cur_block);
|
||||
new_text.back().push_back(cur_block);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,11 +248,11 @@ namespace
|
|||
|
||||
bool CheckLineLengths(int max_width) const
|
||||
{
|
||||
for (std::vector<EbuTextRow>::const_iterator row = text_rows.begin(); row != text_rows.end(); ++row)
|
||||
for (auto const& row : text_rows)
|
||||
{
|
||||
int line_length = 0;
|
||||
for (EbuTextRow::const_iterator it = row->begin(); it != row->end(); ++it)
|
||||
line_length += it->text.size();
|
||||
for (auto const& block : row)
|
||||
line_length += block.text.size();
|
||||
|
||||
if (line_length > max_width)
|
||||
// early return as soon as any line is over length
|
||||
|
@ -281,9 +280,8 @@ namespace
|
|||
|
||||
bool underline = style_underline, italic = style_italic;
|
||||
|
||||
for (std::vector<AssDialogueBlock*>::iterator bl = line->Blocks.begin(); bl != line->Blocks.end(); ++bl)
|
||||
for (auto b : line->Blocks)
|
||||
{
|
||||
AssDialogueBlock *b = *bl;
|
||||
switch (b->GetType())
|
||||
{
|
||||
case BLOCK_PLAIN:
|
||||
|
@ -386,9 +384,9 @@ namespace
|
|||
subs_list.reserve(copy.Line.size());
|
||||
|
||||
// convert to intermediate format
|
||||
for (entryIter orgline = copy.Line.begin(); orgline != copy.Line.end(); ++orgline)
|
||||
for (auto& orgline : copy.Line)
|
||||
{
|
||||
AssDialogue *line = dynamic_cast<AssDialogue*>(&*orgline);
|
||||
AssDialogue *line = dynamic_cast<AssDialogue*>(&orgline);
|
||||
if (!line) continue;
|
||||
|
||||
// add a new subtitle and work on it
|
||||
|
@ -455,35 +453,33 @@ namespace
|
|||
return reinterpret_cast<const char *>(str.wx_str());
|
||||
}
|
||||
|
||||
std::string convert_subtitle_line(std::vector<EbuSubtitle>::const_iterator sub, agi::charset::IconvWrapper *encoder, bool enable_formatting)
|
||||
std::string convert_subtitle_line(EbuSubtitle const& sub, agi::charset::IconvWrapper *encoder, bool enable_formatting)
|
||||
{
|
||||
std::string fullstring;
|
||||
for (std::vector<EbuTextRow>::const_iterator row = sub->text_rows.begin(); row != sub->text_rows.end(); ++row)
|
||||
for (auto const& row : sub.text_rows)
|
||||
{
|
||||
if (!fullstring.empty())
|
||||
fullstring += EBU_FORMAT_LINEBREAK;
|
||||
|
||||
// formatting is reset at the start of every row, so keep track per row
|
||||
bool underline = false, italic = false;
|
||||
for (std::vector<EbuFormattedText>::const_iterator block = row->begin(); block != row->end(); ++block)
|
||||
for (auto const& block : row)
|
||||
{
|
||||
if (enable_formatting)
|
||||
{
|
||||
// insert codes for changed formatting
|
||||
if (underline != block->underline)
|
||||
fullstring += EBU_FORMAT_UNDERLINE[block->underline];
|
||||
if (italic != block->italic)
|
||||
fullstring += EBU_FORMAT_ITALIC[block->italic];
|
||||
if (underline != block.underline)
|
||||
fullstring += EBU_FORMAT_UNDERLINE[block.underline];
|
||||
if (italic != block.italic)
|
||||
fullstring += EBU_FORMAT_ITALIC[block.italic];
|
||||
|
||||
underline = block->underline;
|
||||
italic = block->italic;
|
||||
underline = block.underline;
|
||||
italic = block.italic;
|
||||
}
|
||||
|
||||
// convert text to specified encoding
|
||||
fullstring += encoder->Convert(std::string(wx_str(block->text), buffer_size(block->text)));
|
||||
fullstring += encoder->Convert(std::string(wx_str(block.text), buffer_size(block.text)));
|
||||
}
|
||||
|
||||
// check that this is not the last row
|
||||
if (row+1 != sub->text_rows.end())
|
||||
// insert linebreak for non-final lines
|
||||
fullstring += EBU_FORMAT_LINEBREAK;
|
||||
}
|
||||
return fullstring;
|
||||
}
|
||||
|
@ -515,33 +511,33 @@ namespace
|
|||
|
||||
std::vector<BlockTTI> tti;
|
||||
tti.reserve(subs_list.size());
|
||||
for (std::vector<EbuSubtitle>::const_iterator sub = subs_list.begin(); sub != subs_list.end(); ++sub)
|
||||
for (auto const& sub : subs_list)
|
||||
{
|
||||
std::string fullstring = convert_subtitle_line(sub, encoder.get(),
|
||||
export_settings.display_standard == EbuExportSettings::DSC_Open);
|
||||
|
||||
// construct a base block that can be copied and filled
|
||||
BlockTTI base;
|
||||
base.sgn = sub->group_number;
|
||||
base.sgn = sub.group_number;
|
||||
base.sn = Endian::MachineToLittle(subtitle_number++);
|
||||
base.ebn = 255;
|
||||
base.cf = sub->comment_flag;
|
||||
base.cf = sub.comment_flag;
|
||||
memset(base.tf, EBU_FORMAT_UNUSED_SPACE, sizeof(base.tf));
|
||||
smpte_at_frame(fps, sub->time_in, base.tci);
|
||||
smpte_at_frame(fps, sub->time_out, base.tco);
|
||||
base.cs = sub->cumulative_status;
|
||||
smpte_at_frame(fps, sub.time_in, base.tci);
|
||||
smpte_at_frame(fps, sub.time_out, base.tco);
|
||||
base.cs = sub.cumulative_status;
|
||||
|
||||
if (export_settings.translate_alignments)
|
||||
{
|
||||
// vertical position
|
||||
if (sub->vertical_position == EbuSubtitle::PositionTop)
|
||||
if (sub.vertical_position == EbuSubtitle::PositionTop)
|
||||
base.vp = min_row;
|
||||
else if (sub->vertical_position == EbuSubtitle::PositionMiddle)
|
||||
base.vp = std::min<uint8_t>(min_row, max_row / 2 - (max_row / 5 * sub->text_rows.size()));
|
||||
else //if (sub->vertical_position == EbuSubtitle::PositionBottom)
|
||||
else if (sub.vertical_position == EbuSubtitle::PositionMiddle)
|
||||
base.vp = std::min<uint8_t>(min_row, max_row / 2 - (max_row / 5 * sub.text_rows.size()));
|
||||
else //if (sub.vertical_position == EbuSubtitle::PositionBottom)
|
||||
base.vp = max_row - 1;
|
||||
|
||||
base.jc = sub->justification_code;
|
||||
base.jc = sub.justification_code;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -687,8 +683,6 @@ void Ebu3264SubtitleFormat::WriteFile(const AssFile *src, wxString const& filena
|
|||
// write file
|
||||
agi::io::Save f(STD_STR(filename), true);
|
||||
f.Get().write((const char *)&gsi, sizeof(gsi));
|
||||
for (std::vector<BlockTTI>::iterator block = tti.begin(); block != tti.end(); ++block)
|
||||
{
|
||||
f.Get().write((const char *)&*block, sizeof(*block));
|
||||
}
|
||||
for (auto const& block : tti)
|
||||
f.Get().write((const char *)&block, sizeof(block));
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ void EncoreSubtitleFormat::WriteFile(const AssFile *src, wxString const& filenam
|
|||
// Write lines
|
||||
int i = 0;
|
||||
TextFileWriter file(filename, "UTF-8");
|
||||
for (constEntryIter cur = copy.Line.begin(); cur != copy.Line.end(); ++cur) {
|
||||
if (const AssDialogue *current = dynamic_cast<const AssDialogue*>(&*cur)) {
|
||||
for (auto const& line : copy.Line) {
|
||||
if (const AssDialogue *current = dynamic_cast<const AssDialogue*>(&line)) {
|
||||
++i;
|
||||
file.WriteLineToFile(wxString::Format("%i %s %s %s", i, ft.ToSMPTE(current->Start), ft.ToSMPTE(current->End), current->Text));
|
||||
}
|
||||
|
|
|
@ -142,8 +142,8 @@ void MicroDVDSubtitleFormat::WriteFile(const AssFile *src, wxString const& filen
|
|||
}
|
||||
|
||||
// Write lines
|
||||
for (constEntryIter cur = copy.Line.begin(); cur != copy.Line.end(); ++cur) {
|
||||
if (const AssDialogue *current = dynamic_cast<const AssDialogue*>(&*cur)) {
|
||||
for (auto const& line : copy.Line) {
|
||||
if (const AssDialogue *current = dynamic_cast<const AssDialogue*>(&line)) {
|
||||
int start = fps.FrameAtTime(current->Start, agi::vfr::START);
|
||||
int end = fps.FrameAtTime(current->End, agi::vfr::END);
|
||||
|
||||
|
|
|
@ -509,8 +509,8 @@ void SRTSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename,
|
|||
|
||||
// Write lines
|
||||
int i=1;
|
||||
for (constEntryIter cur = copy.Line.begin(); cur != copy.Line.end(); ++cur) {
|
||||
if (const AssDialogue *current = dynamic_cast<const AssDialogue*>(&*cur)) {
|
||||
for (auto const& line : copy.Line) {
|
||||
if (const AssDialogue *current = dynamic_cast<const AssDialogue*>(&line)) {
|
||||
file.WriteLineToFile(wxString::Format("%d", i++));
|
||||
file.WriteLineToFile(WriteSRTTime(current->Start) + " --> " + WriteSRTTime(current->End));
|
||||
file.WriteLineToFile(ConvertTags(current));
|
||||
|
@ -523,26 +523,26 @@ bool SRTSubtitleFormat::CanSave(const AssFile *file) const {
|
|||
wxString supported_tags[] = { "\\b", "\\i", "\\s", "\\u" };
|
||||
|
||||
AssStyle defstyle;
|
||||
for (constEntryIter cur = file->Line.begin(); cur != file->Line.end(); ++cur) {
|
||||
for (auto const& line : file->Line) {
|
||||
// Check style, if anything non-default is found, return false
|
||||
if (const AssStyle *curstyle = dynamic_cast<const AssStyle*>(&*cur)) {
|
||||
if (const AssStyle *curstyle = dynamic_cast<const AssStyle*>(&line)) {
|
||||
if (curstyle->GetEntryData() != defstyle.GetEntryData())
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for attachments, if any is found, return false
|
||||
if (dynamic_cast<const AssAttachment*>(&*cur)) return false;
|
||||
if (dynamic_cast<const AssAttachment*>(&line)) return false;
|
||||
|
||||
// Check dialogue
|
||||
if (const AssDialogue *curdiag = dynamic_cast<const AssDialogue*>(&*cur)) {
|
||||
if (const AssDialogue *curdiag = dynamic_cast<const AssDialogue*>(&line)) {
|
||||
std::vector<AssDialogueBlock*> blocks = curdiag->ParseTags();
|
||||
for (size_t i = 0; i < blocks.size(); ++i) {
|
||||
AssDialogueBlockOverride *ovr = dynamic_cast<AssDialogueBlockOverride*>(blocks[i]);
|
||||
for (auto block : blocks) {
|
||||
AssDialogueBlockOverride *ovr = dynamic_cast<AssDialogueBlockOverride*>(block);
|
||||
if (!ovr) continue;
|
||||
|
||||
// Verify that all overrides used are supported
|
||||
for (size_t j = 0; j < ovr->Tags.size(); ++j) {
|
||||
if (!std::binary_search(supported_tags, supported_tags + 4, ovr->Tags[j]->Name)) {
|
||||
for (auto tag : ovr->Tags) {
|
||||
if (!std::binary_search(supported_tags, std::end(supported_tags), tag->Name)) {
|
||||
delete_clear(blocks);
|
||||
return false;
|
||||
}
|
||||
|
@ -565,13 +565,12 @@ wxString SRTSubtitleFormat::ConvertTags(const AssDialogue *diag) const {
|
|||
|
||||
std::vector<AssDialogueBlock *> blocks = diag->ParseTags();
|
||||
|
||||
for (size_t i = 0; i < blocks.size(); ++i) {
|
||||
if (AssDialogueBlockOverride* block = dynamic_cast<AssDialogueBlockOverride*>(blocks[i])) {
|
||||
for (auto block : blocks) {
|
||||
if (AssDialogueBlockOverride* ovr = dynamic_cast<AssDialogueBlockOverride*>(block)) {
|
||||
// Iterate through overrides
|
||||
for (size_t j = 0; j < block->Tags.size(); j++) {
|
||||
AssOverrideTag *tag = block->Tags[j];
|
||||
for (auto tag : ovr->Tags) {
|
||||
if (tag->IsValid() && tag->Name.size() == 2) {
|
||||
std::map<char, bool>::iterator it = tag_states.find(tag->Name[1]);
|
||||
auto it = tag_states.find(tag->Name[1]);
|
||||
if (it != tag_states.end()) {
|
||||
bool temp = tag->Params[0]->Get(false);
|
||||
if (temp && !it->second)
|
||||
|
@ -584,16 +583,16 @@ wxString SRTSubtitleFormat::ConvertTags(const AssDialogue *diag) const {
|
|||
}
|
||||
}
|
||||
// Plain text
|
||||
else if (AssDialogueBlockPlain *plain = dynamic_cast<AssDialogueBlockPlain*>(blocks[i])) {
|
||||
else if (AssDialogueBlockPlain *plain = dynamic_cast<AssDialogueBlockPlain*>(block)) {
|
||||
final += plain->GetText();
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure all tags are closed
|
||||
// Otherwise unclosed overrides might affect lines they shouldn't, see bug #809 for example
|
||||
for (std::map<char, bool>::iterator it = tag_states.begin(); it != tag_states.end(); ++it) {
|
||||
if (it->second)
|
||||
final += wxString::Format("</%c>", it->first);
|
||||
for (auto it : tag_states) {
|
||||
if (it.second)
|
||||
final += wxString::Format("</%c>", it.first);
|
||||
}
|
||||
|
||||
delete_clear(blocks);
|
||||
|
|
|
@ -75,8 +75,8 @@ void TranStationSubtitleFormat::WriteFile(const AssFile *src, wxString const& fi
|
|||
SmpteFormatter ft(fps);
|
||||
TextFileWriter file(filename, encoding);
|
||||
AssDialogue *prev = 0;
|
||||
for (entryIter it = copy.Line.begin(); it != copy.Line.end(); ++it) {
|
||||
AssDialogue *cur = dynamic_cast<AssDialogue*>(&*it);
|
||||
for (auto& line : copy.Line) {
|
||||
AssDialogue *cur = dynamic_cast<AssDialogue*>(&line);
|
||||
|
||||
if (prev && cur) {
|
||||
file.WriteLineToFile(ConvertLine(©, prev, fps, ft, cur->Start));
|
||||
|
|
|
@ -135,13 +135,13 @@ AssDialogue *TTXTSubtitleFormat::ProcessLine(wxXmlNode *node, AssDialogue *prev,
|
|||
finalText.reserve(text.size());
|
||||
bool in = false;
|
||||
bool first = true;
|
||||
for (size_t i = 0; i < text.size(); ++i) {
|
||||
if (text[i] == '\'') {
|
||||
for (auto chr : text) {
|
||||
if (chr == '\'') {
|
||||
if (!in && !first) finalText += "\\N";
|
||||
first = false;
|
||||
in = !in;
|
||||
}
|
||||
else if (in) finalText += text[i];
|
||||
else if (in) finalText += chr;
|
||||
}
|
||||
diag->Text = finalText;
|
||||
}
|
||||
|
@ -176,8 +176,8 @@ void TTXTSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename,
|
|||
|
||||
// Create lines
|
||||
const AssDialogue *prev = 0;
|
||||
for (constEntryIter cur = copy.Line.begin(); cur != copy.Line.end(); ++cur) {
|
||||
const AssDialogue *current = dynamic_cast<const AssDialogue*>(&*cur);
|
||||
for (auto const& line : copy.Line) {
|
||||
const AssDialogue *current = dynamic_cast<const AssDialogue*>(&line);
|
||||
if (current && !current->Comment) {
|
||||
WriteLine(root, prev, current);
|
||||
prev = current;
|
||||
|
|
|
@ -129,8 +129,8 @@ void TXTSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename,
|
|||
size_t num_actor_names = 0, num_dialogue_lines = 0;
|
||||
|
||||
// Detect number of lines with Actor field filled out
|
||||
for (constEntryIter l = src->Line.begin(); l != src->Line.end(); ++l) {
|
||||
const AssDialogue *dia = dynamic_cast<const AssDialogue*>(&*l);
|
||||
for (auto const& line : src->Line) {
|
||||
const AssDialogue *dia = dynamic_cast<const AssDialogue*>(&line);
|
||||
if (dia && !dia->Comment) {
|
||||
num_dialogue_lines++;
|
||||
if (!dia->Actor.empty())
|
||||
|
@ -146,8 +146,8 @@ void TXTSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename,
|
|||
file.WriteLineToFile(wxString("# Exported by Aegisub ") + GetAegisubShortVersionString());
|
||||
|
||||
// Write the file
|
||||
for (constEntryIter l = src->Line.begin(); l != src->Line.end(); ++l) {
|
||||
const AssDialogue *dia = dynamic_cast<const AssDialogue*>(&*l);
|
||||
for (auto const& line : src->Line) {
|
||||
const AssDialogue *dia = dynamic_cast<const AssDialogue*>(&line);
|
||||
if (!dia) continue;
|
||||
|
||||
wxString out_line;
|
||||
|
@ -161,10 +161,9 @@ void TXTSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename,
|
|||
wxString out_text;
|
||||
if (strip_formatting) {
|
||||
std::vector<AssDialogueBlock*> blocks = dia->ParseTags();
|
||||
for (std::vector<AssDialogueBlock*>::iterator block = blocks.begin(); block != blocks.end(); ++block) {
|
||||
if ((*block)->GetType() == BLOCK_PLAIN) {
|
||||
out_text += (*block)->GetText();
|
||||
}
|
||||
for (auto block : blocks) {
|
||||
if (block->GetType() == BLOCK_PLAIN)
|
||||
out_text += block->GetText();
|
||||
}
|
||||
delete_clear(blocks);
|
||||
}
|
||||
|
|
|
@ -46,34 +46,28 @@
|
|||
#include "include/aegisub/subtitles_provider.h"
|
||||
#endif
|
||||
|
||||
/// @brief Get provider
|
||||
/// @return
|
||||
///
|
||||
SubtitlesProvider* SubtitlesProviderFactory::GetProvider() {
|
||||
std::vector<std::string> list = GetClasses(OPT_GET("Subtitle/Provider")->GetString());
|
||||
if (list.empty()) throw wxString("No subtitle providers are available.");
|
||||
|
||||
// Get provider
|
||||
wxString error;
|
||||
for (unsigned int i=0;i<list.size();i++) {
|
||||
for (auto const& factory : list) {
|
||||
try {
|
||||
size_t pos = list[i].find('/');
|
||||
std::string subType = pos < list[i].size() - 1 ? list[i].substr(pos + 1) : "";
|
||||
SubtitlesProvider *provider = Create(list[i], subType);
|
||||
size_t pos = factory.find('/');
|
||||
std::string subType = pos < factory.size() - 1 ? factory.substr(pos + 1) : "";
|
||||
SubtitlesProvider *provider = Create(factory, subType);
|
||||
if (provider) return provider;
|
||||
}
|
||||
catch (agi::UserCancelException const&) { throw; }
|
||||
catch (wxString const& err) { error += list[i] + " factory: " + err + "\n"; }
|
||||
catch (const char *err) { error += list[i] + " factory: " + wxString(err) + "\n"; }
|
||||
catch (...) { error += list[i] + " factory: Unknown error\n"; }
|
||||
catch (wxString const& err) { error += factory + " factory: " + err + "\n"; }
|
||||
catch (const char *err) { error += factory + " factory: " + wxString(err) + "\n"; }
|
||||
catch (...) { error += factory + " factory: Unknown error\n"; }
|
||||
}
|
||||
|
||||
// Failed
|
||||
throw error;
|
||||
}
|
||||
|
||||
/// @brief Register providers
|
||||
///
|
||||
void SubtitlesProviderFactory::RegisterProviders() {
|
||||
#ifdef WITH_CSRI
|
||||
std::vector<std::string> csri_providers(CSRISubtitlesProvider::GetSubTypes());
|
||||
|
|
|
@ -75,8 +75,8 @@ std::vector<std::string> Thesaurus::GetLanguageList() const {
|
|||
dat.Sort();
|
||||
|
||||
// Drop extensions and the th_ prefix
|
||||
for (size_t i = 0; i < idx.size(); ++i) idx[i] = idx[i].Mid(3, idx[i].size() - 7);
|
||||
for (size_t i = 0; i < dat.size(); ++i) dat[i] = dat[i].Mid(3, dat[i].size() - 7);
|
||||
for (auto& fn : idx) fn = fn.Mid(3, fn.size() - 7);
|
||||
for (auto& fn : dat) fn = fn.Mid(3, fn.size() - 7);
|
||||
|
||||
// Verify that each idx has a dat
|
||||
for (size_t i = 0, j = 0; i < idx.size() && j < dat.size(); ) {
|
||||
|
|
|
@ -104,8 +104,8 @@ std::shared_ptr<AegiVideoFrame> ThreadedFrameSource::ProcFrame(int frameNum, dou
|
|||
// instead muck around with its innards to just temporarily
|
||||
// remove the non-visible lines without deleting them
|
||||
std::deque<AssEntry*> full;
|
||||
for (entryIter it = subs->Line.begin(); it != subs->Line.end(); ++it)
|
||||
full.push_back(&*it);
|
||||
for (auto& line : subs->Line)
|
||||
full.push_back(&line);
|
||||
subs->Line.remove_if(invisible_line(time));
|
||||
|
||||
try {
|
||||
|
|
|
@ -114,9 +114,7 @@ namespace {
|
|||
bool needs_onidle = false;
|
||||
bool last_was_sep = false;
|
||||
|
||||
for (json::Array::const_iterator it = arr.begin(); it != arr.end(); ++it) {
|
||||
json::String const& command_name = *it;
|
||||
|
||||
for (json::String const& command_name : arr) {
|
||||
if (command_name.empty()) {
|
||||
if (!last_was_sep)
|
||||
AddSeparator();
|
||||
|
|
|
@ -402,19 +402,19 @@ class cache_cleaner : public wxThread {
|
|||
}
|
||||
|
||||
int deleted = 0;
|
||||
for (std::multimap<int64_t,wxFileName>::iterator i = cachefiles.begin(); i != cachefiles.end(); i++) {
|
||||
for (auto const& i : cachefiles) {
|
||||
// stop cleaning?
|
||||
if ((total_size <= max_size && cachefiles.size() - deleted <= max_files) || cachefiles.size() - deleted < 2)
|
||||
break;
|
||||
|
||||
int64_t fsize = i->second.GetSize().GetValue();
|
||||
int64_t fsize = i.second.GetSize().GetValue();
|
||||
#ifdef __WXMSW__
|
||||
int res = wxRemove(i->second.GetFullPath());
|
||||
int res = wxRemove(i.second.GetFullPath());
|
||||
#else
|
||||
int res = unlink(i->second.GetFullPath().fn_str());
|
||||
int res = unlink(i.second.GetFullPath().fn_str());
|
||||
#endif
|
||||
if (res) {
|
||||
LOG_D("utils/clean_cache") << "failed to remove file " << STD_STR(i->second.GetFullPath());
|
||||
LOG_D("utils/clean_cache") << "failed to remove file " << STD_STR(i.second.GetFullPath());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -289,9 +289,7 @@ void VideoOutGL::UploadFrameData(const AegiVideoFrame& frame) {
|
|||
// Set the row length, needed to be able to upload partial rows
|
||||
CHECK_ERROR(glPixelStorei(GL_UNPACK_ROW_LENGTH, frame.pitch / frame.GetBpp()));
|
||||
|
||||
for (unsigned i = 0; i < textureList.size(); i++) {
|
||||
TextureInfo& ti = textureList[i];
|
||||
|
||||
for (auto& ti : textureList) {
|
||||
CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, ti.textureID));
|
||||
CHECK_ERROR(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ti.sourceW,
|
||||
ti.sourceH, format, GL_UNSIGNED_BYTE, frame.data + ti.dataOffset));
|
||||
|
|
|
@ -63,7 +63,7 @@ const AegiVideoFrame VideoProviderCache::GetFrame(int n) {
|
|||
size_t total_size = 0;
|
||||
|
||||
// See if frame is cached
|
||||
for (boost::container::list<CachedFrame>::iterator cur = cache.begin(); cur != cache.end(); ++cur) {
|
||||
for (auto cur = cache.begin(); cur != cache.end(); ++cur) {
|
||||
if (cur->frame_number == n) {
|
||||
cache.push_front(*cur);
|
||||
cache.erase(cur);
|
||||
|
|
|
@ -64,32 +64,32 @@ VideoProvider *VideoProviderFactory::GetProvider(wxString video) {
|
|||
bool fileSupported = false;
|
||||
std::string errors;
|
||||
errors.reserve(1024);
|
||||
for (int i = 0; i < (signed)list.size(); ++i) {
|
||||
for (auto const& factory : list) {
|
||||
std::string err;
|
||||
try {
|
||||
VideoProvider *provider = Create(list[i], video);
|
||||
LOG_I("manager/video/provider") << list[i] << ": opened " << STD_STR(video);
|
||||
VideoProvider *provider = Create(factory, video);
|
||||
LOG_I("manager/video/provider") << factory << ": opened " << STD_STR(video);
|
||||
if (provider->WantsCaching()) {
|
||||
return new VideoProviderCache(provider);
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
catch (agi::FileNotFoundError const&) {
|
||||
err = list[i] + ": file not found.";
|
||||
err = factory + ": file not found.";
|
||||
// Keep trying other providers as this one may just not be able to
|
||||
// open a valid path
|
||||
}
|
||||
catch (VideoNotSupported const&) {
|
||||
fileFound = true;
|
||||
err = list[i] + ": video is not in a supported format.";
|
||||
err = factory + ": video is not in a supported format.";
|
||||
}
|
||||
catch (VideoOpenError const& ex) {
|
||||
fileSupported = true;
|
||||
err = list[i] + ": " + ex.GetMessage();
|
||||
err = factory + ": " + ex.GetMessage();
|
||||
}
|
||||
catch (agi::vfr::Error const& ex) {
|
||||
fileSupported = true;
|
||||
err = list[i] + ": " + ex.GetMessage();
|
||||
err = factory + ": " + ex.GetMessage();
|
||||
}
|
||||
errors += err;
|
||||
errors += "\n";
|
||||
|
|
|
@ -204,8 +204,8 @@ void VideoSlider::OnPaint(wxPaintEvent &) {
|
|||
int curX;
|
||||
if (OPT_GET("Video/Slider/Show Keyframes")->GetBool()) {
|
||||
dc.SetPen(wxPen(shad));
|
||||
for (size_t i=0;i<keyframes.size();i++) {
|
||||
curX = GetXAtValue(keyframes[i]);
|
||||
for (int frame : keyframes) {
|
||||
curX = GetXAtValue(frame);
|
||||
dc.DrawLine(curX,2,curX,8);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -337,8 +337,8 @@ template<class FeatureType>
|
|||
void VisualTool<FeatureType>::RemoveSelection(feature_iterator feat) {
|
||||
if (!sel_features.erase(feat) || !feat->line) return;
|
||||
|
||||
for (selection_iterator it = sel_features.begin(); it != sel_features.end(); ++it) {
|
||||
if ((*it)->line == feat->line) return;
|
||||
for (auto sel : sel_features) {
|
||||
if (sel->line == feat->line) return;
|
||||
}
|
||||
|
||||
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
||||
|
@ -370,13 +370,13 @@ struct scoped_tag_parse {
|
|||
|
||||
// Find a tag's parameters in a line or return NULL if it's not found
|
||||
static param_vec find_tag(const AssDialogue *line, wxString tag_name) {
|
||||
for (size_t i = 0; i < line->Blocks.size(); ++i) {
|
||||
const AssDialogueBlockOverride *ovr = dynamic_cast<const AssDialogueBlockOverride*>(line->Blocks[i]);
|
||||
for (auto block : line->Blocks) {
|
||||
const AssDialogueBlockOverride *ovr = dynamic_cast<const AssDialogueBlockOverride*>(block);
|
||||
if (!ovr) continue;
|
||||
|
||||
for (size_t j = 0; j < ovr->Tags.size(); ++j) {
|
||||
if (ovr->Tags[j]->Name == tag_name)
|
||||
return &ovr->Tags[j]->Params;
|
||||
for (auto tag : ovr->Tags) {
|
||||
if (tag->Name == tag_name)
|
||||
return &tag->Params;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,12 +116,11 @@ void VisualToolClip::UpdateHold() {
|
|||
void VisualToolClip::CommitHold() {
|
||||
wxString value = wxString::Format("(%s,%s)", ToScriptCoords(cur_1.Min(cur_2)).Str(), ToScriptCoords(cur_1.Max(cur_2)).Str());
|
||||
|
||||
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
||||
for (SubtitleSelection::iterator it = sel.begin(); it != sel.end(); ++it) {
|
||||
for (auto line : c->selectionController->GetSelectedSet()) {
|
||||
// This check is technically not correct as it could be outside of an
|
||||
// override block... but that's rather unlikely
|
||||
bool has_iclip = (*it)->Text.find("\\iclip") != wxString::npos;
|
||||
SetOverride(*it, has_iclip ? "\\iclip" : "\\clip", value);
|
||||
bool has_iclip = line->Text.find("\\iclip") != wxString::npos;
|
||||
SetOverride(line, has_iclip ? "\\iclip" : "\\clip", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,21 +40,20 @@ VisualToolCross::~VisualToolCross() {
|
|||
void VisualToolCross::OnDoubleClick() {
|
||||
Vector2D d = ToScriptCoords(mouse_pos) - GetLinePosition(active_line);
|
||||
|
||||
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
||||
for (SubtitleSelection::const_iterator it = sel.begin(); it != sel.end(); ++it) {
|
||||
for (auto line : c->selectionController->GetSelectedSet()) {
|
||||
Vector2D p1, p2;
|
||||
int t1, t2;
|
||||
if (GetLineMove(*it, p1, p2, t1, t2)) {
|
||||
if (GetLineMove(line, p1, p2, t1, t2)) {
|
||||
if (t1 > 0 || t2 > 0)
|
||||
SetOverride(*it, "\\move", wxString::Format("(%s,%s,%d,%d)", Text(p1 + d), Text(p2 + d), t1, t2));
|
||||
SetOverride(line, "\\move", wxString::Format("(%s,%s,%d,%d)", Text(p1 + d), Text(p2 + d), t1, t2));
|
||||
else
|
||||
SetOverride(*it, "\\move", wxString::Format("(%s,%s)", Text(p1 + d), Text(p2 + d)));
|
||||
SetOverride(line, "\\move", wxString::Format("(%s,%s)", Text(p1 + d), Text(p2 + d)));
|
||||
}
|
||||
else
|
||||
SetOverride(*it, "\\pos", "(" + Text(GetLinePosition(*it) + d) + ")");
|
||||
SetOverride(line, "\\pos", "(" + Text(GetLinePosition(line) + d) + ")");
|
||||
|
||||
if (Vector2D org = GetLineOrigin(*it))
|
||||
SetOverride(*it, "\\org", "(" + Text(org + d) + ")");
|
||||
if (Vector2D org = GetLineOrigin(line))
|
||||
SetOverride(line, "\\org", "(" + Text(org + d) + ")");
|
||||
}
|
||||
|
||||
Commit(_("positioning"));
|
||||
|
|
|
@ -81,8 +81,7 @@ void VisualToolDrag::UpdateToggleButtons() {
|
|||
void VisualToolDrag::OnSubTool(wxCommandEvent &) {
|
||||
// Toggle \move <-> \pos
|
||||
VideoContext *vc = c->videoController;
|
||||
for (SubtitleSelection::const_iterator cur = selection.begin(); cur != selection.end(); ++cur) {
|
||||
AssDialogue *line = *cur;
|
||||
for (auto line : selection) {
|
||||
Vector2D p1, p2;
|
||||
int t1, t2;
|
||||
|
||||
|
@ -115,8 +114,8 @@ void VisualToolDrag::OnFileChanged() {
|
|||
primary = 0;
|
||||
active_feature = features.end();
|
||||
|
||||
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it);
|
||||
for (auto& line : c->ass->Line) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&line);
|
||||
if (diag && IsDisplayed(diag))
|
||||
MakeFeatures(diag);
|
||||
}
|
||||
|
@ -131,8 +130,8 @@ void VisualToolDrag::OnFrameChanged() {
|
|||
feature_iterator feat = features.begin();
|
||||
feature_iterator end = features.end();
|
||||
|
||||
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it);
|
||||
for (auto& line : c->ass->Line) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&line);
|
||||
if (!diag) continue;
|
||||
|
||||
if (IsDisplayed(diag)) {
|
||||
|
@ -282,9 +281,8 @@ bool VisualToolDrag::InitializeDrag(feature_iterator feature) {
|
|||
int time = c->videoController->TimeAtFrame(frame_number) - feature->line->Start;
|
||||
int change = time - feature->time;
|
||||
|
||||
for (sel_iterator cur = sel_features.begin(); cur != sel_features.end(); ++cur) {
|
||||
(*cur)->time += change;
|
||||
}
|
||||
for (auto feat : sel_features)
|
||||
feat->time += change;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -312,21 +310,20 @@ void VisualToolDrag::UpdateDrag(feature_iterator feature) {
|
|||
void VisualToolDrag::OnDoubleClick() {
|
||||
Vector2D d = ToScriptCoords(mouse_pos) - (primary ? ToScriptCoords(primary->pos) : GetLinePosition(active_line));
|
||||
|
||||
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
||||
for (SubtitleSelection::const_iterator it = sel.begin(); it != sel.end(); ++it) {
|
||||
for (auto line : c->selectionController->GetSelectedSet()) {
|
||||
Vector2D p1, p2;
|
||||
int t1, t2;
|
||||
if (GetLineMove(*it, p1, p2, t1, t2)) {
|
||||
if (GetLineMove(line, p1, p2, t1, t2)) {
|
||||
if (t1 > 0 || t2 > 0)
|
||||
SetOverride(*it, "\\move", wxString::Format("(%s,%s,%d,%d)", (p1 + d).Str(), (p2 + d).Str(), t1, t2));
|
||||
SetOverride(line, "\\move", wxString::Format("(%s,%s,%d,%d)", (p1 + d).Str(), (p2 + d).Str(), t1, t2));
|
||||
else
|
||||
SetOverride(*it, "\\move", wxString::Format("(%s,%s)", (p1 + d).Str(), (p2 + d).Str()));
|
||||
SetOverride(line, "\\move", wxString::Format("(%s,%s)", (p1 + d).Str(), (p2 + d).Str()));
|
||||
}
|
||||
else
|
||||
SetOverride(*it, "\\pos", (GetLinePosition(*it) + d).PStr());
|
||||
SetOverride(line, "\\pos", (GetLinePosition(line) + d).PStr());
|
||||
|
||||
if (Vector2D org = GetLineOrigin(*it))
|
||||
SetOverride(*it, "\\org", (org + d).PStr());
|
||||
if (Vector2D org = GetLineOrigin(line))
|
||||
SetOverride(line, "\\org", (org + d).PStr());
|
||||
}
|
||||
|
||||
Commit(_("positioning"));
|
||||
|
|
|
@ -133,10 +133,10 @@ void VisualToolVectorClip::Draw() {
|
|||
|
||||
// Draw lines connecting the bicubic features
|
||||
gl.SetLineColour(colour[3], 0.9f, 1);
|
||||
for (Spline::iterator cur = spline.begin(); cur != spline.end(); ++cur) {
|
||||
if (cur->type == SplineCurve::BICUBIC) {
|
||||
gl.DrawDashedLine(cur->p1, cur->p2, 6);
|
||||
gl.DrawDashedLine(cur->p3, cur->p4, 6);
|
||||
for (auto const& curve : spline) {
|
||||
if (curve.type == SplineCurve::BICUBIC) {
|
||||
gl.DrawDashedLine(curve.p1, curve.p2, 6);
|
||||
gl.DrawDashedLine(curve.p3, curve.p4, 6);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,12 +204,11 @@ void VisualToolVectorClip::Save() {
|
|||
value += wxString::Format("%d,", spline.GetScale());
|
||||
value += spline.EncodeToAss() + ")";
|
||||
|
||||
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
||||
for (SubtitleSelection::iterator it = sel.begin(); it != sel.end(); ++it) {
|
||||
for (auto line : c->selectionController->GetSelectedSet()) {
|
||||
// This check is technically not correct as it could be outside of an
|
||||
// override block... but that's rather unlikely
|
||||
bool has_iclip = (*it)->Text.find("\\iclip") != wxString::npos;
|
||||
SetOverride(*it, has_iclip ? "\\iclip" : "\\clip", value);
|
||||
bool has_iclip = line->Text.find("\\iclip") != wxString::npos;
|
||||
SetOverride(line, has_iclip ? "\\iclip" : "\\clip", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue