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, Direction dir, Slur const* slur_l)
30 Paper_def* paper = note->paper_l ();
33 Real notewidth = paper->note_width () * 0.8;
36 Stem* stem_l = note->stem_l_;
37 Real internote = stem_l-> staff_line_leading_f ()/2.;
40 set o_.x () to middle of notehead or on the exact position of stem,
41 according to slur direction
43 o_.x () = stem_l->hpos_f ();
54 if (stem_l->dir_ != dir)
55 o_.x () -= 0.5 * notewidth * stem_l->dir_;
57 o_.y () = stem_l->extent (Y_AXIS)[dir];
59 leave a gap: slur mustn't touch head/stem
61 o_.y () += 2.5 * internote * dir;
63 if (stem_l->dir_ != dir)
64 o_.y () += 1.0 * internote * dir;
67 Dimension_cache *common = note->common_group (slur_l, Y_AXIS);
68 Align_element * align = dynamic_cast<Align_element*> (common->element_l ());
69 if (align && align->axis() == Y_AXIS)
71 if (align->threshold_interval_[MIN] !=
72 align->threshold_interval_[MAX])
73 warning (_ ("minVerticalAlign != maxVerticalAlign: interstaff beams/slurs may be broken"));
75 interstaff_f_ = align->threshold_interval_[MIN];
77 Dimension_cache * slur_refpoint = &slur_l->dim_cache_[Y_AXIS];
78 Dimension_cache * note_refpoint = ¬e->dim_cache_[Y_AXIS];
80 while (slur_refpoint->parent_l_ != common)
81 slur_refpoint = slur_refpoint->parent_l_;
82 while (note_refpoint->parent_l_ != common)
83 note_refpoint = note_refpoint->parent_l_;
87 align->get_priority (dynamic_cast<Score_element*> (slur_refpoint->element_l ()));
89 align->get_priority (dynamic_cast<Score_element*> (note_refpoint->element_l ()));
92 our staff is lower -> interstaff_f_ *= -1
95 if (slur_prio < stem_prio)
97 o_.y () += interstaff_f_;