From: Carl Worth Date: Tue, 1 Oct 2013 15:57:15 +0000 (-0700) Subject: Add a keybinding for Enter to clear all notes X-Git-Url: https://git.cworth.org/git?p=scherzo;a=commitdiff_plain;h=3408abbc3a573ee14378aa7bd06d79ada529aded Add a keybinding for Enter to clear all notes This shouldn't actually be necessary, but in case there are ever any stuck notes, this can help to clear them. --- diff --git a/scherzo.c b/scherzo.c index e57ccbe..d1a9e9f 100644 --- 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) {