]> git.donarmstrong.com Git - lilypond.git/blob - lily/axis-group-engraver.cc
Update source file headers. Fixes using standard GNU package conventions.
[lilypond.git] / lily / axis-group-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "axis-group-engraver.hh"
21
22 #include "axis-group-interface.hh"
23 #include "pointer-group-interface.hh"
24 #include "context.hh"
25 #include "international.hh"
26 #include "spanner.hh"
27 #include "warn.hh"
28
29 #include "translator.icc"
30
31 Axis_group_engraver::Axis_group_engraver ()
32 {
33   must_be_last_ = true;
34   staffline_ = 0;
35 }
36
37 void
38 Axis_group_engraver::process_music ()
39 {
40   if (!staffline_)
41     {
42       staffline_ = get_spanner ();
43       Grob *it = unsmob_grob (get_property ("currentCommandColumn"));
44       staffline_->set_bound (LEFT, it);
45     }
46 }
47
48 Spanner *
49 Axis_group_engraver::get_spanner ()
50 {
51   return make_spanner ("VerticalAxisGroup", SCM_EOL);
52 }
53
54 void
55 Axis_group_engraver::finalize ()
56 {
57   if (staffline_)
58     {
59       Grob *it = unsmob_grob (get_property ("currentCommandColumn"));
60       staffline_->set_bound (RIGHT, it);
61
62       Pointer_group_interface::set_ordered (staffline_, ly_symbol2scm ("elements"), false);
63     }
64 }
65
66 void
67 Axis_group_engraver::acknowledge_grob (Grob_info i)
68 {
69   elts_.push_back (i.grob ());
70 }
71
72 /*
73   maybe should check if our parent is set, because we now get a
74   cyclic parent relationship if we have two Axis_group_engravers in
75   the context.  */
76 void
77 Axis_group_engraver::process_acknowledged ()
78 {
79   if (!staffline_)
80     return;
81
82   for (vsize i = 0; i < elts_.size (); i++)
83     {
84       if (!unsmob_grob (elts_[i]->get_object ("axis-group-parent-Y")))
85         {
86           if (staffline_->get_parent (Y_AXIS)
87               && staffline_->get_parent (Y_AXIS) == elts_[i])
88             {
89               staffline_->warning (_ ("Axis_group_engraver: vertical group already has a parent"));
90               staffline_->warning (_ ("are there two Axis_group_engravers?"));
91               staffline_->warning (_ ("removing this vertical group"));
92               staffline_->suicide ();
93               staffline_ = 0;
94               break;
95             }
96           add_element (elts_[i]);
97         }
98     }
99   elts_.clear ();
100 }
101
102 void
103 Axis_group_engraver::add_element (Grob *e)
104 {
105   Axis_group_interface::add_element (staffline_, e);
106 }
107
108 ADD_ACKNOWLEDGER (Axis_group_engraver, grob);
109
110 ADD_TRANSLATOR (Axis_group_engraver,
111                 /* doc */
112                 "Group all objects created in this context in a"
113                 " @code{VerticalAxisGroup} spanner.",
114
115                 /* create */
116                 "VerticalAxisGroup ",
117
118                 /* read */
119                 "currentCommandColumn ",
120
121                 /* write */
122                 ""
123                 );