]> git.donarmstrong.com Git - lilypond.git/blob - lily/encompass-info.cc
release: 1.1.18
[lilypond.git] / lily / encompass-info.cc
1 /*
2   encompass-info.cc -- implement Encompass_info
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
7
8 */
9
10 #include "proto.hh"
11 #include "stem.hh"
12 #include "note-column.hh"
13 #include "paper-def.hh"
14 #include "encompass-info.hh"
15
16 Encompass_info::Encompass_info ()
17 {
18   assert (0);
19 }
20
21 Encompass_info::Encompass_info (Note_column const* note, Direction dir)
22 {
23   Paper_def* paper = note->paper ();
24   Real interline = paper->interline_f ();
25   // UGH
26   Real notewidth = paper->note_width () * 0.8;
27   Real internote = interline / 2;
28
29   Stem* stem = note->stem_l_;
30   /* 
31     set o_.x () to middle of notehead or on the exact position of stem,
32     according to slur direction
33    */
34   o_.x () = stem->hpos_f ();
35
36   /*
37      stem->dir == dir
38                       ________
39            |   |     /        \
40           x|  x|       |x  |x
41         \________/     |   |
42
43    */
44
45   if (stem->dir_ != dir)
46     o_.x () -= 0.5 * notewidth * stem->dir_;
47
48   o_.y () = stem->extent (Y_AXIS)[dir];
49   /*
50    leave a gap: slur mustn't touch head/stem
51    */
52   o_.y () += 2.5 * internote * dir;
53
54   if (stem->dir_ != dir)
55     o_.y () += 1.0 * internote * dir;
56 }
57