]> git.cworth.org Git - scherzo/commitdiff
Add a keybinding for Enter to clear all notes
authorCarl Worth <cworth@cworth.org>
Tue, 1 Oct 2013 15:57:15 +0000 (08:57 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 1 Oct 2013 16:30:48 +0000 (09:30 -0700)
This shouldn't actually be necessary, but in case there are ever any
stuck notes, this can help to clear them.

scherzo.c

index e57ccbe9b3fe7f831d535bf73d77544d62dce04e..d1a9e9f5d98bf5fd0cdaf993fccb6a8f2dea5d2f 100644 (file)
--- a/scherzo.c
+++ b/scherzo.c
@@ -100,6 +100,12 @@ _judge_pitch (scherzo_t *scherzo, pitch_t pitch);
 static void
 _score_challenge (scherzo_t *scherzo);
 
+static void
+pitch_group_remove_pitches (pitch_group_t *group);
+
+static void
+scherzo_update_notes_and_chord (scherzo_t *scherzo);
+
 static int
 on_delete_event_quit (unused (GtkWidget *widget),
                      unused (GdkEvent *event),
@@ -270,6 +276,12 @@ on_key_press_event (GtkWidget *widget,
     case GDK_KEY_space:
        scherzo_press_pedal (scherzo);
        break;
+    case GDK_KEY_Return:
+       /* Clear all notes when Return is pressed. */
+       pitch_group_remove_pitches (&scherzo->notes_pressed);
+       pitch_group_remove_pitches (&scherzo->notes_pedaled);
+       scherzo_update_notes_and_chord (scherzo);
+       break;
     }
 
     if (pitch != PITCH_NOT_A_PITCH) 
@@ -281,7 +293,6 @@ on_key_press_event (GtkWidget *widget,
        return TRUE;
     }
 
-
     /* Allow an unhandled event to propagate to other handlers. */
     return FALSE;
 }
@@ -1085,6 +1096,14 @@ pitch_group_remove_pitch (pitch_group_t *group, pitch_t pitch)
 }
 */
 
+/* Remove all pitches from a pitch_group_t */
+static void
+pitch_group_remove_pitches (pitch_group_t *group)
+{
+    talloc_free (group->pitches);
+    pitch_group_init (group->ctx, group);
+}
+
 static void
 scherzo_update_notes_and_chord (scherzo_t *scherzo)
 {