summaryrefslogtreecommitdiff
path: root/libs/surfaces/push2/gui.h
blob: 8d8829c26035c5aeb207e3df9c0d18e196471cda (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
    Copyright (C) 2015 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.

*/

#ifndef __ardour_push2_gui_h__
#define __ardour_push2_gui_h__

#include <vector>
#include <string>

#include <gtkmm/box.h>
#include <gtkmm/button.h>
#include <gtkmm/combobox.h>
#include <gtkmm/image.h>
#include <gtkmm/table.h>
#include <gtkmm/treestore.h>
#include <gtkmm/spinbutton.h>
#include <gtkmm/notebook.h>

namespace Gtk {
	class CellRendererCombo;
	class ListStore;
}

#include "push2.h"
#include "mode.h"

namespace ArdourSurface {

class P2GUI : public Gtk::VBox
{
public:
	P2GUI (Push2&);
	~P2GUI ();

	void build_pad_table ();

private:
	Push2& p2;
	PBD::ScopedConnectionList p2_connections;
	Gtk::HBox hpacker;
	Gtk::Table table;
	Gtk::Table action_table;
	Gtk::ComboBox input_combo;
	Gtk::ComboBox output_combo;
	Gtk::Image    image;

	void update_port_combos ();
	PBD::ScopedConnection connection_change_connection;
	void connection_handler ();

	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;
	};

	MidiPortColumns midi_port_columns;
	bool ignore_active_change;

	Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
	void active_port_changed (Gtk::ComboBox*,bool for_input);

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

	ActionColumns action_columns;
	Glib::RefPtr<Gtk::TreeStore> available_action_model;
	std::map<std::string,std::string> action_map; // map from action names to paths

	void build_available_action_menu ();
	bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);

	/* Pads */

	Gtk::Table pad_table;

	/* root notes */

	Gtk::Adjustment root_note_octave_adjustment;
	Gtk::SpinButton root_note_octave;
	Gtk::Label root_note_octave_label;

	void root_note_octave_adjustment_changed ();

	struct NoteColumns : public Gtk::TreeModel::ColumnRecord {
		NoteColumns () {
			add (number);
			add (name);
		}
		Gtk::TreeModelColumn<int>         number;
		Gtk::TreeModelColumn<std::string> name;
	};
	NoteColumns note_columns;
	Glib::RefPtr<Gtk::ListStore> build_note_columns ();
	Gtk::ComboBox root_note_selector;
	Gtk::Label root_note_label;

	void root_note_changed ();

	/* modes/scales */

	struct ModeColumns : public Gtk::TreeModel::ColumnRecord {
		ModeColumns () {
			add (mode);
			add (name);
		}
		Gtk::TreeModelColumn<MusicalMode::Type>  mode;
		Gtk::TreeModelColumn<std::string> name;
	};
	ModeColumns mode_columns;
	Glib::RefPtr<Gtk::ListStore> build_mode_columns ();
	Gtk::ComboBox mode_selector;
	Gtk::Label mode_label;

	Gtk::CheckButton inkey_button;

	Gtk::Notebook pad_notebook;
	Gtk::Table    mode_packer;
	Gtk::VBox     custom_packer;

	struct PressureModeColumns : public Gtk::TreeModel::ColumnRecord {
		PressureModeColumns() {
			add (mode);
			add (name);
		}
		Gtk::TreeModelColumn<Push2::PressureMode>  mode;
		Gtk::TreeModelColumn<std::string> name;
	};
	PressureModeColumns pressure_mode_columns;
	Glib::RefPtr<Gtk::ListStore> build_pressure_mode_columns ();
	Gtk::ComboBox pressure_mode_selector;
	Gtk::Label pressure_mode_label;

	void reprogram_pad_scale ();
	void reprogram_pressure_mode ();
};

}

#endif /* __ardour_push2_gui_h__ */