X-Git-Url: https://git.cworth.org/git?p=scherzo;a=blobdiff_plain;f=score.c;h=b2866096e3c0183c254ae6ae3838e9325c637dcb;hp=7a1c231a4b82cfdcef0d972dcf88ac6c1168e645;hb=03f4abc3182dfe2602d44d38ce7b3db2892e018e;hpb=e808e5df23cb5d8deb23296c38d1eb6b4581563d diff --git a/score.c b/score.c index 7a1c231..b286609 100644 --- a/score.c +++ b/score.c @@ -18,6 +18,8 @@ * along with this program. If not, see http://www.gnu.org/licenses/ . */ +#include + #include "score.h" struct score_staff @@ -222,7 +224,6 @@ _draw_staff (score_t *score, cairo_t *cr, { int i; cairo_glyph_t clef_glyph; - cairo_text_extents_t clef_extents; cairo_save (cr); @@ -249,8 +250,6 @@ _draw_staff (score_t *score, cairo_t *cr, cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */ cairo_show_glyphs (cr, &clef_glyph, 1); - cairo_glyph_extents (cr, &clef_glyph, 1, &clef_extents); - /* Draw staff lines */ for (i = 0; i < 5; i++) { cairo_move_to (cr, 0, i * score->space_height + score->line_width / 2.0); @@ -263,12 +262,14 @@ _draw_staff (score_t *score, cairo_t *cr, cairo_stroke (cr); /* Make space for clef before drawing notes */ - cairo_translate (cr, (int) (1.5 * clef_extents.width), 0); + cairo_translate (cr, (int) (4 * score->space_height), 0); /* Draw notes */ for (i = 0; i < staff->num_notes; i++) { _draw_note (score, cr, staff, staff->notes[i]); + /* Draw all notes concurrent for now (as a chord) cairo_translate (cr, score->space_height * 2.0, 0); + */ } cairo_restore (cr); @@ -402,3 +403,47 @@ score_staff_add_note (score_staff_t *staff, return note; } +void +score_staff_remove_note (score_staff_t *staff, score_note_t *note) +{ + int i; + + for (i = 0; i < staff->num_notes; i++) + if (staff->notes[i] == note) + break; + + if (i == staff->num_notes) + return; + + if (i < staff->num_notes - 1) + { + memmove (staff->notes + i, + staff->notes + i + 1, + (staff->num_notes - 1 - i) * sizeof (score_note_t *)); + } + + staff->num_notes -= 1; +} + +score_note_t * +score_staff_find_note (score_staff_t *staff, + score_pitch_t pitch, + int octave, + score_duration_t duration) +{ + int i; + score_note_t *note; + + for (i = 0; i < staff->num_notes; i++) { + note = staff->notes[i]; + if (note->pitch == pitch && + note->octave == octave && + note->duration == duration) + { + return note; + } + } + + return NULL; +} +