2 extender-engraver.cc -- implement Extender_engraver
4 (c) 1999 Glen Prideaux <glenprideaux@iname.com>,
5 Han-Wen Nienhuys, Jan Nieuwenhuizen.
10 #include "musical-request.hh"
11 #include "lyric-extender.hh"
12 #include "paper-column.hh"
14 #include "engraver.hh"
15 #include "drul-array.hh"
16 #include "lyric-extender.hh"
21 Generate an centred extender. Should make a Extender_spanner that
22 typesets a nice centred extender of varying length depending on the
23 gap between syllables.
25 We remember the last Item that come across. When we get a
26 request, we create the spanner, and attach the left point to the
27 last lyrics, and the right point to any lyrics we receive by
29 class Extender_engraver
: public Engraver
31 Score_element
*last_lyric_l_
;
32 Score_element
*current_lyric_l_
;
37 VIRTUAL_COPY_CONS (Translator
);
40 virtual void acknowledge_element (Score_element_info
);
41 virtual void do_removal_processing();
42 virtual void do_process_music();
43 virtual bool do_try_music (Music
*);
44 virtual void do_pre_move_processing();
45 virtual void do_post_move_processing ();
51 ADD_THIS_TRANSLATOR (Extender_engraver
);
53 Extender_engraver::Extender_engraver ()
62 Extender_engraver::acknowledge_element (Score_element_info i
)
65 if (dynamic_cast<Item
*> (i
.elem_l_
)
66 && to_boolean (i
.elem_l_
->get_elt_property ("text-item-interface")))
68 current_lyric_l_
= i
.elem_l_
;
70 && !extender_p_
->get_bound (RIGHT
)
73 Lyric_extender(extender_p_
).set_textitem (RIGHT
, dynamic_cast<Item
*> (i
.elem_l_
));
80 Extender_engraver::do_try_music (Music
* r
)
82 if (Extender_req
* p
= dynamic_cast <Extender_req
*> (r
))
94 Extender_engraver::do_removal_processing ()
98 req_l_
->warning (_ ("unterminated extender"));
99 extender_p_
->set_bound(RIGHT
, unsmob_element (get_property ("currentCommandColumn")));
104 Extender_engraver::do_process_music ()
110 req_l_
->warning (_ ("Nothing to connect extender to on the left. Ignoring extender request."));
114 extender_p_
= new Spanner (get_property ("basicLyricExtenderProperties"));
115 extender_p_
->set_extent_callback (Score_element::point_dimension_callback
, Y_AXIS
);
117 Lyric_extender (extender_p_
).set_textitem (LEFT
, last_lyric_l_
);
118 announce_element (Score_element_info (extender_p_
, req_l_
));
124 Extender_engraver::do_pre_move_processing ()
128 typeset_element (extender_p_
);
132 if (current_lyric_l_
)
134 last_lyric_l_
= current_lyric_l_
;
140 Extender_engraver::do_post_move_processing ()