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>
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 ()
26 Encompass_info::Encompass_info (Note_column const* note_column, Direction dir, Slur const* slur_l)
30 Stem* stem_l = note_column->stem_l_;
33 warning (_ ("Slur over rest?"));
34 o_[X_AXIS] = note_column->hpos_f ();
38 o_[X_AXIS] = stem_l->hpos_f ();
42 Let's not do this; yields ugly assymetric slurs.
44 set o_[X_AXIS] to middle of notehead or on the exact position of stem,
45 according to slur direction
56 dx_f_drul_[d] = -d * spanned_drul_[d]->extent (X_AXIS).length ();
58 if (stem_l->dir_ != dir)
59 o_[X_AXIS] -= 0.5 * stem_l->dir_ * note_column->extent (X_AXIS).length ();
64 Instead; simply set x to middle of notehead
67 o_[X_AXIS] -= 0.5 * stem_l->dir_ * note_column->extent (X_AXIS).length ();
71 if (stem_l->dir_ == dir)
73 o_[Y_AXIS] = stem_l->extent (Y_AXIS)[dir];
77 o_[Y_AXIS] = note_column->extent (Y_AXIS)[dir];
81 leave a gap: slur mustn't touch head/stem
83 o_[Y_AXIS] += dir * slur_l->paper_l ()->get_var ("slur_y_free");
85 Dimension_cache *common = stem_l->common_group (slur_l, Y_AXIS);
86 Align_element * align = dynamic_cast<Align_element*> (common->element_l ());
87 if (align && align->axis() == Y_AXIS)
89 if (align->threshold_interval_[MIN] !=
90 align->threshold_interval_[MAX])
91 warning (_ ("minVerticalAlign != maxVerticalAlign: interstaff beams/slurs may be broken"));
93 interstaff_f_ = align->threshold_interval_[MIN];
95 Dimension_cache * slur_refpoint = slur_l->dim_cache_[Y_AXIS];
96 Dimension_cache * note_refpoint = note_column->dim_cache_[Y_AXIS];
98 while (slur_refpoint->parent_l_ != common)
99 slur_refpoint = slur_refpoint->parent_l_;
100 while (note_refpoint->parent_l_ != common)
101 note_refpoint = note_refpoint->parent_l_;
105 align->get_priority (dynamic_cast<Score_element*> (slur_refpoint->element_l ()));
107 align->get_priority (dynamic_cast<Score_element*> (note_refpoint->element_l ()));
110 our staff is lower -> interstaff_f_ *= -1
113 if (slur_prio < stem_prio)
115 o_[Y_AXIS] += interstaff_f_;