ardour
mono_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 "pbd/controllable.h"
25 #include "mono_panner_editor.h"
26 #include "mono_panner.h"
27 #include "i18n.h"
28 
29 using namespace Gtk;
30 using namespace Gtkmm2ext;
31 
33  : PannerEditor (_("Mono Panner"))
34  , _panner (p)
35  , _ignore_changes (false)
36 {
37  Table* t = manage (new Table (2, 3));
38  t->set_spacings (6);
39 
40  int n = 0;
41 
42  t->attach (*manage (left_aligned_label (_("Left"))), 0, 1, n, n + 1);
43  t->attach (_left, 1, 2, n, n + 1);
44  t->attach (*manage (left_aligned_label (_("%"))), 2, 3, n, n + 1);
45  ++n;
46 
47  t->attach (*manage (left_aligned_label (_("Right"))), 0, 1, n, n + 1);
48  t->attach (_right, 1, 2, n, n + 1);
49  t->attach (*manage (left_aligned_label (_("%"))), 2, 3, n, n + 1);
50  ++n;
51 
52  get_vbox()->pack_start (*manage (t));
53  get_vbox()->set_spacing (6);
54 
55  _left.set_increments (1, 10);
56  _left.set_range (0, 100);
57  _right.set_increments (1, 10);
58  _right.set_range (0, 100);
59 
62  _left.signal_value_changed().connect (sigc::mem_fun (*this, &MonoPannerEditor::left_changed));
63  _right.signal_value_changed().connect (sigc::mem_fun (*this, &MonoPannerEditor::right_changed));
64 
65  show_all ();
66  update_editor ();
67 }
68 
69 void
71 {
72  _panner = 0;
73 }
74 
75 void
77 {
78  if (!_panner) {
79  return;
80  }
81 
82  float const v = _panner->get_controllable()->get_value();
83 
84  _ignore_changes = true;
85  _left.set_value (100 * (1 - v));
86  _right.set_value (100 * v);
87  _ignore_changes = false;
88 }
89 
90 void
92 {
93  if (_ignore_changes || !_panner) {
94  return;
95  }
96 
97  float const v = 1 - _left.get_value () / 100;
98 
99  _ignore_changes = true;
100  _right.set_value (100 * v);
102  _ignore_changes = false;
103 }
104 
105 void
107 {
108  if (_ignore_changes || !_panner) {
109  return;
110  }
111 
112  float const v = _right.get_value () / 100;
113 
114  _ignore_changes = true;
115  _left.set_value (100 * (1 - v));
117  _ignore_changes = false;
118 }
119 
PBD::Signal0< void > DropReferences
Definition: destructible.h:34
PBD::ScopedConnectionList _connections
Definition: ardour_ui.h:130
Gtk::SpinButton _right
#define invalidator(x)
Definition: gui_thread.h:40
#define _(Text)
Definition: i18n.h:11
MonoPanner * _panner
MonoPannerEditor(MonoPanner *)
#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
boost::shared_ptr< PBD::Controllable > get_controllable() const
Definition: mono_panner.h:45
virtual void set_value(double)=0
Gtk::SpinButton _left
PBD::Signal0< void > Changed
Definition: controllable.h:94