Release: update news.
[lilypond/patrick.git] / lily / figured-bass-position-engraver.cc
blob6db165a9ba5d1456456dc823f58890e6a7986749
1 /*
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"
23 #include "context.hh"
24 #include "spanner.hh"
25 #include "item.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_;
35 Spanner *positioner_;
36 vector<Grob*> support_;
37 vector<Grob*> span_support_;
38 protected:
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 ();
48 void stop_spanner ();
49 void stop_translation_timestep ();
52 Figured_bass_position_engraver::Figured_bass_position_engraver ()
54 positioner_ = 0;
55 bass_figure_alignment_ = 0;
58 void
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_);
68 void
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));
76 positioner_ = 0;
77 bass_figure_alignment_ = 0;
80 void
81 Figured_bass_position_engraver::finalize ()
83 stop_spanner ();
86 void
87 Figured_bass_position_engraver::acknowledge_note_column (Grob_info info)
89 support_.push_back (info.grob ());
92 void
93 Figured_bass_position_engraver::acknowledge_end_slur (Grob_info info)
95 vector<Grob*>::iterator i = find (span_support_.begin (), span_support_.end (),
96 info.grob ());
98 if (i < span_support_.end ())
99 span_support_.erase (i);
102 void
103 Figured_bass_position_engraver::acknowledge_slur (Grob_info info)
105 span_support_.push_back (info.grob ());
108 void
109 Figured_bass_position_engraver::acknowledge_tie (Grob_info info)
111 support_.push_back (info.grob ());
114 void
115 Figured_bass_position_engraver::stop_translation_timestep ()
117 if (positioner_)
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]);
125 support_.clear ();
128 void
129 Figured_bass_position_engraver::acknowledge_end_bass_figure_alignment (Grob_info /* info */)
131 stop_spanner ();
134 void
135 Figured_bass_position_engraver::acknowledge_bass_figure_alignment (Grob_info info)
137 bass_figure_alignment_ = dynamic_cast<Spanner*> (info.grob ());
138 start_spanner ();
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,
151 /* doc */
152 "Position figured bass alignments over notes.",
154 /* create */
155 "BassFigureAlignmentPositioning ",
157 /* read */
160 /* write */