2 trill-spanner-engraver.cc -- implement Trill_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2009 Jan Nieuwenhuizen <janneke@gnu.org>
10 C&P from text-spanner.cc
12 - todo: ending should be detected automatically? a new note
13 automatically is the end of the trill?
16 #include "engraver.hh"
18 #include "international.hh"
19 #include "note-column.hh"
20 #include "pointer-group-interface.hh"
21 #include "side-position-interface.hh"
22 #include "stream-event.hh"
25 #include "translator.icc"
27 class Trill_spanner_engraver
: public Engraver
30 TRANSLATOR_DECLARATIONS (Trill_spanner_engraver
);
32 virtual void finalize ();
33 DECLARE_TRANSLATOR_LISTENER (trill_span
);
34 DECLARE_ACKNOWLEDGER (note_column
);
36 void stop_translation_timestep ();
37 void process_music ();
42 Stream_event
*current_event_
;
43 Drul_array
<Stream_event
*> event_drul_
;
47 Trill_spanner_engraver::Trill_spanner_engraver ()
52 event_drul_
.set (0, 0);
55 IMPLEMENT_TRANSLATOR_LISTENER (Trill_spanner_engraver
, trill_span
);
57 Trill_spanner_engraver::listen_trill_span (Stream_event
*ev
)
59 Direction d
= to_dir (ev
->get_property ("span-direction"));
60 ASSIGN_EVENT_ONCE (event_drul_
[d
], ev
);
64 Trill_spanner_engraver::acknowledge_note_column (Grob_info info
)
68 Pointer_group_interface::add_grob (span_
,
69 ly_symbol2scm ("note-columns"),
71 if (!span_
->get_bound (LEFT
))
72 add_bound_item (span_
, info
.grob ());
76 Pointer_group_interface::add_grob (finished_
, ly_symbol2scm ("note-columns"),
78 if (!finished_
->get_bound (RIGHT
))
79 add_bound_item (finished_
, info
.grob ());
84 Trill_spanner_engraver::process_music ()
87 && (event_drul_
[STOP
] || event_drul_
[START
]))
89 Stream_event
*ender
= event_drul_
[STOP
];
91 ender
= event_drul_
[START
];
93 announce_end_grob (finished_
, ender
->self_scm ());
98 if (event_drul_
[START
])
100 current_event_
= event_drul_
[START
];
101 span_
= make_spanner ("TrillSpanner", event_drul_
[START
]->self_scm ());
102 Side_position_interface::set_axis (span_
, Y_AXIS
);
107 Trill_spanner_engraver::typeset_all ()
111 if (!finished_
->get_bound (RIGHT
))
113 Grob
*e
= unsmob_grob (get_property ("currentMusicalColumn"));
114 finished_
->set_bound (RIGHT
, e
);
121 Trill_spanner_engraver::stop_translation_timestep ()
123 if (span_
&& !span_
->get_bound (LEFT
))
125 Grob
*e
= unsmob_grob (get_property ("currentMusicalColumn"));
126 span_
->set_bound (LEFT
, e
);
130 event_drul_
.set (0, 0);
134 Trill_spanner_engraver::finalize ()
139 Grob
*e
= unsmob_grob (get_property ("currentCommandColumn"));
140 span_
->set_bound (RIGHT
, e
);
144 ADD_ACKNOWLEDGER (Trill_spanner_engraver
, note_column
);
146 ADD_TRANSLATOR (Trill_spanner_engraver
,
148 "Create trill spanner from an event.",
154 "currentCommandColumn "
155 "currentMusicalColumn ",