remove the apparently unnecessary "ui_bind()" macro from entire source base
[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/amp.h"
23 #include "ardour/io.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 ("SendUIFrame");
51
52         _vbox.set_spacing (5);
53         _vbox.set_border_width (5);
54
55         _vbox.pack_start (_hbox, false, false, false);
56         // until sends have their own Pannable, don't show this
57         // because it controls the Route Pannable which confuses
58         // users (among others)
59         // _vbox.pack_start (_panners, false, false);
60
61         io = manage (new IOSelector (parent, session, s->output()));
62
63         pack_start (_vbox, false, false);
64
65         pack_start (*io, true, true);
66
67         io->show ();
68         _gpm.show_all ();
69         _panners.show_all ();
70         _vbox.show ();
71         _hbox.show ();
72
73         _send->set_metering (true);
74
75         _send->output()->changed.connect (connections, invalidator (*this), boost::bind (&SendUI::outs_changed, this, _1, _2), gui_context());
76
77         _panners.set_width (Wide);
78         _panners.setup_pan ();
79
80         _gpm.setup_meters ();
81         _gpm.set_fader_name ("SendUIFrame");
82
83         // screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (
84         //              sigc::mem_fun (*this, &SendUI::update));
85         fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
86                         sigc::mem_fun (*this, &SendUI::fast_update));
87 }
88
89 SendUI::~SendUI ()
90 {
91         _send->set_metering (false);
92
93         /* XXX not clear that we need to do this */
94
95         screen_update_connection.disconnect();
96         fast_screen_update_connection.disconnect();
97 }
98
99 void
100 SendUI::outs_changed (IOChange change, void* /*ignored*/)
101 {
102         ENSURE_GUI_THREAD (*this, &SendUI::outs_changed, change, ignored)
103         if (change.type & IOChange::ConfigurationChanged) {
104                 _panners.setup_pan ();
105                 _gpm.setup_meters ();
106         }
107 }
108
109 void
110 SendUI::update ()
111 {
112 }
113
114 void
115 SendUI::fast_update ()
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         signal_delete_event().connect (sigc::bind (
139                                                sigc::ptr_fun (just_hide_it),
140                                                reinterpret_cast<Window *> (this)));
141 }
142
143 SendUIWindow::~SendUIWindow ()
144 {
145         delete ui;
146 }
147
148 void
149 SendUIWindow::send_going_away ()
150 {
151         ENSURE_GUI_THREAD (*this, &SendUIWindow::send_going_away)
152         going_away_connection.disconnect ();
153         delete_when_idle (this);
154 }
155