Initial import of gtk2_ardour.
[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 <gtkmmext/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
32 SendUI::SendUI (Send& s, Session& se)
33         : _send (s),
34           _session (se),
35           gpm (s, se),
36           panners (s, se)
37 {
38         hbox.pack_start (gpm, true, true);
39         set_name ("SendUIFrame");
40         
41         vbox.set_spacing (5);
42         vbox.set_border_width (5);
43
44         vbox.pack_start (hbox, false, false, false);
45         vbox.pack_start (panners, false,false);
46
47         io = new IOSelector (se, s, false);
48         
49         pack_start (vbox, false, false);
50
51         pack_start (*io, true, true);
52
53         show_all ();
54
55         _send.set_metering (true);
56
57         _send.output_changed.connect (slot (*this, &SendUI::ins_changed));
58         _send.output_changed.connect (slot (*this, &SendUI::outs_changed));
59         
60         panners.set_width (Wide);
61         panners.setup_pan ();
62
63         gpm.setup_meters ();
64         gpm.set_fader_name ("SendUIFrame");
65
66         screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (slot (*this, &SendUI::update));
67         fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (slot (*this, &SendUI::fast_update));
68 }
69
70 SendUI::~SendUI ()
71 {
72         _send.set_metering (false);
73         
74         /* XXX not clear that we need to do this */
75
76         screen_update_connection.disconnect();
77         fast_screen_update_connection.disconnect();
78 }
79
80 void
81 SendUI::ins_changed (IOChange change, void* ignored)
82 {
83         ENSURE_GUI_THREAD(bind (slot (*this, &SendUI::ins_changed), change, ignored));
84         if (change & ConfigurationChanged) {
85                 panners.setup_pan ();
86         }
87 }
88
89 void
90 SendUI::outs_changed (IOChange change, void* ignored)
91 {
92         ENSURE_GUI_THREAD(bind (slot (*this, &SendUI::outs_changed), change, ignored));
93         if (change & ConfigurationChanged) {
94                 panners.setup_pan ();
95                 gpm.setup_meters ();
96         }
97 }
98
99 void
100 SendUI::send_going_away (Redirect *ignored)
101 {
102         ENSURE_GUI_THREAD (bind (slot (*this, &SendUI::send_going_away), ignored));
103
104         delete this;
105 }
106
107 void
108 SendUI::update ()
109 {
110         gpm.update_meters ();
111 }
112
113 void
114 SendUI::fast_update ()
115 {
116         if (_session.meter_falloff() > 0.0f) {
117                 gpm.update_meters_falloff ();
118         }
119 }
120         
121 SendUIWindow::SendUIWindow (Send& s, Session& ss)
122 {
123         ui = new SendUI (s, ss);
124
125         vpacker.set_border_width (5);
126
127         hpacker.pack_start (*ui, true, true);
128
129         vpacker.pack_start (hpacker);
130
131         add (vpacker);
132         set_name ("SendUIWindow");
133
134         s.GoingAway.connect (slot (*this, &SendUIWindow::send_going_away));
135
136         delete_event.connect (bind (slot (just_hide_it), reinterpret_cast<Window *> (this)));
137
138 }
139
140 SendUIWindow::~SendUIWindow ()
141 {
142         delete ui;
143 }
144
145 void
146 SendUIWindow::send_going_away (Redirect *ignored)
147 {
148         ENSURE_GUI_THREAD(bind (slot (*this, &SendUIWindow::send_going_away), ignored));
149         
150         delete this;
151 }
152