mirror of https://github.com/odrling/Aegisub
Use auto more places
This commit is contained in:
parent
0d50820178
commit
6cd6ee9845
|
@ -78,9 +78,8 @@ void AudioMarkerProviderKeyframes::Update() {
|
||||||
|
|
||||||
void AudioMarkerProviderKeyframes::GetMarkers(TimeRange const& range, AudioMarkerVector &out) const {
|
void AudioMarkerProviderKeyframes::GetMarkers(TimeRange const& range, AudioMarkerVector &out) const {
|
||||||
// Find first and last keyframes inside the range
|
// Find first and last keyframes inside the range
|
||||||
std::vector<AudioMarkerKeyframe>::const_iterator
|
auto a = lower_bound(markers.begin(), markers.end(), range.begin());
|
||||||
a = lower_bound(markers.begin(), markers.end(), range.begin()),
|
auto b = upper_bound(markers.begin(), markers.end(), range.end());
|
||||||
b = upper_bound(markers.begin(), markers.end(), range.end());
|
|
||||||
|
|
||||||
// Place pointers to the markers in the output vector
|
// Place pointers to the markers in the output vector
|
||||||
for (; a != b; ++a)
|
for (; a != b; ++a)
|
||||||
|
|
|
@ -224,7 +224,7 @@ struct time_snap_scene : public validate_video_loaded {
|
||||||
int prev = 0;
|
int prev = 0;
|
||||||
int next = 0;
|
int next = 0;
|
||||||
|
|
||||||
const std::vector<int> &keyframes = con->GetKeyFrames();
|
auto const& keyframes = con->GetKeyFrames();
|
||||||
if (curFrame < keyframes.front())
|
if (curFrame < keyframes.front())
|
||||||
next = keyframes.front();
|
next = keyframes.front();
|
||||||
else if (curFrame >= keyframes.back()) {
|
else if (curFrame >= keyframes.back()) {
|
||||||
|
@ -232,7 +232,7 @@ struct time_snap_scene : public validate_video_loaded {
|
||||||
next = con->GetLength();
|
next = con->GetLength();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::vector<int>::const_iterator kf = std::lower_bound(keyframes.begin(), keyframes.end(), curFrame);
|
auto kf = std::lower_bound(keyframes.begin(), keyframes.end(), curFrame);
|
||||||
if (*kf == curFrame) {
|
if (*kf == curFrame) {
|
||||||
prev = *kf;
|
prev = *kf;
|
||||||
next = *(kf + 1);
|
next = *(kf + 1);
|
||||||
|
|
|
@ -360,8 +360,8 @@ struct video_frame_next_keyframe : public validator_video_loaded {
|
||||||
STR_HELP("Seek to the next keyframe")
|
STR_HELP("Seek to the next keyframe")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
std::vector<int> const& kf = c->videoController->GetKeyFrames();
|
auto const& kf = c->videoController->GetKeyFrames();
|
||||||
std::vector<int>::const_iterator pos = lower_bound(kf.begin(), kf.end(), c->videoController->GetFrameN() + 1);
|
auto pos = lower_bound(kf.begin(), kf.end(), c->videoController->GetFrameN() + 1);
|
||||||
|
|
||||||
c->videoController->JumpToFrame(pos == kf.end() ? c->videoController->GetLength() - 1 : *pos);
|
c->videoController->JumpToFrame(pos == kf.end() ? c->videoController->GetLength() - 1 : *pos);
|
||||||
}
|
}
|
||||||
|
@ -431,14 +431,13 @@ struct video_frame_prev_keyframe : public validator_video_loaded {
|
||||||
STR_HELP("Seek to the previous keyframe")
|
STR_HELP("Seek to the previous keyframe")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
std::vector<int> const& kf = c->videoController->GetKeyFrames();
|
auto const& kf = c->videoController->GetKeyFrames();
|
||||||
if (kf.empty()) {
|
if (kf.empty()) {
|
||||||
c->videoController->JumpToFrame(0);
|
c->videoController->JumpToFrame(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int>::const_iterator pos =
|
auto pos = lower_bound(kf.begin(), kf.end(), c->videoController->GetFrameN());
|
||||||
lower_bound(kf.begin(), kf.end(), c->videoController->GetFrameN());
|
|
||||||
|
|
||||||
if (pos != kf.begin())
|
if (pos != kf.begin())
|
||||||
--pos;
|
--pos;
|
||||||
|
|
|
@ -102,8 +102,8 @@ public:
|
||||||
/// @return A pointer to a DialogType or nullptr if no dialog of the given type has been created
|
/// @return A pointer to a DialogType or nullptr if no dialog of the given type has been created
|
||||||
template<class DialogType>
|
template<class DialogType>
|
||||||
DialogType *Get() const {
|
DialogType *Get() const {
|
||||||
DialogMap::const_iterator it = created_dialogs.find(&typeid(DialogType));
|
auto it = created_dialogs.find(&typeid(DialogType));
|
||||||
return it != created_dialogs.end() ? static_cast<DialogType*>(it->second) : 0;
|
return it != created_dialogs.end() ? static_cast<DialogType*>(it->second) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
~DialogManager() {
|
~DialogManager() {
|
||||||
|
|
|
@ -81,7 +81,7 @@ static wxString get_history_string(json::Object &obj) {
|
||||||
lines = wxString::Format(_("from %d onward"), (int)(int64_t)sel.front()["start"]);
|
lines = wxString::Format(_("from %d onward"), (int)(int64_t)sel.front()["start"]);
|
||||||
else {
|
else {
|
||||||
lines += _("sel ");
|
lines += _("sel ");
|
||||||
for (json::Array::const_iterator it = sel.begin(); it != sel.end(); ++it) {
|
for (auto it = sel.begin(); it != sel.end(); ++it) {
|
||||||
int beg = (int64_t)(*it)["start"];
|
int beg = (int64_t)(*it)["start"];
|
||||||
int end = (int64_t)(*it)["end"];
|
int end = (int64_t)(*it)["end"];
|
||||||
if (beg == end)
|
if (beg == end)
|
||||||
|
|
|
@ -110,7 +110,7 @@ void FontCollector::ProcessDialogueLine(const AssDialogue *line, int index) {
|
||||||
if (overriden)
|
if (overriden)
|
||||||
used_styles[style].lines.insert(index);
|
used_styles[style].lines.insert(index);
|
||||||
std::set<wxUniChar>& chars = used_styles[style].chars;
|
std::set<wxUniChar>& chars = used_styles[style].chars;
|
||||||
for (wxString::const_iterator it = text.begin(); it != text.end(); ++it) {
|
for (auto it = text.begin(); it != text.end(); ++it) {
|
||||||
wxUniChar cur = *it;
|
wxUniChar cur = *it;
|
||||||
if (cur == L'\\' && it + 1 != text.end()) {
|
if (cur == L'\\' && it + 1 != text.end()) {
|
||||||
wxUniChar next = *++it;
|
wxUniChar next = *++it;
|
||||||
|
|
|
@ -279,7 +279,7 @@ struct CommandMenuBar : public wxMenuBar {
|
||||||
/// @param[out] value Output value to write to
|
/// @param[out] value Output value to write to
|
||||||
/// @return Was the requested index found
|
/// @return Was the requested index found
|
||||||
bool read_entry(json::Object const& obj, const char *name, std::string *value) {
|
bool read_entry(json::Object const& obj, const char *name, std::string *value) {
|
||||||
json::Object::const_iterator it = obj.find(name);
|
auto it = obj.find(name);
|
||||||
if (it == obj.end()) return false;
|
if (it == obj.end()) return false;
|
||||||
*value = static_cast<json::String const&>(it->second);
|
*value = static_cast<json::String const&>(it->second);
|
||||||
return true;
|
return true;
|
||||||
|
@ -313,7 +313,7 @@ menu_map const& get_menus_root() {
|
||||||
menu_items const& get_menu(std::string const& name) {
|
menu_items const& get_menu(std::string const& name) {
|
||||||
menu_map const& root = get_menus_root();
|
menu_map const& root = get_menus_root();
|
||||||
|
|
||||||
menu_map::const_iterator it = root.find(name);
|
auto it = root.find(name);
|
||||||
if (it == root.end()) throw menu::UnknownMenu("Menu named " + name + " not found");
|
if (it == root.end()) throw menu::UnknownMenu("Menu named " + name + " not found");
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,14 +69,14 @@ std::string Spline::EncodeToAss() const {
|
||||||
result.reserve(size() * 10);
|
result.reserve(size() * 10);
|
||||||
char last = 0;
|
char last = 0;
|
||||||
|
|
||||||
for (const_iterator cur = begin(); cur != end(); ++cur) {
|
for (auto const& pt : *this) {
|
||||||
switch (cur->type) {
|
switch (pt.type) {
|
||||||
case SplineCurve::POINT:
|
case SplineCurve::POINT:
|
||||||
if (last != 'm') {
|
if (last != 'm') {
|
||||||
result += "m ";
|
result += "m ";
|
||||||
last = 'm';
|
last = 'm';
|
||||||
}
|
}
|
||||||
result += ToScript(cur->p1).DStr(' ');
|
result += ToScript(pt.p1).DStr(' ');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SplineCurve::LINE:
|
case SplineCurve::LINE:
|
||||||
|
@ -84,7 +84,7 @@ std::string Spline::EncodeToAss() const {
|
||||||
result += "l ";
|
result += "l ";
|
||||||
last = 'l';
|
last = 'l';
|
||||||
}
|
}
|
||||||
result += ToScript(cur->p2).DStr(' ');
|
result += ToScript(pt.p2).DStr(' ');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SplineCurve::BICUBIC:
|
case SplineCurve::BICUBIC:
|
||||||
|
@ -92,9 +92,9 @@ std::string Spline::EncodeToAss() const {
|
||||||
result += "b ";
|
result += "b ";
|
||||||
last = 'b';
|
last = 'b';
|
||||||
}
|
}
|
||||||
result += ToScript(cur->p2).DStr(' ') + " ";
|
result += ToScript(pt.p2).DStr(' ') + " ";
|
||||||
result += ToScript(cur->p3).DStr(' ') + " ";
|
result += ToScript(pt.p3).DStr(' ') + " ";
|
||||||
result += ToScript(cur->p4).DStr(' ');
|
result += ToScript(pt.p4).DStr(' ');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace {
|
||||||
/// Populate the toolbar with buttons
|
/// Populate the toolbar with buttons
|
||||||
void Populate() {
|
void Populate() {
|
||||||
json::Object const& root = get_root();
|
json::Object const& root = get_root();
|
||||||
json::Object::const_iterator root_it = root.find(name);
|
auto root_it = root.find(name);
|
||||||
if (root_it == root.end()) {
|
if (root_it == root.end()) {
|
||||||
// Toolbar names are all hardcoded so this should never happen
|
// Toolbar names are all hardcoded so this should never happen
|
||||||
throw agi::InternalError("Toolbar named " + name + " not found.", 0);
|
throw agi::InternalError("Toolbar named " + name + " not found.", 0);
|
||||||
|
|
|
@ -127,7 +127,7 @@ void VideoSlider::OnMouse(wxMouseEvent &event) {
|
||||||
// Shift click to snap to keyframe
|
// Shift click to snap to keyframe
|
||||||
if (event.ShiftDown() && keyframes.size()) {
|
if (event.ShiftDown() && keyframes.size()) {
|
||||||
int clickedFrame = GetValueAtX(x);
|
int clickedFrame = GetValueAtX(x);
|
||||||
std::vector<int>::const_iterator pos = lower_bound(keyframes.begin(), keyframes.end(), clickedFrame);
|
auto pos = lower_bound(keyframes.begin(), keyframes.end(), clickedFrame);
|
||||||
if (pos == keyframes.end())
|
if (pos == keyframes.end())
|
||||||
--pos;
|
--pos;
|
||||||
else if (pos + 1 != keyframes.end() && clickedFrame - *pos > (*pos + 1) - clickedFrame)
|
else if (pos + 1 != keyframes.end() && clickedFrame - *pos > (*pos + 1) - clickedFrame)
|
||||||
|
|
Loading…
Reference in New Issue