]> git.donarmstrong.com Git - lilypond.git/blob - lily/vertically-spaced-context-engraver.cc
* lily/include/translator.icc: new file.
[lilypond.git] / lily / vertically-spaced-context-engraver.cc
1 /*
2   vertically-spaced-contexts-engraver.cc -- implement Vertically_spaced_contexts_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 */
9
10 #include "engraver.hh"
11 #include "grob.hh"
12 #include "axis-group-interface.hh"
13 #include "context.hh"
14 #include "pointer-group-interface.hh"
15
16 class Vertically_spaced_contexts_engraver : public Engraver
17 {
18   TRANSLATOR_DECLARATIONS(Vertically_spaced_contexts_engraver);
19 protected:
20   virtual void acknowledge_grob (Grob_info);
21   virtual void initialize ();
22
23 private:
24   Grob * system_;
25 };
26
27
28
29 Vertically_spaced_contexts_engraver::Vertically_spaced_contexts_engraver ()
30 {
31   system_ = 0;
32 }
33
34 void
35 Vertically_spaced_contexts_engraver::initialize ()
36 {
37   system_ = unsmob_grob (get_property ("rootSystem"));
38 }
39
40 void
41 Vertically_spaced_contexts_engraver::acknowledge_grob (Grob_info gi)
42 {
43   if (Axis_group_interface::has_interface (gi.grob ())
44       && gi.grob ()->internal_has_interface (ly_symbol2scm ("vertically-spaceable-interface")))
45     {
46       SCM spaceable = get_property ("verticallySpacedContexts");
47       Context *orig = gi.origin_contexts (this)[0];
48
49       if (scm_memq (ly_symbol2scm (orig->context_name ().to_str0 ()),
50                     spaceable) != SCM_BOOL_F)
51         {
52           Pointer_group_interface::add_grob (system_,
53                                              ly_symbol2scm ("spaceable-staves"),
54                                              gi.grob ());
55         }
56     }
57 }
58
59 #include "translator.icc"
60
61 ADD_TRANSLATOR (Vertically_spaced_contexts_engraver,
62                 /* descr */ "",
63                 /* creats*/ "",
64                 /* accepts */ "",
65                 /* acks  */ "axis-group-interface",
66                 /* reads */ "verticallySpacedContexts",
67                 /* write */ "verticallySpacedContexts");