2 Copyright (C) 2012 Paul Davis
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.
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.
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.
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"
30 using namespace Gtkmm2ext;
32 MonoPannerEditor::MonoPannerEditor (MonoPanner* p)
33 : PannerEditor (_("Mono Panner"))
35 , _ignore_changes (false)
37 Table* t = manage (new Table (2, 3));
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);
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);
52 get_vbox()->pack_start (*manage (t));
53 get_vbox()->set_spacing (6);
55 _left.set_increments (1, 10);
56 _left.set_range (0, 100);
57 _right.set_increments (1, 10);
58 _right.set_range (0, 100);
60 _panner->get_controllable()->Changed.connect (_connections, invalidator (*this), boost::bind (&MonoPannerEditor::update_editor, this), gui_context ());
61 _panner->DropReferences.connect (_connections, invalidator (*this), boost::bind (&MonoPannerEditor::panner_going_away, this), gui_context ());
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));
70 MonoPannerEditor::panner_going_away ()
76 MonoPannerEditor::update_editor ()
82 float const v = _panner->get_controllable()->get_value();
84 _ignore_changes = true;
85 _left.set_value (100 * (1 - v));
86 _right.set_value (100 * v);
87 _ignore_changes = false;
91 MonoPannerEditor::left_changed ()
93 if (_ignore_changes || !_panner) {
97 float const v = 1 - _left.get_value () / 100;
99 _ignore_changes = true;
100 _right.set_value (100 * v);
101 _panner->get_controllable()->set_value (v);
102 _ignore_changes = false;
106 MonoPannerEditor::right_changed ()
108 if (_ignore_changes || !_panner) {
112 float const v = _right.get_value () / 100;
114 _ignore_changes = true;
115 _left.set_value (100 * (1 - v));
116 _panner->get_controllable()->set_value (v);
117 _ignore_changes = false;