2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "engraver.hh"
26 #include "side-position-interface.hh"
27 #include "translator.icc"
28 #include "axis-group-interface.hh"
30 class Figured_bass_position_engraver
: public Engraver
32 TRANSLATOR_DECLARATIONS (Figured_bass_position_engraver
);
34 Spanner
*bass_figure_alignment_
;
36 vector
<Grob
*> support_
;
37 vector
<Grob
*> span_support_
;
39 DECLARE_ACKNOWLEDGER (note_column
);
40 DECLARE_ACKNOWLEDGER (slur
);
41 DECLARE_END_ACKNOWLEDGER (slur
);
42 DECLARE_ACKNOWLEDGER (tie
);
43 DECLARE_ACKNOWLEDGER (bass_figure_alignment
);
44 DECLARE_END_ACKNOWLEDGER (bass_figure_alignment
);
46 virtual void finalize ();
47 void start_spanner ();
49 void stop_translation_timestep ();
52 Figured_bass_position_engraver::Figured_bass_position_engraver ()
55 bass_figure_alignment_
= 0;
59 Figured_bass_position_engraver::start_spanner ()
61 assert (!positioner_
);
63 positioner_
= make_spanner ("BassFigureAlignmentPositioning", bass_figure_alignment_
->self_scm ());
64 positioner_
->set_bound (LEFT
, bass_figure_alignment_
->get_bound (LEFT
));
65 Axis_group_interface::add_element (positioner_
, bass_figure_alignment_
);
69 Figured_bass_position_engraver::stop_spanner ()
71 if (positioner_
&& !positioner_
->get_bound (RIGHT
))
73 positioner_
->set_bound (RIGHT
, bass_figure_alignment_
->get_bound (RIGHT
));
77 bass_figure_alignment_
= 0;
81 Figured_bass_position_engraver::finalize ()
87 Figured_bass_position_engraver::acknowledge_note_column (Grob_info info
)
89 support_
.push_back (info
.grob ());
93 Figured_bass_position_engraver::acknowledge_end_slur (Grob_info info
)
95 vector
<Grob
*>::iterator i
= find (span_support_
.begin (), span_support_
.end (),
98 if (i
< span_support_
.end ())
99 span_support_
.erase (i
);
103 Figured_bass_position_engraver::acknowledge_slur (Grob_info info
)
105 span_support_
.push_back (info
.grob ());
109 Figured_bass_position_engraver::acknowledge_tie (Grob_info info
)
111 support_
.push_back (info
.grob ());
115 Figured_bass_position_engraver::stop_translation_timestep ()
119 for (vsize i
= 0; i
< span_support_
.size (); i
++)
120 Side_position_interface::add_support (positioner_
, span_support_
[i
]);
121 for (vsize i
= 0; i
< support_
.size (); i
++)
122 Side_position_interface::add_support (positioner_
, support_
[i
]);
129 Figured_bass_position_engraver::acknowledge_end_bass_figure_alignment (Grob_info
/* info */)
135 Figured_bass_position_engraver::acknowledge_bass_figure_alignment (Grob_info info
)
137 bass_figure_alignment_
= dynamic_cast<Spanner
*> (info
.grob ());
142 ADD_ACKNOWLEDGER (Figured_bass_position_engraver
, note_column
);
143 ADD_ACKNOWLEDGER (Figured_bass_position_engraver
, slur
);
144 ADD_END_ACKNOWLEDGER (Figured_bass_position_engraver
, slur
);
146 ADD_ACKNOWLEDGER (Figured_bass_position_engraver
, tie
);
147 ADD_ACKNOWLEDGER (Figured_bass_position_engraver
, bass_figure_alignment
);
148 ADD_END_ACKNOWLEDGER (Figured_bass_position_engraver
, bass_figure_alignment
);
150 ADD_TRANSLATOR (Figured_bass_position_engraver
,
152 "Position figured bass alignments over notes.",
155 "BassFigureAlignmentPositioning ",