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