2 text-engraver.cc -- implement Text_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "dimension-cache.hh"
11 #include "engraver.hh"
12 #include "staff-side.hh"
13 #include "text-item.hh"
14 #include "musical-request.hh"
15 #include "note-head.hh"
17 #include "staff-symbol.hh"
19 class Text_engraver : public Engraver
21 Link_array<Text_script_req> reqs_;
22 Link_array<Staff_side_item> positionings_;
23 Link_array<Text_item> texts_;
26 VIRTUAL_COPY_CONS(Translator);
28 virtual bool do_try_music (Music* m);
29 virtual void do_pre_move_processing ();
30 virtual void do_post_move_processing ();
31 virtual void do_process_requests ();
32 virtual void acknowledge_element (Score_element_info);
35 Text_engraver::Text_engraver ()
41 Text_engraver::do_try_music (Music *m)
43 if (Text_script_req *r = dynamic_cast<Text_script_req*> (m))
53 Text_engraver::acknowledge_element (Score_element_info i)
55 if (Note_head *n = dynamic_cast<Note_head*> (i.elem_l_))
57 for (int i=0; i < positionings_.size (); i++)
59 positionings_[i]->add_support (n);
60 if (positionings_[i]->axis_ == X_AXIS
61 && !positionings_[i]->parent_l (Y_AXIS))
62 positionings_[i]->set_parent (n, Y_AXIS);
65 if (Stem *n = dynamic_cast<Stem*> (i.elem_l_))
67 for (int i=0; i < positionings_.size (); i++)
69 positionings_[i]->add_support (n);
75 Text_engraver::do_process_requests ()
77 for (int i=0; i < reqs_.size (); i++)
79 Text_script_req * r = reqs_[i];
81 Text_item *text = new Text_item;
82 Staff_side_item *ss = new Staff_side_item;
86 SCM axisprop = get_property ("scriptHorizontal",0);
87 if (gh_boolean_p (axisprop) && gh_scm2bool (axisprop))
90 text->set_parent (ss, Y_AXIS);
93 ss->set_victim (text);
94 ss->set_elt_property (script_priority_scm_sym,
99 text->text_str_ = r->text_str_;
101 if (r->style_str_.length_i ())
102 text->set_elt_property (style_scm_sym, ly_ch_C_to_scm (r->style_str_.ch_C()));
104 SCM empty = get_property ("textEmptyDimension", 0);
105 if (gh_boolean_p (empty) && gh_scm2bool (empty))
107 text->set_empty (true, X_AXIS);
110 announce_element (Score_element_info (text, r));
111 announce_element (Score_element_info (ss, r));
114 positionings_.push (ss);
119 Text_engraver::do_pre_move_processing ()
121 for (int i=0; i < texts_.size (); i++)
123 typeset_element (texts_[i]);
124 typeset_element (positionings_[i]);
127 positionings_.clear ();
131 Text_engraver::do_post_move_processing ()
136 ADD_THIS_TRANSLATOR(Text_engraver);