2 axis-group-engraver.cc -- implement Axis_group_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2004 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"
18 Put stuff in a Spanner with an Axis_group_interface.
19 Use as last element of a context.
21 class Axis_group_engraver : public Engraver
25 Link_array<Grob> elts_;
26 virtual void process_music ();
27 virtual void finalize ();
28 virtual void acknowledge_grob (Grob_info);
29 virtual void process_acknowledged_grobs ();
30 virtual Spanner* get_spanner () ;
31 virtual void add_element (Grob*) ;
33 TRANSLATOR_DECLARATIONS (Axis_group_engraver);
36 Axis_group_engraver::Axis_group_engraver ()
42 Axis_group_engraver::process_music ()
46 staffline_ = get_spanner ();
48 Grob * it = unsmob_grob (get_property ("currentCommandColumn"));
50 staffline_->set_bound (LEFT,it);
52 announce_grob (staffline_, SCM_EOL);
57 Axis_group_engraver::get_spanner ()
59 return make_spanner ("VerticalAxisGroup");
63 TODO: should we junk minimumVerticalExtent/extraVerticalExtent ?
67 Axis_group_engraver::finalize ()
72 String type = daddy_context_->context_name ();
73 SCM dims = get_property ("verticalExtent");
75 if (is_number_pair (dims))
76 staffline_->set_extent (dims, Y_AXIS);
78 dims = get_property ("minimumVerticalExtent");
79 if (is_number_pair (dims) )
80 staffline_->set_property ("minimum-Y-extent", dims);
82 dims = get_property ("extraVerticalExtent");
83 if (is_number_pair (dims))
84 staffline_->set_property ("extra-Y-extent", dims);
86 Grob * it = unsmob_grob (get_property ("currentCommandColumn"));
88 staffline_->set_bound (RIGHT,it);
90 typeset_grob (staffline_);
95 Axis_group_engraver::acknowledge_grob (Grob_info i)
101 maybe should check if our parent is set, because we now get a
102 cyclic parent relationship if we have two Axis_group_engravers in
105 Axis_group_engraver::process_acknowledged_grobs ()
108 for (int i=0; i < elts_.size (); i++)
110 Grob *par = elts_[i]->get_parent (Y_AXIS);
112 if (!par || !Axis_group_interface::has_interface (par))
113 if (elts_[i]->is_empty (Y_AXIS))
116 We have to do _something_, otherwise staff objects will
117 end up with System as parent.
120 elts_[i]->set_parent (staffline_, Y_AXIS);
123 add_element (elts_[i]);
129 Axis_group_engraver::add_element (Grob*e)
131 Axis_group_interface::add_element (staffline_, e);
134 /****************************************************************/
138 maybenot such a good idea after all., to put class declarations in
143 #include "hara-kiri-group-spanner.hh"
144 #include "rhythmic-head.hh"
146 class Hara_kiri_engraver : public Axis_group_engraver
149 virtual Spanner*get_spanner ();
150 virtual void acknowledge_grob (Grob_info);
151 virtual void add_element (Grob *e);
153 TRANSLATOR_DECLARATIONS (Hara_kiri_engraver);
157 Hara_kiri_engraver::add_element (Grob*e)
159 Hara_kiri_group_spanner::add_element (staffline_, e);
164 Hara_kiri_engraver::get_spanner ()
166 Spanner * sp = make_spanner ("RemoveEmptyVerticalGroup");
172 Hara_kiri_engraver::acknowledge_grob (Grob_info i)
174 Axis_group_engraver::acknowledge_grob (i);
175 if (i.grob_->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface"))
176 || i.grob_->internal_has_interface (ly_symbol2scm ("lyric-interface"))
179 Hara_kiri_group_spanner::add_interesting_item (staffline_, i.grob_);
184 Hara_kiri_engraver::Hara_kiri_engraver ()
188 ENTER_DESCRIPTION (Hara_kiri_engraver,
189 /* descr */ "Like Axis_group_engraver, but make a hara-kiri spanner, and add "
190 "interesting items (ie. note heads, lyric syllables and normal rests) ",
191 /* creats*/ "RemoveEmptyVerticalGroup",
193 /* acks */ "grob-interface",
197 ENTER_DESCRIPTION (Axis_group_engraver,
198 /* descr */ "Group all objects created in this context in a VerticalAxisGroup spanner.",
199 /* creats*/ "VerticalAxisGroup",
201 /* acks */ "grob-interface",
202 /* reads */ "verticalExtent minimumVerticalExtent extraVerticalExtent",