2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2009 Han-Wen Nienhuys
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.
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.
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/>.
20 #include "protected-scm.hh"
21 #include "note-column.hh"
22 #include "side-position-interface.hh"
23 #include "engraver.hh"
25 #include "text-interface.hh"
28 class Ottava_spanner_engraver
: public Engraver
31 TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver
);
33 virtual void finalize ();
35 DECLARE_ACKNOWLEDGER (note_column
);
37 void process_music ();
38 void stop_translation_timestep ();
39 virtual void derived_mark () const;
50 Ottava_spanner_engraver::derived_mark () const
52 scm_gc_mark (last_ottavation_
);
55 Ottava_spanner_engraver::Ottava_spanner_engraver ()
59 last_ottavation_
= SCM_EOL
;
63 Ottava_spanner_engraver::process_music ()
65 SCM ott
= get_property ("ottavation");
66 if (ott
!= last_ottavation_
)
70 if (Text_interface::is_markup (ott
))
72 span_
= make_spanner ("OttavaBracket", SCM_EOL
);
73 span_
->set_property ("text", ott
);
75 SCM
offset (get_property ("middleCOffset"));
76 if (robust_scm2double (offset
, 0) > 0)
77 span_
->set_property ("direction", scm_from_int (DOWN
));
80 last_ottavation_
= ott
;
84 Ottava_spanner_engraver::acknowledge_note_column (Grob_info info
)
86 Item
*it
= info
.item ();
89 Side_position_interface::add_support (span_
, it
);
91 if (!span_
->get_bound (LEFT
))
92 span_
->set_bound (LEFT
, it
);
93 span_
->set_bound (RIGHT
, it
);
98 Ottava_spanner_engraver::typeset_all ()
105 if (!finished_
->get_bound (RIGHT
))
107 Grob
*e
= unsmob_grob (get_property ("currentMusicalColumn"));
108 finished_
->set_bound (d
, e
);
111 while (flip (&d
) != LEFT
);
118 Ottava_spanner_engraver::stop_translation_timestep ()
120 if (span_
&& !span_
->get_bound (LEFT
))
122 Grob
*e
= unsmob_grob (get_property ("currentMusicalColumn"));
123 span_
->set_bound (LEFT
, e
);
130 Ottava_spanner_engraver::finalize ()
136 last_ottavation_
= SCM_EOL
;
139 #include "translator.icc"
141 ADD_ACKNOWLEDGER (Ottava_spanner_engraver
, note_column
);
143 ADD_TRANSLATOR (Ottava_spanner_engraver
,
145 "Create a text spanner when the ottavation property changes.",
152 "originalMiddleCPosition "
153 "currentMusicalColumn ",