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 ();
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);
59 SCM c0 (get_property ("middleCPosition"));
60 SCM oc0 (get_property ("originalCentralCPosition"));
61 if (scm_less_p (oc0, c0) == SCM_BOOL_T)
62 span_->set_property ("direction", scm_int2num (DOWN));
65 last_ottavation_ = ott;
69 Ottava_spanner_engraver::acknowledge_grob (Grob_info info)
71 Item *it = dynamic_cast<Item *> (info.grob_);
72 if (span_ && it && Note_column::has_interface (info.grob_))
74 Side_position_interface::add_support (span_, it);
76 if (!span_->get_bound (LEFT))
77 span_->set_bound (LEFT, it);
78 span_->set_bound (RIGHT, it);
83 Ottava_spanner_engraver::typeset_all ()
90 if (!finished_->get_bound (RIGHT))
92 Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
93 finished_->set_bound (d, e);
96 while (flip (&d) != LEFT);
103 Ottava_spanner_engraver::stop_translation_timestep ()
105 if (span_ && !span_->get_bound (LEFT))
107 Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
108 span_->set_bound (LEFT, e);
115 Ottava_spanner_engraver::finalize ()
121 last_ottavation_ = SCM_EOL;
124 ADD_TRANSLATOR (Ottava_spanner_engraver,
125 /* descr */ "Create a text spanner when the ottavation property changes..",
126 /* creats*/ "OttavaBracket",
128 /* acks */ "note-column-interface",
129 /* reads */ "ottavation",