2 easy-notation.cc -- implement easy notation heads
4 source file of the GNU LilyPond music typesetter
6 (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "note-head.hh"
12 #include "text-item.hh"
14 #include "output-def.hh"
17 #include "font-interface.hh"
18 #include "staff-symbol-referencer.hh"
21 MAKE_SCHEME_CALLBACK (Note_head, brew_ez_stencil, 1);
23 Note_head::brew_ez_stencil (SCM smob)
25 Grob *me = unsmob_grob (smob);
26 int log = Note_head::get_balltype (me);
28 SCM cause = me->get_property ("cause");
29 SCM spitch = unsmob_music (cause)->get_property ("pitch");
30 Pitch *pit = unsmob_pitch (spitch);
32 SCM idx = scm_int2num (pit->get_notename ());
33 SCM names = me->get_property ("note-names");
34 SCM charstr = SCM_EOL;
35 if (scm_is_vector (names))
36 charstr = scm_vector_ref (names, idx);
40 s[0] = (pit->get_notename () + 2) % 7 + 'a';
41 s[0] = toupper (s[0]);
42 charstr = scm_makfrom0str (s);
47 = Text_interface::interpret_string (me->get_layout()->self_scm (),
48 Font_interface::text_font_alist_chain (me),
51 Stencil l (*unsmob_stencil (letter));
52 l.align_to (X_AXIS, CENTER);
53 l.align_to (Y_AXIS, CENTER);
56 l = Stencil (Box (), l.expr ());
57 Real ss = Staff_symbol_referencer::staff_space (me);
58 Real lt = Staff_symbol_referencer::line_thickness (me);
60 Real radius = (ss + lt) / 2.0;
61 Real stem_thick = 1.3 * lt;
62 if (Grob *stem = unsmob_grob (me->get_property ("stem")))
64 stem_thick = Stem::thickness (stem);
67 int black = (log >= 2);
70 Box extent (Interval (-radius, radius),
71 Interval (-radius, radius));
73 Stencil black_head (extent,
74 scm_list_4 (ly_symbol2scm ("circle"),
75 scm_from_double (radius),
76 scm_from_double (0.0),
81 l = l.in_color (1, 1, 1);
85 white_head = Stencil (extent,
86 scm_list_4 (ly_symbol2scm ("circle"),
87 scm_from_double (radius - stem_thick),
88 scm_from_double (0.0),
91 white_head = white_head.in_color (1, 1, 1);
96 total.add_stencil (l);
97 total.add_stencil (white_head);
98 total.add_stencil (black_head);
99 total.translate_axis (radius, X_AXIS);
101 return total.smobbed_copy ();