Use Stripable::Sorter in libs
[ardour.git] / libs / surfaces / faderport8 / gui.h
1 /*
2  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
3  * Copyright (C) 2015 Paul Davis
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef __ardour_faderport8_gui_h__
21 #define __ardour_faderport8_gui_h__
22
23 #include <vector>
24 #include <string>
25
26 #include <gtkmm/box.h>
27 #include <gtkmm/combobox.h>
28 #include <gtkmm/image.h>
29 #include <gtkmm/table.h>
30 #include <gtkmm/treestore.h>
31
32 namespace Gtk {
33         class CellRendererCombo;
34         class ListStore;
35 }
36
37 #include "faderport8.h"
38
39 namespace ArdourSurface {
40
41 class FP8GUI : public Gtk::VBox
42 {
43 public:
44         FP8GUI (FaderPort8&);
45         ~FP8GUI ();
46
47 private:
48         FaderPort8& fp;
49         Gtk::HBox hpacker;
50         Gtk::Table table;
51         Gtk::Image image;
52
53         /* port connections */
54         Gtk::ComboBox input_combo;
55         Gtk::ComboBox output_combo;
56
57         void update_port_combos ();
58         void connection_handler ();
59         PBD::ScopedConnection connection_change_connection;
60
61         struct MidiPortColumns : public Gtk::TreeModel::ColumnRecord {
62                 MidiPortColumns() {
63                         add (short_name);
64                         add (full_name);
65                 }
66                 Gtk::TreeModelColumn<std::string> short_name;
67                 Gtk::TreeModelColumn<std::string> full_name;
68         };
69
70         MidiPortColumns midi_port_columns;
71         bool ignore_active_change;
72
73         Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
74         void active_port_changed (Gtk::ComboBox*,bool for_input);
75
76         /* user actions */
77         void build_available_action_menu ();
78         void build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id);
79         void action_changed (Gtk::ComboBox* cb, FP8Controls::ButtonId id);
80
81         struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
82                 ActionColumns() {
83                         add (name);
84                         add (path);
85                 }
86                 Gtk::TreeModelColumn<std::string> name;
87                 Gtk::TreeModelColumn<std::string> path;
88         };
89
90         ActionColumns action_columns;
91         Glib::RefPtr<Gtk::TreeStore> available_action_model;
92         std::map<std::string,std::string> action_map; // map from action names to paths
93
94         bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
95 };
96
97 }
98
99 #endif /* __ardour_faderport8_gui_h__ */