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