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, UNISON, SOLO } state_;
34 ADD_THIS_TRANSLATOR (A2_engraver);
36 A2_engraver::A2_engraver ()
43 A2_engraver::do_process_music ()
49 A2_engraver::acknowledge_element (Score_element_info i)
53 SCM unison = get_property ("unison");
54 SCM solo = get_property ("solo");
56 if ((solo == SCM_BOOL_T && state_ != SOLO)
57 || (unison == SCM_BOOL_T && state_ != UNISON))
59 text_p_ = new Item (get_property ("basicTextScriptProperties"));
60 Side_position::set_axis (text_p_, Y_AXIS);
61 announce_element (text_p_, 0);
68 if (solo == SCM_BOOL_T)
71 if (daddy_trans_l_->id_str_ == "one")
72 text = ly_str02scm ("Solo");
75 text = ly_str02scm ("Solo II");
79 else if (unison == SCM_BOOL_T)
81 text = ly_str02scm ("\\`a 2");
85 Side_position::set_direction (text_p_, dir);
86 text_p_->set_elt_property ("text", text);
94 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 unirhythm = get_property ("unirhythm");
119 SCM unison = get_property ("unison");
120 SCM solo = get_property ("solo");
121 SCM interval = get_property ("interval");
124 This still needs some work.
126 if ((unirhythm != SCM_BOOL_T && solo != SCM_BOOL_T)
127 || (unirhythm == SCM_BOOL_T
128 && gh_number_p (interval) && gh_scm2int (interval) < 3))
130 if (daddy_trans_l_->id_str_ == "one")
132 //Directional_element_interface (stem_l).set (UP);
133 stem_l->set_elt_property ("direction", gh_int2scm (1));
135 else if (daddy_trans_l_->id_str_ == "two")
137 //Directional_element_interface (stem_l).set (DOWN);
138 stem_l->set_elt_property ("direction", gh_int2scm (-1));
145 A2_engraver::do_pre_move_processing ()
149 Side_position::add_staff_support (text_p_);
150 typeset_element (text_p_);