lilypond-0.0.50
[lilypond.git] / lily / notehead.cc
blob85132fe55e9cede48d0980640e142b8d1e92ca09
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"
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;
20 rest_b_ = false;
23 void
24 Notehead::set_rhythmic(Rhythmic_req*r_req_l)
26 balltype = r_req_l->duration_.type_i_;
27 dots = r_req_l->duration_.dots_i_;
30 IMPLEMENT_STATIC_NAME(Notehead);
32 void
33 Notehead::do_print()const
35 #ifndef NPRINT
36 if (rest_b_)
37 mtor << "REST! ";
38 mtor << "balltype "<< balltype << ", position = "<< position
39 << "dots " << dots;
40 #endif
44 int
45 Notehead::compare(Notehead *const &a, Notehead * const &b)
47 return a->position - b->position;
50 Molecule*
51 Notehead::brew_molecule_p() const return out;
53 Paper_def *p = paper();
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);
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);
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);
84 out->translate(Offset(0,dy*position));