X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fgregorian-ligature-engraver.cc;h=f2ff7ee5c7d72597bcda9c6b95308694590b16f1;hb=ade98f4d66d4ba96d239b06c4ab9eefffad1381f;hp=230a0e5425dc81de0ef9e562a441fde5818927df;hpb=b37e3f652677ae0298423db9fa0e552e5fce0c92;p=lilypond.git diff --git a/lily/gregorian-ligature-engraver.cc b/lily/gregorian-ligature-engraver.cc index 230a0e5425..f2ff7ee5c7 100644 --- a/lily/gregorian-ligature-engraver.cc +++ b/lily/gregorian-ligature-engraver.cc @@ -1,9 +1,20 @@ /* - gregorian-ligature-engraver.cc -- implement Gregorian_ligature_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2003--2010 Juergen Reuter - (c) 2003--2006 Juergen Reuter + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "gregorian-ligature-engraver.hh" @@ -14,8 +25,12 @@ #include "pitch.hh" #include "spanner.hh" #include "staff-symbol-referencer.hh" +#include "stream-event.hh" #include "warn.hh" +/* ASSIGN_EVENT_ONCE */ +#include "translator.icc" + /* * This abstract class is the common superclass for all ligature * engravers for Gregorian chant notation. It cares for the musical @@ -32,19 +47,13 @@ Gregorian_ligature_engraver::Gregorian_ligature_engraver () pes_or_flexa_req_ = 0; } -bool -Gregorian_ligature_engraver::try_music (Music *m) +void +Gregorian_ligature_engraver::listen_pes_or_flexa (Stream_event *ev) { - if (m->is_mus_type ("pes-or-flexa-event")) - { - pes_or_flexa_req_ = m; - return true; - } - else - return Ligature_engraver::try_music (m); + ASSIGN_EVENT_ONCE (pes_or_flexa_req_, ev); } -void fix_prefix (char *name, int mask, +void fix_prefix (char const *name, int mask, int *current_set, int min_set, int max_set, Grob *primitive) { @@ -84,10 +93,10 @@ void fix_prefix_set (int *current_set, int min_set, int max_set, Grob *primitive fix_prefix ("pes_or_flexa", LINEA, current_set, min_set, max_set, primitive); } -void check_and_fix_all_prefixes (Array primitives) +void check_and_fix_all_prefixes (vector primitives) { - /* Check for illegal head modifier combinations */ - for (int i = 0; i < primitives.size (); i++) + /* Check for invalid head modifier combinations */ + for (vsize i = 0; i < primitives.size (); i++) { Grob *primitive = primitives[i].grob (); @@ -195,35 +204,37 @@ void check_and_fix_all_prefixes (Array primitives) * Marks those heads that participate in a pes or flexa. */ void -provide_context_info (Array primitives) +provide_context_info (vector primitives) { Grob *prev_primitive = 0; int prev_prefix_set = 0; int prev_context_info = 0; int prev_pitch = 0; - for (int i = 0; i < primitives.size (); i++) + for (vsize i = 0; i < primitives.size (); i++) { Grob *primitive = primitives[i].grob (); - Music *music_cause = primitives[i].music_cause (); + Stream_event *event_cause = primitives[i].event_cause (); int context_info = 0; - int pitch = unsmob_pitch (music_cause->get_property ("pitch"))->steps (); + int pitch = unsmob_pitch (event_cause->get_property ("pitch"))->steps (); int prefix_set = scm_to_int (primitive->get_property ("prefix-set")); if (prefix_set & PES_OR_FLEXA) - if (!i) // ligature may not start with 2nd head of pes or flexa - primitive->warning (_ ("can't apply `\\~' on first head of ligature")); - else if (pitch > prev_pitch) // pes - { - prev_context_info |= PES_LOWER; - context_info |= PES_UPPER; - } - else if (pitch < prev_pitch) // flexa - { - prev_context_info |= FLEXA_LEFT; - context_info |= FLEXA_RIGHT; - } - else // (pitch == prev_pitch) - primitive->warning (_ ("can't apply `\\~' on heads with identical pitch")); + { + if (!i) // ligature may not start with 2nd head of pes or flexa + primitive->warning (_ ("cannot apply `\\~' on first head of ligature")); + else if (pitch > prev_pitch) // pes + { + prev_context_info |= PES_LOWER; + context_info |= PES_UPPER; + } + else if (pitch < prev_pitch) // flexa + { + prev_context_info |= FLEXA_LEFT; + context_info |= FLEXA_RIGHT; + } + else // (pitch == prev_pitch) + primitive->warning (_ ("cannot apply `\\~' on heads with identical pitch")); + } if (prev_prefix_set & DEMINUTUM) context_info |= AFTER_DEMINUTUM; @@ -242,7 +253,7 @@ provide_context_info (Array primitives) void Gregorian_ligature_engraver::build_ligature (Spanner *ligature, - Array primitives) + vector primitives) { // apply style-independent checking and transformation check_and_fix_all_prefixes (primitives);