2 text-spanner-engraver.cc -- implement Ottava_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2003 Han-Wen Nienhuys
7 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "protected-scm.hh"
11 #include "note-column.hh"
13 #include "side-position-interface.hh"
14 #include "engraver.hh"
16 class Ottava_spanner_engraver : public Engraver
19 TRANSLATOR_DECLARATIONS(Ottava_spanner_engraver);
21 virtual void finalize ();
22 virtual void acknowledge_grob (Grob_info);
23 virtual void process_music ();
24 virtual void stop_translation_timestep ();
29 Protected_scm last_ottavation_;
35 Ottava_spanner_engraver::Ottava_spanner_engraver ()
39 last_ottavation_ = SCM_EOL;
43 Ottava_spanner_engraver::process_music ()
45 SCM ott = get_property ("ottavation");
46 if (ott != last_ottavation_)
50 if (gh_string_p (ott))
52 span_ = new Spanner (get_property ("OttavaSpanner"));
53 span_->set_grob_property ("edge-text", gh_cons (ott, SCM_EOL));
54 announce_grob (span_, SCM_EOL);
58 last_ottavation_ = ott;
62 Ottava_spanner_engraver::acknowledge_grob (Grob_info info)
64 Item *it = dynamic_cast<Item*> (info.grob_);
65 if (span_ && it && Note_column::has_interface (info.grob_))
67 Side_position_interface::add_support (span_, it);
68 if (!span_->get_bound (LEFT))
69 span_->set_bound (LEFT, it);
70 span_->set_bound (RIGHT, it);
75 Ottava_spanner_engraver::typeset_all ()
79 Side_position_interface::add_staff_support (finished_);
84 if (!finished_->get_bound (RIGHT))
86 Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
87 finished_->set_bound (d, e);
90 while (flip (&d) != LEFT);
92 typeset_grob (finished_);
98 Ottava_spanner_engraver::stop_translation_timestep ()
100 if (span_ && !span_->get_bound (LEFT))
102 Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
103 span_->set_bound (LEFT, e);
110 Ottava_spanner_engraver::finalize ()
118 ENTER_DESCRIPTION(Ottava_spanner_engraver,
119 /* descr */ "Create a text spanner when the ottavation property changes..",
120 /* creats*/ "OttavaSpanner",
122 /* acks */ "note-column-interface",
123 /* reads */ "ottavation",