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