Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / figured-bass-position-engraver.cc
blob705bba24b791f0ee12f14f169ec8db0e57c56bde
1 /*
2 figured-bass-position-engraver.cc -- implement Figured_bass_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 */
10 #include "engraver.hh"
12 #include "context.hh"
13 #include "spanner.hh"
14 #include "item.hh"
15 #include "side-position-interface.hh"
16 #include "translator.icc"
17 #include "axis-group-interface.hh"
19 class Figured_bass_position_engraver : public Engraver
21 TRANSLATOR_DECLARATIONS (Figured_bass_position_engraver);
23 Spanner *bass_figure_alignment_;
24 Spanner *positioner_;
25 vector<Grob*> support_;
26 vector<Grob*> span_support_;
27 protected:
28 DECLARE_ACKNOWLEDGER (note_column);
29 DECLARE_ACKNOWLEDGER (slur);
30 DECLARE_END_ACKNOWLEDGER (slur);
31 DECLARE_ACKNOWLEDGER (tie);
32 DECLARE_ACKNOWLEDGER (bass_figure_alignment);
33 DECLARE_END_ACKNOWLEDGER (bass_figure_alignment);
35 virtual void finalize ();
36 void start_spanner ();
37 void stop_spanner ();
38 void stop_translation_timestep ();
41 Figured_bass_position_engraver::Figured_bass_position_engraver ()
43 positioner_ = 0;
44 bass_figure_alignment_ = 0;
47 void
48 Figured_bass_position_engraver::start_spanner ()
50 assert (!positioner_);
52 positioner_ = make_spanner ("BassFigureAlignmentPositioning", bass_figure_alignment_->self_scm ());
53 positioner_->set_bound (LEFT, bass_figure_alignment_->get_bound (LEFT));
54 Axis_group_interface::add_element (positioner_, bass_figure_alignment_);
57 void
58 Figured_bass_position_engraver::stop_spanner ()
60 if (positioner_ && !positioner_->get_bound (RIGHT))
62 positioner_->set_bound (RIGHT, bass_figure_alignment_->get_bound (RIGHT));
65 positioner_ = 0;
66 bass_figure_alignment_ = 0;
69 void
70 Figured_bass_position_engraver::finalize ()
72 stop_spanner ();
75 void
76 Figured_bass_position_engraver::acknowledge_note_column (Grob_info info)
78 support_.push_back (info.grob ());
81 void
82 Figured_bass_position_engraver::acknowledge_end_slur (Grob_info info)
84 vector<Grob*>::iterator i = find (span_support_.begin (), span_support_.end (),
85 info.grob ());
87 if (i < span_support_.end ())
88 span_support_.erase (i);
91 void
92 Figured_bass_position_engraver::acknowledge_slur (Grob_info info)
94 span_support_.push_back (info.grob ());
97 void
98 Figured_bass_position_engraver::acknowledge_tie (Grob_info info)
100 support_.push_back (info.grob ());
103 void
104 Figured_bass_position_engraver::stop_translation_timestep ()
106 if (positioner_)
108 for (vsize i = 0; i < span_support_.size (); i++)
109 Side_position_interface::add_support (positioner_, span_support_[i]);
110 for (vsize i = 0; i < support_.size (); i++)
111 Side_position_interface::add_support (positioner_, support_[i]);
114 support_.clear ();
117 void
118 Figured_bass_position_engraver::acknowledge_end_bass_figure_alignment (Grob_info /* info */)
120 stop_spanner ();
123 void
124 Figured_bass_position_engraver::acknowledge_bass_figure_alignment (Grob_info info)
126 bass_figure_alignment_ = dynamic_cast<Spanner*> (info.grob ());
127 start_spanner ();
131 ADD_ACKNOWLEDGER (Figured_bass_position_engraver, note_column);
132 ADD_ACKNOWLEDGER (Figured_bass_position_engraver, slur);
133 ADD_END_ACKNOWLEDGER (Figured_bass_position_engraver, slur);
135 ADD_ACKNOWLEDGER (Figured_bass_position_engraver, tie);
136 ADD_ACKNOWLEDGER (Figured_bass_position_engraver, bass_figure_alignment);
137 ADD_END_ACKNOWLEDGER (Figured_bass_position_engraver, bass_figure_alignment);
139 ADD_TRANSLATOR (Figured_bass_position_engraver,
140 /* doc */
141 "Position figured bass alignments over notes.",
143 /* create */
144 "BassFigureAlignmentPositioning ",
146 /* read */
149 /* write */