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