2 balloon-engraver.cc -- implement Balloon_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2006--2007 Han-Wen Nienhuys <hanwen@lilypond.org>
10 #include "engraver.hh"
12 #include "stream-event.hh"
15 #include "translator.icc"
17 class Balloon_engraver
: public Engraver
19 TRANSLATOR_DECLARATIONS (Balloon_engraver
);
21 DECLARE_TRANSLATOR_LISTENER (annotate_output
);
22 DECLARE_ACKNOWLEDGER (grob
);
23 vector
<Stream_event
*> events_
;
25 void stop_translation_timestep ();
27 void balloonify (Grob
*, Stream_event
*);
30 IMPLEMENT_TRANSLATOR_LISTENER (Balloon_engraver
, annotate_output
);
32 Balloon_engraver::listen_annotate_output (Stream_event
*ev
)
34 events_
.push_back (ev
);
38 Balloon_engraver::stop_translation_timestep ()
43 Balloon_engraver::Balloon_engraver ()
48 Balloon_engraver::balloonify (Grob
*g
, Stream_event
*event
)
50 Grob
* b
= make_item ("BalloonTextItem", event
->self_scm ());
51 b
->set_property ("text", event
->get_property ("text"));
52 b
->set_parent (g
, Y_AXIS
);
53 b
->set_parent (g
, X_AXIS
);
57 Balloon_engraver::acknowledge_grob (Grob_info info
)
59 Stream_event
*cause
= info
.event_cause ();
61 SCM arts
= cause
? cause
->get_property ("articulations") : SCM_EOL
;
62 for (SCM s
= arts
; scm_is_pair (s
); s
= scm_cdr (s
))
64 Stream_event
*e
= unsmob_stream_event (scm_car (s
));
65 if (e
->in_event_class ("annotate-output-event"))
67 balloonify (info
.grob (), e
);
71 for (vsize i
= 0; i
< events_
.size (); i
++)
73 if (info
.grob ()->name () == ly_symbol2string (events_
[i
]->get_property ("symbol")))
74 balloonify (info
.grob (), events_
[i
]);
80 ADD_ACKNOWLEDGER (Balloon_engraver
, grob
);
82 ADD_TRANSLATOR (Balloon_engraver
,
84 "Create balloon texts.",