2 abbreviation-beam-engraver.cc -- implement Abbreviation_beam_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "duration-convert.hh"
11 #include "time-description.hh"
12 #include "abbreviation-beam-engraver.hh"
14 #include "abbreviation-beam.hh"
15 #include "musical-request.hh"
18 #include "score-engraver.hh"
20 ADD_THIS_TRANSLATOR (Abbreviation_beam_engraver
);
22 Abbreviation_beam_engraver::Abbreviation_beam_engraver ()
24 reqs_drul_
[LEFT
] = reqs_drul_
[RIGHT
] = 0;
26 finished_abeam_p_
= 0;
31 Abbreviation_beam_engraver::do_try_music (Music
* m
)
33 if (Abbreviation_beam_req
* b
= dynamic_cast <Abbreviation_beam_req
*> (m
))
35 Direction d
= b
->span_dir_
;
36 if (reqs_drul_
[d
] && !reqs_drul_
[d
]->equal_b (b
))
39 if ((d
== STOP
) && !abeam_p_
)
41 m
->warning (_ ("No abbreviation beam to end"));
53 Abbreviation_beam_engraver::do_process_requests ()
58 reqs_drul_
[STOP
]->warning (_("No abbreviation beam to end"));
60 finished_abeam_p_
= abeam_p_
;
66 Score_engraver
* e
= 0;
67 Translator
* t
= daddy_grav_l ();
68 for (; !e
&& t
; t
= t
->daddy_trans_l_
)
70 e
= dynamic_cast<Score_engraver
*> (t
);
74 programming_error ("No score engraver!");
79 if (reqs_drul_
[START
])
83 reqs_drul_
[START
]->warning (_ ("Already have an abbreviation beam"));
87 prev_start_req_
= reqs_drul_
[START
];
89 abeam_p_
= new Abbreviation_beam
;
90 announce_element (Score_element_info (abeam_p_
, reqs_drul_
[LEFT
]));
95 Abbreviation_beam_engraver::do_post_move_processing ()
97 reqs_drul_
[START
] = 0;
101 Abbreviation_beam_engraver::do_pre_move_processing ()
107 Abbreviation_beam_engraver::typeset_beam ()
109 if (finished_abeam_p_
)
111 typeset_element (finished_abeam_p_
);
112 finished_abeam_p_
= 0;
114 reqs_drul_
[STOP
] = 0;
119 Abbreviation_beam_engraver::do_removal_processing ()
124 prev_start_req_
->warning (_ ("Unfinished abbreviation beam"));
125 finished_abeam_p_
= abeam_p_
;
131 Abbreviation_beam_engraver::acknowledge_element (Score_element_info i
)
135 if (Stem
* s
= dynamic_cast<Stem
*> (i
.elem_l_
))
137 int type_i
= prev_start_req_
->type_i_
;
138 s
->flag_i_
= intlog2 (type_i
) - 2;
140 s
->beams_i_drul_
[LEFT
] = s
->flag_i_
;
141 s
->beams_i_drul_
[RIGHT
] = s
->flag_i_
;
143 abeam_p_
->multiple_i_
= s
->flag_i_
;
145 abbrev gaps on all but half note
148 if (s
->type_i () != 1)
150 int gap_i
=s
->flag_i_
- ((s
->type_i () >? 2) - 2);
151 s
->set_elt_property (beam_gap_scm_sym
, gh_int2scm(gap_i
));
154 if (s
->type_i () != 1)
156 int gap_i
=s
->flag_i_
- ((s
->type_i () >? 2) - 2);
157 abeam_p_
->set_elt_property (beam_gap_scm_sym
, gh_int2scm(gap_i
));
161 abeam_p_
->add_stem (s
);