]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-arpeggio.cc
patch::: 1.3.94.jcn3
[lilypond.git] / lily / span-arpeggio.cc
1 /*
2   span-arpeggio.cc -- implement Span_arpeggio
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "axis-group-interface.hh"
10 #include "molecule.hh"
11 #include "paper-def.hh"
12 #include "lookup.hh"
13 #include "arpeggio.hh"
14 #include "span-arpeggio.hh"
15 #include "score-element.hh"
16 #include "stem.hh"
17 #include "staff-symbol-referencer.hh"
18
19 bool
20 Span_arpeggio::has_interface (Score_element* me)
21 {
22   return me && me->has_interface (ly_symbol2scm ("span-arpeggio-interface"));
23 }
24
25 /*
26   We could collapse this with Arpeggio::brew_molecule, but that requires
27   hairy scm callback hacking.
28  */
29 MAKE_SCHEME_CALLBACK (Span_arpeggio, brew_molecule, 1);
30 SCM 
31 Span_arpeggio::brew_molecule (SCM smob) 
32 {
33   Score_element *me = unsmob_element (smob);
34   
35   Interval iv;
36   Score_element *common = me;
37   for (SCM s = me->get_elt_property ("arpeggios"); gh_pair_p (s); s = gh_cdr (s))
38     {
39       Score_element *arpeggio = unsmob_element (gh_car (s));
40       common = arpeggio->common_refpoint (common, Y_AXIS);
41     }
42   // Hmm, nothing in common?
43   if (0) //common)
44     for (SCM s = me->get_elt_property ("arpeggios"); gh_pair_p (s); s = gh_cdr (s))
45       {
46         Score_element *arpeggio = unsmob_element (gh_car (s));
47         Real c = common->relative_coordinate (arpeggio, Y_AXIS);
48         //iv.unite (Arpeggio::head_positions (stem));
49         iv.unite (Interval (c, c));
50       }
51   else
52     iv = Interval (-23, 5);
53
54   Molecule mol;
55   Molecule arpeggio = me->paper_l ()->lookup_l (0)->afm_find ("scripts-arpeggio");
56   Real staff_space = Staff_symbol_referencer::staff_space (me);
57   for (int i = (int)iv[MIN]/ 2; i < (int)(iv[MAX] - 1)/ 2; i++)
58     {
59       Molecule a (arpeggio);
60       a.translate_axis (i * staff_space, Y_AXIS);
61       mol.add_molecule (a);
62     }
63   mol.translate (Offset (-2 * staff_space, 0);
64
65   return mol.create_scheme (); 
66 }
67