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"
20 Note_head::flip_around_stem (Direction d)
22 Real l= make_molecule ().dim_[X_AXIS].length ();
23 translate_axis (l * d, X_AXIS);
27 Note_head::dim_callback (Dimension_cache const * c)
29 Note_head* n = dynamic_cast<Note_head*> (c->element_l ());
30 return n->make_molecule ().dim_[X_AXIS];
33 Note_head::Note_head ()
35 dim_cache_[X_AXIS]->callback_l_ = dim_callback;
39 Note_head::do_pre_processing ()
41 // 8 ball looks the same as 4 ball:
43 SCM style = get_elt_property ("style");
44 if (style != SCM_UNDEFINED)
46 type = ly_scm2string (style);
50 if (balltype_i () > 2 || type == "harmonic" || type == "cross")
51 set_elt_property ("duration-log", gh_int2scm (2));
53 if (Dots *d = dots_l ())
54 { // move into Rhythmic_head?
56 Staff_symbol_referencer_interface si (d);
57 Staff_symbol_referencer_interface me (this);
59 si.set_position(int (me.position_f ()));
64 Note_head::compare (Note_head *const &a, Note_head * const &b)
66 Staff_symbol_referencer_interface s1(a);
67 Staff_symbol_referencer_interface s2(b);
69 return sign(s1.position_f () - s2.position_f ());
73 Note_head::make_molecule () const
76 SCM style = get_elt_property ("style");
77 if (style != SCM_UNDEFINED)
79 type = ly_scm2string (style);
82 return lookup_l()->afm_find (String ("noteheads-")
83 + to_str (balltype_i ()) + type);
87 Note_head::do_brew_molecule_p() const
89 Staff_symbol_referencer_interface si (this);
91 Real inter_f = si.staff_line_leading_f ()/2;
92 int sz = si.lines_i ()-1;
93 Real p = si.position_f ();
94 int streepjes_i = abs (p) < sz
96 : (abs((int)p) - sz) /2;
98 Molecule* out = new Molecule (make_molecule ());
104 Direction dir = (Direction)sign (p);
105 Interval hd = out->dim_[X_AXIS];
106 Real hw = hd.length ()/4;
109 = lookup_l ()->ledger_line (Interval (hd[LEFT] - hw,
112 int parity = abs(int (p)) % 2;
114 for (int i=0; i < streepjes_i; i++)
117 s.translate_axis (-dir * inter_f * (i*2 + parity),
119 out->add_molecule (s);