2 ottava-engraver.cc -- implement Ottava_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2009 Han-Wen Nienhuys
9 #include "protected-scm.hh"
10 #include "note-column.hh"
11 #include "side-position-interface.hh"
12 #include "engraver.hh"
14 #include "text-interface.hh"
17 class Ottava_spanner_engraver
: public Engraver
20 TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver
);
22 virtual void finalize ();
24 DECLARE_ACKNOWLEDGER (note_column
);
26 void process_music ();
27 void stop_translation_timestep ();
28 virtual void derived_mark () const;
39 Ottava_spanner_engraver::derived_mark () const
41 scm_gc_mark (last_ottavation_
);
44 Ottava_spanner_engraver::Ottava_spanner_engraver ()
48 last_ottavation_
= SCM_EOL
;
52 Ottava_spanner_engraver::process_music ()
54 SCM ott
= get_property ("ottavation");
55 if (ott
!= last_ottavation_
)
59 if (Text_interface::is_markup (ott
))
61 span_
= make_spanner ("OttavaBracket", SCM_EOL
);
62 span_
->set_property ("text", ott
);
64 SCM
offset (get_property ("middleCOffset"));
65 if (robust_scm2double (offset
, 0) > 0)
66 span_
->set_property ("direction", scm_from_int (DOWN
));
69 last_ottavation_
= ott
;
73 Ottava_spanner_engraver::acknowledge_note_column (Grob_info info
)
75 Item
*it
= info
.item ();
78 Side_position_interface::add_support (span_
, it
);
80 if (!span_
->get_bound (LEFT
))
81 span_
->set_bound (LEFT
, it
);
82 span_
->set_bound (RIGHT
, it
);
87 Ottava_spanner_engraver::typeset_all ()
94 if (!finished_
->get_bound (RIGHT
))
96 Grob
*e
= unsmob_grob (get_property ("currentMusicalColumn"));
97 finished_
->set_bound (d
, e
);
100 while (flip (&d
) != LEFT
);
107 Ottava_spanner_engraver::stop_translation_timestep ()
109 if (span_
&& !span_
->get_bound (LEFT
))
111 Grob
*e
= unsmob_grob (get_property ("currentMusicalColumn"));
112 span_
->set_bound (LEFT
, e
);
119 Ottava_spanner_engraver::finalize ()
125 last_ottavation_
= SCM_EOL
;
128 #include "translator.icc"
130 ADD_ACKNOWLEDGER (Ottava_spanner_engraver
, note_column
);
132 ADD_TRANSLATOR (Ottava_spanner_engraver
,
134 "Create a text spanner when the ottavation property changes.",
141 "originalMiddleCPosition "
142 "currentMusicalColumn ",