2 arpeggio.cc -- implement Arpeggio
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 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 (int 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 (int 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))
73 Font_metric *fm = Font_interface::get_default_font (me);
74 Stencil squiggle = fm->find_by_name ("scripts.arpeggio");
79 arrow = fm->find_by_name ("scripts.arpeggio.arrow." + to_string (dir));
80 heads[dir] -= dir * arrow.extent (Y_AXIS).length ();
83 for (Real y = heads[LEFT]; y < heads[RIGHT];
84 y += squiggle.extent (Y_AXIS).length ())
85 mol.add_at_edge (Y_AXIS, UP, squiggle, 0.0, 0);
87 mol.translate_axis (heads[LEFT], Y_AXIS);
89 mol.add_at_edge (Y_AXIS, dir, arrow, 0, 0);
91 return mol.smobbed_copy ();
94 /* Draws a vertical bracket to the left of a chord
95 Chris Jackson <chris@fluffhouse.org.uk> */
97 MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_bracket, 1);
99 Arpeggio::brew_chord_bracket (SCM smob)
101 Grob *me = unsmob_grob (smob);
104 extract_grob_set (me, "stems", stems);
105 for (int i = 0; i < stems.size (); i++)
107 Grob *stem = stems[i];
108 common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem),
113 Real my_y = me->relative_coordinate (common, Y_AXIS);
115 for (int i = 0; i < stems.size (); i++)
117 Grob *stem = stems[i];
118 Grob *ss = Staff_symbol_referencer::get_staff_symbol (stem);
119 Interval iv = Stem::head_positions (stem);
120 iv *= Staff_symbol::staff_space (ss) / 2.0;
121 heads.unite (iv + ss->relative_coordinate (common, Y_AXIS) - my_y);
124 Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
125 Real sp = 1.5 * Staff_symbol_referencer::staff_space (me);
126 Real dy = heads.length () + sp;
129 Stencil mol (Lookup::bracket (Y_AXIS, Interval (0, dy), lt, x, lt));
130 mol.translate_axis (heads[LEFT] - sp / 2.0, Y_AXIS);
131 return mol.smobbed_copy ();
135 We have to do a callback, because print () triggers a
136 vertical alignment if it is cross-staff.
138 MAKE_SCHEME_CALLBACK (Arpeggio, width_callback, 2);
140 Arpeggio::width_callback (SCM smob, SCM axis)
142 Grob *me = unsmob_grob (smob);
145 assert (scm_to_int (axis) == X_AXIS);
146 Stencil arpeggio = Font_interface::get_default_font (me)->find_by_name ("scripts.arpeggio");
148 return ly_interval2scm (arpeggio.extent (X_AXIS));
151 ADD_INTERFACE (Arpeggio, "arpeggio-interface",
152 "Functions and settings for drawing an arpeggio symbol (a wavy line left to noteheads.",
153 "stems arpeggio-direction");