]> git.donarmstrong.com Git - lilypond.git/blob - src/notehead.cc
release: 0.0.20
[lilypond.git] / src / notehead.cc
1 #include "misc.hh"
2
3 #include "notehead.hh"
4 #include "dimen.hh" 
5 #include "debug.hh"
6 #include "paper.hh"
7 #include "lookup.hh"
8 #include "molecule.hh"
9
10
11 Notehead::Notehead(int ss)
12 {
13     x_dir = 0;
14     staff_size=ss;
15     position = 0;
16     balltype = 0;
17     dots = 0;
18 }
19
20 void
21 Notehead::print()const
22 {
23 #ifndef NPRINT
24     mtor << "Head "<< balltype << ", position = "<< position
25          << "dots " << dots;
26     Item::print();
27 #endif
28 }
29
30 void
31 Notehead::preprocess()
32 {
33     brew_molecole();
34 }
35
36 int
37 Notehead::compare(Notehead*&a, Notehead*&b)
38 {
39     return a->position - b->position;
40 }
41
42 void
43 Notehead::brew_molecole()
44 {
45     assert(pstaff_);
46     assert(!output);
47
48     Paperdef *p = paper();
49
50     Real dy = p->internote();
51     Symbol s = p->lookup_->ball(balltype);
52     
53     output = new Molecule(Atom(s));
54     if (dots) {
55         Symbol d = p->lookup_->dots(dots);
56         Molecule dm;
57         dm.add(Atom(d));
58         if (!(position %2))
59             dm.translate(Offset(0,dy));
60         output->add_right(dm);
61     }
62     output->translate(Offset(x_dir * p->note_width(),0));
63     bool streepjes = (position<-1)||(position > staff_size+1);
64     if (streepjes) {
65         int dir = sign(position);
66         int s =(position<-1) ? -((-position)/2): (position-staff_size)/2;
67         Symbol str = p->lookup_->streepjes(s);
68         Molecule sm;
69         sm.add(Atom(str));
70         if (position % 2)
71             sm.translate(Offset(0,-dy* dir));
72         output->add(sm);            
73     }
74     
75
76     output->translate(Offset(0,dy*position));
77 }
78