2 text-spanner-engraver.cc -- implement Ottava_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Han-Wen Nienhuys
9 #include "protected-scm.hh"
10 #include "note-column.hh"
11 #include "side-position-interface.hh"
12 #include "engraver.hh"
14 class Ottava_spanner_engraver : public Engraver
17 TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver);
19 virtual void finalize ();
21 DECLARE_ACKNOWLEDGER (note_column);
23 void process_music ();
24 void stop_translation_timestep ();
25 virtual void derived_mark () const;
36 Ottava_spanner_engraver::derived_mark () const
38 scm_gc_mark (last_ottavation_);
41 Ottava_spanner_engraver::Ottava_spanner_engraver ()
45 last_ottavation_ = SCM_EOL;
49 Ottava_spanner_engraver::process_music ()
51 SCM ott = get_property ("ottavation");
52 if (ott != last_ottavation_)
56 if (scm_is_string (ott))
58 span_ = make_spanner ("OttavaBracket", SCM_EOL);
59 span_->set_property ("text", ott);
61 SCM c0 (get_property ("middleCPosition"));
62 SCM oc0 (get_property ("originalCentralCPosition"));
63 if (scm_less_p (oc0, c0) == SCM_BOOL_T)
64 span_->set_property ("direction", scm_from_int (DOWN));
67 last_ottavation_ = ott;
71 Ottava_spanner_engraver::acknowledge_note_column (Grob_info info)
73 Item *it = info.item ();
76 Side_position_interface::add_support (span_, it);
78 if (!span_->get_bound (LEFT))
79 span_->set_bound (LEFT, it);
80 span_->set_bound (RIGHT, it);
85 Ottava_spanner_engraver::typeset_all ()
92 if (!finished_->get_bound (RIGHT))
94 Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
95 finished_->set_bound (d, e);
98 while (flip (&d) != LEFT);
105 Ottava_spanner_engraver::stop_translation_timestep ()
107 if (span_ && !span_->get_bound (LEFT))
109 Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
110 span_->set_bound (LEFT, e);
117 Ottava_spanner_engraver::finalize ()
123 last_ottavation_ = SCM_EOL;
126 #include "translator.icc"
127 ADD_ACKNOWLEDGER (Ottava_spanner_engraver, note_column);
128 ADD_TRANSLATOR (Ottava_spanner_engraver,
129 /* doc */ "Create a text spanner when the ottavation property changes..",
130 /* create */ "OttavaBracket",
132 /* read */ "ottavation",