2 * Copyright (C) 2010-2018 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2011-2015 David Robillard <d@drobilla.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 "pianokeyboard.h"
35 /** StepEntry is a singleton class which presents a GUI to the user to allow
36 * them to carry out step editing. It does not understand the details of making
37 * changes to the model directly, but instead calls into a StepEditor object to
40 * The StepEntry is a singleton, used over and over each time the user wants to
41 * step edit; the StepEditor is owned by a MidiTimeAxisView and re-used for any
42 * step editing in the MidiTrack for which the MidiTimeAxisView is a view.
45 class StepEntry : public ArdourWindow
48 static StepEntry& instance();
52 void set_step_editor (StepEditor*);
54 Temporal::Beats note_length();
55 uint8_t note_velocity() const;
56 uint8_t note_channel() const;
58 int current_octave () const { return (int) floor (octave_adjustment.get_value()); }
60 static void setup_actions_and_bindings ();
63 static StepEntry* _instance;
66 void note_off_event_handler (int note);
67 void rest_event_handler ();
69 Temporal::Beats _current_note_length;
70 uint8_t _current_note_velocity;
74 Gtk::HBox note_length_box;
75 Gtk::HBox note_velocity_box;
77 Gtk::ToggleButton chord_button;
78 Gtk::ToggleButton triplet_button;
79 Gtk::ToggleButton dot0_button;
80 Gtk::ToggleButton dot1_button;
81 Gtk::ToggleButton dot2_button;
82 Gtk::ToggleButton dot3_button;
83 Gtk::Adjustment dot_adjustment;
86 Gtk::ToggleButton restart_button;
89 Gtk::Button beat_resync_button;
90 Gtk::Button bar_resync_button;
91 Gtk::Button resync_button;
93 Gtk::Button sustain_button;
94 Gtk::Button rest_button;
95 Gtk::Button grid_rest_button;
98 Gtk::Button back_button;
100 Gtk::RadioButton length_1_button;
101 Gtk::RadioButton length_2_button;
102 Gtk::RadioButton length_4_button;
103 Gtk::RadioButton length_8_button;
104 Gtk::RadioButton length_12_button;
105 Gtk::RadioButton length_16_button;
106 Gtk::RadioButton length_32_button;
107 Gtk::RadioButton length_64_button;
109 Gtk::RadioButton velocity_ppp_button;
110 Gtk::RadioButton velocity_pp_button;
111 Gtk::RadioButton velocity_p_button;
112 Gtk::RadioButton velocity_mp_button;
113 Gtk::RadioButton velocity_mf_button;
114 Gtk::RadioButton velocity_f_button;
115 Gtk::RadioButton velocity_ff_button;
116 Gtk::RadioButton velocity_fff_button;
118 Gtk::Adjustment channel_adjustment;
119 Gtk::SpinButton channel_spinner;
121 Gtk::Adjustment octave_adjustment;
122 Gtk::SpinButton octave_spinner;
124 Gtk::Adjustment length_divisor_adjustment;
125 Gtk::SpinButton length_divisor_spinner;
127 Gtk::Adjustment velocity_adjustment;
128 Gtk::SpinButton velocity_spinner;
130 Gtk::Adjustment bank_adjustment;
131 Gtk::SpinButton bank_spinner;
132 Gtk::Button bank_button;
134 Gtk::Adjustment program_adjustment;
135 Gtk::SpinButton program_spinner;
136 Gtk::Button program_button;
138 void length_changed ();
139 void velocity_changed ();
140 void velocity_value_change ();
141 void length_value_change ();
143 APianoKeyboard _piano;
148 void program_click ();
149 void beat_resync_click ();
150 void bar_resync_click ();
152 bool piano_enter_notify_event (GdkEventCrossing *ev);
153 bool on_key_release_event (GdkEventKey*);
154 bool on_key_press_event (GdkEventKey*);
160 void insert_note (uint8_t);
162 void insert_grid_rest ();
164 void insert_asharp ();
167 void insert_csharp ();
169 void insert_dsharp ();
172 void insert_fsharp ();
174 void insert_gsharp ();
175 void note_length_change (GtkAction*);
176 void note_velocity_change (GtkAction*);
177 bool radio_button_press (GdkEventButton*);
178 bool radio_button_release (GdkEventButton*, Gtk::RadioButton*, int);
179 void inc_note_velocity ();
180 void dec_note_velocity ();
181 void next_note_velocity ();
182 void prev_note_velocity ();
183 void inc_note_length ();
184 void dec_note_length ();
185 void next_note_length ();
186 void prev_note_length ();
189 void octave_n (int n);
190 void octave_0 () { octave_n (0); }
191 void octave_1 () { octave_n (1); }
192 void octave_2 () { octave_n (2); }
193 void octave_3 () { octave_n (3); }
194 void octave_4 () { octave_n (4); }
195 void octave_5 () { octave_n (5); }
196 void octave_6 () { octave_n (6); }
197 void octave_7 () { octave_n (7); }
198 void octave_8 () { octave_n (8); }
199 void octave_9 () { octave_n (9); }
200 void octave_10 () { octave_n (10); }
201 void dot_change (GtkAction*);
202 void dot_value_change ();
203 void toggle_triplet();
207 void sync_to_edit_point ();
209 /* static versions of action methods, so that we can register actions without
210 having an actual StepEntry object.
213 static void se_insert_rest () { if (_instance) { _instance->insert_rest (); } }
214 static void se_insert_grid_rest () { if (_instance) { _instance->insert_grid_rest (); } }
215 static void se_insert_a () { if (_instance) { _instance->insert_a (); } }
216 static void se_insert_asharp () { if (_instance) { _instance->insert_asharp (); } }
217 static void se_insert_b () { if (_instance) { _instance->insert_b (); } }
218 static void se_insert_c () { if (_instance) { _instance->insert_c (); } }
219 static void se_insert_csharp () { if (_instance) { _instance->insert_csharp (); } }
220 static void se_insert_d () { if (_instance) { _instance->insert_d (); } }
221 static void se_insert_dsharp () { if (_instance) { _instance->insert_dsharp (); } }
222 static void se_insert_e () { if (_instance) { _instance->insert_e (); } }
223 static void se_insert_f () { if (_instance) { _instance->insert_f (); } }
224 static void se_insert_fsharp () { if (_instance) { _instance->insert_fsharp (); } }
225 static void se_insert_g () { if (_instance) { _instance->insert_g (); } }
226 static void se_insert_gsharp () { if (_instance) { _instance->insert_gsharp (); } }
227 static void se_note_length_change (GtkAction* act) { if (_instance) { _instance->note_length_change (act); } }
228 static void se_note_velocity_change (GtkAction* act) { if (_instance) { _instance->note_velocity_change (act); } }
229 static bool se_radio_button_press (GdkEventButton* ev) { if (_instance) { return _instance->radio_button_press (ev); } return false; }
230 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; }
231 static void se_inc_note_velocity () { if (_instance) { _instance->inc_note_velocity (); } }
232 static void se_dec_note_velocity () { if (_instance) { _instance->dec_note_velocity (); } }
233 static void se_next_note_velocity () { if (_instance) { _instance->next_note_velocity (); } }
234 static void se_prev_note_velocity () { if (_instance) { _instance->prev_note_velocity (); } }
235 static void se_inc_note_length () { if (_instance) { _instance->inc_note_length (); } }
236 static void se_dec_note_length () { if (_instance) { _instance->dec_note_length (); } }
237 static void se_next_note_length () { if (_instance) { _instance->next_note_length (); } }
238 static void se_prev_note_length () { if (_instance) { _instance->prev_note_length (); } }
239 static void se_next_octave () { if (_instance) { _instance->next_octave (); } }
240 static void se_prev_octave () { if (_instance) { _instance->prev_octave (); } }
241 static void se_octave_n (int n) { if (_instance) { _instance->octave_n (n); } }
242 static void se_octave_0 () { if (_instance) { _instance->octave_0 (); } }
243 static void se_octave_1 () { if (_instance) { _instance->octave_1 (); } }
244 static void se_octave_2 () { if (_instance) { _instance->octave_2 (); } }
245 static void se_octave_3 () { if (_instance) { _instance->octave_3 (); } }
246 static void se_octave_4 () { if (_instance) { _instance->octave_4 (); } }
247 static void se_octave_5 () { if (_instance) { _instance->octave_5 (); } }
248 static void se_octave_6 () { if (_instance) { _instance->octave_6 (); } }
249 static void se_octave_7 () { if (_instance) { _instance->octave_7 (); } }
250 static void se_octave_8 () { if (_instance) { _instance->octave_8 (); } }
251 static void se_octave_9 () { if (_instance) { _instance->octave_9 (); } }
252 static void se_octave_10 () { if (_instance) { _instance->octave_10 (); } }
253 static void se_dot_change (GtkAction* act) { if (_instance) { _instance->dot_change (act); } }
254 static void se_dot_value_change () { if (_instance) { _instance->dot_value_change (); } }
255 static void se_toggle_triplet() { if (_instance) { _instance->toggle_triplet (); } }
256 static void se_toggle_chord() { if (_instance) { _instance->toggle_chord (); } }
257 static void se_do_sustain () { if (_instance) { _instance->do_sustain (); } }
258 static void se_back() { if (_instance) { _instance->back (); } }
259 static void se_sync_to_edit_point () { if (_instance) { _instance->sync_to_edit_point (); } }
261 static void load_bindings ();
262 static Gtkmm2ext::Bindings* bindings;
263 static void register_actions ();
266 #endif /* __gtk2_ardour_step_entry_h__ */