independent panning for external sends
[ardour.git] / gtk2_ardour / send_ui.cc
1 /*
2     Copyright (C) 2002 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 <gtkmm2ext/doi.h>
21
22 #include "ardour/io.h"
23 #include "ardour/send.h"
24 #include "ardour/rc_configuration.h"
25
26 #include "utils.h"
27 #include "send_ui.h"
28 #include "io_selector.h"
29 #include "ardour_ui.h"
30 #include "gui_thread.h"
31
32 #include "i18n.h"
33
34 using namespace std;
35 using namespace ARDOUR;
36 using namespace PBD;
37
38 SendUI::SendUI (Gtk::Window* parent, boost::shared_ptr<Send> s, Session* session)
39         : _send (s)
40         , _gpm (session, 250)
41         , _panners (session)
42 {
43         assert (_send);
44
45         _panners.set_panner (s->panner_shell(), s->panner());
46         _gpm.set_controls (boost::shared_ptr<Route>(), s->meter(), s->amp());
47
48         _hbox.pack_start (_gpm, true, true);
49         set_name (X_("SendUIFrame"));
50
51         _vbox.set_spacing (5);
52         _vbox.set_border_width (5);
53
54         _vbox.pack_start (_hbox, false, false, false);
55         _vbox.pack_start (_panners, false, false);
56
57         io = manage (new IOSelector (parent, session, s->output()));
58
59         pack_start (_vbox, false, false);
60
61         pack_start (*io, true, true);
62
63         io->show ();
64         _gpm.show_all ();
65         _panners.show_all ();
66         _vbox.show ();
67         _hbox.show ();
68
69         _send->set_metering (true);
70
71         _send->output()->changed.connect (connections, invalidator (*this), boost::bind (&SendUI::outs_changed, this, _1, _2), gui_context());
72
73         _panners.set_width (Wide);
74         _panners.setup_pan ();
75
76         _gpm.setup_meters ();
77         _gpm.set_fader_name (X_("SendUIFader"));
78
79         // screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (
80         //              sigc::mem_fun (*this, &SendUI::update));
81         fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
82                         sigc::mem_fun (*this, &SendUI::fast_update));
83 }
84
85 SendUI::~SendUI ()
86 {
87         _send->set_metering (false);
88
89         /* XXX not clear that we need to do this */
90
91         screen_update_connection.disconnect();
92         fast_screen_update_connection.disconnect();
93 }
94
95 void
96 SendUI::outs_changed (IOChange change, void* /*ignored*/)
97 {
98         ENSURE_GUI_THREAD (*this, &SendUI::outs_changed, change, ignored)
99         if (change.type & IOChange::ConfigurationChanged) {
100                 _panners.setup_pan ();
101                 _gpm.setup_meters ();
102         }
103 }
104
105 void
106 SendUI::update ()
107 {
108 }
109
110 void
111 SendUI::fast_update ()
112 {
113         if (!is_mapped()) {
114                 return;
115         }
116
117         if (Config->get_meter_falloff() > 0.0f) {
118                 _gpm.update_meters ();
119         }
120 }
121
122 SendUIWindow::SendUIWindow (boost::shared_ptr<Send> s, Session* session)
123         : ArdourWindow (string (_("Send ")) + s->name())
124 {
125         ui = new SendUI (this, s, session);
126
127         hpacker.pack_start (*ui, true, true);
128
129         add (hpacker);
130
131         set_name ("SendUIWindow");
132
133         ui->show ();
134         hpacker.show ();
135
136         s->DropReferences.connect (going_away_connection, invalidator (*this), boost::bind (&SendUIWindow::send_going_away, this), gui_context());
137 }
138
139 SendUIWindow::~SendUIWindow ()
140 {
141         delete ui;
142 }
143
144 void
145 SendUIWindow::send_going_away ()
146 {
147         ENSURE_GUI_THREAD (*this, &SendUIWindow::send_going_away)
148         going_away_connection.disconnect ();
149         delete_when_idle (this);
150 }
151