ardour
stereo_panner_editor.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #include <gtkmm.h>
21 #include "gtkmm2ext/utils.h"
22 #include "gtkmm2ext/gtk_ui.h"
23 #include "gtkmm2ext/gui_thread.h"
24 #include "ardour/panner.h"
25 #include "pbd/controllable.h"
26 #include "stereo_panner_editor.h"
27 #include "stereo_panner.h"
28 #include "i18n.h"
29 
30 using namespace std;
31 using namespace Gtk;
32 using namespace Gtkmm2ext;
33 
35  : PannerEditor (_("Stereo Panner"))
36  , _panner (p)
37  , _ignore_changes (false)
38 {
39  Table* t = manage (new Table (2, 3));
40  t->set_spacings (6);
41 
42  int n = 0;
43 
44  t->attach (*manage (left_aligned_label (_("Position"))), 0, 1, n, n + 1);
45  t->attach (_position, 1, 2, n, n + 1);
46  t->attach (*manage (left_aligned_label (_("%"))), 2, 3, n, n + 1);
47  ++n;
48 
49  t->attach (*manage (left_aligned_label (_("Width"))), 0, 1, n, n + 1);
50  t->attach (_width, 1, 2, n, n + 1);
51  t->attach (*manage (left_aligned_label (_("%"))), 2, 3, n, n + 1);
52  ++n;
53 
54  get_vbox()->pack_start (*manage (t));
55  get_vbox()->set_spacing (6);
56 
57  _position.set_increments (1, 10);
58  _width.set_increments (1, 10);
60  set_width_range ();
61 
64  );
65 
68  );
69 
71  _position.signal_value_changed().connect (sigc::mem_fun (*this, &StereoPannerEditor::position_changed));
72  _width.signal_value_changed().connect (sigc::mem_fun (*this, &StereoPannerEditor::width_changed));
73 
74  show_all ();
75  update_editor ();
76 }
77 
78 void
80 {
81  _panner = 0;
82 }
83 
84 void
86 {
87  if (!_panner) {
88  return;
89  }
90 
91  _ignore_changes = true;
92  _position.set_value (100 * _panner->get_position_controllable()->get_value ());
93  _width.set_value (100 * _panner->get_width_controllable()->get_value ());
94  _ignore_changes = false;
95 }
96 
97 void
99 {
100  if (_ignore_changes || !_panner) {
101  return;
102  }
103 
104  _ignore_changes = true;
105  double const v = _position.get_value() / 100;
107  set_width_range ();
108  _ignore_changes = false;
109 }
110 
111 void
113 {
114  if (_ignore_changes || !_panner) {
115  return;
116  }
117 
118  _ignore_changes = true;
119  double const v = _width.get_value() / 100;
122  _ignore_changes = false;
123 }
124 
125 void
127 {
128  pair<double, double> const pr = _panner->panner()->position_range ();
129  _position.set_range (pr.first * 100, pr.second * 100);
130 }
131 
132 void
134 {
135  pair<double, double> const wr = _panner->panner()->width_range ();
136  _width.set_range (wr.first * 100, wr.second * 100);
137 }
138 
Gtk::SpinButton _width
PBD::Signal0< void > DropReferences
Definition: destructible.h:34
PBD::ScopedConnectionList _connections
Definition: ardour_ui.h:130
Definition: Beats.hpp:239
boost::shared_ptr< ARDOUR::Panner > panner()
#define invalidator(x)
Definition: gui_thread.h:40
#define _(Text)
Definition: i18n.h:11
StereoPannerEditor(StereoPanner *)
boost::shared_ptr< PBD::Controllable > get_position_controllable() const
Definition: stereo_panner.h:45
#define gui_context()
Definition: gui_thread.h:36
LIBGTKMM2EXT_API Gtk::Label * left_aligned_label(std::string const &)
virtual double get_value(void) const =0
Gtk::SpinButton _position
virtual std::pair< double, double > width_range() const
Definition: panner.h:88
virtual void set_value(double)=0
PBD::Signal0< void > Changed
Definition: controllable.h:94
boost::shared_ptr< PBD::Controllable > get_width_controllable() const
Definition: stereo_panner.h:46
virtual std::pair< double, double > position_range() const
Definition: panner.h:87