lilypond-1.1.5
[lilypond.git] / src / notehead.cc
blob722b231e6837fa123c54f2a6383910cfac3401bb
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 "musicalrequest.hh"
12 Notehead::Notehead(int ss)
14 x_dir = 0;
15 staff_size=ss;
16 position = 0;
17 balltype = 0;
18 dots = 0;
19 extremal = 0;
22 void
23 Notehead::set_rhythmic(Rhythmic_req*r_req_l)
25 balltype = r_req_l->balltype;
26 dots = r_req_l->dots;
29 void
30 Notehead::do_print()const
32 #ifndef NPRINT
33 mtor << "balltype "<< balltype << ", position = "<< position
34 << "dots " << dots;
35 #endif
39 int
40 Notehead::compare(Notehead *const &a, Notehead * const &b)
42 return a->position - b->position;
45 Molecule*
46 Notehead::brew_molecule_p() const return out;
48 Paper_def *p = paper();
50 Real dy = p->internote();
51 Symbol s = p->lookup_p_->ball(balltype);
53 out = new Molecule(Atom(s));
54 if (dots) {
55 Symbol d = p->lookup_p_->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);
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_p_->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);
75 out->translate(Offset(0,dy*position));