2 arpeggio.cc -- implement Arpeggio
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2006 Jan Nieuwenhuizen <janneke@gnu.org>
12 #include "output-def.hh"
14 #include "staff-symbol-referencer.hh"
15 #include "staff-symbol.hh"
17 #include "font-interface.hh"
19 #include "pointer-group-interface.hh"
21 MAKE_SCHEME_CALLBACK (Arpeggio, print, 1);
23 Arpeggio::print (SCM smob)
25 Grob *me = unsmob_grob (smob);
29 extract_grob_set (me, "stems", stems);
30 for (vsize i = 0; i < stems.size (); i++)
32 Grob *stem = stems[i];
33 common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem),
40 Using stems here is not very convenient; should store noteheads
41 instead, and also put them into the support. Now we will mess up
42 in vicinity of a collision.
46 Real my_y = me->relative_coordinate (common, Y_AXIS);
48 for (vsize i = 0; i < stems.size (); i++)
50 Grob *stem = stems[i];
51 Grob *ss = Staff_symbol_referencer::get_staff_symbol (stem);
52 Interval iv = Stem::head_positions (stem);
53 iv *= Staff_symbol::staff_space (ss) / 2.0;
55 heads.unite (iv + ss->relative_coordinate (common, Y_AXIS)
59 if (heads.is_empty () || heads.length () < 0.5)
61 programming_error ("no heads for arpeggio found?");
66 SCM ad = me->get_property ("arpeggio-direction");
67 Direction dir = CENTER;
68 if (is_direction (ad))
72 Font_metric *fm = Font_interface::get_default_font (me);
73 Stencil squiggle = fm->find_by_name ("scripts.arpeggio");
78 arrow = fm->find_by_name ("scripts.arpeggio.arrow." + to_string (dir));
79 heads[dir] -= dir * arrow.extent (Y_AXIS).length ();
82 for (Real y = heads[LEFT]; y < heads[RIGHT];
83 y += squiggle.extent (Y_AXIS).length ())
84 mol.add_at_edge (Y_AXIS, UP, squiggle, 0.0, 0);
86 mol.translate_axis (heads[LEFT], Y_AXIS);
88 mol.add_at_edge (Y_AXIS, dir, arrow, 0, 0);
90 return mol.smobbed_copy ();
93 /* Draws a vertical bracket to the left of a chord
94 Chris Jackson <chris@fluffhouse.org.uk> */
96 MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_bracket, 1);
98 Arpeggio::brew_chord_bracket (SCM smob)
100 Grob *me = unsmob_grob (smob);
103 extract_grob_set (me, "stems", stems);
104 for (vsize i = 0; i < stems.size (); i++)
106 Grob *stem = stems[i];
107 common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem),
112 Real my_y = me->relative_coordinate (common, Y_AXIS);
114 for (vsize i = 0; i < stems.size (); i++)
116 Grob *stem = stems[i];
117 Grob *ss = Staff_symbol_referencer::get_staff_symbol (stem);
118 Interval iv = Stem::head_positions (stem);
119 iv *= Staff_symbol::staff_space (ss) / 2.0;
120 heads.unite (iv + ss->relative_coordinate (common, Y_AXIS) - my_y);
123 Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
124 Real sp = 1.5 * Staff_symbol_referencer::staff_space (me);
125 Real dy = heads.length () + sp;
128 Stencil mol (Lookup::bracket (Y_AXIS, Interval (0, dy), lt, x, lt));
129 mol.translate_axis (heads[LEFT] - sp / 2.0, Y_AXIS);
130 return mol.smobbed_copy ();
134 We have to do a callback, because print () triggers a
135 vertical alignment if it is cross-staff.
137 MAKE_SCHEME_CALLBACK (Arpeggio, width, 1);
139 Arpeggio::width (SCM smob)
141 Grob *me = unsmob_grob (smob);
142 Stencil arpeggio = Font_interface::get_default_font (me)->find_by_name ("scripts.arpeggio");
144 return ly_interval2scm (arpeggio.extent (X_AXIS));
147 ADD_INTERFACE (Arpeggio,
148 "Functions and settings for drawing an arpeggio symbol (a wavy line left to noteheads.",
151 "arpeggio-direction "
153 "script-priority " // TODO: make around-note-interface