lilypond-1.3.31
[lilypond.git] / lily / hyphen-engraver.cc
blob1b73e0149932cbb34ab59f5219ed5c4f565064b7
1 /*
2 hyphen-engraver.cc -- implement Hyphen_engraver
4 (c) 1999 Glen Prideaux <glenprideaux@iname.com>
5 */
7 #include "proto.hh"
8 #include "musical-request.hh"
9 #include "hyphen-engraver.hh"
10 #include "hyphen-spanner.hh"
11 #include "paper-column.hh"
12 #include "text-item.hh"
13 #include "extender-engraver.hh"
15 ADD_THIS_TRANSLATOR (Hyphen_engraver);
17 Hyphen_engraver::Hyphen_engraver ()
19 current_lyric_l_ = 0;
20 last_lyric_l_ = 0;
21 hyphen_spanner_p_ = 0;
22 req_l_ = 0;
25 void
26 Hyphen_engraver::acknowledge_element (Score_element_info i)
28 if (Text_item* t = dynamic_cast<Text_item*> (i.elem_l_))
30 current_lyric_l_ = t;
31 if (hyphen_spanner_p_
32 && !hyphen_spanner_p_->spanned_drul_[RIGHT]
35 hyphen_spanner_p_->set_textitem (RIGHT, t);
41 bool
42 Hyphen_engraver::do_try_music (Music* r)
44 if (Hyphen_req* p = dynamic_cast <Hyphen_req *> (r))
46 if (req_l_)
47 return false;
49 req_l_ = p;
50 return true;
52 return false;
55 void
56 Hyphen_engraver::do_removal_processing ()
58 if (hyphen_spanner_p_)
60 req_l_->warning (_ ("unterminated hyphen"));
61 hyphen_spanner_p_->set_bounds(RIGHT, get_staff_info ().command_pcol_l ());
65 void
66 Hyphen_engraver::do_process_requests ()
68 if (req_l_)
70 if (!last_lyric_l_)
72 req_l_->warning (_ ("Nothing to connect hyphen to on the left. Ignoring hyphen request."));
73 return;
76 hyphen_spanner_p_ = new Hyphen_spanner;
77 hyphen_spanner_p_->set_textitem (LEFT, last_lyric_l_);
78 announce_element (Score_element_info (hyphen_spanner_p_, req_l_));
83 void
84 Hyphen_engraver::do_pre_move_processing ()
86 if (hyphen_spanner_p_)
88 typeset_element (hyphen_spanner_p_);
89 hyphen_spanner_p_ = 0;
92 if (current_lyric_l_)
94 last_lyric_l_ = current_lyric_l_;
95 current_lyric_l_ =0;
99 void
100 Hyphen_engraver::do_post_move_processing ()
102 req_l_ = 0;