2 notehead.cc -- implement Note_head
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "note-head.hh"
14 #include "molecule.hh"
15 #include "musical-request.hh"
16 #include "dimension-cache.hh"
17 #include "staff-symbol-referencer.hh"
23 Note_head::do_pre_processing ()
25 // 8 ball looks the same as 4 ball:
27 SCM style
= get_elt_property ("style");
28 if (gh_string_p (style
))
30 type
= ly_scm2string (style
);
34 if (balltype_i () > 2 || type
== "harmonic" || type
== "cross")
35 set_elt_property ("duration-log", gh_int2scm (2));
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);
42 si
.set_position(int (me
.position_f ()));
50 Note_head::do_brew_molecule_p() const
52 Staff_symbol_referencer_interface
si (this);
54 Real inter_f
= si
.staff_space ()/2;
55 int sz
= si
.lines_i ()-1;
56 Real p
= si
.position_f ();
57 int streepjes_i
= abs (p
) < sz
59 : (abs((int)p
) - sz
) /2;
62 SCM style
= get_elt_property ("style");
63 if (gh_string_p (style
))
65 type
= ly_scm2string (style
);
69 new Molecule (lookup_l()->afm_find (String ("noteheads-") + to_str (balltype_i ()) + type
));
71 Box ledgerless
= out
->dim_
;
75 Direction dir
= (Direction
)sign (p
);
76 Interval hd
= out
->dim_
[X_AXIS
];
77 Real hw
= hd
.length ()/4;
80 = lookup_l ()->ledger_line (Interval (hd
[LEFT
] - hw
,
83 int parity
= abs(int (p
)) % 2;
85 for (int i
=0; i
< streepjes_i
; i
++)
88 s
.translate_axis (-dir
* inter_f
* (i
*2 + parity
),
90 out
->add_molecule (s
);
94 out
->dim_
= ledgerless
;