summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-12-10 01:08:56 +0100
committerCarl Hetherington <cth@carlh.net>2022-12-10 01:16:06 +0100
commit02b74112721d13a27b0bbaece714d5c8ea743d43 (patch)
tree3a27196ba8c53b603e0d3369593858e471a071f8 /src/wx
parent11afb1f4bb9c8dd2e366ed216dd324d197d18b9a (diff)
Move some methods out of util.{cc,h}
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/gain_calculator_dialog.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/wx/gain_calculator_dialog.cc b/src/wx/gain_calculator_dialog.cc
index 9c8b87dac..62708fd22 100644
--- a/src/wx/gain_calculator_dialog.cc
+++ b/src/wx/gain_calculator_dialog.cc
@@ -20,11 +20,12 @@
#include "gain_calculator_dialog.h"
#include "wx_util.h"
-#include "lib/util.h"
#include "lib/cinema_sound_processor.h"
+
using boost::optional;
+
GainCalculatorDialog::GainCalculatorDialog (wxWindow* parent)
: TableDialog (parent, _("Gain Calculator"), 2, 1, true)
{
@@ -50,9 +51,19 @@ optional<float>
GainCalculatorDialog::db_change () const
{
if (_wanted->GetValue().IsEmpty() || _actual->GetValue().IsEmpty()) {
- return optional<float>();
+ return {};
}
+ auto relaxed_string_to_float = [](std::string s) {
+ try {
+ boost::algorithm::replace_all(s, ",", ".");
+ return boost::lexical_cast<float>(s);
+ } catch (boost::bad_lexical_cast &) {
+ boost::algorithm::replace_all(s, ".", ",");
+ return boost::lexical_cast<float>(s);
+ }
+ };
+
return CinemaSoundProcessor::from_index(
_processor->GetSelection())->db_for_fader_change(
relaxed_string_to_float(wx_to_std(_wanted->GetValue())),