b472698feecec1571645be74c35499c34c3536fe
[ardour.git] / libs / surfaces / push2 / gui.h
1 /*
2     Copyright (C) 2015 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 #ifndef __ardour_push2_gui_h__
21 #define __ardour_push2_gui_h__
22
23 #include <vector>
24 #include <string>
25
26 #include <gtkmm/box.h>
27 #include <gtkmm/button.h>
28 #include <gtkmm/combobox.h>
29 #include <gtkmm/image.h>
30 #include <gtkmm/table.h>
31 #include <gtkmm/treestore.h>
32 #include <gtkmm/spinbutton.h>
33 #include <gtkmm/notebook.h>
34
35 namespace Gtk {
36         class CellRendererCombo;
37         class ListStore;
38 }
39
40 #include "push2.h"
41 #include "mode.h"
42
43 namespace ArdourSurface {
44
45 class P2GUI : public Gtk::VBox
46 {
47 public:
48         P2GUI (Push2&);
49         ~P2GUI ();
50
51         void build_pad_table ();
52
53 private:
54         Push2& p2;
55         PBD::ScopedConnectionList p2_connections;
56         Gtk::HBox hpacker;
57         Gtk::Table table;
58         Gtk::Table action_table;
59         Gtk::ComboBox input_combo;
60         Gtk::ComboBox output_combo;
61         Gtk::Image    image;
62
63         void update_port_combos ();
64         PBD::ScopedConnection connection_change_connection;
65         void connection_handler ();
66
67         struct MidiPortColumns : public Gtk::TreeModel::ColumnRecord {
68                 MidiPortColumns() {
69                         add (short_name);
70                         add (full_name);
71                 }
72                 Gtk::TreeModelColumn<std::string> short_name;
73                 Gtk::TreeModelColumn<std::string> full_name;
74         };
75
76         MidiPortColumns midi_port_columns;
77         bool ignore_active_change;
78
79         Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
80         void active_port_changed (Gtk::ComboBox*,bool for_input);
81
82         struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
83                 ActionColumns() {
84                         add (name);
85                         add (path);
86                 }
87                 Gtk::TreeModelColumn<std::string> name;
88                 Gtk::TreeModelColumn<std::string> path;
89         };
90
91         ActionColumns action_columns;
92         Glib::RefPtr<Gtk::TreeStore> available_action_model;
93         std::map<std::string,std::string> action_map; // map from action names to paths
94
95         void build_available_action_menu ();
96         bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
97
98         /* Pads */
99
100         Gtk::Table pad_table;
101
102         /* root notes */
103
104         Gtk::Adjustment root_note_octave_adjustment;
105         Gtk::SpinButton root_note_octave;
106         Gtk::Label root_note_octave_label;
107
108         void root_note_octave_adjustment_changed ();
109
110         struct NoteColumns : public Gtk::TreeModel::ColumnRecord {
111                 NoteColumns () {
112                         add (number);
113                         add (name);
114                 }
115                 Gtk::TreeModelColumn<int>         number;
116                 Gtk::TreeModelColumn<std::string> name;
117         };
118         NoteColumns note_columns;
119         Glib::RefPtr<Gtk::ListStore> build_note_columns ();
120         Gtk::ComboBox root_note_selector;
121         Gtk::Label root_note_label;
122
123         void root_note_changed ();
124
125         /* modes/scales */
126
127         struct ModeColumns : public Gtk::TreeModel::ColumnRecord {
128                 ModeColumns () {
129                         add (mode);
130                         add (name);
131                 }
132                 Gtk::TreeModelColumn<MusicalMode::Type>  mode;
133                 Gtk::TreeModelColumn<std::string> name;
134         };
135         ModeColumns mode_columns;
136         Glib::RefPtr<Gtk::ListStore> build_mode_columns ();
137         Gtk::ComboBox mode_selector;
138         Gtk::Label mode_label;
139
140         Gtk::CheckButton inkey_button;
141
142         Gtk::Notebook pad_notebook;
143         Gtk::Table    mode_packer;
144         Gtk::VBox     custom_packer;
145
146         void reprogram_pad_scale ();
147 };
148
149 }
150
151 #endif /* __ardour_push2_gui_h__ */