Clean up and comment PortMatrix event handling a bit.
[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 using namespace std;
34 using namespace ARDOUR;
35 using namespace PBD;
36
37 SendUI::SendUI (Gtk::Window* parent, boost::shared_ptr<Send> s, Session& se)
38         : _send (s)
39         , _session (se)
40         , _gpm (se, 250)
41         , _panners (se)
42 {
43         _panners.set_panner (s->panner());
44         _gpm.set_controls (boost::shared_ptr<Route>(), s->meter(), s->amp());
45
46         _hbox.pack_start (_gpm, true, true);
47         set_name ("SendUIFrame");
48
49         _vbox.set_spacing (5);
50         _vbox.set_border_width (5);
51
52         _vbox.pack_start (_hbox, false, false, false);
53         _vbox.pack_start (_panners, false, false);
54
55         io = manage (new IOSelector (parent, &se, s->output()));
56
57         pack_start (_vbox, false, false);
58
59         pack_start (*io, true, true);
60
61         show_all ();
62
63         _send->set_metering (true);
64
65         _send->input()->changed.connect (mem_fun (*this, &SendUI::ins_changed));
66         _send->output()->changed.connect (mem_fun (*this, &SendUI::outs_changed));
67
68         _panners.set_width (Wide);
69         _panners.setup_pan ();
70
71         _gpm.setup_meters ();
72         _gpm.set_fader_name ("SendUIFrame");
73
74         // screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (
75         //              mem_fun (*this, &SendUI::update));
76         fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
77                         mem_fun (*this, &SendUI::fast_update));
78 }
79
80 SendUI::~SendUI ()
81 {
82         _send->set_metering (false);
83
84         /* XXX not clear that we need to do this */
85
86         screen_update_connection.disconnect();
87         fast_screen_update_connection.disconnect();
88 }
89
90 void
91 SendUI::ins_changed (IOChange change, void* ignored)
92 {
93         ENSURE_GUI_THREAD(bind (mem_fun (*this, &SendUI::ins_changed), change, ignored));
94         if (change & ConfigurationChanged) {
95                 _panners.setup_pan ();
96         }
97 }
98
99 void
100 SendUI::outs_changed (IOChange change, void* ignored)
101 {
102         ENSURE_GUI_THREAD(bind (mem_fun (*this, &SendUI::outs_changed), change, ignored));
103         if (change & 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& ss)
123         : ArdourDialog (string("Ardour: send ") + s->name())
124 {
125         ui = new SendUI (this, s, ss);
126
127         hpacker.pack_start (*ui, true, true);
128
129         get_vbox()->set_border_width (5);
130         get_vbox()->pack_start (hpacker);
131
132         set_name ("SendUIWindow");
133
134         going_away_connection = s->GoingAway.connect (
135                         mem_fun (*this, &SendUIWindow::send_going_away));
136
137         signal_delete_event().connect (bind (
138                                                sigc::ptr_fun (just_hide_it),
139                                                reinterpret_cast<Window *> (this)));
140 }
141
142 SendUIWindow::~SendUIWindow ()
143 {
144         delete ui;
145 }
146
147 void
148 SendUIWindow::send_going_away ()
149 {
150         ENSURE_GUI_THREAD (mem_fun (*this, &SendUIWindow::send_going_away));
151         delete_when_idle (this);
152         going_away_connection.disconnect ();
153 }
154