2 hyphen-engraver.cc -- implement Hyphen_engraver
4 (c) 1999 Glen Prideaux <glenprideaux@iname.com>
8 #include "musical-request.hh"
9 #include "hyphen-spanner.hh"
10 #include "paper-column.hh"
12 #include "engraver.hh"
15 Generate an centred hyphen. Should make a Hyphen_spanner that
16 typesets a nice centred hyphen of varying length depending on the
17 gap between syllables.
19 We remember the last Item that come across. When we get a
20 request, we create the spanner, and attach the left point to the
21 last lyrics, and the right point to any lyrics we receive by
23 class Hyphen_engraver : public Engraver
25 Score_element *last_lyric_l_;
26 Score_element *current_lyric_l_;
31 VIRTUAL_COPY_CONS (Translator);
34 virtual void acknowledge_element (Score_element_info);
35 virtual void do_removal_processing();
36 virtual void do_process_music();
37 virtual bool do_try_music (Music*);
38 virtual void do_pre_move_processing();
39 virtual void do_post_move_processing ();
44 ADD_THIS_TRANSLATOR (Hyphen_engraver);
46 Hyphen_engraver::Hyphen_engraver ()
55 Hyphen_engraver::acknowledge_element (Score_element_info i)
58 if (i.elem_l_->has_interface (ly_symbol2scm ("text-item-interface")))
60 current_lyric_l_ = i.elem_l_;
62 && !hyphen_p_->get_bound (RIGHT)
65 Hyphen_spanner (hyphen_p_).set_textitem (RIGHT, i.elem_l_);
72 Hyphen_engraver::do_try_music (Music* r)
74 if (Hyphen_req* p = dynamic_cast <Hyphen_req *> (r))
86 Hyphen_engraver::do_removal_processing ()
90 req_l_->warning (_ ("unterminated hyphen"));
91 hyphen_p_->set_bound(RIGHT, unsmob_element (get_property ("currentCommandColumn")));
96 Hyphen_engraver::do_process_music ()
102 req_l_->warning (_ ("Nothing to connect hyphen to on the left. Ignoring hyphen request."));
106 hyphen_p_ = new Spanner (get_property ("basicHyphenSpannerProperties"));
107 hyphen_p_->set_extent_callback (Score_element::point_dimension_callback,Y_AXIS);
108 Hyphen_spanner (hyphen_p_).set_textitem (LEFT, last_lyric_l_);
109 announce_element (Score_element_info (hyphen_p_, req_l_));
115 Hyphen_engraver::do_pre_move_processing ()
119 typeset_element (hyphen_p_);
123 if (current_lyric_l_)
125 last_lyric_l_ = current_lyric_l_;
131 Hyphen_engraver::do_post_move_processing ()