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