X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=scherzo.c;h=d1a9e9f5d98bf5fd0cdaf993fccb6a8f2dea5d2f;hb=3408abbc3a573ee14378aa7bd06d79ada529aded;hp=e57ccbe9b3fe7f831d535bf73d77544d62dce04e;hpb=fbfb0b3acfebeb22fae538588557f523ee539617;p=scherzo 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) {