Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / laissez-vibrer-engraver.cc
blob49c64ce772d8908ef7d70e0206fb8c3523f2fd66
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "engraver.hh"
22 #include "item.hh"
23 #include "pointer-group-interface.hh"
24 #include "stream-event.hh"
26 #include "translator.icc"
28 class Laissez_vibrer_engraver : public Engraver
30 Stream_event *event_;
31 Grob *lv_column_;
32 vector<Grob*> lv_ties_;
34 void stop_translation_timestep ();
35 DECLARE_ACKNOWLEDGER (note_head);
36 protected:
37 DECLARE_TRANSLATOR_LISTENER (laissez_vibrer);
38 public:
39 TRANSLATOR_DECLARATIONS (Laissez_vibrer_engraver);
42 Laissez_vibrer_engraver::Laissez_vibrer_engraver ()
44 event_ = 0;
45 lv_column_ = 0;
48 void
49 Laissez_vibrer_engraver::stop_translation_timestep ()
51 event_ = 0;
52 lv_column_ = 0;
53 lv_ties_.clear ();
56 IMPLEMENT_TRANSLATOR_LISTENER (Laissez_vibrer_engraver, laissez_vibrer);
57 void
58 Laissez_vibrer_engraver::listen_laissez_vibrer (Stream_event *ev)
60 ASSIGN_EVENT_ONCE (event_, ev);
63 void
64 Laissez_vibrer_engraver::acknowledge_note_head (Grob_info inf)
66 if (!event_)
67 return;
69 SCM cause = event_->self_scm ();
71 if (!lv_column_)
72 lv_column_ = make_item ("LaissezVibrerTieColumn", cause);
74 Grob *lv_tie = make_item ("LaissezVibrerTie", cause);
75 lv_tie->set_object ("note-head", inf.grob ()->self_scm ());
77 Pointer_group_interface::add_grob (lv_column_, ly_symbol2scm ("ties"),
78 lv_tie);
80 if (is_direction (unsmob_stream_event (cause)->get_property ("direction")))
82 Direction d = to_dir (unsmob_stream_event (cause)->get_property ("direction"));
83 lv_tie->set_property ("direction", scm_from_int (d));
86 lv_tie->set_parent (lv_column_, Y_AXIS);
88 lv_ties_.push_back (lv_tie);
91 ADD_ACKNOWLEDGER (Laissez_vibrer_engraver, note_head);
92 ADD_TRANSLATOR (Laissez_vibrer_engraver,
93 /* doc */
94 "Create laissez vibrer items.",
96 /* create */
97 "LaissezVibrerTie "
98 "LaissezVibrerTieColumn ",
100 /* read */
103 /* write */