]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-arpeggio.cc
patch::: 1.3.95.jcn1
[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   Score_element *common = 0;
38   for (SCM s = me->get_elt_property ("arpeggios"); gh_pair_p (s); s = gh_cdr (s))
39     {
40       Score_element *arpeggio = unsmob_element (gh_car (s));
41       if (common)
42         common = arpeggio->common_refpoint (common, Y_AXIS);
43       else
44         common = arpeggio;
45     }
46   if (0)  //common)
47     for (SCM s = me->get_elt_property ("arpeggios"); gh_pair_p (s); s = gh_cdr (s))
48       {
49         Score_element *arpeggio = unsmob_element (gh_car (s));
50         // this dumps core: someone has no y-parent
51         Real c = common->relative_coordinate (arpeggio, Y_AXIS);
52         //iv.unite (Arpeggio::head_positions (stem));
53         iv.unite (Interval (c, c));
54       }
55   else
56     iv = Interval (-23, 5);
57
58   Molecule mol;
59   Molecule arpeggio = me->paper_l ()->lookup_l (0)->afm_find ("scripts-arpeggio");
60   Real staff_space = Staff_symbol_referencer::staff_space (me);
61   for (int i = (int)iv[MIN]/ 2; i < (int)(iv[MAX] - 1)/ 2; i++)
62     {
63       Molecule a (arpeggio);
64       a.translate_axis (i * staff_space, Y_AXIS);
65       mol.add_molecule (a);
66     }
67   mol.translate (Offset (-2 * staff_space, 0));
68
69   return mol.create_scheme (); 
70 }
71