]> git.donarmstrong.com Git - lilypond.git/blob - lily/output-property-engraver.cc
*** empty log message ***
[lilypond.git] / lily / output-property-engraver.cc
1 /*   
2   output-property-engraver.cc -- implement Output_property_engraver
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7   
8  */
9
10 #include "engraver.hh"
11 #include "context.hh"
12 #include "grob.hh"
13 #include "stream-event.hh"
14
15 #include "translator.icc"
16
17
18 class Output_property_engraver : public Engraver
19 {
20   TRANSLATOR_DECLARATIONS (Output_property_engraver);
21 protected:
22   vector<Stream_event*> props_;
23   DECLARE_ACKNOWLEDGER (grob);
24   DECLARE_TRANSLATOR_LISTENER (layout_instruction);
25
26   void stop_translation_timestep ();
27 };
28
29 IMPLEMENT_TRANSLATOR_LISTENER (Output_property_engraver, layout_instruction);
30 void
31 Output_property_engraver::listen_layout_instruction (Stream_event *ev)
32 {
33   /*
34     UGH. Only swallow the output property event in the context
35     it was intended for. This is inelegant but not inefficient.
36   */
37   if (context ()->is_alias (ev->get_property ("context-type")))
38     props_.push_back (ev);
39 }
40
41 void
42 Output_property_engraver::acknowledge_grob (Grob_info inf)
43 {
44   for (vsize i = props_.size (); i--;)
45     {
46       Stream_event *o = props_[i];
47       Context *d = inf.context ();
48       SCM proc = o->get_property ("procedure");
49       scm_call_3 (proc,
50                   inf.grob ()->self_scm (),
51                   d->self_scm (), 
52                   context ()->self_scm ());
53     }
54 }
55
56 void
57 Output_property_engraver::stop_translation_timestep ()
58 {
59   props_.clear ();
60 }
61
62 Output_property_engraver::Output_property_engraver ()
63 {
64 }
65
66 ADD_ACKNOWLEDGER (Output_property_engraver,grob);
67 ADD_TRANSLATOR (Output_property_engraver,
68
69                 /* doc */
70                 "Apply a procedure to any grob acknowledged. ",
71                 
72                 /* create */
73                 "",
74                 
75                 /* accept */
76                 "layout-instruction-event",
77                 
78                 /* read */
79                 "",
80                 
81                 /* write */
82                 "");