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