-#if 0 // this is nonsense..., don't issue warning
- if (stem_l_->staff_sym_l_->dim_cache_[Y_AXIS].valid_b ())
- {
- interstaff_f_ = stem_l_->staff_sym_l_->absolute_coordinate (Y_AXIS)
- - beam_l_->sinfo_[0].stem_l_->staff_sym_l_->absolute_coordinate (Y_AXIS) / internote_f;
- }
- else
-#endif
- {
- // warning (_ ("invalid dimension cache: guessing staff position"));
- if (beam_l_->vertical_align_drul_[MIN] !=
- beam_l_->vertical_align_drul_[MAX])
- warning (_ ("minVerticalAlign != maxVerticalAlign: interstaff slurs may be broken"));
- interstaff_f_ = beam_l_->vertical_align_drul_[MIN] / internote_f;
- // urg, guess staff order:
- // if our stem ends higher, our staff is probably lower...
- if (idealy_f_ * beam_dir_ > beam_l_->sinfo_[0].idealy_f_ * beam_dir_)
- interstaff_f_ *= -1;
- }
+ if (align->threshold_interval_[MIN] !=
+ align->threshold_interval_[MAX])
+ warning (_ ("minVerticalAlign != maxVerticalAlign: interstaff beams/slurs may be broken"));
+
+ interstaff_f_ = align->threshold_interval_[MIN] / internote_f;
+
+ Dimension_cache * beam_refpoint = beam_l->dim_cache_[Y_AXIS];
+ Dimension_cache * stem_refpoint = stem_l_->dim_cache_[Y_AXIS];
+
+ while (beam_refpoint->parent_l_ != common)
+ beam_refpoint = beam_refpoint->parent_l_;
+ while (stem_refpoint->parent_l_ != common)
+ stem_refpoint = stem_refpoint->parent_l_;
+
+
+ int beam_prio =
+ align->get_priority (dynamic_cast<Score_element*> (beam_refpoint->element_l ()));
+ int stem_prio =
+ align->get_priority (dynamic_cast<Score_element*> (stem_refpoint->element_l ()));
+
+ /*
+ our staff is lower -> interstaff_f_ *= -1
+ */
+ if (beam_prio < stem_prio)
+ interstaff_f_ *= -1;
+