2 notehead.cc -- implement Note_head
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "note-head.hh"
14 #include "molecule.hh"
15 #include "musical-request.hh"
17 #include "staff-symbol-referencer.hh"
20 build a ledger line for small pieces.
23 Note_head::ledger_line (Interval xwid, Score_element *me)
25 Drul_array<Molecule> endings;
26 endings[LEFT] = me->lookup_l()->afm_find ("noteheads-ledgerending");
27 Molecule *e = &endings[LEFT];
30 Real thick = e->extent (Y_AXIS).length();
31 Real len = e->extent (X_AXIS).length () - thick;
36 endings[d].translate_axis (xwid[d] - endings[d].extent (X_AXIS)[d], X_AXIS);
37 total.add_molecule (endings[d]);
38 } while ((flip(&d)) != LEFT);
40 Real xpos = xwid [LEFT] + len;
42 while (xpos + len + thick /2 <= xwid[RIGHT])
44 e->translate_axis (len, X_AXIS);
45 total.add_molecule (*e);
53 MAKE_SCHEME_CALLBACK(Note_head,brew_molecule);
56 Note_head::brew_molecule (SCM smob)
58 Score_element *me = unsmob_element (smob);
61 Real inter_f = Staff_symbol_referencer::staff_space (me)/2;
62 int sz = Staff_symbol_referencer::line_count (me)-1;
63 Real p = Staff_symbol_referencer::position_f (me);
64 int streepjes_i = abs (p) < sz
66 : (abs((int)p) - sz) /2;
68 SCM style = me->get_elt_property ("style");
69 if (!gh_symbol_p (style))
74 // ugh: use gh_call ()
75 Molecule out = me->lookup_l()->afm_find (String ("noteheads-") +
76 ly_scm2string (scm_eval2 (gh_list (ly_symbol2scm("find-notehead-symbol"),
77 me->get_elt_property ("duration-log"),
84 Direction dir = (Direction)sign (p);
85 Interval hd = out.extent (X_AXIS);
86 Real hw = hd.length ()/4;
87 Molecule ledger (ledger_line (Interval (hd[LEFT] - hw,
88 hd[RIGHT] + hw), me));
91 ledger.set_empty (true);
92 int parity = abs(int (p)) % 2;
94 for (int i=0; i < streepjes_i; i++)
97 s.translate_axis (-dir * inter_f * (i*2 + parity),
102 return out.create_scheme();
106 Note_head::has_interface (Score_element*m)
108 return m&& m->has_interface (ly_symbol2scm ("note-head-interface"));