2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2015 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 void acknowledge_note_column (Grob_info);
40 void acknowledge_slur (Grob_info);
41 void acknowledge_end_slur (Grob_info);
42 void acknowledge_end_tie (Grob_info);
43 void acknowledge_bass_figure_alignment (Grob_info);
44 void acknowledge_end_bass_figure_alignment (Grob_info);
46 virtual void finalize ();
47 void start_spanner ();
49 void stop_translation_timestep ();
52 Figured_bass_position_engraver::Figured_bass_position_engraver (Context *c)
56 bass_figure_alignment_ = 0;
60 Figured_bass_position_engraver::start_spanner ()
62 assert (!positioner_);
64 positioner_ = make_spanner ("BassFigureAlignmentPositioning", bass_figure_alignment_->self_scm ());
65 positioner_->set_bound (LEFT, bass_figure_alignment_->get_bound (LEFT));
66 Axis_group_interface::add_element (positioner_, bass_figure_alignment_);
70 Figured_bass_position_engraver::stop_spanner ()
72 if (positioner_ && !positioner_->get_bound (RIGHT))
74 positioner_->set_bound (RIGHT, bass_figure_alignment_->get_bound (RIGHT));
78 bass_figure_alignment_ = 0;
82 Figured_bass_position_engraver::finalize ()
88 Figured_bass_position_engraver::acknowledge_note_column (Grob_info info)
90 support_.push_back (info.grob ());
94 Figured_bass_position_engraver::acknowledge_end_slur (Grob_info info)
96 vector<Grob *>::iterator i = find (span_support_.begin (), span_support_.end (),
99 if (i < span_support_.end ())
100 span_support_.erase (i);
104 Figured_bass_position_engraver::acknowledge_slur (Grob_info info)
106 span_support_.push_back (info.grob ());
110 Figured_bass_position_engraver::acknowledge_end_tie (Grob_info info)
112 support_.push_back (info.grob ());
116 Figured_bass_position_engraver::stop_translation_timestep ()
120 for (vsize i = 0; i < span_support_.size (); i++)
121 Side_position_interface::add_support (positioner_, span_support_[i]);
122 for (vsize i = 0; i < support_.size (); i++)
123 Side_position_interface::add_support (positioner_, support_[i]);
130 Figured_bass_position_engraver::acknowledge_end_bass_figure_alignment (Grob_info /* info */)
136 Figured_bass_position_engraver::acknowledge_bass_figure_alignment (Grob_info info)
138 bass_figure_alignment_ = dynamic_cast<Spanner *> (info.grob ());
145 Figured_bass_position_engraver::boot ()
147 ADD_ACKNOWLEDGER (Figured_bass_position_engraver, note_column);
148 ADD_ACKNOWLEDGER (Figured_bass_position_engraver, slur);
149 ADD_END_ACKNOWLEDGER (Figured_bass_position_engraver, slur);
150 ADD_END_ACKNOWLEDGER (Figured_bass_position_engraver, tie);
151 ADD_ACKNOWLEDGER (Figured_bass_position_engraver, bass_figure_alignment);
152 ADD_END_ACKNOWLEDGER (Figured_bass_position_engraver, bass_figure_alignment);
155 ADD_TRANSLATOR (Figured_bass_position_engraver,
157 "Position figured bass alignments over notes.",
160 "BassFigureAlignmentPositioning ",