diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-06-09 23:56:33 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-06-09 23:56:33 +0100 |
| commit | 93c996b302589dee7d43d990f3650d636345a545 (patch) | |
| tree | 976732dc7774b8b4ae5a3f2490bc4a6259d2892b /src | |
| parent | 7e690d21278df14b113f3602cbbd43f6214fd614 (diff) | |
Use a SpinCtrlDouble for audio gain, and change its representation
from float to double.
Requested-by: Mattias Mattsson
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/audio_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/audio_content.h | 6 | ||||
| -rw-r--r-- | src/wx/audio_panel.cc | 6 | ||||
| -rw-r--r-- | src/wx/audio_panel.h | 4 | ||||
| -rw-r--r-- | src/wx/content_widget.h | 24 | ||||
| -rw-r--r-- | src/wx/wx_util.cc | 15 | ||||
| -rw-r--r-- | src/wx/wx_util.h | 3 |
7 files changed, 52 insertions, 8 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index bf00b672a..29d159a29 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -98,7 +98,7 @@ AudioContent::as_xml (xmlpp::Node* node) const void -AudioContent::set_audio_gain (float g) +AudioContent::set_audio_gain (double g) { { boost::mutex::scoped_lock lm (_mutex); diff --git a/src/lib/audio_content.h b/src/lib/audio_content.h index 2a1216d86..2c324a3a4 100644 --- a/src/lib/audio_content.h +++ b/src/lib/audio_content.h @@ -62,10 +62,10 @@ public: 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; } @@ -77,7 +77,7 @@ public: 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; }; diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc index 1c679d336..72cb9fe6a 100644 --- a/src/wx/audio_panel.cc +++ b/src/wx/audio_panel.cc @@ -50,9 +50,9 @@ AudioPanel::AudioPanel (FilmEditor* e) ++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) @@ -88,6 +88,8 @@ AudioPanel::AudioPanel (FilmEditor* e) _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)); diff --git a/src/wx/audio_panel.h b/src/wx/audio_panel.h index f1b932e7c..2ba5a9ffc 100644 --- a/src/wx/audio_panel.h +++ b/src/wx/audio_panel.h @@ -21,7 +21,7 @@ #include "film_editor_panel.h" #include "content_widget.h" -class wxSpinCtrl; +class wxSpinCtrlDouble; class wxButton; class wxChoice; class wxStaticText; @@ -44,7 +44,7 @@ private: void mapping_changed (AudioMapping); void setup_stream_description (); - ContentSpinCtrl<AudioContent>* _gain; + ContentSpinCtrlDouble<AudioContent>* _gain; wxButton* _gain_calculate_button; wxButton* _show; ContentSpinCtrl<AudioContent>* _delay; diff --git a/src/wx/content_widget.h b/src/wx/content_widget.h index 30501c1a9..ca9485006 100644 --- a/src/wx/content_widget.h +++ b/src/wx/content_widget.h @@ -222,6 +222,30 @@ public: } }; +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> { diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 96278b82b..b73cd490d 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -190,6 +190,15 @@ checked_set (wxSpinCtrl* widget, int value) } 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) { if (widget->GetSelection() != value) { @@ -297,6 +306,12 @@ wx_get (wxChoice* w) return w->GetSelection (); } +double +wx_get (wxSpinCtrlDouble* w) +{ + return w->GetValue (); +} + void run_gui_loop () { diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index 56ed500f6..12a7115d5 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -31,6 +31,7 @@ class wxFilePickerCtrl; class wxSpinCtrl; +class wxSpinCtrlDouble; class wxGridBagSizer; #define DCPOMATIC_SIZER_X_GAP 8 @@ -86,6 +87,7 @@ extern std::string string_client_data (wxClientData* o); 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); @@ -95,6 +97,7 @@ extern void checked_set (wxStaticText* 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. |
