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"
12 #include "side-position-interface.hh"
13 #include "engraver.hh"
15 class Ottava_spanner_engraver : public Engraver
18 TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver);
20 virtual void finalize ();
21 virtual void acknowledge_grob (Grob_info);
22 virtual void process_music ();
23 virtual void stop_translation_timestep ();
24 virtual void derived_mark () const;
35 Ottava_spanner_engraver::derived_mark () const
37 scm_gc_mark (last_ottavation_ );
40 Ottava_spanner_engraver::Ottava_spanner_engraver ()
44 last_ottavation_ = SCM_EOL;
48 Ottava_spanner_engraver::process_music ()
50 SCM ott = get_property ("ottavation");
51 if (ott != last_ottavation_)
55 if (scm_is_string (ott))
57 span_ = make_spanner ("OttavaBracket", SCM_EOL);
58 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_int2num (DOWN));
67 last_ottavation_ = ott;
71 Ottava_spanner_engraver::acknowledge_grob (Grob_info info)
73 Item *it = dynamic_cast<Item*> (info.grob_);
74 if (span_ && it && Note_column::has_interface (info.grob_))
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 ENTER_DESCRIPTION (Ottava_spanner_engraver,
127 /* descr */ "Create a text spanner when the ottavation property changes..",
128 /* creats*/ "OttavaBracket",
130 /* acks */ "note-column-interface",
131 /* reads */ "ottavation",