2 arpegggio.cc -- implement Arpeggio
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "paper-def.hh"
12 #include "arpeggio.hh"
13 #include "score-element.hh"
15 #include "staff-symbol-referencer.hh"
16 #include "staff-symbol.hh"
20 Arpeggio::has_interface (Score_element* me)
22 return me && me->has_interface (ly_symbol2scm ("arpeggio-interface"));
25 MAKE_SCHEME_CALLBACK (Arpeggio, brew_molecule, 1);
27 Arpeggio::brew_molecule (SCM smob)
29 Score_element *me = unsmob_element (smob);
31 Score_element * common = me;
32 for (SCM s = me->get_elt_property ("stems"); gh_pair_p (s); s = gh_cdr (s))
34 Score_element * stem = unsmob_element (gh_car (s));
35 common = common->common_refpoint (Staff_symbol_referencer::staff_symbol_l (stem),
42 Using stems here is not very convenient; should store noteheads
43 instead, and also put them into the support. Now we will mess up
44 in vicinity of a collision.
48 Real my_y = me->relative_coordinate (common, Y_AXIS);
50 for (SCM s = me->get_elt_property ("stems"); gh_pair_p (s); s = gh_cdr (s))
52 Score_element * stem = unsmob_element (gh_car (s));
53 Score_element * ss = Staff_symbol_referencer::staff_symbol_l (stem);
54 Interval iv =Stem::head_positions (stem);
55 iv *= Staff_symbol::staff_space (ss)/2.0;
57 heads.unite (iv + ss->relative_coordinate (common, Y_AXIS)
63 programming_error ("Huh? Dumb blonde encountered?");
65 Nee Valerie, jij bent _niet_ dom.
71 Molecule arpeggio = me->paper_l ()->lookup_l (0)->afm_find ("scripts-arpeggio");
74 while (y < heads[RIGHT])
76 mol.add_at_edge (Y_AXIS, UP,arpeggio, 0.0);
77 y+= arpeggio. extent (Y_AXIS).length ();
79 mol.translate_axis (heads[LEFT], Y_AXIS);
81 return mol.create_scheme ();
85 We have to do a callback, because brew_molecule () triggers a
86 vertical alignment if it is cross-staff.
87 This callback alos adds padding.
89 MAKE_SCHEME_CALLBACK(Arpeggio, width_callback,2);
91 Arpeggio::width_callback (SCM smob, SCM axis)
93 Score_element * me = unsmob_element (smob);
94 Axis a = (Axis)gh_scm2int (axis);
96 Molecule arpeggio = me->paper_l ()->lookup_l (0)->afm_find ("scripts-arpeggio");
98 return ly_interval2scm (arpeggio.extent (X_AXIS) * 1.5);