2 Copyright (C) 2010 Paul Davis
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.
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.
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.
20 #ifndef __gtk2_ardour_step_entry_h__
21 #define __gtk2_ardour_step_entry_h__
23 #include <gtkmm/togglebutton.h>
24 #include <gtkmm/radiobutton.h>
25 #include <gtkmm/spinbutton.h>
26 #include <gtkmm/box.h>
27 #include <gtkmm/adjustment.h>
28 #include <gtkmm2ext/bindings.h>
30 #include "ardour_window.h"
31 #include "gtk_pianokeyboard.h"
35 class StepEntry : public ArdourWindow
38 static StepEntry& instance();
42 void set_step_editor (StepEditor*);
44 void note_off_event_handler (int note);
45 void rest_event_handler ();
47 Temporal::Beats note_length();
48 uint8_t note_velocity() const;
49 uint8_t note_channel() const;
51 int current_octave () const { return (int) floor (octave_adjustment.get_value()); }
53 static void setup_actions_and_bindings ();
56 static StepEntry* _instance;
59 Temporal::Beats _current_note_length;
60 uint8_t _current_note_velocity;
64 Gtk::HBox note_length_box;
65 Gtk::HBox note_velocity_box;
67 Gtk::ToggleButton chord_button;
68 Gtk::ToggleButton triplet_button;
69 Gtk::ToggleButton dot0_button;
70 Gtk::ToggleButton dot1_button;
71 Gtk::ToggleButton dot2_button;
72 Gtk::ToggleButton dot3_button;
73 Gtk::Adjustment dot_adjustment;
76 Gtk::ToggleButton restart_button;
79 Gtk::Button beat_resync_button;
80 Gtk::Button bar_resync_button;
81 Gtk::Button resync_button;
83 Gtk::Button sustain_button;
84 Gtk::Button rest_button;
85 Gtk::Button grid_rest_button;
88 Gtk::Button back_button;
90 Gtk::RadioButton length_1_button;
91 Gtk::RadioButton length_2_button;
92 Gtk::RadioButton length_4_button;
93 Gtk::RadioButton length_8_button;
94 Gtk::RadioButton length_12_button;
95 Gtk::RadioButton length_16_button;
96 Gtk::RadioButton length_32_button;
97 Gtk::RadioButton length_64_button;
99 Gtk::RadioButton velocity_ppp_button;
100 Gtk::RadioButton velocity_pp_button;
101 Gtk::RadioButton velocity_p_button;
102 Gtk::RadioButton velocity_mp_button;
103 Gtk::RadioButton velocity_mf_button;
104 Gtk::RadioButton velocity_f_button;
105 Gtk::RadioButton velocity_ff_button;
106 Gtk::RadioButton velocity_fff_button;
108 Gtk::Adjustment channel_adjustment;
109 Gtk::SpinButton channel_spinner;
111 Gtk::Adjustment octave_adjustment;
112 Gtk::SpinButton octave_spinner;
114 Gtk::Adjustment length_divisor_adjustment;
115 Gtk::SpinButton length_divisor_spinner;
117 Gtk::Adjustment velocity_adjustment;
118 Gtk::SpinButton velocity_spinner;
120 Gtk::Adjustment bank_adjustment;
121 Gtk::SpinButton bank_spinner;
122 Gtk::Button bank_button;
124 Gtk::Adjustment program_adjustment;
125 Gtk::SpinButton program_spinner;
126 Gtk::Button program_button;
128 void length_changed ();
129 void velocity_changed ();
130 void velocity_value_change ();
131 void length_value_change ();
133 PianoKeyboard* _piano;
138 void program_click ();
139 void beat_resync_click ();
140 void bar_resync_click ();
142 bool piano_enter_notify_event (GdkEventCrossing *ev);
143 bool on_key_release_event (GdkEventKey*);
144 bool on_key_press_event (GdkEventKey*);
150 void insert_note (uint8_t);
152 void insert_grid_rest ();
154 void insert_asharp ();
157 void insert_csharp ();
159 void insert_dsharp ();
162 void insert_fsharp ();
164 void insert_gsharp ();
165 void note_length_change (GtkAction*);
166 void note_velocity_change (GtkAction*);
167 bool radio_button_press (GdkEventButton*);
168 bool radio_button_release (GdkEventButton*, Gtk::RadioButton*, int);
169 void inc_note_velocity ();
170 void dec_note_velocity ();
171 void next_note_velocity ();
172 void prev_note_velocity ();
173 void inc_note_length ();
174 void dec_note_length ();
175 void next_note_length ();
176 void prev_note_length ();
179 void octave_n (int n);
180 void octave_0 () { octave_n (0); }
181 void octave_1 () { octave_n (1); }
182 void octave_2 () { octave_n (2); }
183 void octave_3 () { octave_n (3); }
184 void octave_4 () { octave_n (4); }
185 void octave_5 () { octave_n (5); }
186 void octave_6 () { octave_n (6); }
187 void octave_7 () { octave_n (7); }
188 void octave_8 () { octave_n (8); }
189 void octave_9 () { octave_n (9); }
190 void octave_10 () { octave_n (10); }
191 void dot_change (GtkAction*);
192 void dot_value_change ();
193 void toggle_triplet();
197 void sync_to_edit_point ();
199 /* static versions of action methods, so that we can register actions without
200 having an actual StepEntry object.
203 static void se_insert_rest () { if (_instance) { _instance->insert_rest (); } }
204 static void se_insert_grid_rest () { if (_instance) { _instance->insert_grid_rest (); } }
205 static void se_insert_a () { if (_instance) { _instance->insert_a (); } }
206 static void se_insert_asharp () { if (_instance) { _instance->insert_asharp (); } }
207 static void se_insert_b () { if (_instance) { _instance->insert_b (); } }
208 static void se_insert_c () { if (_instance) { _instance->insert_c (); } }
209 static void se_insert_csharp () { if (_instance) { _instance->insert_csharp (); } }
210 static void se_insert_d () { if (_instance) { _instance->insert_d (); } }
211 static void se_insert_dsharp () { if (_instance) { _instance->insert_dsharp (); } }
212 static void se_insert_e () { if (_instance) { _instance->insert_e (); } }
213 static void se_insert_f () { if (_instance) { _instance->insert_f (); } }
214 static void se_insert_fsharp () { if (_instance) { _instance->insert_fsharp (); } }
215 static void se_insert_g () { if (_instance) { _instance->insert_g (); } }
216 static void se_insert_gsharp () { if (_instance) { _instance->insert_gsharp (); } }
217 static void se_note_length_change (GtkAction* act) { if (_instance) { _instance->note_length_change (act); } }
218 static void se_note_velocity_change (GtkAction* act) { if (_instance) { _instance->note_velocity_change (act); } }
219 static bool se_radio_button_press (GdkEventButton* ev) { if (_instance) { return _instance->radio_button_press (ev); } return false; }
220 static bool se_radio_button_release (GdkEventButton* ev, Gtk::RadioButton* rb, int n) { if (_instance) { return _instance->radio_button_release (ev, rb, n); } return false; }
221 static void se_inc_note_velocity () { if (_instance) { _instance->inc_note_velocity (); } }
222 static void se_dec_note_velocity () { if (_instance) { _instance->dec_note_velocity (); } }
223 static void se_next_note_velocity () { if (_instance) { _instance->next_note_velocity (); } }
224 static void se_prev_note_velocity () { if (_instance) { _instance->prev_note_velocity (); } }
225 static void se_inc_note_length () { if (_instance) { _instance->inc_note_length (); } }
226 static void se_dec_note_length () { if (_instance) { _instance->dec_note_length (); } }
227 static void se_next_note_length () { if (_instance) { _instance->next_note_length (); } }
228 static void se_prev_note_length () { if (_instance) { _instance->prev_note_length (); } }
229 static void se_next_octave () { if (_instance) { _instance->next_octave (); } }
230 static void se_prev_octave () { if (_instance) { _instance->prev_octave (); } }
231 static void se_octave_n (int n) { if (_instance) { _instance->octave_n (n); } }
232 static void se_octave_0 () { if (_instance) { _instance->octave_0 (); } }
233 static void se_octave_1 () { if (_instance) { _instance->octave_1 (); } }
234 static void se_octave_2 () { if (_instance) { _instance->octave_2 (); } }
235 static void se_octave_3 () { if (_instance) { _instance->octave_3 (); } }
236 static void se_octave_4 () { if (_instance) { _instance->octave_4 (); } }
237 static void se_octave_5 () { if (_instance) { _instance->octave_5 (); } }
238 static void se_octave_6 () { if (_instance) { _instance->octave_6 (); } }
239 static void se_octave_7 () { if (_instance) { _instance->octave_7 (); } }
240 static void se_octave_8 () { if (_instance) { _instance->octave_8 (); } }
241 static void se_octave_9 () { if (_instance) { _instance->octave_9 (); } }
242 static void se_octave_10 () { if (_instance) { _instance->octave_10 (); } }
243 static void se_dot_change (GtkAction* act) { if (_instance) { _instance->dot_change (act); } }
244 static void se_dot_value_change () { if (_instance) { _instance->dot_value_change (); } }
245 static void se_toggle_triplet() { if (_instance) { _instance->toggle_triplet (); } }
246 static void se_toggle_chord() { if (_instance) { _instance->toggle_chord (); } }
247 static void se_do_sustain () { if (_instance) { _instance->do_sustain (); } }
248 static void se_back() { if (_instance) { _instance->back (); } }
249 static void se_sync_to_edit_point () { if (_instance) { _instance->sync_to_edit_point (); } }
251 static void load_bindings ();
252 static Gtkmm2ext::Bindings* bindings;
253 static void register_actions ();
256 #endif /* __gtk2_ardour_step_entry_h__ */