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