Remove a (no longer needed) source file from our MSVC project (evoral)
[ardour.git] / gtk2_ardour / send_ui.cc
1 /*
2  * Copyright (C) 2005-2016 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
4  * Copyright (C) 2007-2012 David Robillard <d@drobilla.net>
5  * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
6  * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #include <gtkmm2ext/doi.h>
24
25 #include "ardour/io.h"
26 #include "ardour/panner_manager.h"
27 #include "ardour/send.h"
28 #include "ardour/rc_configuration.h"
29
30 #include "send_ui.h"
31 #include "io_selector.h"
32 #include "timers.h"
33 #include "gui_thread.h"
34
35 #include "pbd/i18n.h"
36
37 using namespace std;
38 using namespace ARDOUR;
39 using namespace PBD;
40
41 SendUI::SendUI (Gtk::Window* parent, boost::shared_ptr<Send> s, Session* session)
42         : _send (s)
43         , _gpm (session, 250)
44         , _panners (session)
45 {
46         assert (_send);
47
48         _vbox.pack_start (_hbox, false, false, false);
49         _vbox.pack_start (_panners, false, false);
50
51         io = Gtk::manage (new IOSelector (parent, session, s->output()));
52
53         pack_start (_vbox, false, false);
54
55         pack_start (*io, true, true);
56
57         io->show ();
58         _gpm.show_all ();
59         _panners.show_all ();
60         _vbox.show ();
61         _hbox.show ();
62
63         _send->set_metering (true);
64
65         _send->output()->changed.connect (connections, invalidator (*this), boost::bind (&SendUI::outs_changed, this, _1, _2), gui_context());
66
67         uint32_t const in = _send->pans_required();
68         uint32_t const out = _send->pan_outs();
69
70         _panners.set_width (Wide);
71         _panners.set_available_panners(PannerManager::instance().PannerManager::get_available_panners(in, out));
72         _panners.setup_pan ();
73
74         _gpm.setup_meters ();
75         _gpm.set_fader_name (X_("SendUIFader"));
76
77         // screen_update_connection = Timers::rapid_connect (
78         //              sigc::mem_fun (*this, &SendUI::update));
79         fast_screen_update_connection = Timers::super_rapid_connect (
80                         sigc::mem_fun (*this, &SendUI::fast_update));
81 }
82
83 SendUI::~SendUI ()
84 {
85         _send->set_metering (false);
86
87         /* XXX not clear that we need to do this */
88
89         screen_update_connection.disconnect();
90         fast_screen_update_connection.disconnect();
91 }
92
93 void
94 SendUI::outs_changed (IOChange change, void* /*ignored*/)
95 {
96         ENSURE_GUI_THREAD (*this, &SendUI::outs_changed, change, ignored)
97         if (change.type & IOChange::ConfigurationChanged) {
98                 uint32_t const in = _send->pans_required();
99                 uint32_t const out = _send->pan_outs();
100                 if (_panners._panner == 0) {
101                         _panners.set_panner (_send->panner_shell(), _send->panner());
102                 }
103                 _panners.set_available_panners(PannerManager::instance().PannerManager::get_available_panners(in, out));
104                 _panners.setup_pan ();
105                 _panners.show_all ();
106                 _gpm.setup_meters ();
107         }
108 }
109
110 void
111 SendUI::update ()
112 {
113 }
114
115 void
116 SendUI::fast_update ()
117 {
118         if (!is_mapped()) {
119                 return;
120         }
121
122         if (Config->get_meter_falloff() > 0.0f) {
123                 _gpm.update_meters ();
124         }
125 }
126
127 SendUIWindow::SendUIWindow (boost::shared_ptr<Send> s, Session* session)
128         : ArdourWindow (string (_("Send ")) + s->name())
129 {
130         ui = new SendUI (this, s, session);
131
132         hpacker.pack_start (*ui, true, true);
133
134         add (hpacker);
135
136         set_name ("SendUIWindow");
137
138         ui->show ();
139         hpacker.show ();
140
141 }
142
143 SendUIWindow::~SendUIWindow ()
144 {
145         delete ui;
146 }