2 arpeggio.cc -- implement Arpeggio
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2006 Jan Nieuwenhuizen <janneke@gnu.org>
11 #include "output-def.hh"
13 #include "staff-symbol-referencer.hh"
14 #include "staff-symbol.hh"
16 #include "font-interface.hh"
18 #include "pointer-group-interface.hh"
20 MAKE_SCHEME_CALLBACK (Arpeggio, print, 1);
22 Arpeggio::print (SCM smob)
24 Grob *me = unsmob_grob (smob);
28 extract_grob_set (me, "stems", stems);
29 for (vsize i = 0; i < stems.size (); i++)
31 Grob *stem = stems[i];
32 common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem),
39 Using stems here is not very convenient; should store noteheads
40 instead, and also put them into the support. Now we will mess up
41 in vicinity of a collision.
45 Real my_y = me->relative_coordinate (common, Y_AXIS);
47 for (vsize i = 0; i < stems.size (); i++)
49 Grob *stem = stems[i];
50 Grob *ss = Staff_symbol_referencer::get_staff_symbol (stem);
51 Interval iv = Stem::head_positions (stem);
52 iv *= Staff_symbol::staff_space (ss) / 2.0;
54 heads.unite (iv + ss->relative_coordinate (common, Y_AXIS)
58 if (heads.is_empty () || heads.length () < 0.5)
60 programming_error ("no heads for arpeggio found?");
65 SCM ad = me->get_property ("arpeggio-direction");
66 Direction dir = CENTER;
67 if (is_direction (ad))
71 Font_metric *fm = Font_interface::get_default_font (me);
72 Stencil squiggle = fm->find_by_name ("scripts.arpeggio");
77 arrow = fm->find_by_name ("scripts.arpeggio.arrow." + to_string (dir));
78 heads[dir] -= dir * arrow.extent (Y_AXIS).length ();
81 for (Real y = heads[LEFT]; y < heads[RIGHT];
82 y += squiggle.extent (Y_AXIS).length ())
83 mol.add_at_edge (Y_AXIS, UP, squiggle, 0.0, 0);
85 mol.translate_axis (heads[LEFT], Y_AXIS);
87 mol.add_at_edge (Y_AXIS, dir, arrow, 0, 0);
89 return mol.smobbed_copy ();
92 /* Draws a vertical bracket to the left of a chord
93 Chris Jackson <chris@fluffhouse.org.uk> */
95 MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_bracket, 1);
97 Arpeggio::brew_chord_bracket (SCM smob)
99 Grob *me = unsmob_grob (smob);
102 extract_grob_set (me, "stems", stems);
103 for (vsize i = 0; i < stems.size (); i++)
105 Grob *stem = stems[i];
106 common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem),
111 Real my_y = me->relative_coordinate (common, Y_AXIS);
113 for (vsize i = 0; i < stems.size (); i++)
115 Grob *stem = stems[i];
116 Grob *ss = Staff_symbol_referencer::get_staff_symbol (stem);
117 Interval iv = Stem::head_positions (stem);
118 iv *= Staff_symbol::staff_space (ss) / 2.0;
119 heads.unite (iv + ss->relative_coordinate (common, Y_AXIS) - my_y);
122 Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
123 Real sp = 1.5 * Staff_symbol_referencer::staff_space (me);
124 Real dy = heads.length () + sp;
127 Stencil mol (Lookup::bracket (Y_AXIS, Interval (0, dy), lt, x, lt));
128 mol.translate_axis (heads[LEFT] - sp / 2.0, Y_AXIS);
129 return mol.smobbed_copy ();
133 We have to do a callback, because print () triggers a
134 vertical alignment if it is cross-staff.
136 MAKE_SCHEME_CALLBACK (Arpeggio, width, 1);
138 Arpeggio::width (SCM smob)
140 Grob *me = unsmob_grob (smob);
141 Stencil arpeggio = Font_interface::get_default_font (me)->find_by_name ("scripts.arpeggio");
143 return ly_interval2scm (arpeggio.extent (X_AXIS));
146 ADD_INTERFACE (Arpeggio, "arpeggio-interface",
147 "Functions and settings for drawing an arpeggio symbol (a wavy line left to noteheads.",
150 "arpeggio-direction "