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