-MidiRegionView::key_press (GdkEventKey* ev)
-{
- /* since GTK bindings are generally activated on press, and since
- detectable auto-repeat is the name of the game and only sends
- repeated presses, carry out key actions at key press, not release.
- */
-
- if (ev->keyval == GDK_Alt_L || ev->keyval == GDK_Alt_R){
- _mouse_state = SelectTouchDragging;
- return true;
-
- } else if (ev->keyval == GDK_Escape) {
- clear_selection();
- _mouse_state = None;
-
- } else if (ev->keyval == GDK_comma || ev->keyval == GDK_period) {
-
- bool start = (ev->keyval == GDK_comma);
- bool end = (ev->keyval == GDK_period);
- bool shorter = Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier);
- bool fine = Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier);
-
- change_note_lengths (fine, shorter, 0.0, start, end);
-
- return true;
-
- } else if (ev->keyval == GDK_Delete) {
-
- delete_selection();
- return true;
-
- } else if (ev->keyval == GDK_Tab) {
-
- if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
- goto_previous_note ();
- } else {
- goto_next_note ();
- }
- return true;
-
- } else if (ev->keyval == GDK_Up) {
-
- bool allow_smush = Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier);
- bool fine = !Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier);
-
- if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) {
- change_velocities (true, fine, allow_smush);
- } else {
- transpose (true, fine, allow_smush);
- }
- return true;
-
- } else if (ev->keyval == GDK_Down) {
-
- bool allow_smush = Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier);
- bool fine = !Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier);
-
- if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) {
- change_velocities (false, fine, allow_smush);
- } else {
- transpose (false, fine, allow_smush);
- }
- return true;
-
- } else if (ev->keyval == GDK_Left) {
-
- nudge_notes (false);
- return true;
-
- } else if (ev->keyval == GDK_Right) {
-
- nudge_notes (true);
- return true;
-
- } else if (ev->keyval == GDK_Control_L) {
- return true;
-
- }
-
- return false;
+MidiRegionView::key_release (GdkEventKey* ev)
+{
+ if ((_mouse_state == SelectTouchDragging) && (ev->keyval == GDK_Alt_L || ev->keyval == GDK_Alt_R)) {
+ _mouse_state = None;
+ return true;
+ }
+ return false;
+}
+
+void
+MidiRegionView::channel_edit ()
+{
+ if (_selection.empty()) {
+ return;
+ }
+
+ /* pick a note somewhat at random (since Selection is a set<>) to
+ * provide the "current" channel for the dialog.
+ */
+
+ uint8_t current_channel = (*_selection.begin())->note()->channel ();
+ MidiChannelDialog channel_dialog (current_channel);
+ int ret = channel_dialog.run ();
+
+ switch (ret) {
+ case Gtk::RESPONSE_OK:
+ break;
+ default:
+ return;
+ }
+
+ uint8_t new_channel = channel_dialog.active_channel ();
+
+ start_note_diff_command (_("channel edit"));
+
+ for (Selection::iterator i = _selection.begin(); i != _selection.end(); ) {
+ Selection::iterator next = i;
+ ++next;
+ change_note_channel (*i, new_channel);
+ i = next;
+ }
+
+ apply_diff ();