]> git.donarmstrong.com Git - lilypond.git/blob - lily/notehead.cc
release: 0.1.13
[lilypond.git] / lily / notehead.cc
1 /*
2   notehead.cc -- implement Note_head
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "misc.hh"
10 #include "dots.hh"
11 #include "note-head.hh"
12 #include "dimen.hh" 
13 #include "debug.hh"
14 #include "paper-def.hh"
15 #include "lookup.hh"
16 #include "molecule.hh"
17 #include "musical-request.hh"
18
19
20 Note_head::Note_head ()
21 {
22   x_dir_ = CENTER;
23   staff_size_i_= 8;             // UGH
24   position_i_ = 0;
25   extremal_i_ = 0;
26 }
27
28 void
29 Note_head::do_pre_processing ()
30 {
31   // 8 ball looks the same as 4 ball:
32   if (balltype_i_ > 2)
33     balltype_i_ = 2;
34   if (dots_l_)                  // move into Rhythmic_head?
35     dots_l_->position_i_ = position_i_;
36 }
37
38 IMPLEMENT_IS_TYPE_B1(Note_head,Rhythmic_head);
39
40
41 int
42 Note_head::compare (Note_head *const  &a, Note_head * const &b)
43 {
44   return a->position_i_ - b->position_i_;
45 }
46
47 Molecule*
48 Note_head::brew_molecule_p() const 
49 {
50   Molecule*out = 0;
51   Paper_def *p = paper();
52   Real inter_f = p->internote_f ();
53
54   // ugh
55   bool streepjes_b = (position_i_<-1) || (position_i_ > staff_size_i_+1);
56   
57   Symbol  s = p->lookup_l()->ball (balltype_i_);
58   out = new Molecule (Atom (s));
59   out->translate (x_dir_ * s.dim.x().length (), X_AXIS);
60
61   if (streepjes_b) 
62     {
63       int dir = sign (position_i_);
64       int s =(position_i_<-1) 
65         ? -((-position_i_)/2)
66         : (position_i_-staff_size_i_)/2;
67         
68       Symbol str = p->lookup_l()->streepjes (s);
69       Molecule sm;
70       sm.add (Atom (str));
71       if (position_i_ % 2)
72         sm.translate (-inter_f* dir, Y_AXIS);
73       out->add (sm);        
74     }
75   
76   out->translate (inter_f*position_i_, Y_AXIS);
77   return out;
78 }