2 clef.cc -- implement Clef_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>,
7 Mats Bengtsson <matsb@s3.kth.se>
11 #include "clef-grav.hh"
12 #include "clef-item.hh"
14 #include "command-request.hh"
15 #include "time-description.hh"
17 Clef_engraver::Clef_engraver()
27 Ugh. Should have support for Dictionaries in mudela.
30 Clef_engraver::set_type (String s
)
32 if (s
.right_str(2) == "_8") // Down one octave
35 s
= s
.left_str(s
.length_i() - 2);
37 else if (s
.right_str(2) == "^8") // Up one octave
40 s
= s
.left_str(s
.length_i() - 2);
45 if (clef_type_str_
== "violin" || clef_type_str_
== "G" || clef_type_str_
== "G2")
47 else if (clef_type_str_
== "french")
49 else if (clef_type_str_
== "soprano")
51 else if (clef_type_str_
== "mezzosoprano")
53 else if (clef_type_str_
== "alto")
55 else if (clef_type_str_
== "tenor")
57 else if (clef_type_str_
== "baritone")
59 else if (clef_type_str_
== "varbaritone")
61 else if (clef_type_str_
== "bass" || clef_type_str_
== "F")
63 else if (clef_type_str_
== "subbass")
66 switch(clef_type_str_
[0])
69 c0_position_i_
= 2 * (clef_type_str_
[1] - '0') - 2;
72 c0_position_i_
= 2 * (clef_type_str_
[1] - '0') - 10;
75 c0_position_i_
= 2 * (clef_type_str_
[1] - '0') - 6;
80 c0_position_i_
-= (int) octave_dir_
* 7;
86 Clef_engraver::fill_staff_info (Staff_info
&i
)
88 i
.c0_position_i_l_
= &c0_position_i_
;
92 Clef_engraver::read_req (Clef_change_req
*c_l
)
94 if (!set_type (c_l
->clef_str_
))
95 c_l
->error (_("unknown clef type "));
100 Generate a clef at the start of a measure. (when you see a Bar,
104 Clef_engraver::acknowledge_element (Score_elem_info info
)
106 if (info
.elem_l_
->is_type_b (Bar::static_name ())
107 && clef_type_str_
.length_i())
111 clef_p_
->default_b_
= true;
116 Clef_engraver::do_creation_processing()
118 Scalar def
= get_property ("defaultclef");
119 if (def
.operator bool ()) // egcs: Scalar to bool is ambiguous
121 if (clef_type_str_
.length_i ())
123 clef_p_
->default_b_
= false;
127 Clef_engraver::do_try_request (Request
* r_l
)
129 Command_req
* creq_l
= r_l
->command();
130 if (!creq_l
|| !creq_l
->clefchange())
133 clef_req_l_
= creq_l
->clefchange();
134 read_req (clef_req_l_
);
139 Clef_engraver::create_clef()
143 clef_p_
= new Clef_item
;
144 clef_p_
->break_priority_i_
= -2; // ugh
145 announce_element (Score_elem_info (clef_p_
,clef_req_l_
));
147 clef_p_
->read (*this);
151 Clef_engraver::do_process_requests()
156 clef_p_
->default_b_
= false;
161 Clef_engraver::do_pre_move_processing()
165 typeset_element (clef_p_
);
170 Clef_engraver::do_post_move_processing()
176 Clef_engraver::do_removal_processing()
183 IMPLEMENT_IS_TYPE_B1(Clef_engraver
,Engraver
);
184 ADD_THIS_TRANSLATOR(Clef_engraver
);