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"
13 #include "translator-group.hh"
14 #include "side-position-interface.hh"
15 #include "directional-element-interface.hh"
17 class A2_engraver : public Engraver
21 VIRTUAL_COPY_CONS (Translator);
24 virtual void do_process_music ();
25 virtual void acknowledge_element (Score_element_info);
27 virtual void do_pre_move_processing ();
31 enum State { NORMAL, SOLO, SPLIT_INTERVAL, UNISON } state_;
34 ADD_THIS_TRANSLATOR (A2_engraver);
36 A2_engraver::A2_engraver ()
43 A2_engraver::do_process_music ()
47 SCM unison = get_property ("unison");
48 SCM unirhythm = get_property ("unirhythm");
49 SCM solo = get_property ("solo");
50 SCM split_interval = get_property ("split-interval");
51 SCM solo_adue = get_property ("soloADue");
53 if (solo_adue == SCM_BOOL_T
54 && ((solo == SCM_BOOL_T && state_ != SOLO)
55 || (unison == SCM_BOOL_T && state_ != UNISON
56 && daddy_trans_l_->id_str_ == "one")))
58 text_p_ = new Item (get_property ("basicTextScriptProperties"));
59 Side_position::set_axis (text_p_, Y_AXIS);
60 announce_element (text_p_, 0);
64 if (solo == SCM_BOOL_T)
67 if (daddy_trans_l_->id_str_ == "one")
69 text = get_property ("soloText");
73 text = get_property ("soloIIText");
77 else if (unison == SCM_BOOL_T)
80 if (daddy_trans_l_->id_str_ == "one")
81 text = get_property ("aDueText");
84 Side_position::set_direction (text_p_, dir);
85 text_p_->set_elt_property ("text", text);
87 else if (unison == SCM_BOOL_T)
89 else if (unirhythm == SCM_BOOL_T && split_interval == SCM_BOOL_T)
90 state_ = SPLIT_INTERVAL;
95 A2_engraver::acknowledge_element (Score_element_info i)
99 if (Note_head::has_interface (i.elem_l_))
101 Score_element*t = text_p_;
102 Side_position::add_support (t, i.elem_l_);
103 if (Side_position::get_axis (t) == X_AXIS
104 && !t->parent_l (Y_AXIS))
105 t->set_parent (i.elem_l_, Y_AXIS);
107 if (Stem::has_interface (i.elem_l_))
109 Side_position::add_support (text_p_, i.elem_l_);
114 if (Stem::has_interface (i.elem_l_))
116 Item *stem_l = dynamic_cast<Item*> (i.elem_l_);
118 SCM unison = get_property ("unison");
119 SCM unirhythm = get_property ("unirhythm");
120 SCM solo = get_property ("solo");
121 SCM split_interval = get_property ("split-interval");
122 SCM solo_adue = get_property ("soloADue");
124 if ((unirhythm != SCM_BOOL_T && solo != SCM_BOOL_T)
125 || (unirhythm == SCM_BOOL_T && split_interval == SCM_BOOL_T
126 && (unison != SCM_BOOL_T || solo_adue != SCM_BOOL_T)))
128 if (daddy_trans_l_->id_str_ == "one")
130 stem_l->set_elt_property ("direction", gh_int2scm (1));
132 else if (daddy_trans_l_->id_str_ == "two")
134 stem_l->set_elt_property ("direction", gh_int2scm (-1));
141 A2_engraver::do_pre_move_processing ()
145 Side_position::add_staff_support (text_p_);
146 typeset_element (text_p_);