2 stem-tremolo.cc -- implement Stem_tremolo
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "stem-tremolo.hh"
13 #include "paper-def.hh"
17 #include "staff-symbol-referencer.hh"
18 #include "directional-element-interface.hh"
22 lengthen stem if necessary
26 Stem_tremolo::set_interface (Score_element *me)
32 Stem_tremolo::dim_callback (Score_element * se, Axis )
34 Real space = Staff_symbol_referencer::staff_space (se);
35 return Interval (-space, space);
40 MAKE_SCHEME_CALLBACK(Stem_tremolo,brew_molecule);
42 Stem_tremolo::brew_molecule (SCM smob)
44 Score_element *me= unsmob_element (smob);
45 Score_element * stem = unsmob_element (me->get_elt_property ("stem"));
46 Score_element * beam = Stem::beam_l (stem);
52 SCM s = beam->get_elt_property ("height");
54 dy = gh_scm2double (s);
55 Real dx = Beam::last_visible_stem (beam)->relative_coordinate (0, X_AXIS)
56 - Beam::first_visible_stem (beam)->relative_coordinate (0, X_AXIS);
57 dydx = dx ? dy/dx : 0;
63 Real ss = Staff_symbol_referencer::staff_space (stem);
64 Real thick = gh_scm2double (me->get_elt_property ("beam-thickness"));
65 Real width = gh_scm2double (me->get_elt_property ("beam-width"));
69 Molecule a (me->lookup_l ()->beam (dydx, width, thick));
70 a.translate (Offset (-width/2, width / 2 * dydx));
73 SCM s = me->get_elt_property ("tremolo-flags");
75 tremolo_flags = gh_scm2int (s);
80 int mult = beam ? Beam::get_multiplicity (beam) : 0;
81 Real interbeam_f = me->paper_l ()->interbeam_f (mult);
83 for (int i = 0; i < tremolo_flags; i++)
86 b.translate_axis (interbeam_f * i, Y_AXIS);
90 mol.translate_axis (-mol.extent (Y_AXIS).center (), Y_AXIS);
93 // ugh, rather calc from Stem_tremolo_req
94 int beams_i = Stem::beam_count(stem, RIGHT) >? Stem::beam_count (stem, LEFT);
95 mol.translate (Offset(stem->relative_coordinate (0, X_AXIS) - me->relative_coordinate (0, X_AXIS),
96 Stem::stem_end_position (stem ) * ss / 2 -
97 Directional_element_interface::get (beam) * beams_i * interbeam_f));
102 Beams should intersect one beamthickness below stem end
104 Real dy = Stem::stem_end_position (stem ) * ss / 2;
105 dy -= mol.extent (Y_AXIS).length () / 2 * Stem::get_direction (stem );
108 uhg. Should use relative coords and placement
110 Real whole_note_correction;
111 if (Stem::invisible_b (stem ))
112 whole_note_correction = -Stem::get_direction (stem )
113 * Stem::support_head (stem )->extent (X_AXIS).length () / 2;
115 whole_note_correction = 0;
117 mol.translate (Offset (stem->relative_coordinate (0, X_AXIS) - me->relative_coordinate (0, X_AXIS) +
118 whole_note_correction, dy));
121 return mol.create_scheme();
126 Stem_tremolo::set_stem (Score_element*me,Score_element *s)
128 me->set_elt_property ("stem", s->self_scm ());