]> git.donarmstrong.com Git - lilypond.git/blob - lily/note-head.cc
f1b3bf192d658b1ef9971ce0447dcbab8947ed38
[lilypond.git] / lily / note-head.cc
1 /*
2   notehead.cc -- implement Note_head
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "misc.hh"
10 #include "dots.hh"
11 #include "note-head.hh"
12 #include "debug.hh"
13 #include "lookup.hh"
14 #include "molecule.hh"
15 #include "musical-request.hh"
16 #include "dimension-cache.hh"
17 #include "staff-symbol-referencer.hh"
18
19
20
21
22 void
23 Note_head::do_pre_processing ()
24 {
25   // 8 ball looks the same as 4 ball:
26   String type; 
27   SCM style  = get_elt_property ("style");
28   if (gh_string_p (style))
29     {
30       type = ly_scm2string (style);
31     }
32   
33   
34   if (balltype_i () > 2 || type == "harmonic" || type == "cross")
35     set_elt_property ("duration-log", gh_int2scm (2));
36
37   if (Dots *d = dots_l ())
38     { // move into Rhythmic_head?
39       Staff_symbol_referencer_interface si (d);
40       Staff_symbol_referencer_interface me (this);      
41       
42       si.set_position(int (me.position_f ()));
43     }
44 }
45
46
47
48
49 Molecule*
50 Note_head::do_brew_molecule_p() const 
51 {
52   Staff_symbol_referencer_interface si (this);
53   
54   Real inter_f = si.staff_space ()/2;
55   int sz = si.line_count ()-1;
56   Real p = si.position_f ();
57   int streepjes_i = abs (p) < sz 
58     ? 0
59     : (abs((int)p) - sz) /2;
60
61  String type; 
62   SCM style  = get_elt_property ("style");
63   if (gh_string_p (style))
64     {
65       type = ly_scm2string (style);
66     }
67   
68   Molecule*  out =
69     new Molecule (lookup_l()->afm_find (String ("noteheads-") + to_str (balltype_i ()) + type));
70
71   Box ledgerless = out->dim_;
72
73   if (streepjes_i) 
74     {
75       Direction dir = (Direction)sign (p);
76       Interval hd = out->dim_[X_AXIS];
77       Real hw = hd.length ()/4;
78       
79       Molecule ledger
80         = lookup_l ()->ledger_line  (Interval (hd[LEFT] - hw,
81                                                hd[RIGHT] + hw));
82       
83       int parity =  abs(int (p)) % 2;
84       
85       for (int i=0; i < streepjes_i; i++)
86         {
87           Molecule s (ledger);
88           s.translate_axis (-dir * inter_f * (i*2 + parity),
89                            Y_AXIS);
90           out->add_molecule (s);
91         }
92     }
93
94   out->dim_ = ledgerless;
95   return out;
96 }
97