2 axis-group-engraver.cc -- implement Axis_group_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "axis-group-engraver.hh"
12 #include "paper-column.hh"
13 #include "axis-group-interface.hh"
14 #include "engraver-group-engraver.hh"
18 Axis_group_engraver::Axis_group_engraver ()
25 Axis_group_engraver::process_music ()
29 staffline_ = get_spanner ();
30 Grob *it = unsmob_grob (get_property ("currentCommandColumn"));
31 staffline_->set_bound (LEFT, it);
36 Axis_group_engraver::get_spanner ()
38 return make_spanner ("VerticalAxisGroup", SCM_EOL);
42 TODO: should we junk minimumVerticalExtent/extraVerticalExtent ?
46 Axis_group_engraver::finalize ()
51 String type = context ()->context_name ();
52 SCM dims = get_property ("verticalExtent");
54 if (is_number_pair (dims))
55 staffline_->set_extent (dims, Y_AXIS);
57 dims = get_property ("minimumVerticalExtent");
58 if (is_number_pair (dims))
59 staffline_->set_property ("minimum-Y-extent", dims);
61 dims = get_property ("extraVerticalExtent");
62 if (is_number_pair (dims))
63 staffline_->set_property ("extra-Y-extent", dims);
65 Grob *it = unsmob_grob (get_property ("currentCommandColumn"));
67 staffline_->set_bound (RIGHT, it);
73 Axis_group_engraver::acknowledge_grob (Grob_info i)
75 elts_.push (i.grob ());
79 maybe should check if our parent is set, because we now get a
80 cyclic parent relationship if we have two Axis_group_engravers in
83 Axis_group_engraver::process_acknowledged_grobs ()
88 for (int i = 0; i < elts_.size (); i++)
90 if (!unsmob_grob (elts_[i]->get_object ("axis-group-parent-Y")))
92 if (staffline_->get_parent (Y_AXIS)
93 && staffline_->get_parent (Y_AXIS) == elts_[i])
95 staffline_->warning (_ ("Axis_group_engraver: vertical group already has a parent"));
96 staffline_->warning (_ ("are there two Axis_group_engravers?"));
97 staffline_->warning (_ ("removing this vertical group"));
98 staffline_->suicide ();
102 else if (elts_[i]->is_empty (Y_AXIS))
105 We have to do _something_, otherwise staff objects will
106 end up with System as parent.
109 elts_[i]->set_parent (staffline_, Y_AXIS);
112 add_element (elts_[i]);
119 Axis_group_engraver::add_element (Grob *e)
121 Axis_group_interface::add_element (staffline_, e);
124 ADD_TRANSLATOR (Axis_group_engraver,
125 /* descr */ "Group all objects created in this context in a VerticalAxisGroup spanner.",
126 /* creats*/ "VerticalAxisGroup",
128 /* acks */ "grob-interface",
129 /* reads */ "verticalExtent minimumVerticalExtent extraVerticalExtent",