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