summaryrefslogtreecommitdiff
path: root/gtk2_ardour/step_entry.h
blob: 685f859302301b84f2fdd59bd8a8b6cedc9e6580 (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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
    Copyright (C) 2010 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 __gtk2_ardour_step_entry_h__
#define __gtk2_ardour_step_entry_h__

#include <gtkmm/togglebutton.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/spinbutton.h>
#include <gtkmm/box.h>
#include <gtkmm/adjustment.h>
#include <gtkmm2ext/bindings.h>

#include "ardour_window.h"
#include "gtk_pianokeyboard.h"

class StepEditor;

class StepEntry : public ArdourWindow
{
public:
	StepEntry (StepEditor&);
	~StepEntry ();

	void note_off_event_handler (int note);
	void rest_event_handler ();

	Evoral::Beats note_length();
	uint8_t note_velocity() const;
	uint8_t note_channel() const;

	int current_octave () const { return (int) floor (octave_adjustment.get_value()); }

private:
	Evoral::Beats _current_note_length;
	uint8_t _current_note_velocity;

	Gtk::VBox packer;
	Gtk::HBox upper_box;
	Gtk::HBox note_length_box;
	Gtk::HBox note_velocity_box;

	Gtk::ToggleButton chord_button;
	Gtk::ToggleButton triplet_button;
	Gtk::ToggleButton dot0_button;
	Gtk::ToggleButton dot1_button;
	Gtk::ToggleButton dot2_button;
	Gtk::ToggleButton dot3_button;
	Gtk::Adjustment   dot_adjustment;
	Gtk::VBox dot_box1;
	Gtk::VBox dot_box2;
	Gtk::ToggleButton restart_button;

	Gtk::VBox   resync_box;
	Gtk::Button beat_resync_button;
	Gtk::Button bar_resync_button;
	Gtk::Button resync_button;

	Gtk::Button sustain_button;
	Gtk::Button rest_button;
	Gtk::Button grid_rest_button;
	Gtk::VBox   rest_box;

	Gtk::Button back_button;

	Gtk::RadioButton length_1_button;
	Gtk::RadioButton length_2_button;
	Gtk::RadioButton length_4_button;
	Gtk::RadioButton length_8_button;
	Gtk::RadioButton length_12_button;
	Gtk::RadioButton length_16_button;
	Gtk::RadioButton length_32_button;
	Gtk::RadioButton length_64_button;

	Gtk::RadioButton velocity_ppp_button;
	Gtk::RadioButton velocity_pp_button;
	Gtk::RadioButton velocity_p_button;
	Gtk::RadioButton velocity_mp_button;
	Gtk::RadioButton velocity_mf_button;
	Gtk::RadioButton velocity_f_button;
	Gtk::RadioButton velocity_ff_button;
	Gtk::RadioButton velocity_fff_button;

	Gtk::Adjustment channel_adjustment;
	Gtk::SpinButton channel_spinner;

	Gtk::Adjustment octave_adjustment;
	Gtk::SpinButton octave_spinner;

	Gtk::Adjustment length_divisor_adjustment;
	Gtk::SpinButton length_divisor_spinner;

	Gtk::Adjustment velocity_adjustment;
	Gtk::SpinButton velocity_spinner;

	Gtk::Adjustment bank_adjustment;
	Gtk::SpinButton bank_spinner;
	Gtk::Button     bank_button;

	Gtk::Adjustment program_adjustment;
	Gtk::SpinButton program_spinner;
	Gtk::Button     program_button;

	void length_changed ();
	void velocity_changed ();
	void velocity_value_change ();
	void length_value_change ();

	PianoKeyboard* _piano;
	Gtk::Widget* piano;
	StepEditor*   se;

	void bank_click ();
	void program_click ();
	void beat_resync_click ();
	void bar_resync_click ();

	bool piano_enter_notify_event (GdkEventCrossing *ev);
	bool on_key_release_event (GdkEventKey*);
	bool on_key_press_event (GdkEventKey*);

	void on_show ();

	/* actions */

	void register_actions ();

	void insert_note (uint8_t);
	void insert_rest ();
	void insert_grid_rest ();

	void insert_a ();
	void insert_asharp ();
	void insert_b ();
	void insert_c ();
	void insert_csharp ();
	void insert_d ();
	void insert_dsharp ();
	void insert_e ();
	void insert_f ();
	void insert_fsharp ();
	void insert_g ();
	void insert_gsharp ();

	void note_length_change (GtkAction*);
	void note_velocity_change (GtkAction*);

	bool radio_button_press (GdkEventButton*);
	bool radio_button_release (GdkEventButton*, Gtk::RadioButton*, int);

	void load_bindings ();
	Gtkmm2ext::ActionMap myactions;
	Gtkmm2ext::Bindings*  bindings;

	void inc_note_velocity ();
	void dec_note_velocity ();
	void next_note_velocity ();
	void prev_note_velocity ();

	void inc_note_length ();
	void dec_note_length ();
	void next_note_length ();
	void prev_note_length ();

	void next_octave ();
	void prev_octave ();

	void octave_n (int n);
	void octave_0 () { octave_n (0); }
	void octave_1 () { octave_n (1); }
	void octave_2 () { octave_n (2); }
	void octave_3 () { octave_n (3); }
	void octave_4 () { octave_n (4); }
	void octave_5 () { octave_n (5); }
	void octave_6 () { octave_n (6); }
	void octave_7 () { octave_n (7); }
	void octave_8 () { octave_n (8); }
	void octave_9 () { octave_n (9); }
	void octave_10 () { octave_n (10); }

	void dot_change (GtkAction*);
	void dot_value_change ();

	void toggle_triplet();
	void toggle_chord();

	void do_sustain ();
	void back();
	void sync_to_edit_point ();
};

#endif /* __gtk2_ardour_step_entry_h__ */