]> git.donarmstrong.com Git - lilypond.git/blob - lily/notehead.cc
release: 0.0.45
[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 IMPLEMENT_STATIC_NAME(Notehead);
30
31 void
32 Notehead::do_print()const
33 {
34 #ifndef NPRINT
35     mtor << "balltype "<< balltype << ", position = "<< position
36          << "dots " << dots;
37 #endif
38 }
39
40
41 int
42 Notehead::compare(Notehead *const  &a, Notehead * const &b)
43 {
44     return a->position - b->position;
45 }
46
47 Molecule*
48 Notehead::brew_molecule_p() const return out;
49 {
50     Paper_def *p = paper();
51
52     Real dy = p->internote();
53     Symbol s = p->lookup_l()->ball(balltype);
54     
55     out = new Molecule(Atom(s));
56     if (dots) {
57         Symbol d = p->lookup_l()->dots(dots);
58         Molecule dm;
59         dm.add(Atom(d));
60         if (!(position %2))
61             dm.translate(Offset(0,dy));
62         out->add_right(dm);
63     }
64     out->translate(Offset(x_dir * p->note_width(),0));
65     bool streepjes = (position<-1)||(position > staff_size+1);
66     if (streepjes) {
67         int dir = sign(position);
68         int s =(position<-1) ? -((-position)/2): (position-staff_size)/2;
69         Symbol str = p->lookup_l()->streepjes(s);
70         Molecule sm;
71         sm.add(Atom(str));
72         if (position % 2)
73             sm.translate(Offset(0,-dy* dir));
74         out->add(sm);       
75     }
76     
77     out->translate(Offset(0,dy*position));
78 }
79