X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftab-tie-follow-engraver.cc;h=75a7b5b2ea710bd42ec5283eb7b8de6549045e30;hb=5d84bfad4626892bcffd05adcced53c8a2329047;hp=fbeb93266e14c481899384ecf24cafe14a136139;hpb=03075ddb8334c04774181dfa02313bac0f9bc03f;p=lilypond.git diff --git a/lily/tab-tie-follow-engraver.cc b/lily/tab-tie-follow-engraver.cc index fbeb93266e..75a7b5b2ea 100644 --- a/lily/tab-tie-follow-engraver.cc +++ b/lily/tab-tie-follow-engraver.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2010 Carl D. Sorensen + Copyright (C) 2010--2015 Carl D. Sorensen LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,85 +26,111 @@ using namespace std; #include "context.hh" #include "item.hh" +#include "spanner.hh" #include "translator.icc" /* - Change tab-note-head properties for a note_head at the right end of a tie + Change tab-note-head properties when a tie is followed by a + slurs or glissando. */ class Tab_tie_follow_engraver : public Engraver { - vector ties_; - vector note_heads_; + vector slurs_; + vector glissandi_; + vector note_heads_; public: TRANSLATOR_DECLARATIONS (Tab_tie_follow_engraver); protected: - DECLARE_ACKNOWLEDGER (tie); - DECLARE_ACKNOWLEDGER (tab_note_head); - void process_acknowledged (); + void acknowledge_glissando (Grob_info); + void acknowledge_slur (Grob_info); + void acknowledge_tab_note_head (Grob_info); void stop_translation_timestep (); }; -Tab_tie_follow_engraver::Tab_tie_follow_engraver () +Tab_tie_follow_engraver::Tab_tie_follow_engraver (Context *c) + : Engraver (c) { } void -Tab_tie_follow_engraver::acknowledge_tie (Grob_info info) +Tab_tie_follow_engraver::acknowledge_glissando (Grob_info info) { - ties_.push_back (info.grob ()); + glissandi_.push_back (info.spanner ()); } void Tab_tie_follow_engraver::acknowledge_tab_note_head (Grob_info info) { - note_heads_.push_back (info.grob ()); + note_heads_.push_back (info.item ()); } void -Tab_tie_follow_engraver::process_acknowledged () +Tab_tie_follow_engraver::acknowledge_slur (Grob_info info) { - if (ties_.size () && note_heads_.size ()) + slurs_.push_back (info.spanner ()); +} + +void +Tab_tie_follow_engraver::stop_translation_timestep () +{ + for (vsize k = 0; k < note_heads_.size (); k++) { - SCM proc = ly_lily_module_constant ("ly:spanner-bound"); - for (vsize i = 0; i < ties_.size (); i++) + bool spanner_start = false; + for (vsize j = 0; j < slurs_.size (); j++) { - SCM right_bound = scm_call_2 (proc, - ties_[i]->self_scm (), - scm_from_int (RIGHT)); - - for (vsize k = 0; k < note_heads_.size (); k++) - if (right_bound == note_heads_[k]->self_scm ()) - note_heads_[k]->set_property ("tie-follow", SCM_BOOL_T); - } + Item *left_item = slurs_[j]->get_bound (LEFT); + if (left_item) + { + SCM left_cause = left_item->get_property ("cause"); + Item *slur_cause = unsmob (left_cause); + if (slur_cause == note_heads_[k]) + { + note_heads_[k]->set_property ("span-start", SCM_BOOL_T); + spanner_start = true; + break; + } + } + } + if (!spanner_start) + for (vsize j = 0; j < glissandi_.size (); j++) + { + Item *left_bound = glissandi_[j]->get_bound (LEFT); + if (left_bound == note_heads_[k]) + { + note_heads_[k]->set_property ("span-start", SCM_BOOL_T); + break; + } + } } + slurs_.clear (); + glissandi_.clear (); + note_heads_.clear (); } + void -Tab_tie_follow_engraver::stop_translation_timestep () +Tab_tie_follow_engraver::boot () { - ties_.clear (); - note_heads_.clear(); + ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, slur); + ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, glissando); + ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, tab_note_head); } -ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, tie); -ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, tab_note_head); - ADD_TRANSLATOR (Tab_tie_follow_engraver, - /* doc */ - "Adjust TabNoteHead properties when a tie is followed" - " by a slur or glissando.", + /* doc */ + "Adjust TabNoteHead properties when a tie is followed" + " by a slur or glissando.", - /* create */ - " ", + /* create */ + " ", - /* read */ + /* read */ " ", - /* write */ + /* write */ " " - ); - + );