2 encompass-info.cc -- implement Encompass_info
4 source file of the GNU LilyPond music typesetter
6 (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
12 #include "note-column.hh"
13 #include "paper-def.hh"
14 #include "encompass-info.hh"
16 #include "staff-sym.hh"
19 Encompass_info::Encompass_info ()
24 Encompass_info::Encompass_info (Note_column const* note, Direction dir)
26 Paper_def* paper = note->paper ();
27 Real interline = paper->interline_f ();
29 Real notewidth = paper->note_width () * 0.8;
30 Real internote = interline / 2;
32 Stem* stem_l = note->stem_l_;
34 set o_.x () to middle of notehead or on the exact position of stem,
35 according to slur direction
37 o_.x () = stem_l->hpos_f ();
48 if (stem_l->dir_ != dir)
49 o_.x () -= 0.5 * notewidth * stem_l->dir_;
51 o_.y () = stem_l->extent (Y_AXIS)[dir];
53 leave a gap: slur mustn't touch head/stem
55 o_.y () += 2.5 * internote * dir;
57 if (stem_l->dir_ != dir)
58 o_.y () += 1.0 * internote * dir;
60 Slur* slur_l_ = stem_l->slur_l_;
61 if (slur_l_->encompass_arr_.size ()
62 && stem_l->staff_sym_l_ != slur_l_->encompass_arr_[0]->stem_l_->staff_sym_l_)
64 if (stem_l->staff_sym_l_->dim_cache_[Y_AXIS].valid_b ())
66 interstaff_f_ = stem_l->staff_sym_l_->absolute_coordinate (Y_AXIS)
67 - slur_l_->encompass_arr_[0]->stem_l_->staff_sym_l_->absolute_coordinate (Y_AXIS);
71 warning (_ ("invalid dimension cache: guessing staff position"));
72 if (slur_l_->vertical_align_drul_[MIN] !=
73 slur_l_->vertical_align_drul_[MAX])
74 warning (_ ("minVerticalAlign != maxVerticalAlign: interstaff slurs may be broken"));
75 interstaff_f_ = slur_l_->vertical_align_drul_[MIN];
76 // urg, guess staff order:
77 // if our stem ends higher, our staff is probably lower...
78 if (stem_l->chord_start_f () > slur_l_->encompass_arr_[0]->stem_l_->chord_start_f ())
81 o_.y () += interstaff_f_;