Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / laissez-vibrer-engraver.cc
blob0c4c79367918c7e113e6e4c8febfd9e75354e515
1 /*
2 laissez-vibrer-engraver.cc -- implement Laissez_vibrer_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 */
10 #include "engraver.hh"
11 #include "item.hh"
12 #include "pointer-group-interface.hh"
13 #include "stream-event.hh"
15 #include "translator.icc"
17 class Laissez_vibrer_engraver : public Engraver
19 Stream_event *event_;
20 Grob *lv_column_;
21 vector<Grob*> lv_ties_;
23 void stop_translation_timestep ();
24 DECLARE_ACKNOWLEDGER (note_head);
25 protected:
26 DECLARE_TRANSLATOR_LISTENER (laissez_vibrer);
27 public:
28 TRANSLATOR_DECLARATIONS (Laissez_vibrer_engraver);
31 Laissez_vibrer_engraver::Laissez_vibrer_engraver ()
33 event_ = 0;
34 lv_column_ = 0;
37 void
38 Laissez_vibrer_engraver::stop_translation_timestep ()
40 event_ = 0;
41 lv_column_ = 0;
42 lv_ties_.clear ();
45 IMPLEMENT_TRANSLATOR_LISTENER (Laissez_vibrer_engraver, laissez_vibrer);
46 void
47 Laissez_vibrer_engraver::listen_laissez_vibrer (Stream_event *ev)
49 ASSIGN_EVENT_ONCE (event_, ev);
52 void
53 Laissez_vibrer_engraver::acknowledge_note_head (Grob_info inf)
55 if (!event_)
56 return;
58 SCM cause = event_->self_scm ();
60 if (!lv_column_)
61 lv_column_ = make_item ("LaissezVibrerTieColumn", cause);
63 Grob *lv_tie = make_item ("LaissezVibrerTie", cause);
64 lv_tie->set_object ("note-head", inf.grob ()->self_scm ());
66 Pointer_group_interface::add_grob (lv_column_, ly_symbol2scm ("ties"),
67 lv_tie);
69 if (is_direction (unsmob_stream_event (cause)->get_property ("direction")))
71 Direction d = to_dir (unsmob_stream_event (cause)->get_property ("direction"));
72 lv_tie->set_property ("direction", scm_from_int (d));
75 lv_tie->set_parent (lv_column_, Y_AXIS);
77 lv_ties_.push_back (lv_tie);
80 ADD_ACKNOWLEDGER (Laissez_vibrer_engraver, note_head);
81 ADD_TRANSLATOR (Laissez_vibrer_engraver,
82 /* doc */
83 "Create laissez vibrer items.",
85 /* create */
86 "LaissezVibrerTie "
87 "LaissezVibrerTieColumn ",
89 /* read */
90 "",
92 /* write */