]> git.donarmstrong.com Git - lilypond.git/blob - lily/engraver.cc
* lily/*-performer.cc: Converted try_music to listen_*
[lilypond.git] / lily / engraver.cc
1 /*
2   engraver.cc -- implement Engraver
3
4   Sourcefile of GNU LilyPond music type setter
5
6   (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "engraver.hh"
10
11 #include "context.hh"
12 #include "item.hh"
13 #include "lilypond-key.hh"
14 #include "music.hh"
15 #include "score-engraver.hh"
16 #include "spanner.hh"
17 #include "stream-event.hh"
18 #include "warn.hh"
19
20 Engraver_group *
21 Engraver::get_daddy_engraver () const
22 {
23   return dynamic_cast<Engraver_group *> (get_daddy_translator ());
24 }
25
26 void
27 Engraver::announce_grob (Grob_info inf)
28 {
29   get_daddy_engraver ()->announce_grob (inf);
30 }
31
32 void
33 Engraver::announce_end_grob (Grob_info inf)
34 {
35   get_daddy_engraver ()->announce_grob (inf);
36 }
37
38 /*
39   CAUSE is the object (typically a Stream_event object)  that
40   was the reason for making E.
41 */
42 void
43 Engraver::announce_grob (Grob *e, SCM cause)
44 {
45   /* TODO: Remove Music code when it's no longer needed */
46   if (Music *m = unsmob_music (cause))
47     {
48       cause = m->to_event ()->unprotect ();
49     }
50   if (unsmob_stream_event (cause) || unsmob_grob (cause))
51     e->set_property ("cause", cause);
52
53   Grob_info i (this, e);
54
55   Engraver_group *g = get_daddy_engraver ();
56   if (g)
57     g->announce_grob (i);
58 }
59
60
61 /*
62   CAUSE is the object (typically a Music object)  that
63   was the reason for making E.
64 */
65 void
66 Engraver::announce_end_grob (Grob *e, SCM cause)
67 {
68   /* TODO: Remove Music code when it's no longer needed */
69   if (Music *m = unsmob_music (cause))
70     {
71       cause = m->to_event ()->unprotect ();
72     }
73   if (unsmob_stream_event (cause) || unsmob_grob (cause))
74     e->set_property ("cause", cause);
75
76   Grob_info i (this, e);
77
78   i.start_end_ = STOP;
79   Engraver_group *g = get_daddy_engraver ();
80   if (g)
81     g->announce_grob (i);
82 }
83
84
85 Engraver::Engraver ()
86 {
87 }
88
89 #include "translator.icc"
90
91 ADD_TRANSLATOR (Engraver,
92                 "Base class for engravers. Does nothing, so it is not used.",
93                 "",
94                 "",
95                 "",
96                 "");
97