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 ("OttavaBracket"));
53 span_->set_grob_property ("text", ott);
54 announce_grob (span_, SCM_EOL);
56 SCM c0 (get_property ("centralCPosition"));
57 SCM oc0 (get_property ("originalCentralCPosition"));
58 if (scm_less_p (oc0, c0) == SCM_BOOL_T)
59 span_->set_grob_property ("direction", gh_int2scm (DOWN));
62 last_ottavation_ = ott;
66 Ottava_spanner_engraver::acknowledge_grob (Grob_info info)
68 Item *it = dynamic_cast<Item*> (info.grob_);
69 if (span_ && it && Note_column::has_interface (info.grob_))
71 Side_position_interface::add_support (span_, it);
73 if (!span_->get_bound (LEFT))
74 span_->set_bound (LEFT, it);
75 span_->set_bound (RIGHT, it);
80 Ottava_spanner_engraver::typeset_all ()
87 if (!finished_->get_bound (RIGHT))
89 Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
90 finished_->set_bound (d, e);
93 while (flip (&d) != LEFT);
95 typeset_grob (finished_);
101 Ottava_spanner_engraver::stop_translation_timestep ()
103 if (span_ && !span_->get_bound (LEFT))
105 Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
106 span_->set_bound (LEFT, e);
113 Ottava_spanner_engraver::finalize ()
119 last_ottavation_ = SCM_EOL;
122 ENTER_DESCRIPTION(Ottava_spanner_engraver,
123 /* descr */ "Create a text spanner when the ottavation property changes..",
124 /* creats*/ "OttavaBracket",
126 /* acks */ "note-column-interface",
127 /* reads */ "ottavation",