lilypond-1.3.67
[lilypond.git] / lily / cross-staff.cc
blob8e5e8e6f4a84f393994c10bfd23a36c2d3ab8ed8
1 #include "cross-staff.hh"
2 #include "item.hh"
3 #include "align-interface.hh"
4 #include "spanner.hh"
5 #include "warn.hh"
7 /*
8 JUNKME
9 */
10 Real
11 calc_interstaff_dist (Item const *item, Spanner const *span)
13 Real interstaff = 0.0;
14 Score_element *common = item->common_refpoint (span, Y_AXIS);
15 Align_interface align(common);
17 if (align.has_interface_b () && align.axis() == Y_AXIS)
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"));
24 interstaff = 0.0;
25 if (gh_pair_p (threshold))
26 interstaff = gh_scm2double (gh_car (threshold));
28 Score_element const * span_refpoint = span;
29 while (span_refpoint->parent_l (Y_AXIS) != common)
30 span_refpoint = span_refpoint->parent_l (Y_AXIS);
32 Score_element const * note_refpoint = item;
33 while (note_refpoint->parent_l (Y_AXIS) != common)
34 note_refpoint = note_refpoint->parent_l (Y_AXIS);
36 int span_prio =
37 align.get_count ((Score_element*) dynamic_cast<Score_element const*> (span_refpoint));
38 int item_prio =
39 align.get_count ((Score_element*) dynamic_cast<Score_element const *> (note_refpoint));
42 our staff is lower -> interstaff *= -1
45 if (span_prio < item_prio)
46 interstaff *= -1;
47 return interstaff;
49 else return 0.0;