2 axis-group-engraver.cc -- implement Axis_group_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "paper-column.hh"
11 #include "axis-group-interface.hh"
12 #include "engraver.hh"
13 #include "engraver-group-engraver.hh"
16 Put stuff in a Spanner with an Axis_group_interface.
17 Use as last element of a context.
19 class Axis_group_engraver
: public Engraver
23 Link_array
<Grob
> elts_
;
24 virtual void initialize ();
25 virtual void finalize ();
26 virtual void acknowledge_grob (Grob_info
);
27 virtual void process_acknowledged_grobs ();
28 virtual Spanner
* get_spanner () const;
29 virtual void add_element (Grob
*) ;
31 TRANSLATOR_DECLARATIONS(Axis_group_engraver
);
36 Axis_group_engraver::Axis_group_engraver ()
42 Axis_group_engraver::initialize ()
44 staffline_
= get_spanner ();
46 Grob
* it
= unsmob_grob (get_property ("currentCommandColumn"));
48 staffline_
->set_bound (LEFT
,it
);
50 announce_grob(staffline_
, SCM_EOL
);
54 Axis_group_engraver::get_spanner () const
56 return new Spanner (get_property ("VerticalAxisGroup"));
60 Axis_group_engraver::finalize ()
62 String type
= get_daddy_grav ()->type_string_
;
63 SCM dims
= get_property ("verticalExtent");
65 if (gh_pair_p (dims
) && gh_number_p (ly_car (dims
))
66 && gh_number_p (ly_cdr (dims
)))
68 staffline_
->set_extent (Grob::preset_extent_proc
, Y_AXIS
);
69 staffline_
->set_grob_property ("Y-extent", dims
);
72 dims
= get_property ("minimumVerticalExtent");
73 if (gh_pair_p (dims
) && gh_number_p (ly_car (dims
))
74 && gh_number_p (ly_cdr (dims
)))
75 staffline_
->set_grob_property ("minimum-Y-extent", dims
);
77 dims
= get_property ("extraVerticalExtent");
78 if (gh_pair_p (dims
) && gh_number_p (ly_car (dims
))
79 && gh_number_p (ly_cdr (dims
)))
80 staffline_
->set_grob_property ("extra-Y-extent", dims
);
82 Grob
* it
= unsmob_grob (get_property ("currentCommandColumn"));
85 staffline_
->set_bound (RIGHT
,it
);
87 typeset_grob (staffline_
);
92 Axis_group_engraver::acknowledge_grob (Grob_info i
)
98 maybe should check if our parent is set, because we now get a
99 cyclic parent relationship if we have two Axis_group_engravers in
102 Axis_group_engraver::process_acknowledged_grobs ()
105 for (int i
=0; i
< elts_
.size (); i
++)
107 Grob
*par
= elts_
[i
]->get_parent (Y_AXIS
);
109 if ((!par
|| !Axis_group_interface::has_interface (par
))
110 && ! elts_
[i
]->empty_b (Y_AXIS
))
111 add_element (elts_
[i
]);
117 Axis_group_engraver::add_element (Grob
*e
)
119 Axis_group_interface::add_element (staffline_
, e
);
122 ////////////////////////////////////////////////////////
123 // maybenot such a good idea after all., to put classes in .cc
125 #include "hara-kiri-group-spanner.hh"
126 #include "rhythmic-head.hh"
128 class Hara_kiri_engraver
: public Axis_group_engraver
131 virtual Spanner
*get_spanner ()const;
132 virtual void acknowledge_grob (Grob_info
);
133 virtual void add_element (Grob
*e
);
135 TRANSLATOR_DECLARATIONS(Hara_kiri_engraver
);
139 Hara_kiri_engraver::add_element (Grob
*e
)
141 Hara_kiri_group_spanner::add_element (staffline_
, e
);
146 Hara_kiri_engraver::get_spanner () const
148 Spanner
* sp
= new Spanner (get_property ("HaraKiriVerticalGroup"));
154 Hara_kiri_engraver::acknowledge_grob (Grob_info i
)
156 Axis_group_engraver::acknowledge_grob (i
);
157 if (Rhythmic_head::has_interface (i
.grob_
)
158 || i
.grob_
->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
160 Hara_kiri_group_spanner::add_interesting_item (staffline_
, i
.grob_
);
164 Hara_kiri_engraver::Hara_kiri_engraver(){}
166 ENTER_DESCRIPTION(Hara_kiri_engraver
,
167 /* descr */ "Like Axis_group_engraver, but make a hara kiri spanner, and add
168 interesting items (ie. note heads, lyric syllables and normal rests)
170 /* creats*/ "HaraKiriVerticalGroup",
171 /* acks */ "grob-interface",
175 ENTER_DESCRIPTION(Axis_group_engraver
,
176 /* descr */ "Group all objects created in this context in a VerticalAxisGroup spanner.",
177 /* creats*/ "VerticalAxisGroup",
178 /* acks */ "grob-interface",
179 /* reads */ "verticalExtent minimumVerticalExtent extraVerticalExtent",