more changes flowing from a persistent MonitorSection object
[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_window.h"
31 #include "gtk_pianokeyboard.h"
32
33 class StepEditor;
34
35 class StepEntry : public ArdourWindow
36 {
37 public:
38         StepEntry (StepEditor&);
39         ~StepEntry ();
40
41         void note_off_event_handler (int note);
42         void rest_event_handler ();
43
44         Temporal::Beats 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         Temporal::Beats _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 dot0_button;
62         Gtk::ToggleButton dot1_button;
63         Gtk::ToggleButton dot2_button;
64         Gtk::ToggleButton dot3_button;
65         Gtk::Adjustment   dot_adjustment;
66         Gtk::VBox dot_box1;
67         Gtk::VBox dot_box2;
68         Gtk::ToggleButton restart_button;
69
70         Gtk::VBox   resync_box;
71         Gtk::Button beat_resync_button;
72         Gtk::Button bar_resync_button;
73         Gtk::Button resync_button;
74
75         Gtk::Button sustain_button;
76         Gtk::Button rest_button;
77         Gtk::Button grid_rest_button;
78         Gtk::VBox   rest_box;
79
80         Gtk::Button back_button;
81
82         Gtk::RadioButton length_1_button;
83         Gtk::RadioButton length_2_button;
84         Gtk::RadioButton length_4_button;
85         Gtk::RadioButton length_8_button;
86         Gtk::RadioButton length_12_button;
87         Gtk::RadioButton length_16_button;
88         Gtk::RadioButton length_32_button;
89         Gtk::RadioButton length_64_button;
90
91         Gtk::RadioButton velocity_ppp_button;
92         Gtk::RadioButton velocity_pp_button;
93         Gtk::RadioButton velocity_p_button;
94         Gtk::RadioButton velocity_mp_button;
95         Gtk::RadioButton velocity_mf_button;
96         Gtk::RadioButton velocity_f_button;
97         Gtk::RadioButton velocity_ff_button;
98         Gtk::RadioButton velocity_fff_button;
99
100         Gtk::Adjustment channel_adjustment;
101         Gtk::SpinButton channel_spinner;
102
103         Gtk::Adjustment octave_adjustment;
104         Gtk::SpinButton octave_spinner;
105
106         Gtk::Adjustment length_divisor_adjustment;
107         Gtk::SpinButton length_divisor_spinner;
108
109         Gtk::Adjustment velocity_adjustment;
110         Gtk::SpinButton velocity_spinner;
111
112         Gtk::Adjustment bank_adjustment;
113         Gtk::SpinButton bank_spinner;
114         Gtk::Button     bank_button;
115
116         Gtk::Adjustment program_adjustment;
117         Gtk::SpinButton program_spinner;
118         Gtk::Button     program_button;
119
120         void length_changed ();
121         void velocity_changed ();
122         void velocity_value_change ();
123         void length_value_change ();
124
125         PianoKeyboard* _piano;
126         Gtk::Widget* piano;
127         StepEditor*   se;
128
129         void bank_click ();
130         void program_click ();
131         void beat_resync_click ();
132         void bar_resync_click ();
133
134         bool piano_enter_notify_event (GdkEventCrossing *ev);
135         bool on_key_release_event (GdkEventKey*);
136         bool on_key_press_event (GdkEventKey*);
137
138         void on_show ();
139
140         /* actions */
141
142         void register_actions ();
143
144         void insert_note (uint8_t);
145         void insert_rest ();
146         void insert_grid_rest ();
147
148         void insert_a ();
149         void insert_asharp ();
150         void insert_b ();
151         void insert_c ();
152         void insert_csharp ();
153         void insert_d ();
154         void insert_dsharp ();
155         void insert_e ();
156         void insert_f ();
157         void insert_fsharp ();
158         void insert_g ();
159         void insert_gsharp ();
160
161         void note_length_change (GtkAction*);
162         void note_velocity_change (GtkAction*);
163
164         bool radio_button_press (GdkEventButton*);
165         bool radio_button_release (GdkEventButton*, Gtk::RadioButton*, int);
166
167         void load_bindings ();
168         Gtkmm2ext::Bindings*  bindings;
169
170         void inc_note_velocity ();
171         void dec_note_velocity ();
172         void next_note_velocity ();
173         void prev_note_velocity ();
174
175         void inc_note_length ();
176         void dec_note_length ();
177         void next_note_length ();
178         void prev_note_length ();
179
180         void next_octave ();
181         void prev_octave ();
182
183         void octave_n (int n);
184         void octave_0 () { octave_n (0); }
185         void octave_1 () { octave_n (1); }
186         void octave_2 () { octave_n (2); }
187         void octave_3 () { octave_n (3); }
188         void octave_4 () { octave_n (4); }
189         void octave_5 () { octave_n (5); }
190         void octave_6 () { octave_n (6); }
191         void octave_7 () { octave_n (7); }
192         void octave_8 () { octave_n (8); }
193         void octave_9 () { octave_n (9); }
194         void octave_10 () { octave_n (10); }
195
196         void dot_change (GtkAction*);
197         void dot_value_change ();
198
199         void toggle_triplet();
200         void toggle_chord();
201
202         void do_sustain ();
203         void back();
204         void sync_to_edit_point ();
205 };
206
207 #endif /* __gtk2_ardour_step_entry_h__ */