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"
19 Note_head::flip_around_stem (Direction d)
21 translate_axis (do_width ().length () * d, X_AXIS);
24 Note_head::Note_head ()
29 Note_head::do_pre_processing ()
31 Rhythmic_head::do_pre_processing ();
33 // 8 ball looks the same as 4 ball:
35 SCM style = get_elt_property ("style");
36 if (style != SCM_UNDEFINED)
38 type = ly_scm2string (style);
42 if (balltype_i_ > 2 || type == "harmonic" || type == "cross")
45 if (dots_l_) // move into Rhythmic_head?
46 dots_l_->set_position(int (position_f ()));
54 Note_head::compare (Note_head *const &a, Note_head * const &b)
56 return sign(a->position_f () - b->position_f ());
60 Don't account for ledgerlines in the width.
63 Note_head::do_width () const
65 return make_molecule ().dim_[X_AXIS];
69 Note_head::make_molecule () const
72 SCM style = get_elt_property ("style");
73 if (style != SCM_UNDEFINED)
75 type = ly_scm2string (style);
78 return lookup_l()->afm_find (String ("noteheads-")
79 + to_str (balltype_i_) + type);
83 Note_head::do_brew_molecule_p() const
85 Real inter_f = staff_line_leading_f ()/2;
86 int sz = lines_i ()-1;
88 int streepjes_i = abs (position_f ()) < sz
90 : (abs((int)position_f ()) - sz) /2;
92 Molecule* out = new Molecule (make_molecule ());
98 Direction dir = (Direction)sign (position_f ());
99 Interval hd = out->dim_[X_AXIS];
100 Real hw = hd.length ()/4;
103 = lookup_l ()->ledger_line (Interval (hd[LEFT] - hw,
106 int parity = abs(int (position_f ())) % 2;
108 for (int i=0; i < streepjes_i; i++)
111 s.translate_axis (-dir * inter_f * (i*2 + parity),
113 out->add_molecule (s);