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"
19 class A2_engraver : public Engraver
23 VIRTUAL_COPY_CONS (Translator);
25 virtual void acknowledge_grob (Grob_info);
26 virtual void create_grobs ();
27 virtual void stop_translation_timestep ();
30 enum State { SOLO, SPLIT_INTERVAL, UNIRHYTHM, UNISILENCE, UNISON } state_;
33 ADD_THIS_TRANSLATOR (A2_engraver);
35 A2_engraver::A2_engraver ()
42 A2_engraver::create_grobs ()
44 if (!to_boolean (get_property ("combineParts")))
48 SCM unison = get_property ("unison");
49 SCM solo = get_property ("solo");
50 SCM solo_adue = get_property ("soloADue");
52 if (solo_adue == SCM_BOOL_T
53 && ((solo == SCM_BOOL_T && state_ != SOLO)
54 || (unison == SCM_BOOL_T && state_ != UNISON
55 && daddy_trans_l_->id_str_.left_str (3) == "one")))
57 text_p_ = new Item (get_property ("TextScript"));
58 Side_position::set_axis (text_p_, Y_AXIS);
59 announce_grob (text_p_, 0);
63 if (solo == SCM_BOOL_T)
66 if (daddy_trans_l_->id_str_.left_str (3) == "one")
68 text = get_property ("soloText");
72 text = get_property ("soloIIText");
76 else if (unison == SCM_BOOL_T)
79 if (daddy_trans_l_->id_str_.left_str (3) == "one")
80 text = get_property ("aDueText");
83 Side_position::set_direction (text_p_, dir);
84 text_p_->set_grob_property ("text", text);
90 A2_engraver::acknowledge_grob (Grob_info i)
92 if (!to_boolean (get_property ("combineParts")))
97 if (Note_head::has_interface (i.elem_l_))
100 Side_position::add_support (t, i.elem_l_);
101 if (Side_position::get_axis (t) == X_AXIS
102 && !t->parent_l (Y_AXIS))
103 t->set_parent (i.elem_l_, Y_AXIS);
105 if (Stem::has_interface (i.elem_l_))
107 Side_position::add_support (text_p_, i.elem_l_);
111 SCM unisilence = get_property ("unisilence");
112 SCM unison = get_property ("unison");
113 SCM unirhythm = get_property ("unirhythm");
114 SCM solo = get_property ("solo");
115 SCM split_interval = get_property ("split-interval");
116 SCM solo_adue = get_property ("soloADue");
118 State previous_state = state_;
119 if (unisilence == SCM_BOOL_T)
124 else if (solo == SCM_BOOL_T)
126 else if (unison == SCM_BOOL_T)
128 else if (unirhythm == SCM_BOOL_T && split_interval == SCM_BOOL_T)
129 state_ = SPLIT_INTERVAL;
133 if (Stem::has_interface (i.elem_l_)
134 || Slur::has_interface (i.elem_l_)
136 Usually, dynamics are removed by *_devnull_engravers for the
137 second voice. We don't want all dynamics for the first voice
138 to be placed above the staff. */
140 || i.elem_l_->has_interface (ly_symbol2scm ("dynamic-interface"))
141 || i.elem_l_->has_interface (ly_symbol2scm ("text-interface"))
146 Hmm. We must set dir when solo, in order to get
147 the rests collided to the right position
149 if ((unirhythm != SCM_BOOL_T) || (solo == SCM_BOOL_T)
150 || ((unisilence == SCM_BOOL_T && previous_state != UNISON))
151 || (unirhythm == SCM_BOOL_T && split_interval == SCM_BOOL_T
152 && (unison != SCM_BOOL_T || solo_adue != SCM_BOOL_T)))
154 if (daddy_trans_l_->id_str_.left_str (3) == "one")
156 i.elem_l_->set_grob_property ("direction", gh_int2scm (1));
158 else if (daddy_trans_l_->id_str_.left_str (3) == "two")
160 i.elem_l_->set_grob_property ("direction", gh_int2scm (-1));
167 A2_engraver::stop_translation_timestep ()
171 Side_position::add_staff_support (text_p_);
172 typeset_grob (text_p_);