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