Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / tab-tie-follow-engraver.cc
bloba815c5a3bb98f262b704d3514c9d5268d2c2a153
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2010--2011 Carl D. Sorensen
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include <cctype>
21 #include <cstdio>
23 #include "engraver.hh"
25 using namespace std;
27 #include "context.hh"
28 #include "item.hh"
29 #include "spanner.hh"
31 #include "translator.icc"
34 Change tab-note-head properties when a tie is followed by a
35 slurs or glissando.
37 class Tab_tie_follow_engraver : public Engraver
39 vector<Spanner *> slurs_;
40 vector<Spanner *> glissandi_;
41 vector<Item *> note_heads_;
43 public:
44 TRANSLATOR_DECLARATIONS (Tab_tie_follow_engraver);
46 protected:
47 DECLARE_ACKNOWLEDGER (glissando);
48 DECLARE_ACKNOWLEDGER (slur);
49 DECLARE_ACKNOWLEDGER (tab_note_head);
51 void stop_translation_timestep ();
54 Tab_tie_follow_engraver::Tab_tie_follow_engraver ()
58 void
59 Tab_tie_follow_engraver::acknowledge_glissando (Grob_info info)
61 glissandi_.push_back (info.spanner ());
64 void
65 Tab_tie_follow_engraver::acknowledge_tab_note_head (Grob_info info)
67 note_heads_.push_back (info.item ());
70 void
71 Tab_tie_follow_engraver::acknowledge_slur (Grob_info info)
73 slurs_.push_back (info.spanner ());
76 void
77 Tab_tie_follow_engraver::stop_translation_timestep ()
79 for (vsize k = 0; k < note_heads_.size (); k++)
81 bool spanner_start = false;
82 for (vsize j = 0; j < slurs_.size (); j++)
84 Item* left_item = slurs_[j]->get_bound (LEFT);
85 if (left_item)
87 SCM left_cause = left_item->get_property ("cause");
88 Item *slur_cause = unsmob_item (left_cause);
89 if (slur_cause == note_heads_[k])
91 note_heads_[k]->set_property ("span-start", SCM_BOOL_T);
92 spanner_start = true;
93 break;
97 if (!spanner_start)
98 for (vsize j = 0; j < glissandi_.size (); j++)
100 Item *left_bound = glissandi_[j]->get_bound (LEFT);
101 if (left_bound == note_heads_[k])
103 note_heads_[k]->set_property ("span-start", SCM_BOOL_T);
104 break;
108 slurs_.clear ();
109 glissandi_.clear ();
110 note_heads_.clear();
113 ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, slur);
114 ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, glissando);
115 ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, tab_note_head);
118 ADD_TRANSLATOR (Tab_tie_follow_engraver,
119 /* doc */
120 "Adjust TabNoteHead properties when a tie is followed"
121 " by a slur or glissando.",
123 /* create */
124 " ",
126 /* read */
127 " ",
129 /* write */