Make processor box send faders adjust their size correctly.
[ardour.git] / gtk2_ardour / return_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/return.h"
25 #include "ardour/rc_configuration.h"
26
27 #include "utils.h"
28 #include "return_ui.h"
29 #include "io_selector.h"
30 #include "ardour_ui.h"
31 #include "gui_thread.h"
32
33 using namespace std;
34 using namespace ARDOUR;
35 using namespace PBD;
36
37 ReturnUI::ReturnUI (Gtk::Window* parent, boost::shared_ptr<Return> r, Session& se)
38         : _return (r)
39         , _session (se)
40         , _gpm (se, 250)
41 {
42         _gpm.set_controls (boost::shared_ptr<Route>(), r->meter(), r->amp());
43
44         _hbox.pack_start (_gpm, true, true);
45         set_name ("ReturnUIFrame");
46
47         _vbox.set_spacing (5);
48         _vbox.set_border_width (5);
49
50         _vbox.pack_start (_hbox, false, false, false);
51
52         io = manage (new IOSelector (parent, se, r->output()));
53
54         pack_start (_vbox, false, false);
55
56         pack_start (*io, true, true);
57
58         show_all ();
59
60         _return->set_metering (true);
61         _return->input()->changed.connect (mem_fun (*this, &ReturnUI::ins_changed));
62
63         _gpm.setup_meters ();
64         _gpm.set_fader_name ("ReturnUIFrame");
65
66         // screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (mem_fun (*this, &ReturnUI::update));
67         fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (mem_fun (*this, &ReturnUI::fast_update));
68 }
69
70 ReturnUI::~ReturnUI ()
71 {
72         _return->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 ReturnUI::ins_changed (IOChange change, void* ignored)
82 {
83         ENSURE_GUI_THREAD(bind (mem_fun (*this, &ReturnUI::ins_changed), change, ignored));
84         if (change & ConfigurationChanged) {
85                 _gpm.setup_meters ();
86         }
87 }
88
89 void
90 ReturnUI::update ()
91 {
92 }
93
94 void
95 ReturnUI::fast_update ()
96 {
97         if (Config->get_meter_falloff() > 0.0f) {
98                 _gpm.update_meters ();
99         }
100 }
101
102 ReturnUIWindow::ReturnUIWindow (boost::shared_ptr<Return> s, Session& ss)
103         : ArdourDialog (string("Ardour: return ") + s->name())
104 {
105         ui = new ReturnUI (this, s, ss);
106
107         hpacker.pack_start (*ui, true, true);
108
109         get_vbox()->set_border_width (5);
110         get_vbox()->pack_start (hpacker);
111
112         set_name ("ReturnUIWindow");
113
114         going_away_connection = s->GoingAway.connect (mem_fun (*this, &ReturnUIWindow::return_going_away));
115         signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window *> (this)));
116 }
117
118 ReturnUIWindow::~ReturnUIWindow ()
119 {
120         delete ui;
121 }
122
123 void
124 ReturnUIWindow::return_going_away ()
125 {
126         ENSURE_GUI_THREAD (mem_fun (*this, &ReturnUIWindow::return_going_away));
127         delete_when_idle (this);
128         going_away_connection.disconnect ();
129 }
130