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