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"
17 #include "note-head.hh"
20 Encompass_info::Encompass_info ()
25 Encompass_info::Encompass_info (Note_column
const* note
, Direction dir
)
29 Paper_def
* paper
= note
->paper ();
30 Real interline
= paper
->interline_f ();
32 Real notewidth
= paper
->note_width () * 0.8;
33 Real internote
= interline
/ 2;
35 Stem
* stem_l
= note
->stem_l_
;
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 ();
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
);
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_
;
85 interstaff_f_
*= sign (d
);
86 else if (stem_l
->chord_start_f () >
87 slur_l
->encompass_arr_
[0]->stem_l_
->chord_start_f ())
90 o_
.y () += interstaff_f_
;