lotsa keybindings for nearly everything in the step editor
[ardour.git] / gtk2_ardour / step_entry.h
1 /*
2     Copyright (C) 2010 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __gtk2_ardour_step_entry_h__
21 #define __gtk2_ardour_step_entry_h__
22
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>
29
30 #include "ardour_dialog.h"
31 #include "gtk_pianokeyboard.h"
32
33 class MidiTimeAxisView;
34
35 class StepEntry : public ArdourDialog
36 {
37   public:
38         StepEntry (MidiTimeAxisView&);
39         ~StepEntry ();
40
41         void note_off_event_handler (int note);
42         void rest_event_handler ();
43
44         Evoral::MusicalTime note_length();
45         uint8_t note_velocity() const;
46         uint8_t note_channel() const;
47         
48         int current_octave () const { return (int) floor (octave_adjustment.get_value()); }
49         
50   private:
51         Evoral::MusicalTime _current_note_length;
52         uint8_t _current_note_velocity;
53
54         Gtk::VBox packer;
55         Gtk::HBox upper_box;
56         Gtk::HBox note_length_box;
57         Gtk::HBox note_velocity_box;
58
59         Gtk::ToggleButton chord_button;
60         Gtk::ToggleButton triplet_button;
61         Gtk::ToggleButton dot_button;
62         Gtk::ToggleButton restart_button;
63
64         Gtk::VBox   resync_box;
65         Gtk::Button beat_resync_button;
66         Gtk::Button bar_resync_button;
67
68         Gtk::Button sustain_button;
69         Gtk::Button rest_button;
70         Gtk::Button grid_rest_button;
71         Gtk::VBox   rest_box;
72
73         Gtk::RadioButton length_1_button;
74         Gtk::RadioButton length_2_button;
75         Gtk::RadioButton length_4_button;
76         Gtk::RadioButton length_8_button;
77         Gtk::RadioButton length_12_button;
78         Gtk::RadioButton length_16_button;
79         Gtk::RadioButton length_32_button;
80         Gtk::RadioButton length_64_button;
81
82         Gtk::RadioButton velocity_ppp_button;
83         Gtk::RadioButton velocity_pp_button;
84         Gtk::RadioButton velocity_p_button;
85         Gtk::RadioButton velocity_mp_button;
86         Gtk::RadioButton velocity_mf_button;
87         Gtk::RadioButton velocity_f_button;
88         Gtk::RadioButton velocity_ff_button;
89         Gtk::RadioButton velocity_fff_button;
90
91         Gtk::Adjustment channel_adjustment;
92         Gtk::SpinButton channel_spinner;
93
94         Gtk::Adjustment octave_adjustment;
95         Gtk::SpinButton octave_spinner;
96
97         Gtk::Adjustment length_divisor_adjustment;
98         Gtk::SpinButton length_divisor_spinner;
99
100         Gtk::Adjustment velocity_adjustment;
101         Gtk::SpinButton velocity_spinner;
102
103         Gtk::Adjustment bank_adjustment;
104         Gtk::SpinButton bank_spinner;
105         Gtk::Button     bank_button;
106
107         Gtk::Adjustment program_adjustment;
108         Gtk::SpinButton program_spinner;
109         Gtk::Button     program_button;
110
111         void length_changed ();
112         void velocity_changed ();
113         void velocity_value_change ();
114         void length_value_change ();
115
116         PianoKeyboard* _piano;
117         Gtk::Widget* piano;
118         MidiTimeAxisView* _mtv;
119
120         void bank_click ();
121         void program_click ();
122         void beat_resync_click ();
123         void bar_resync_click ();
124
125         bool piano_enter_notify_event (GdkEventCrossing *ev);
126         bool on_key_release_event (GdkEventKey*);
127         bool on_key_press_event (GdkEventKey*);
128
129         void on_show ();
130
131         /* actions */
132
133         void register_actions ();
134         Gtkmm2ext::ActionMap myactions;
135
136         void insert_note (uint8_t);
137         void insert_rest ();
138         void insert_grid_rest ();
139
140         void insert_a ();
141         void insert_asharp ();
142         void insert_b ();
143         void insert_c ();
144         void insert_csharp ();
145         void insert_d ();
146         void insert_dsharp ();
147         void insert_e ();
148         void insert_f ();
149         void insert_fsharp ();
150         void insert_g ();
151         void insert_gsharp ();
152         
153         void note_length_change (GtkAction*);
154         void note_velocity_change (GtkAction*);
155
156         bool radio_button_press (GdkEventButton*);
157         bool radio_button_release (GdkEventButton*, Gtk::RadioButton*, int);
158
159         void load_bindings ();
160         Gtkmm2ext::Bindings  bindings;
161
162         void inc_note_velocity ();
163         void dec_note_velocity ();
164         void next_note_velocity ();
165         void prev_note_velocity ();
166
167         void inc_note_length ();
168         void dec_note_length ();
169         void next_note_length ();
170         void prev_note_length ();
171
172         void next_octave ();
173         void prev_octave ();
174
175         void octave_n (int n);
176         void octave_0 () { octave_n (0); }
177         void octave_1 () { octave_n (1); }
178         void octave_2 () { octave_n (2); }
179         void octave_3 () { octave_n (3); }
180         void octave_4 () { octave_n (4); }
181         void octave_5 () { octave_n (5); }
182         void octave_6 () { octave_n (6); }
183         void octave_7 () { octave_n (7); }
184         void octave_8 () { octave_n (8); }
185         void octave_9 () { octave_n (9); }
186         void octave_10 () { octave_n (10); }
187
188         void toggle_dotted();
189         void toggle_triplet();
190         void toggle_chord();
191         
192         void do_sustain ();
193 };
194
195 #endif /* __gtk2_ardour_step_entry_h__ */