]> git.donarmstrong.com Git - lilypond.git/blob - src/notehead.cc
release: 0.0.9
[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     staff_size=ss;
12     position = 0;
13     balltype = 0;
14     dots = 0;
15 }
16
17 void
18 Notehead::print()const
19 {
20     mtor << "Head "<<balltype<<", position = "<< position << "dots " << dots;
21     Item::print();
22 }
23
24 void
25 Notehead::preprocess()
26 {
27     brew_molecole();
28 }
29
30 void
31 Notehead::brew_molecole()
32 {
33     assert(pstaff_);
34     assert(!output);
35
36     Paperdef *p = paper();
37
38     Real dy = p->interline()/2;
39     Symbol s = p->lookup_->ball(balltype);
40     
41     output = new Molecule(Atom(s));
42     if (dots) {
43         Symbol d = p->lookup_->dots(dots);
44         Molecule dm;
45         dm.add(Atom(d));
46         if (!(position %2))
47             dm.translate(Offset(0,dy));
48         output->add_right(dm);
49     }
50     bool streepjes = (position<-1)||(position > staff_size+1);
51     if (streepjes) {
52         int dir = sgn(position);
53         int s =(position<-1) ? -((-position)/2): (position-staff_size)/2;
54         Symbol str = p->lookup_->streepjes(s);
55         Molecule sm;
56         sm.add(Atom(str));
57         if (position % 2)
58             sm.translate(Offset(0,-dy* dir));
59         output->add(sm);            
60     }
61     
62
63     output->translate(Offset(0,dy*position));
64 }
65