]> git.donarmstrong.com Git - lilypond.git/blob - src/notehead.cc
859e41fad9fa76b1e1f1942dc11ffbd6741d50c6
[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     extremal = 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
31 int
32 Notehead::compare(Notehead*&a, Notehead*&b)
33 {
34     return a->position - b->position;
35 }
36
37 Molecule*
38 Notehead::brew_molecule_p() const return out;
39 {
40     Paperdef *p = paper();
41
42     Real dy = p->internote();
43     Symbol s = p->lookup_p_->ball(balltype);
44     
45     out = new Molecule(Atom(s));
46     if (dots) {
47         Symbol d = p->lookup_p_->dots(dots);
48         Molecule dm;
49         dm.add(Atom(d));
50         if (!(position %2))
51             dm.translate(Offset(0,dy));
52         out->add_right(dm);
53     }
54     out->translate(Offset(x_dir * p->note_width(),0));
55     bool streepjes = (position<-1)||(position > staff_size+1);
56     if (streepjes) {
57         int dir = sign(position);
58         int s =(position<-1) ? -((-position)/2): (position-staff_size)/2;
59         Symbol str = p->lookup_p_->streepjes(s);
60         Molecule sm;
61         sm.add(Atom(str));
62         if (position % 2)
63             sm.translate(Offset(0,-dy* dir));
64         out->add(sm);       
65     }
66     
67
68     out->translate(Offset(0,dy*position));
69 }
70