]> git.donarmstrong.com Git - lilypond.git/blob - lily/output-property-engraver.cc
release commit
[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--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7   
8  */
9
10 #include "engraver.hh"
11 #include "grob.hh"
12 #include "context.hh"
13
14 #include "translator.icc"
15
16
17 class Output_property_engraver : public Engraver
18 {
19   TRANSLATOR_DECLARATIONS (Output_property_engraver);
20 protected:
21   Link_array<Music> props_;
22   DECLARE_ACKNOWLEDGER (grob)
23
24   void stop_translation_timestep ();
25   virtual bool try_music (Music*);
26 };
27
28
29 bool
30 Output_property_engraver::try_music (Music* m)
31 {
32   if (m->is_mus_type ("layout-instruction"))
33     {
34       props_.push (m);
35       return true;
36     }
37   return false;
38 }
39
40 void
41 Output_property_engraver::acknowledge_grob (Grob_info inf)
42 {
43   for (int i = props_.size (); i--;)
44     {
45       Music *o = props_[i];
46       Context *d = inf.context ();
47       SCM proc = o->get_property ("procedure");
48       scm_call_3 (proc,
49                   inf.grob ()->self_scm (),
50                   d->self_scm (), 
51                   context ()->self_scm ());
52     }
53 }
54
55 void
56 Output_property_engraver::stop_translation_timestep ()
57 {
58   props_.clear ();
59 }
60
61 Output_property_engraver::Output_property_engraver ()
62 {
63 }
64
65 ADD_ACKNOWLEDGER (Output_property_engraver,grob);
66 ADD_TRANSLATOR (Output_property_engraver,
67
68                 /* doc */
69                 "Apply a procedure to any grob acknowledged. ",
70                 
71                 /* create */
72                 "",
73                 
74                 /* accept */
75                 "layout-instruction",
76                 
77                 /* read */
78                 "",
79                 
80                 /* write */
81                 "");