Drop references held by any GUI Lua script after execution
[ardour.git] / gtk2_ardour / patch_change_dialog.h
1 /*
2  * Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
3  * Copyright (C) 2012-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2013-2015 David Robillard <d@drobilla.net>
5  * Copyright (C) 2017-2019 Robin Gareus <robin@gareus.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #include <gtkmm/spinbutton.h>
23 #include <gtkmm/comboboxtext.h>
24
25 #include "evoral/PatchChange.h"
26 #include "ardour_dialog.h"
27 #include "audio_clock.h"
28
29 namespace ARDOUR {
30         class BeatsSamplesConverter;
31         class Session;
32         class InstrumentInfo;
33 }
34
35 namespace MIDI {
36         namespace Name {
37                 class PatchBank;
38         }
39 }
40
41 class PatchChangeDialog : public ArdourDialog
42 {
43 public:
44         PatchChangeDialog (
45                 const ARDOUR::BeatsSamplesConverter*,
46                 ARDOUR::Session*,
47                 Evoral::PatchChange<Temporal::Beats> const&,
48                 ARDOUR::InstrumentInfo&,
49                 const Gtk::BuiltinStockID&,
50                 bool allow_delete = false,
51                 bool modal = true
52                 );
53
54         Evoral::PatchChange<Temporal::Beats> patch () const;
55
56 protected:
57         void on_response (int);
58
59 private:
60         void fill_bank_combo ();
61         void set_active_bank_combo ();
62         void fill_patch_combo ();
63         void set_active_patch_combo ();
64         void bank_combo_changed ();
65         void patch_combo_changed ();
66         void channel_changed ();
67         void bank_changed ();
68         void program_changed ();
69
70         int get_14bit_bank () const;
71
72         const ARDOUR::BeatsSamplesConverter* _time_converter;
73         ARDOUR::InstrumentInfo& _info;
74         AudioClock _time;
75
76         Gtk::SpinButton   _channel;
77         Gtk::SpinButton   _program;
78         Gtk::SpinButton   _bank_msb;
79         Gtk::SpinButton   _bank_lsb;
80         Gtk::ComboBoxText _bank_combo;
81         Gtk::ComboBoxText _patch_combo;
82
83         boost::shared_ptr<MIDI::Name::PatchBank> _current_patch_bank;
84
85         bool _ignore_signals;
86         bool _keep_open;
87
88         void instrument_info_changed ();
89         PBD::ScopedConnection _info_changed_connection;
90 };