2 text-spanner-engraver.cc -- implement Ottava_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2004 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 ();
20 virtual void acknowledge_grob (Grob_info);
21 virtual void process_music ();
22 virtual void stop_translation_timestep ();
23 virtual void derived_mark () const;
34 Ottava_spanner_engraver::derived_mark () const
36 scm_gc_mark (last_ottavation_ );
39 Ottava_spanner_engraver::Ottava_spanner_engraver ()
43 last_ottavation_ = SCM_EOL;
47 Ottava_spanner_engraver::process_music ()
49 SCM ott = get_property ("ottavation");
50 if (ott != last_ottavation_)
54 if (scm_is_string (ott))
56 span_ = make_spanner ("OttavaBracket", SCM_EOL);
57 span_->set_property ("text", ott);
60 SCM c0 (get_property ("middleCPosition"));
61 SCM oc0 (get_property ("originalCentralCPosition"));
62 if (scm_less_p (oc0, c0) == SCM_BOOL_T)
63 span_->set_property ("direction", scm_int2num (DOWN));
66 last_ottavation_ = ott;
70 Ottava_spanner_engraver::acknowledge_grob (Grob_info info)
72 Item *it = dynamic_cast<Item*> (info.grob_);
73 if (span_ && it && Note_column::has_interface (info.grob_))
75 Side_position_interface::add_support (span_, it);
77 if (!span_->get_bound (LEFT))
78 span_->set_bound (LEFT, it);
79 span_->set_bound (RIGHT, it);
84 Ottava_spanner_engraver::typeset_all ()
91 if (!finished_->get_bound (RIGHT))
93 Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
94 finished_->set_bound (d, e);
97 while (flip (&d) != LEFT);
104 Ottava_spanner_engraver::stop_translation_timestep ()
106 if (span_ && !span_->get_bound (LEFT))
108 Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
109 span_->set_bound (LEFT, e);
116 Ottava_spanner_engraver::finalize ()
122 last_ottavation_ = SCM_EOL;
125 ADD_TRANSLATOR (Ottava_spanner_engraver,
126 /* descr */ "Create a text spanner when the ottavation property changes..",
127 /* creats*/ "OttavaBracket",
129 /* acks */ "note-column-interface",
130 /* reads */ "ottavation",