]> git.donarmstrong.com Git - lilypond.git/blob - lily/output-property-engraver.cc
Fix some bugs in the dynamic engraver and PostScript backend
[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 "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   vector<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       /*
35         UGH. Only swallow the output property event in the context
36         it was intended for. This is inelegant but not inefficient.
37       */
38       if (context ()->is_alias (m->get_property ("context-type")))
39         {
40           props_.push_back (m);
41           return true;
42         }
43     }
44   return false;
45 }
46
47 void
48 Output_property_engraver::acknowledge_grob (Grob_info inf)
49 {
50   for (vsize i = props_.size (); i--;)
51     {
52       Music *o = props_[i];
53       Context *d = inf.context ();
54       SCM proc = o->get_property ("procedure");
55       scm_call_3 (proc,
56                   inf.grob ()->self_scm (),
57                   d->self_scm (), 
58                   context ()->self_scm ());
59     }
60 }
61
62 void
63 Output_property_engraver::stop_translation_timestep ()
64 {
65   props_.clear ();
66 }
67
68 Output_property_engraver::Output_property_engraver ()
69 {
70 }
71
72 ADD_ACKNOWLEDGER (Output_property_engraver,grob);
73 ADD_TRANSLATOR (Output_property_engraver,
74
75                 /* doc */
76                 "Apply a procedure to any grob acknowledged. ",
77                 
78                 /* create */
79                 "",
80                 
81                 /* accept */
82                 "layout-instruction",
83                 
84                 /* read */
85                 "",
86                 
87                 /* write */
88                 "");