From 6694baf3f0e6b3791cbe903558ffbef101be81ae Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 8 Oct 2013 07:19:56 -0700 Subject: [PATCH] Allow using , as the separator in time edit controls --- aegisub/src/ass_time.cpp | 4 ++-- aegisub/src/timeedit_ctrl.cpp | 22 +++++----------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/aegisub/src/ass_time.cpp b/aegisub/src/ass_time.cpp index 801df240b..88328a39f 100644 --- a/aegisub/src/ass_time.cpp +++ b/aegisub/src/ass_time.cpp @@ -40,12 +40,12 @@ AssTime::AssTime(std::string const& text) { int after_decimal = -1; int current = 0; - for (char c : text | boost::adaptors::filtered(boost::is_any_of(":0123456789."))) { + for (char c : text | boost::adaptors::filtered(boost::is_any_of(",.0123456789:"))) { if (c == ':') { time = time * 60 + current; current = 0; } - else if (c == '.') { + else if (c == '.' || c == ',') { time = (time * 60 + current) * 1000; current = 0; after_decimal = 100; diff --git a/aegisub/src/timeedit_ctrl.cpp b/aegisub/src/timeedit_ctrl.cpp index 271615184..8d92a2707 100644 --- a/aegisub/src/timeedit_ctrl.cpp +++ b/aegisub/src/timeedit_ctrl.cpp @@ -67,20 +67,8 @@ TimeEdit::TimeEdit(wxWindow* parent, wxWindowID id, agi::Context *c, const std:: { // Set validator wxTextValidator val(wxFILTER_INCLUDE_CHAR_LIST); - wxArrayString includes; - includes.Add("0"); - includes.Add("1"); - includes.Add("2"); - includes.Add("3"); - includes.Add("4"); - includes.Add("5"); - includes.Add("6"); - includes.Add("7"); - includes.Add("8"); - includes.Add("9"); - includes.Add("."); - includes.Add(":"); - val.SetIncludes(includes); + wxString includes[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", ".", ":", ","}; + val.SetIncludes(wxArrayString(countof(includes), includes)); SetValidator(val); // Other stuff @@ -162,7 +150,7 @@ void TimeEdit::OnKeyDown(wxKeyEvent &event) { event.Skip(); if (byFrame) return; if (insert) return; - if ((key < '0' || key > '9') && key != WXK_BACK && key != WXK_DELETE && key != ';' && key != '.') return; + if ((key < '0' || key > '9') && key != WXK_BACK && key != WXK_DELETE && key != ';' && key != '.' && key != ',') return; event.Skip(false); @@ -182,11 +170,11 @@ void TimeEdit::OnKeyDown(wxKeyEvent &event) { if (start >= (long)text.size()) return; // If the cursor is at punctuation, move it forward to the next digit - if (text[start] == ':' || text[start] == '.') + if (text[start] == ':' || text[start] == '.' || text[start] == ',') ++start; // : and . hop over punctuation but never insert anything - if (key == ';' || key == '.') { + if (key == ';' || key == '.' || key == ',') { SetInsertionPoint(start); return; }