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>
9 #include "note-head.hh"
14 #include "text-interface.hh"
16 #include "output-def.hh"
19 #include "font-interface.hh"
20 #include "staff-symbol-referencer.hh"
23 MAKE_SCHEME_CALLBACK (Note_head, brew_ez_stencil, 1);
25 Note_head::brew_ez_stencil (SCM smob)
27 Grob *me = unsmob_grob (smob);
28 int log = Note_head::get_balltype (me);
30 SCM cause = me->get_property ("cause");
31 SCM spitch = unsmob_music (cause)->get_property ("pitch");
32 Pitch *pit = unsmob_pitch (spitch);
34 SCM idx = scm_from_int (pit->get_notename ());
35 SCM names = me->get_property ("note-names");
36 SCM charstr = SCM_EOL;
37 if (scm_is_vector (names))
38 charstr = scm_vector_ref (names, idx);
42 s[0] = (pit->get_notename () + 2) % 7 + 'a';
43 s[0] = toupper (s[0]);
44 charstr = scm_makfrom0str (s);
48 = Text_interface::interpret_string (me->get_layout ()->self_scm (),
49 Font_interface::text_font_alist_chain (me),
52 Stencil l (*unsmob_stencil (letter));
53 l.align_to (X_AXIS, CENTER);
54 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_object ("stem")))
63 stem_thick = Stem::thickness (stem);
65 int black = (log >= 2);
68 Box extent (Interval (-radius, radius),
69 Interval (-radius, radius));
71 Stencil black_head (extent,
72 scm_list_4 (ly_symbol2scm ("circle"),
73 scm_from_double (radius),
74 scm_from_double (0.0),
78 l = l.in_color (1, 1, 1);
81 white_head = Stencil (extent,
82 scm_list_4 (ly_symbol2scm ("circle"),
83 scm_from_double (radius - stem_thick),
84 scm_from_double (0.0),
87 white_head = white_head.in_color (1, 1, 1);
91 total.add_stencil (l);
92 total.add_stencil (white_head);
93 total.add_stencil (black_head);
94 total.translate_axis (radius, X_AXIS);
96 return total.smobbed_copy ();