Ardour  9.0-pre0-582-g084a23a80d
step_entry.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2018 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2011-2015 David Robillard <d@drobilla.net>
4  * Copyright (C) 2021-2022 Robin Gareus <robin@gareus.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __gtk2_ardour_step_entry_h__
22 #define __gtk2_ardour_step_entry_h__
23 
24 #include <gtkmm/togglebutton.h>
25 #include <gtkmm/radiobutton.h>
26 #include <gtkmm/spinbutton.h>
27 #include <gtkmm/box.h>
28 #include <gtkmm/adjustment.h>
29 #include <gtkmm/sizegroup.h>
30 
31 #include <gtkmm2ext/bindings.h>
32 #include "temporal/tempo.h"
33 
34 #include "widgets/ardour_button.h"
35 
36 #include "ardour_window.h"
37 #include "pianokeyboard.h"
38 
39 class StepEditor;
40 
51 class StepEntry : public ArdourWindow
52 {
53 public:
54  static StepEntry& instance();
55 
57 
59 
61  uint8_t note_velocity() const;
62  uint8_t note_channel() const;
63 
64  int current_octave () const { return (int) floor (octave_adjustment.get_value()); }
65 
67 
68 private:
71 
72  void note_off_event_handler (int note);
74 
77 
82 
92 
97 
102 
104 
106 
115 
124 
127 
130 
133 
136 
140 
144 
147 
149 
151 
152  void bank_click ();
153  void program_click ();
156 
160 
161  void on_show ();
162 
163  /* actions */
164 
165  void insert_note (uint8_t);
166  void insert_rest ();
168  void insert_a ();
169  void insert_asharp ();
170  void insert_b ();
171  void insert_c ();
172  void insert_csharp ();
173  void insert_d ();
174  void insert_dsharp ();
175  void insert_e ();
176  void insert_f ();
177  void insert_fsharp ();
178  void insert_g ();
179  void insert_gsharp ();
191  void next_octave ();
192  void prev_octave ();
193  void octave_n (int n);
194  void octave_0 () { octave_n (0); }
195  void octave_1 () { octave_n (1); }
196  void octave_2 () { octave_n (2); }
197  void octave_3 () { octave_n (3); }
198  void octave_4 () { octave_n (4); }
199  void octave_5 () { octave_n (5); }
200  void octave_6 () { octave_n (6); }
201  void octave_7 () { octave_n (7); }
202  void octave_8 () { octave_n (8); }
203  void octave_9 () { octave_n (9); }
204  void octave_10 () { octave_n (10); }
208  void toggle_chord();
209  void do_sustain ();
210  void back();
212 
213  /* static versions of action methods, so that we can register actions without
214  having an actual StepEntry object.
215  */
216 
217  static void se_insert_rest () { if (_instance) { _instance->insert_rest (); } }
218  static void se_insert_grid_rest () { if (_instance) { _instance->insert_grid_rest (); } }
219  static void se_insert_a () { if (_instance) { _instance->insert_a (); } }
220  static void se_insert_asharp () { if (_instance) { _instance->insert_asharp (); } }
221  static void se_insert_b () { if (_instance) { _instance->insert_b (); } }
222  static void se_insert_c () { if (_instance) { _instance->insert_c (); } }
223  static void se_insert_csharp () { if (_instance) { _instance->insert_csharp (); } }
224  static void se_insert_d () { if (_instance) { _instance->insert_d (); } }
225  static void se_insert_dsharp () { if (_instance) { _instance->insert_dsharp (); } }
226  static void se_insert_e () { if (_instance) { _instance->insert_e (); } }
227  static void se_insert_f () { if (_instance) { _instance->insert_f (); } }
228  static void se_insert_fsharp () { if (_instance) { _instance->insert_fsharp (); } }
229  static void se_insert_g () { if (_instance) { _instance->insert_g (); } }
230  static void se_insert_gsharp () { if (_instance) { _instance->insert_gsharp (); } }
231  static void se_note_length_change (GtkAction* act) { if (_instance) { _instance->note_length_change (act); } }
237  static void se_inc_note_length () { if (_instance) { _instance->inc_note_length (); } }
238  static void se_dec_note_length () { if (_instance) { _instance->dec_note_length (); } }
239  static void se_next_note_length () { if (_instance) { _instance->next_note_length (); } }
240  static void se_prev_note_length () { if (_instance) { _instance->prev_note_length (); } }
241  static void se_next_octave () { if (_instance) { _instance->next_octave (); } }
242  static void se_prev_octave () { if (_instance) { _instance->prev_octave (); } }
243  static void se_octave_n (int n) { if (_instance) { _instance->octave_n (n); } }
244  static void se_octave_0 () { if (_instance) { _instance->octave_0 (); } }
245  static void se_octave_1 () { if (_instance) { _instance->octave_1 (); } }
246  static void se_octave_2 () { if (_instance) { _instance->octave_2 (); } }
247  static void se_octave_3 () { if (_instance) { _instance->octave_3 (); } }
248  static void se_octave_4 () { if (_instance) { _instance->octave_4 (); } }
249  static void se_octave_5 () { if (_instance) { _instance->octave_5 (); } }
250  static void se_octave_6 () { if (_instance) { _instance->octave_6 (); } }
251  static void se_octave_7 () { if (_instance) { _instance->octave_7 (); } }
252  static void se_octave_8 () { if (_instance) { _instance->octave_8 (); } }
253  static void se_octave_9 () { if (_instance) { _instance->octave_9 (); } }
254  static void se_octave_10 () { if (_instance) { _instance->octave_10 (); } }
255  static void se_dot_change (GtkAction* act) { if (_instance) { _instance->dot_change (act); } }
256  static void se_dot_value_change () { if (_instance) { _instance->dot_value_change (); } }
257  static void se_toggle_triplet() { if (_instance) { _instance->toggle_triplet (); } }
258  static void se_toggle_chord() { if (_instance) { _instance->toggle_chord (); } }
259  static void se_do_sustain () { if (_instance) { _instance->do_sustain (); } }
260  static void se_back() { if (_instance) { _instance->back (); } }
262 
263  static void load_bindings ();
265  static void register_actions ();
266 };
267 
268 #endif /* __gtk2_ardour_step_entry_h__ */
double get_value() const
static void se_octave_7()
Definition: step_entry.h:251
static void se_insert_fsharp()
Definition: step_entry.h:228
uint8_t _current_note_velocity
Definition: step_entry.h:76
ArdourWidgets::ArdourButton velocity_mp_button
Definition: step_entry.h:119
void velocity_value_change()
static void se_toggle_chord()
Definition: step_entry.h:258
static void se_octave_10()
Definition: step_entry.h:254
void insert_fsharp()
Gtk::Button bank_button
Definition: step_entry.h:139
static void se_back()
Definition: step_entry.h:260
void do_sustain()
void prev_octave()
uint8_t note_channel() const
void dot_change(GtkAction *)
void next_octave()
Gtk::Button rest_button
Definition: step_entry.h:99
void insert_asharp()
void on_show()
This is a default handler for the signal signal_show().
Gtk::ToggleButton dot3_button
Definition: step_entry.h:87
void insert_dsharp()
ArdourWidgets::ArdourButton velocity_mf_button
Definition: step_entry.h:120
static void se_prev_note_length()
Definition: step_entry.h:240
Gtk::HBox note_length_box
Definition: step_entry.h:80
ArdourWidgets::ArdourButton chord_button
Definition: step_entry.h:105
ArdourWidgets::ArdourButton velocity_ppp_button
Definition: step_entry.h:116
void back()
static void se_insert_grid_rest()
Definition: step_entry.h:218
Gtk::VBox rest_box
Definition: step_entry.h:101
static void se_insert_g()
Definition: step_entry.h:229
ArdourWidgets::ArdourButton length_4_button
Definition: step_entry.h:109
ArdourWidgets::ArdourButton length_1_button
Definition: step_entry.h:107
static void se_octave_3()
Definition: step_entry.h:247
Gtk::ToggleButton dot1_button
Definition: step_entry.h:85
void insert_f()
static void se_insert_csharp()
Definition: step_entry.h:223
Gtk::Adjustment program_adjustment
Definition: step_entry.h:141
void insert_gsharp()
static void se_octave_0()
Definition: step_entry.h:244
void insert_a()
static void se_do_sustain()
Definition: step_entry.h:259
void octave_9()
Definition: step_entry.h:203
void octave_0()
Definition: step_entry.h:194
void octave_6()
Definition: step_entry.h:200
static void se_toggle_triplet()
Definition: step_entry.h:257
APianoKeyboard _piano
Definition: step_entry.h:148
void insert_g()
static void se_dot_change(GtkAction *act)
Definition: step_entry.h:255
static void load_bindings()
static void se_octave_4()
Definition: step_entry.h:248
void note_off_event_handler(int note)
Gtk::HBox upper_box
Definition: step_entry.h:79
static void se_octave_8()
Definition: step_entry.h:252
void octave_8()
Definition: step_entry.h:202
static void se_insert_f()
Definition: step_entry.h:227
Gtk::Button sustain_button
Definition: step_entry.h:98
void note_velocity_change(GtkAction *)
Gtk::ToggleButton dot2_button
Definition: step_entry.h:86
static void se_insert_d()
Definition: step_entry.h:224
void bar_resync_click()
static void se_prev_note_velocity()
Definition: step_entry.h:236
Temporal::Beats note_length()
Gtk::HBox note_velocity_box
Definition: step_entry.h:81
Gtk::Button program_button
Definition: step_entry.h:143
Gtk::Button resync_button
Definition: step_entry.h:96
Gtk::SpinButton channel_spinner
Definition: step_entry.h:126
void program_click()
void octave_10()
Definition: step_entry.h:204
void note_length_change(GtkAction *)
void rest_event_handler()
static void se_octave_9()
Definition: step_entry.h:253
void toggle_chord()
bool on_key_press_event(GdkEventKey *)
This is a default handler for the signal signal_key_press_event().
void insert_c()
Gtk::SpinButton length_divisor_spinner
Definition: step_entry.h:132
uint8_t note_velocity() const
static StepEntry * _instance
Definition: step_entry.h:69
static void se_octave_n(int n)
Definition: step_entry.h:243
ArdourWidgets::ArdourButton velocity_f_button
Definition: step_entry.h:121
void set_step_editor(StepEditor *)
Gtk::Adjustment dot_adjustment
Definition: step_entry.h:88
Gtk::SpinButton octave_spinner
Definition: step_entry.h:129
static void se_insert_a()
Definition: step_entry.h:219
void octave_n(int n)
void octave_2()
Definition: step_entry.h:196
static void se_dec_note_length()
Definition: step_entry.h:238
static void se_insert_dsharp()
Definition: step_entry.h:225
void sync_to_edit_point()
static void se_insert_gsharp()
Definition: step_entry.h:230
void octave_5()
Definition: step_entry.h:199
static void se_dec_note_velocity()
Definition: step_entry.h:234
static void se_octave_5()
Definition: step_entry.h:249
Gtk::SpinButton velocity_spinner
Definition: step_entry.h:135
Gtk::Button grid_rest_button
Definition: step_entry.h:100
ArdourWidgets::ArdourButton length_16_button
Definition: step_entry.h:112
void octave_4()
Definition: step_entry.h:198
static void se_prev_octave()
Definition: step_entry.h:242
ArdourWidgets::ArdourButton length_64_button
Definition: step_entry.h:114
static void se_inc_note_velocity()
Definition: step_entry.h:233
void insert_e()
static void se_next_note_length()
Definition: step_entry.h:239
static void se_insert_e()
Definition: step_entry.h:226
Gtk::Button beat_resync_button
Definition: step_entry.h:94
Gtk::ToggleButton restart_button
Definition: step_entry.h:91
Gtk::VBox packer
Definition: step_entry.h:78
void prev_note_length()
void beat_resync_click()
void next_note_velocity()
void insert_csharp()
void octave_3()
Definition: step_entry.h:197
StepEditor * se
Definition: step_entry.h:150
Gtk::Adjustment velocity_adjustment
Definition: step_entry.h:134
static void se_octave_2()
Definition: step_entry.h:246
ArdourWidgets::ArdourButton length_32_button
Definition: step_entry.h:113
void dec_note_velocity()
int current_octave() const
Definition: step_entry.h:64
static void se_insert_rest()
Definition: step_entry.h:217
Gtk::VBox dot_box1
Definition: step_entry.h:89
void octave_1()
Definition: step_entry.h:195
void octave_7()
Definition: step_entry.h:201
static void se_octave_1()
Definition: step_entry.h:245
void toggle_triplet()
void prev_note_velocity()
Gtk::ToggleButton dot0_button
Definition: step_entry.h:84
Gtk::Button back_button
Definition: step_entry.h:103
Gtk::SpinButton program_spinner
Definition: step_entry.h:142
Gtk::SpinButton bank_spinner
Definition: step_entry.h:138
ArdourWidgets::ArdourButton velocity_pp_button
Definition: step_entry.h:117
Gtk::Adjustment channel_adjustment
Definition: step_entry.h:125
ArdourWidgets::ArdourButton velocity_ff_button
Definition: step_entry.h:122
void length_value_change()
void bank_click()
void insert_grid_rest()
bool on_key_release_event(GdkEventKey *)
This is a default handler for the signal signal_key_release_event().
void dot_value_change()
static void se_octave_6()
Definition: step_entry.h:250
void insert_rest()
static void se_insert_c()
Definition: step_entry.h:222
void insert_d()
void insert_note(uint8_t)
void inc_note_length()
Temporal::Beats _current_note_length
Definition: step_entry.h:75
Gtk::ToggleButton triplet_button
Definition: step_entry.h:83
static Gtkmm2ext::Bindings * bindings
Definition: step_entry.h:264
bool radio_button_press(GdkEventButton *)
ArdourWidgets::ArdourButton velocity_p_button
Definition: step_entry.h:118
Gtk::VBox resync_box
Definition: step_entry.h:93
static void setup_actions_and_bindings()
void insert_b()
static void se_note_velocity_change(GtkAction *act)
Definition: step_entry.h:232
static void se_insert_asharp()
Definition: step_entry.h:220
Gtk::Adjustment bank_adjustment
Definition: step_entry.h:137
void inc_note_velocity()
static void register_actions()
Gtk::Adjustment octave_adjustment
Definition: step_entry.h:128
static void se_dot_value_change()
Definition: step_entry.h:256
ArdourWidgets::ArdourButton velocity_fff_button
Definition: step_entry.h:123
static void se_inc_note_length()
Definition: step_entry.h:237
Gtk::Button bar_resync_button
Definition: step_entry.h:95
bool piano_enter_notify_event(GdkEventCrossing *ev)
Gtk::Adjustment length_divisor_adjustment
Definition: step_entry.h:131
static StepEntry & instance()
void dec_note_length()
static void se_sync_to_edit_point()
Definition: step_entry.h:261
ArdourWidgets::ArdourButton length_2_button
Definition: step_entry.h:108
Gtk::VBox dot_box2
Definition: step_entry.h:90
void next_note_length()
static void se_next_note_velocity()
Definition: step_entry.h:235
static void se_insert_b()
Definition: step_entry.h:221
ArdourWidgets::ArdourButton length_12_button
Definition: step_entry.h:111
static void se_next_octave()
Definition: step_entry.h:241
static void se_note_length_change(GtkAction *act)
Definition: step_entry.h:231
ArdourWidgets::ArdourButton length_8_button
Definition: step_entry.h:110