summaryrefslogtreecommitdiff
path: root/libs/surfaces/us2400/gui.h
blob: 7e0342bb854ba7373d6d7039ee3547d4fa7a4927 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
  Copyright (C) 2010-2012 Paul Davis

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <vector>

#include <gtkmm/combobox.h>
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
#include <gtkmm/table.h>
#include <gtkmm/treeview.h>
#include <gtkmm/liststore.h>
#include <gtkmm/notebook.h>
#include <gtkmm/scrolledwindow.h>

namespace Gtk {
	class CellRendererCombo;
}

#include "button.h"

#include "pbd/i18n.h"

namespace ArdourSurface {

class US2400Protocol;

namespace US2400 {
	class Surface;
}

class US2400ProtocolGUI : public Gtk::Notebook
{
   public:
	US2400ProtocolGUI (US2400Protocol &);

   private:
	US2400Protocol& _cp;
	Gtk::Table         table;
	Gtk::ComboBoxText _profile_combo;

	typedef std::vector<Gtk::ComboBox*> PortCombos;
	PortCombos input_combos;
	PortCombos output_combos;

	struct MidiPortColumns : public Gtk::TreeModel::ColumnRecord {
		MidiPortColumns() {
			add (short_name);
			add (full_name);
		}
		Gtk::TreeModelColumn<std::string> short_name;
		Gtk::TreeModelColumn<std::string> full_name;
	};

	struct AvailableActionColumns : public Gtk::TreeModel::ColumnRecord {
		AvailableActionColumns() {
			add (name);
			add (path);
		}
		Gtk::TreeModelColumn<std::string> name;
		Gtk::TreeModelColumn<std::string> path;
	};

	struct FunctionKeyColumns : public Gtk::TreeModel::ColumnRecord {
		FunctionKeyColumns() {
			add (name);
			add (id);
			add (plain);
			add (shift);
			add (control);
			add (option);
			add (cmdalt);
			add (shiftcontrol);
		};
		Gtk::TreeModelColumn<std::string> name;
		Gtk::TreeModelColumn<US2400::Button::ID>  id;
		Gtk::TreeModelColumn<std::string> plain;
		Gtk::TreeModelColumn<std::string> shift;
		Gtk::TreeModelColumn<std::string> control;
		Gtk::TreeModelColumn<std::string> option;
		Gtk::TreeModelColumn<std::string> cmdalt;
		Gtk::TreeModelColumn<std::string> shiftcontrol;
	};

	AvailableActionColumns available_action_columns;
	FunctionKeyColumns function_key_columns;
	MidiPortColumns midi_port_columns;

	Gtk::ScrolledWindow function_key_scroller;
	Gtk::TreeView function_key_editor;
	Glib::RefPtr<Gtk::ListStore> function_key_model;
	Glib::RefPtr<Gtk::TreeStore> available_action_model;

	Glib::RefPtr<Gtk::ListStore> build_midi_port_list (bool for_input);

	void build_available_action_menu ();
	void refresh_function_key_editor ();
	void build_function_key_editor ();
	void action_changed (const Glib::ustring &sPath, const Glib::ustring &text, Gtk::TreeModelColumnBase);
	Gtk::CellRendererCombo* make_action_renderer (Glib::RefPtr<Gtk::TreeStore> model, Gtk::TreeModelColumnBase);

	void profile_combo_changed ();

	std::map<std::string,std::string> action_map; // map from action names to paths

	Gtk::Widget* device_dependent_widget ();
	Gtk::Widget* _device_dependent_widget;
	int device_dependent_row;

	PBD::ScopedConnection device_change_connection;
	void device_changed ();

	void update_port_combos (std::vector<std::string> const&, std::vector<std::string> const&,
	                         Gtk::ComboBox* input_combo,
	                         Gtk::ComboBox* output_combo,
	                         boost::shared_ptr<US2400::Surface> surface);

	PBD::ScopedConnection connection_change_connection;
	void connection_handler ();

	Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
	bool _ignore_profile_changed;
	bool ignore_active_change;
	void active_port_changed (Gtk::ComboBox* combo, boost::weak_ptr<US2400::Surface> ws, bool for_input);
};

}