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