from float to double.
Requested-by: Mattias Mattsson
2014-06-09 Carl Hetherington <cth@carlh.net>
+ * Make audio gain a floating-point value in the UI (#367).
+
* Work-around out-of-memory crashes with large start trims (#252).
* Version 1.69.24 released.
void
-AudioContent::set_audio_gain (float g)
+AudioContent::set_audio_gain (double g)
{
{
boost::mutex::scoped_lock lm (_mutex);
boost::signals2::connection analyse_audio (boost::function<void()>);
- void set_audio_gain (float);
+ void set_audio_gain (double);
void set_audio_delay (int);
- float audio_gain () const {
+ double audio_gain () const {
boost::mutex::scoped_lock lm (_mutex);
return _audio_gain;
}
private:
/** Gain to apply to audio in dB */
- float _audio_gain;
+ double _audio_gain;
/** Delay to apply to audio (positive moves audio later) in milliseconds */
int _audio_delay;
};
++r;
add_label_to_grid_bag_sizer (grid, this, _("Audio Gain"), true, wxGBPosition (r, 0));
- _gain = new ContentSpinCtrl<AudioContent> (
+ _gain = new ContentSpinCtrlDouble<AudioContent> (
this,
- new wxSpinCtrl (this),
+ new wxSpinCtrlDouble (this),
AudioContentProperty::AUDIO_GAIN,
boost::mem_fn (&AudioContent::audio_gain),
boost::mem_fn (&AudioContent::set_audio_gain)
_sizer->Add (_mapping, 1, wxEXPAND | wxALL, 6);
_gain->wrapped()->SetRange (-60, 60);
+ _gain->wrapped()->SetDigits (1);
+ _gain->wrapped()->SetIncrement (0.5);
_delay->wrapped()->SetRange (-1000, 1000);
_stream->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&AudioPanel::stream_changed, this));
#include "film_editor_panel.h"
#include "content_widget.h"
-class wxSpinCtrl;
+class wxSpinCtrlDouble;
class wxButton;
class wxChoice;
class wxStaticText;
void mapping_changed (AudioMapping);
void setup_stream_description ();
- ContentSpinCtrl<AudioContent>* _gain;
+ ContentSpinCtrlDouble<AudioContent>* _gain;
wxButton* _gain_calculate_button;
wxButton* _show;
ContentSpinCtrl<AudioContent>* _delay;
}
};
+template <class S>
+class ContentSpinCtrlDouble : public ContentWidget<S, wxSpinCtrlDouble, double, double>
+{
+public:
+ ContentSpinCtrlDouble (
+ wxWindow* parent,
+ wxSpinCtrlDouble* wrapped,
+ int property,
+ boost::function<double (S*)> getter,
+ boost::function<void (S*, double)> setter
+ )
+ : ContentWidget<S, wxSpinCtrlDouble, double, double> (
+ parent,
+ wrapped,
+ property,
+ getter, setter,
+ &caster<double, double>,
+ &caster<double, double>
+ )
+ {
+ wrapped->Bind (wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, boost::bind (&ContentWidget<S, wxSpinCtrlDouble, double, double>::view_changed, this));
+ }
+};
+
template <class S, class U>
class ContentChoice : public ContentWidget<S, wxChoice, U, int>
{
}
}
+void
+checked_set (wxSpinCtrlDouble* widget, double value)
+{
+ /* XXX: completely arbitrary epsilon */
+ if (fabs (widget->GetValue() - value) < 1e-16) {
+ widget->SetValue (value);
+ }
+}
+
void
checked_set (wxChoice* widget, int value)
{
return w->GetSelection ();
}
+double
+wx_get (wxSpinCtrlDouble* w)
+{
+ return w->GetValue ();
+}
+
void
run_gui_loop ()
{
class wxFilePickerCtrl;
class wxSpinCtrl;
+class wxSpinCtrlDouble;
class wxGridBagSizer;
#define DCPOMATIC_SIZER_X_GAP 8
extern void checked_set (wxFilePickerCtrl* widget, std::string value);
extern void checked_set (wxSpinCtrl* widget, int value);
+extern void checked_set (wxSpinCtrlDouble* widget, double value);
extern void checked_set (wxChoice* widget, int value);
extern void checked_set (wxChoice* widget, std::string value);
extern void checked_set (wxTextCtrl* widget, std::string value);
extern int wx_get (wxChoice* widget);
extern int wx_get (wxSpinCtrl* widget);
+extern double wx_get (wxSpinCtrlDouble* widget);
/* GTK 2.24.17 has a buggy GtkFileChooserButton and it was put in Ubuntu 13.04.
This also seems to apply to 2.24.20 in Ubuntu 13.10 and 2.24.23 in Ubuntu 14.04.