2 a2-engraver.cc -- implement A2_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
11 #include "note-head.hh"
14 #include "translator-group.hh"
15 #include "side-position-interface.hh"
16 #include "directional-element-interface.hh"
18 class A2_engraver : public Engraver
22 VIRTUAL_COPY_CONS (Translator);
25 void deprecated_process_music ();
26 virtual void acknowledge_element (Score_element_info);
28 virtual void process_acknowledged ();
29 virtual void do_pre_move_processing ();
33 enum State { SOLO, SPLIT_INTERVAL, UNIRHYTHM, UNISILENCE, UNISON } state_;
36 ADD_THIS_TRANSLATOR (A2_engraver);
38 A2_engraver::A2_engraver ()
46 A2_engraver::deprecated_process_music ()
48 if (!to_boolean (get_property ("combineParts")))
52 SCM unison = get_property ("unison");
53 SCM solo = get_property ("solo");
54 SCM solo_adue = get_property ("soloADue");
56 if (solo_adue == SCM_BOOL_T
57 && ((solo == SCM_BOOL_T && state_ != SOLO)
58 || (unison == SCM_BOOL_T && state_ != UNISON
59 && daddy_trans_l_->id_str_ == "one")))
61 text_p_ = new Item (get_property ("TextScript"));
62 Side_position::set_axis (text_p_, Y_AXIS);
63 announce_element (text_p_, 0);
67 if (solo == SCM_BOOL_T)
70 if (daddy_trans_l_->id_str_ == "one")
72 text = get_property ("soloText");
76 text = get_property ("soloIIText");
80 else if (unison == SCM_BOOL_T)
83 if (daddy_trans_l_->id_str_ == "one")
84 text = get_property ("aDueText");
87 Side_position::set_direction (text_p_, dir);
88 text_p_->set_elt_property ("text", text);
94 A2_engraver::acknowledge_element (Score_element_info i)
96 if (!to_boolean (get_property ("combineParts")))
101 if (Note_head::has_interface (i.elem_l_))
103 Score_element*t = text_p_;
104 Side_position::add_support (t, i.elem_l_);
105 if (Side_position::get_axis (t) == X_AXIS
106 && !t->parent_l (Y_AXIS))
107 t->set_parent (i.elem_l_, Y_AXIS);
109 if (Stem::has_interface (i.elem_l_))
111 Side_position::add_support (text_p_, i.elem_l_);
115 SCM unisilence = get_property ("unisilence");
116 SCM unison = get_property ("unison");
117 SCM unirhythm = get_property ("unirhythm");
118 SCM solo = get_property ("solo");
119 SCM split_interval = get_property ("split-interval");
120 SCM solo_adue = get_property ("soloADue");
122 State previous_state = state_;
123 if (unisilence == SCM_BOOL_T)
128 else if (solo == SCM_BOOL_T)
130 else if (unison == SCM_BOOL_T)
132 else if (unirhythm == SCM_BOOL_T && split_interval == SCM_BOOL_T)
133 state_ = SPLIT_INTERVAL;
137 if (Stem::has_interface (i.elem_l_)
138 || Slur::has_interface (i.elem_l_)
139 // || Text_item::has_interface (i.elem_l_)
140 //|| Hairpin::has_interface (i.elem_l_)
144 Hmm. We must set dir when solo, in order to get
145 the rests collided to the right position
147 if ((unirhythm != SCM_BOOL_T) || (solo == SCM_BOOL_T)
148 || ((unisilence == SCM_BOOL_T && previous_state != UNISON))
149 || (unirhythm == SCM_BOOL_T && split_interval == SCM_BOOL_T
150 && (unison != SCM_BOOL_T || solo_adue != SCM_BOOL_T)))
152 if (daddy_trans_l_->id_str_ == "one")
154 i.elem_l_->set_elt_property ("direction", gh_int2scm (1));
156 else if (daddy_trans_l_->id_str_ == "two")
158 i.elem_l_->set_elt_property ("direction", gh_int2scm (-1));
165 A2_engraver::process_acknowledged ()
167 deprecated_process_music ();
171 A2_engraver::do_pre_move_processing ()
175 Side_position::add_staff_support (text_p_);
176 typeset_element (text_p_);