2 ottova-engraver.cc -- implement Ottava_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2007 Han-Wen Nienhuys
9 #include "protected-scm.hh"
10 #include "note-column.hh"
11 #include "side-position-interface.hh"
12 #include "engraver.hh"
16 class Ottava_spanner_engraver : public Engraver
19 TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver);
21 virtual void finalize ();
23 DECLARE_ACKNOWLEDGER (note_column);
25 void process_music ();
26 void stop_translation_timestep ();
27 virtual void derived_mark () const;
38 Ottava_spanner_engraver::derived_mark () const
40 scm_gc_mark (last_ottavation_);
43 Ottava_spanner_engraver::Ottava_spanner_engraver ()
47 last_ottavation_ = SCM_EOL;
51 Ottava_spanner_engraver::process_music ()
53 SCM ott = get_property ("ottavation");
54 if (ott != last_ottavation_)
58 if (scm_is_string (ott))
60 span_ = make_spanner ("OttavaBracket", SCM_EOL);
61 span_->set_property ("text", ott);
63 SCM c0 (get_property ("middleCPosition"));
64 SCM oc0 (get_property ("originalMiddleCPosition"));
65 if (scm_less_p (oc0, c0) == SCM_BOOL_T)
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,
133 /* doc */ "Create a text spanner when the ottavation property changes..",
134 /* create */ "OttavaBracket",
135 /* read */ "ottavation "
136 "originalMiddleCPosition "
137 "currentMusicalColumn "