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_
;
39 warning ("Slur over rest?");
40 o_
[X_AXIS
] = note
->hpos_f ();
44 Real internote
= stem_l
-> staff_line_leading_f ()/2.;
47 set o_[X_AXIS] to middle of notehead or on the exact position of stem,
48 according to slur direction
50 o_
[X_AXIS
] = stem_l
->hpos_f ();
61 if (stem_l
->dir_
!= dir
)
62 o_
[X_AXIS
] -= 0.5 * notewidth
* stem_l
->dir_
;
64 o_
[Y_AXIS
] = stem_l
->extent (Y_AXIS
)[dir
];
66 leave a gap: slur mustn't touch head/stem
68 o_
[Y_AXIS
] += 2.5 * internote
* dir
;
70 if (stem_l
->dir_
!= dir
)
71 o_
[Y_AXIS
] += 1.0 * internote
* dir
;
74 Dimension_cache
*common
= stem_l
->common_group (slur_l
, Y_AXIS
);
75 Align_element
* align
= dynamic_cast<Align_element
*> (common
->element_l ());
76 if (align
&& align
->axis() == Y_AXIS
)
78 if (align
->threshold_interval_
[MIN
] !=
79 align
->threshold_interval_
[MAX
])
80 warning (_ ("minVerticalAlign != maxVerticalAlign: interstaff beams/slurs may be broken"));
82 interstaff_f_
= align
->threshold_interval_
[MIN
];
84 Dimension_cache
* slur_refpoint
= slur_l
->dim_cache_
[Y_AXIS
];
85 Dimension_cache
* note_refpoint
= note
->dim_cache_
[Y_AXIS
];
87 while (slur_refpoint
->parent_l_
!= common
)
88 slur_refpoint
= slur_refpoint
->parent_l_
;
89 while (note_refpoint
->parent_l_
!= common
)
90 note_refpoint
= note_refpoint
->parent_l_
;
94 align
->get_priority (dynamic_cast<Score_element
*> (slur_refpoint
->element_l ()));
96 align
->get_priority (dynamic_cast<Score_element
*> (note_refpoint
->element_l ()));
99 our staff is lower -> interstaff_f_ *= -1
102 if (slur_prio
< stem_prio
)
104 o_
[Y_AXIS
] += interstaff_f_
;