2 arpegggio.cc -- implement Arpeggio
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2002 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "paper-def.hh"
11 #include "arpeggio.hh"
14 #include "staff-symbol-referencer.hh"
15 #include "staff-symbol.hh"
17 #include "font-interface.hh"
20 Arpeggio::has_interface (Grob* 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 Grob *me = unsmob_grob (smob);
32 for (SCM s = me->get_grob_property ("stems"); gh_pair_p (s); s = ly_cdr (s))
34 Grob * stem = unsmob_grob (ly_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_grob_property ("stems"); gh_pair_p (s); s = ly_cdr (s))
52 Grob * stem = unsmob_grob (ly_car (s));
53 Grob * 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.
70 Direction dir = CENTER;
71 if (ly_dir_p (me->get_grob_property ("arpeggio-direction")))
73 dir = to_dir (me->get_grob_property ("arpeggio-direction"));
77 Font_metric *fm =Font_interface::get_default_font (me);
78 Molecule squiggle = fm->find_by_name ("scripts-arpeggio");
80 Real arrow_space = (dir) ? Staff_symbol_referencer::staff_space (me) : 0.0;
83 while (y < heads[RIGHT] - arrow_space)
85 mol.add_at_edge (Y_AXIS, UP,squiggle, 0.0);
86 y+= squiggle. extent (Y_AXIS).length ();
88 mol.translate_axis (heads[LEFT], Y_AXIS);
90 mol.add_at_edge (Y_AXIS, dir,
91 fm->find_by_name ("scripts-arpeggio-arrow-" + to_str (dir)), 0.0);
93 return mol.smobbed_copy () ;
97 We have to do a callback, because brew_molecule () triggers a
98 vertical alignment if it is cross-staff.
99 This callback also adds padding.
101 MAKE_SCHEME_CALLBACK (Arpeggio, width_callback,2);
103 Arpeggio::width_callback (SCM smob, SCM axis)
105 Grob * me = unsmob_grob (smob);
106 Axis a = (Axis)gh_scm2int (axis);
107 assert (a == X_AXIS);
108 Molecule arpeggio = Font_interface::get_default_font (me)->find_by_name ("scripts-arpeggio");
110 return ly_interval2scm (arpeggio.extent (X_AXIS) * 1.5);
114 ADD_INTERFACE (Arpeggio, "arpeggio-interface",
115 "Functions and settings for drawing an arpeggio symbol (a wavy line left to noteheads.",
116 "stems arpeggio-direction");