lilypond-1.1.23
[lilypond.git] / lily / encompass-info.cc
blob7a9100ffb03ad29b60d57d78339632baa68e2b56
1 /*
2 encompass-info.cc -- implement Encompass_info
4 source file of the GNU LilyPond music typesetter
6 (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
8 */
10 #include "proto.hh"
11 #include "stem.hh"
12 #include "note-column.hh"
13 #include "paper-def.hh"
14 #include "encompass-info.hh"
15 #include "slur.hh"
16 #include "staff-sym.hh"
17 #include "note-head.hh"
18 #include "debug.hh"
20 Encompass_info::Encompass_info ()
22 assert (0);
25 Encompass_info::Encompass_info (Note_column const* note, Direction dir)
27 interstaff_f_ = 0;
29 Paper_def* paper = note->paper ();
30 Real interline = paper->interline_f ();
31 // UGH
32 Real notewidth = paper->note_width () * 0.8;
33 Real internote = interline / 2;
35 Stem* stem_l = note->stem_l_;
36 /*
37 set o_.x () to middle of notehead or on the exact position of stem,
38 according to slur direction
40 o_.x () = stem_l->hpos_f ();
43 stem_l->dir == dir
44 ________
45 | | / \
46 x| x| |x |x
47 \________/ | |
51 if (stem_l->dir_ != dir)
52 o_.x () -= 0.5 * notewidth * stem_l->dir_;
54 o_.y () = stem_l->extent (Y_AXIS)[dir];
56 leave a gap: slur mustn't touch head/stem
58 o_.y () += 2.5 * internote * dir;
60 if (stem_l->dir_ != dir)
61 o_.y () += 1.0 * internote * dir;
63 Slur* slur_l = stem_l->slur_l_;
64 if (slur_l->encompass_arr_.size ()
65 && stem_l->staff_sym_l_ != slur_l->encompass_arr_[0]->stem_l_->staff_sym_l_)
67 #if 0 // this is nonsense..., don't issue warning
68 if (stem_l->staff_sym_l_->dim_cache_[Y_AXIS].valid_b ())
70 interstaff_f_ = stem_l->staff_sym_l_->absolute_coordinate (Y_AXIS)
71 - slur_l->encompass_arr_[0]->stem_l_->staff_sym_l_->absolute_coordinate (Y_AXIS);
73 else
74 #endif
76 // warning (_ ("invalid dimension cache: guessing staff position"));
77 if (slur_l->vertical_align_drul_[MIN] !=
78 slur_l->vertical_align_drul_[MAX])
79 warning (_ ("minVerticalAlign != maxVerticalAlign: interstaff slurs may be broken"));
80 interstaff_f_ = slur_l->vertical_align_drul_[MIN];
81 /* urg, guess staff order */
82 int d = note->head_l_arr_.top ()->steps_i_
83 - slur_l->encompass_arr_[0]->head_l_arr_[0]->steps_i_;
84 if (abs (d > 3))
85 interstaff_f_ *= sign (d);
86 else if (stem_l->chord_start_f () >
87 slur_l->encompass_arr_[0]->stem_l_->chord_start_f ())
88 interstaff_f_ *= -1;
90 o_.y () += interstaff_f_;