2 easy-notation.cc -- implement easy notation heads
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "note-head.hh"
14 #include "font-interface.hh"
17 #include "output-def.hh"
19 #include "staff-symbol-referencer.hh"
21 #include "stream-event.hh"
22 #include "text-interface.hh"
23 #include "rhythmic-head.hh"
30 MAKE_SCHEME_CALLBACK (Note_head, brew_ez_stencil, 1);
32 Note_head::brew_ez_stencil (SCM smob)
34 Grob *me = unsmob_grob (smob);
35 int log = Rhythmic_head::duration_log (me);
37 SCM cause = me->get_property ("cause");
38 SCM spitch = unsmob_stream_event (cause)->get_property ("pitch");
39 Pitch *pit = unsmob_pitch (spitch);
41 SCM idx = scm_from_int (pit->get_notename ());
42 SCM names = me->get_property ("note-names");
43 SCM charstr = SCM_EOL;
44 if (scm_is_vector (names))
45 charstr = scm_vector_ref (names, idx);
49 s[0] = (pit->get_notename () + 2) % 7 + 'a';
50 s[0] = toupper (s[0]);
51 charstr = scm_makfrom0str (s);
55 = Text_interface::interpret_string (me->layout ()->self_scm (),
56 Font_interface::text_font_alist_chain (me),
59 Stencil l (*unsmob_stencil (letter));
60 l.align_to (X_AXIS, CENTER);
61 l.align_to (Y_AXIS, CENTER);
63 l = Stencil (Box (), l.expr ());
64 Real ss = Staff_symbol_referencer::staff_space (me);
65 Real lt = Staff_symbol_referencer::line_thickness (me);
67 Real radius = (ss + lt) / 2.0;
68 Real stem_thick = 1.3 * lt;
69 if (Grob *stem = unsmob_grob (me->get_object ("stem")))
70 stem_thick = Stem::thickness (stem);
72 int black = (log >= 2);
75 Box extent (Interval (-radius, radius),
76 Interval (-radius, radius));
78 Stencil black_head (extent,
79 scm_list_4 (ly_symbol2scm ("circle"),
80 scm_from_double (radius),
81 scm_from_double (0.0),
85 l = l.in_color (1, 1, 1);
88 white_head = Stencil (extent,
89 scm_list_4 (ly_symbol2scm ("circle"),
90 scm_from_double (radius - stem_thick),
91 scm_from_double (0.0),
94 white_head = white_head.in_color (1, 1, 1);
98 total.add_stencil (l);
99 total.add_stencil (white_head);
100 total.add_stencil (black_head);
101 total.translate_axis (radius, X_AXIS);
103 return total.smobbed_copy ();