2 encompass-info.cc -- implement Encompass_info
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "dimension-cache.hh"
12 #include "note-column.hh"
13 #include "paper-def.hh"
14 #include "encompass-info.hh"
16 #include "staff-symbol.hh"
17 #include "note-head.hh"
19 #include "align-element.hh"
21 Encompass_info::Encompass_info ()
25 Encompass_info::Encompass_info (Note_column const* note_column, Direction dir, Slur const* slur_l)
29 Stem* stem_l = note_column->stem_l_;
32 warning (_ ("Slur over rest?"));
33 o_[X_AXIS] = note_column->hpos_f ();
34 o_[Y_AXIS] = note_column->extent (Y_AXIS)[dir];
38 o_[X_AXIS] = stem_l->hpos_f ();
41 Simply set x to middle of notehead
44 o_[X_AXIS] -= 0.5 * stem_l->dir_ * note_column->extent (X_AXIS).length ();
46 if ((stem_l->dir_ == dir)
47 && !stem_l->extent (Y_AXIS).empty_b ())
49 o_[Y_AXIS] = stem_l->extent (Y_AXIS)[dir];
53 o_[Y_AXIS] = note_column->extent (Y_AXIS)[dir];
57 leave a gap: slur mustn't touch head/stem
59 o_[Y_AXIS] += dir * slur_l->paper_l ()->get_var ("slur_y_free");
61 Dimension_cache *common = stem_l->common_group (slur_l, Y_AXIS);
62 Align_element * align = dynamic_cast<Align_element*> (common->element_l ());
63 if (align && align->axis() == Y_AXIS)
65 if (align->threshold_interval_[MIN] !=
66 align->threshold_interval_[MAX])
67 warning (_ ("minVerticalAlign != maxVerticalAlign: interstaff beams/slurs may be broken"));
69 interstaff_f_ = align->threshold_interval_[MIN];
71 Dimension_cache * slur_refpoint = slur_l->dim_cache_[Y_AXIS];
72 Dimension_cache * note_refpoint = note_column->dim_cache_[Y_AXIS];
74 while (slur_refpoint->parent_l_ != common)
75 slur_refpoint = slur_refpoint->parent_l_;
76 while (note_refpoint->parent_l_ != common)
77 note_refpoint = note_refpoint->parent_l_;
81 align->get_priority (dynamic_cast<Score_element*> (slur_refpoint->element_l ()));
83 align->get_priority (dynamic_cast<Score_element*> (note_refpoint->element_l ()));
86 our staff is lower -> interstaff_f_ *= -1
89 if (slur_prio < stem_prio)
91 o_[Y_AXIS] += interstaff_f_;