Rework Patch-Change/Select Dialog
[ardour.git] / gtk2_ardour / patch_change_widget.h
1 /*
2  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18
19 #ifndef __gtkardour_patch_change_widget_h__
20 #define __gtkardour_patch_change_widget_h__
21
22 #include <gtkmm/box.h>
23 #include <gtkmm/spinbutton.h>
24 #include <gtkmm/table.h>
25
26 #include "pbd/signals.h"
27
28 #include "ardour/route.h"
29
30 #include "widgets/ardour_button.h"
31 #include "widgets/ardour_dropdown.h"
32
33 #include "ardour_dialog.h"
34
35 class PatchChangeWidget : public Gtk::VBox
36 {
37 public:
38         PatchChangeWidget (boost::shared_ptr<ARDOUR::Route>);
39         ~PatchChangeWidget ();
40
41 protected:
42         int bank (uint8_t) const;
43         uint8_t program (uint8_t) const;
44
45         void on_show ();
46         void on_hide ();
47
48 private:
49         boost::shared_ptr<ARDOUR::Route> _route;
50
51         ArdourWidgets::ArdourDropdown _channel_select;
52         ArdourWidgets::ArdourDropdown _bank_select;
53         Gtk::SpinButton               _bank_msb_spin;
54         Gtk::SpinButton               _bank_lsb_spin;
55         ArdourWidgets::ArdourButton   _program_btn[128];
56         Gtk::Table                    _program_table;
57
58         uint8_t _channel;
59         bool    _ignore_spin_btn_signals;
60
61         void select_channel (uint8_t);
62         void select_bank (uint32_t);
63         void select_bank_spin ();
64         void select_program (uint8_t);
65
66         void bank_changed ();
67         void program_changed ();
68
69         void refill_banks ();
70         void refill_program_list ();
71
72         void instrument_info_changed ();
73
74         PBD::ScopedConnection _info_changed_connection;
75         PBD::ScopedConnection _route_connection;
76         PBD::ScopedConnectionList _ac_connections;
77
78         ARDOUR::InstrumentInfo& _info;
79         boost::shared_ptr<MIDI::Name::PatchBank> _current_patch_bank;
80 };
81
82 class PatchChangeGridDialog : public ArdourDialog
83 {
84 public:
85         PatchChangeGridDialog (std::string const&, boost::shared_ptr<ARDOUR::Route>);
86         void on_hide () { w.hide (); ArdourDialog::on_hide (); }
87         void on_show () { w.show (); ArdourDialog::on_show (); }
88
89 private:
90         PatchChangeWidget w;
91 };
92
93 #endif