use new method in MidiPatchManager to use MIDNAM data when setting a MidiTimeAxisView
[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/rc_configuration.h"
28 #include "ardour/send.h"
29
30 #include "gui_thread.h"
31 #include "io_selector.h"
32 #include "send_ui.h"
33 #include "timers.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         uint32_t const in  = _send->pans_required ();
49         uint32_t const out = _send->pan_outs ();
50         _panners.set_width (Wide);
51         _panners.set_available_panners (PannerManager::instance ().PannerManager::get_available_panners (in, out));
52         _panners.set_panner (s->panner_shell (), s->panner ());
53
54         _send->set_metering (true);
55         _send->output ()->changed.connect (connections, invalidator (*this), boost::bind (&SendUI::outs_changed, this, _1, _2), gui_context ());
56
57         _gpm.setup_meters ();
58         _gpm.set_fader_name (X_("SendUIFader"));
59         _gpm.set_controls (boost::shared_ptr<Route> (), s->meter (), s->amp (), s->gain_control ());
60
61         _io = Gtk::manage (new IOSelector (parent, session, s->output ()));
62
63         set_name (X_("SendUIFrame"));
64
65         _hbox.pack_start (_gpm, true, true);
66
67         _vbox.set_spacing (5);
68         _vbox.set_border_width (5);
69         _vbox.pack_start (_hbox, false, false, false);
70         _vbox.pack_start (_panners, false, false);
71
72         pack_start (_vbox, false, false);
73         pack_start (*_io, true, true);
74
75         _io->show ();
76         _gpm.show_all ();
77         _panners.show_all ();
78         _vbox.show ();
79         _hbox.show ();
80
81         fast_screen_update_connection = Timers::super_rapid_connect (
82             sigc::mem_fun (*this, &SendUI::fast_update));
83 }
84
85 SendUI::~SendUI ()
86 {
87         _send->set_metering (false);
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 SendUIWindow::~SendUIWindow ()
143 {
144         delete ui;
145 }