2 output-property-engraver.cc -- implement Output_property_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "engraver.hh"
12 #include "output-property-music-iterator.hh"
13 #include "translator-group.hh"
15 class Output_property_engraver
: public Engraver
17 TRANSLATOR_DECLARATIONS(Output_property_engraver
);
19 Link_array
<Music
> props_
;
21 virtual void stop_translation_timestep ();
22 virtual void acknowledge_grob (Grob_info
);
23 virtual bool try_music (Music
*);
28 Output_property_engraver::try_music (Music
* m
)
30 if (m
->is_mus_type ("layout-instruction"))
39 Output_property_engraver::acknowledge_grob (Grob_info inf
)
41 for (int i
=props_
.size (); i
--;)
43 Music
* o
= props_
[i
];
44 SCM pred
= o
->get_mus_property ("predicate");
48 if (gh_procedure_p (pred
))
51 should typecheck pred.
53 SCM result
=scm_call_1 (pred
, inf
.grob_
->self_scm ());
54 if (to_boolean (result
))
56 SCM sym
= o
->get_mus_property ("grob-property");
57 SCM val
= o
->get_mus_property ("grob-value");
58 inf
.grob_
->internal_set_grob_property (sym
, val
);
63 Translator_group
* d
=
64 dynamic_cast<Translator_group
*> (inf
.origin_trans_
);
67 d
= dynamic_cast<Translator_group
*> (inf
.origin_trans_
->daddy_trans_
);
69 SCM proc
= o
->get_mus_property ("procedure");
71 inf
.grob_
->self_scm(),
73 daddy_trans_
->self_scm());
79 Output_property_engraver::stop_translation_timestep ()
84 Output_property_engraver::Output_property_engraver()
88 ENTER_DESCRIPTION(Output_property_engraver
,
89 /* descr */ "Interpret Music of Output_property type, and apply a function "
90 " to any Graphic objects that satisfies the predicate.",
92 /* accepts */ "layout-instruction",
93 /* acks */ "grob-interface",