]> git.donarmstrong.com Git - lilypond.git/blob - lily/cross-staff.cc
release: 1.3.113
[lilypond.git] / lily / cross-staff.cc
1 #include "cross-staff.hh"
2 #include "item.hh"
3 #include "align-interface.hh"
4 #include "spanner.hh"
5 #include "warn.hh"
6 #include "paper-def.hh"
7
8
9 /*
10   JUNKME
11  */
12 Real
13 calc_interstaff_dist (Item  *item, Spanner  *span)
14 {
15   Real interstaff = 0.0; 
16   Grob *common = item->common_refpoint (span, Y_AXIS);
17
18
19   if (Align_interface::has_interface (common) && Align_interface::axis(common) == Y_AXIS)
20     {
21       SCM threshold = common->get_grob_property ("forced-distance");
22       interstaff = 1.0;
23       if (!gh_number_p (threshold))
24         warning (_ ("not a forced distance; cross-staff spanners may be broken"));
25       else
26         interstaff *= gh_scm2double (threshold);
27
28       Grob  * span_refpoint = span;
29       while (span_refpoint->parent_l  (Y_AXIS) != common)
30         span_refpoint = span_refpoint->parent_l (Y_AXIS);
31
32       Grob  * note_refpoint = item;
33       while (note_refpoint->parent_l (Y_AXIS) != common)
34         note_refpoint = note_refpoint->parent_l (Y_AXIS);
35
36       int span_prio =
37         Align_interface::get_count (common,(Grob*) dynamic_cast<Grob *> (span_refpoint));
38       int item_prio =
39         Align_interface::get_count (common,(Grob*) dynamic_cast<Grob   *> (note_refpoint));
40
41       /*
42         our staff is lower -> interstaff *= -1
43        */
44
45       if (span_prio < item_prio)
46         interstaff *= -1;
47       return interstaff;
48     }
49   else return 0.0;
50 }
51