]> git.donarmstrong.com Git - lilypond.git/blob - lily/cross-staff.cc
release: 1.3.101
[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   JUNKME
9  */
10 Real
11 calc_interstaff_dist (Item  *item, Spanner  *span)
12 {
13   Real interstaff = 0.0; 
14   Score_element *common = item->common_refpoint (span, Y_AXIS);
15
16
17   if (Align_interface::has_interface (common) && Align_interface::axis(common) == Y_AXIS)
18     {
19       SCM threshold = common->get_elt_property ("threshold");
20       if (!gh_pair_p (threshold)
21           || !scm_equal_p (gh_car (threshold), gh_cdr (threshold)))
22         warning (_ ("minVerticalAlign != maxVerticalAlign: cross staff spanners may be broken"));
23
24
25       
26       interstaff = 1.0;
27       if (gh_pair_p (threshold))
28         interstaff =  gh_scm2double (gh_car (threshold)) * interstaff;
29
30       Score_element  * span_refpoint = span;
31       while (span_refpoint->parent_l  (Y_AXIS) != common)
32         span_refpoint = span_refpoint->parent_l (Y_AXIS);
33
34       Score_element  * note_refpoint = item;
35       while (note_refpoint->parent_l (Y_AXIS) != common)
36         note_refpoint = note_refpoint->parent_l (Y_AXIS);
37
38       int span_prio =
39         Align_interface::get_count (common,(Score_element*) dynamic_cast<Score_element *> (span_refpoint));
40       int item_prio =
41         Align_interface::get_count (common,(Score_element*) dynamic_cast<Score_element   *> (note_refpoint));
42
43       /*
44         our staff is lower -> interstaff *= -1
45        */
46
47       if (span_prio < item_prio)
48         interstaff *= -1;
49       return interstaff;
50     }
51   else return 0.0;
52 }
53