2 abbrev.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 "dimension-cache.hh"
18 #include "staff-symbol-referencer.hh"
19 #include "directional-element-interface.hh"
21 Stem_tremolo::Stem_tremolo ()
23 set_elt_property ("stem", SCM_EOL
);
28 Stem_tremolo::stem_l ()const
30 SCM s
= get_elt_property ("stem");
32 return dynamic_cast<Stem
*> ( unsmob_element (s
));
36 Stem_tremolo::dim_callback (Dimension_cache
const *c
)
38 Stem_tremolo
* s
= dynamic_cast<Stem_tremolo
*> (c
->element_l ());
39 Real space
= Staff_symbol_referencer_interface (s
->stem_l ())
41 return Interval (-space
, space
);
46 Stem_tremolo::do_brew_molecule_p () const
48 Stem
* st
= stem_l ();
50 if (Beam
* b
= st
->beam_l ())
52 mult
= b
->get_multiplicity ();
55 Real interbeam_f
= paper_l ()->interbeam_f (mult
);
56 Real w
= gh_scm2double (get_elt_property ("beam-width"));
57 Real space
= Staff_symbol_referencer_interface (st
).staff_space ();
58 Real half_staff_space
= space
/ 2;
59 Real beam_f
= gh_scm2double (get_elt_property ("beam-thickness"));
64 if (st
&& st
->beam_l ())
67 SCM s
= st
->beam_l ()->get_elt_property ("height");
69 dy
= gh_scm2double (s
);
70 Real dx
= st
->beam_l ()->last_visible_stem ()->hpos_f ()
71 - st
->beam_l ()->first_visible_stem ()->hpos_f ();
74 // ugh, rather calc from Stem_tremolo_req
75 beams_i
= st
->beam_count(RIGHT
) >? st
->beam_count (LEFT
);
78 Molecule
a (lookup_l ()->beam (dydx
, w
, beam_f
));
79 a
.translate (Offset (-w
/2, w
/ 2 * dydx
));
83 SCM a
= get_elt_property ("abbrev-flags");
85 abbrev_flags
= gh_scm2int (a
);
88 Molecule
*beams
= new Molecule
;
89 for (int i
= 0; i
< abbrev_flags
; i
++)
92 b
.translate_axis (interbeam_f
* i
, Y_AXIS
);
93 beams
->add_molecule (b
);
95 beams
->translate_axis (-beams
->extent ()[Y_AXIS
].center (), Y_AXIS
);
101 beams
->translate (Offset(st
->hpos_f () - hpos_f (),
102 st
->stem_end_position () * half_staff_space
-
103 directional_element (st
->beam_l ()).get () * beams_i
* interbeam_f
));
108 Beams should intersect one beamthickness below staff end
110 Real dy
= - beams
->extent ()[Y_AXIS
].length () / 2 * st
->get_direction ();
113 uhg. Should use relative coords and placement
115 Real whole_note_correction
= (st
&& st
->invisible_b( ))
116 ? 0.0 // -st->get_direction () * st->note_delta_f ()/2
119 dy
+= st
->stem_end_position ();
120 beams
->translate (Offset(st
->hpos_f () - hpos_f ()+
121 whole_note_correction
, dy
));
125 there used to be half a page of code that was long commented out.
135 Stem_tremolo::set_stem (Stem
*s
)
137 set_elt_property ("stem", s
->self_scm_
);