]> git.donarmstrong.com Git - lilypond.git/blob - lily/axis-group-engraver.cc
* configure.in (--enable-std-vector): New option.
[lilypond.git] / lily / axis-group-engraver.cc
1 /*
2   axis-group-engraver.cc -- implement Axis_group_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1999--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "axis-group-engraver.hh"
10
11 #include "axis-group-interface.hh"
12 #include "context.hh"
13 #include "international.hh"
14 #include "spanner.hh"
15 #include "warn.hh"
16
17 #include "translator.icc"
18
19 Axis_group_engraver::Axis_group_engraver ()
20 {
21   must_be_last_ = true;
22   staffline_ = 0;
23 }
24
25 void
26 Axis_group_engraver::process_music ()
27 {
28   if (!staffline_)
29     {
30       staffline_ = get_spanner ();
31       Grob *it = unsmob_grob (get_property ("currentCommandColumn"));
32       staffline_->set_bound (LEFT, it);
33     }
34 }
35
36 Spanner *
37 Axis_group_engraver::get_spanner ()
38 {
39   return make_spanner ("VerticalAxisGroup", SCM_EOL);
40 }
41
42 /*
43   TODO: should we junk minimumVerticalExtent/extraVerticalExtent ?
44 */
45
46 void
47 Axis_group_engraver::finalize ()
48 {
49   if (staffline_)
50     {
51       Grob *it = unsmob_grob (get_property ("currentCommandColumn"));
52       staffline_->set_bound (RIGHT, it);
53     }
54 }
55
56 void
57 Axis_group_engraver::acknowledge_grob (Grob_info i)
58 {
59   elts_.push_back (i.grob ());
60 }
61
62 /*
63   maybe should check if our parent is set, because we now get a
64   cyclic parent relationship if we have two Axis_group_engravers in
65   the context.  */
66 void
67 Axis_group_engraver::process_acknowledged ()
68 {
69   if (!staffline_)
70     return;
71
72   for (vsize i = 0; i < elts_.size (); i++)
73     {
74       if (!unsmob_grob (elts_[i]->get_object ("axis-group-parent-Y")))
75         {
76           if (staffline_->get_parent (Y_AXIS)
77               && staffline_->get_parent (Y_AXIS) == elts_[i])
78             {
79               staffline_->warning (_ ("Axis_group_engraver: vertical group already has a parent"));
80               staffline_->warning (_ ("are there two Axis_group_engravers?"));
81               staffline_->warning (_ ("removing this vertical group"));
82               staffline_->suicide ();
83               staffline_ = 0;
84               break;
85             }
86           add_element (elts_[i]);
87         }
88     }
89   elts_.clear ();
90 }
91
92 void
93 Axis_group_engraver::add_element (Grob *e)
94 {
95   Axis_group_interface::add_element (staffline_, e);
96 }
97
98 ADD_ACKNOWLEDGER (Axis_group_engraver, grob);
99
100 ADD_TRANSLATOR (Axis_group_engraver,
101                 /* doc */ "Group all objects created in this context in a VerticalAxisGroup spanner.",
102                 /* create */ "VerticalAxisGroup",
103                 /* accept */ "",
104                 /* read */ "verticalExtent minimumVerticalExtent extraVerticalExtent",
105                 /* write */ "");