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);
24 virtual void acknowledge_grob (Grob_info);
25 virtual void create_grobs ();
26 virtual void stop_translation_timestep ();
29 enum State { SOLO, SPLIT_INTERVAL, UNIRHYTHM, UNISILENCE, UNISON } state_;
32 ADD_THIS_TRANSLATOR (A2_engraver);
34 A2_engraver::A2_engraver ()
41 A2_engraver::create_grobs ()
43 if (!to_boolean (get_property ("combineParts")))
47 SCM unison = get_property ("unison");
48 SCM solo = get_property ("solo");
49 SCM solo_adue = get_property ("soloADue");
51 if (solo_adue == SCM_BOOL_T
52 && ((solo == SCM_BOOL_T && state_ != SOLO)
53 || (unison == SCM_BOOL_T && state_ != UNISON
54 && daddy_trans_l_->id_str_ == "one")))
56 text_p_ = new Item (get_property ("TextScript"));
57 Side_position::set_axis (text_p_, Y_AXIS);
58 announce_grob (text_p_, 0);
62 if (solo == SCM_BOOL_T)
65 if (daddy_trans_l_->id_str_ == "one")
67 text = get_property ("soloText");
71 text = get_property ("soloIIText");
75 else if (unison == SCM_BOOL_T)
78 if (daddy_trans_l_->id_str_ == "one")
79 text = get_property ("aDueText");
82 Side_position::set_direction (text_p_, dir);
83 text_p_->set_grob_property ("text", text);
89 A2_engraver::acknowledge_grob (Grob_info i)
91 if (!to_boolean (get_property ("combineParts")))
96 if (Note_head::has_interface (i.elem_l_))
99 Side_position::add_support (t, i.elem_l_);
100 if (Side_position::get_axis (t) == X_AXIS
101 && !t->parent_l (Y_AXIS))
102 t->set_parent (i.elem_l_, Y_AXIS);
104 if (Stem::has_interface (i.elem_l_))
106 Side_position::add_support (text_p_, i.elem_l_);
110 SCM unisilence = get_property ("unisilence");
111 SCM unison = get_property ("unison");
112 SCM unirhythm = get_property ("unirhythm");
113 SCM solo = get_property ("solo");
114 SCM split_interval = get_property ("split-interval");
115 SCM solo_adue = get_property ("soloADue");
117 State previous_state = state_;
118 if (unisilence == SCM_BOOL_T)
123 else if (solo == SCM_BOOL_T)
125 else if (unison == SCM_BOOL_T)
127 else if (unirhythm == SCM_BOOL_T && split_interval == SCM_BOOL_T)
128 state_ = SPLIT_INTERVAL;
132 if (Stem::has_interface (i.elem_l_)
133 || Slur::has_interface (i.elem_l_)
134 // || Text_item::has_interface (i.elem_l_)
135 //|| Hairpin::has_interface (i.elem_l_)
139 Hmm. We must set dir when solo, in order to get
140 the rests collided to the right position
142 if ((unirhythm != SCM_BOOL_T) || (solo == SCM_BOOL_T)
143 || ((unisilence == SCM_BOOL_T && previous_state != UNISON))
144 || (unirhythm == SCM_BOOL_T && split_interval == SCM_BOOL_T
145 && (unison != SCM_BOOL_T || solo_adue != SCM_BOOL_T)))
147 if (daddy_trans_l_->id_str_ == "one")
149 i.elem_l_->set_grob_property ("direction", gh_int2scm (1));
151 else if (daddy_trans_l_->id_str_ == "two")
153 i.elem_l_->set_grob_property ("direction", gh_int2scm (-1));
160 A2_engraver::stop_translation_timestep ()
164 Side_position::add_staff_support (text_p_);
165 typeset_grob (text_p_);