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"
19 Note_head::flip_around_stem (Direction d)
21 Real l= make_molecule ().dim_[X_AXIS].length ();
22 translate_axis (l * d, X_AXIS);
26 Note_head::dim_callback (Dimension_cache const * c)
28 Note_head* n = dynamic_cast<Note_head*> (c->element_l ());
29 return n->make_molecule ().dim_[X_AXIS];
32 Note_head::Note_head ()
34 dim_cache_[X_AXIS]->callback_l_ = dim_callback;
38 Note_head::do_pre_processing ()
40 Rhythmic_head::do_pre_processing ();
42 // 8 ball looks the same as 4 ball:
44 SCM style = get_elt_property ("style");
45 if (style != SCM_UNDEFINED)
47 type = ly_scm2string (style);
51 if (balltype_i_ > 2 || type == "harmonic" || type == "cross")
54 if (dots_l ()) // move into Rhythmic_head?
55 dots_l ()->set_position(int (position_f ()));
63 Note_head::compare (Note_head *const &a, Note_head * const &b)
65 return sign(a->position_f () - b->position_f ());
71 Note_head::make_molecule () const
74 SCM style = get_elt_property ("style");
75 if (style != SCM_UNDEFINED)
77 type = ly_scm2string (style);
80 return lookup_l()->afm_find (String ("noteheads-")
81 + to_str (balltype_i_) + type);
85 Note_head::do_brew_molecule_p() const
87 Real inter_f = staff_line_leading_f ()/2;
88 int sz = lines_i ()-1;
90 int streepjes_i = abs (position_f ()) < sz
92 : (abs((int)position_f ()) - sz) /2;
94 Molecule* out = new Molecule (make_molecule ());
100 Direction dir = (Direction)sign (position_f ());
101 Interval hd = out->dim_[X_AXIS];
102 Real hw = hd.length ()/4;
105 = lookup_l ()->ledger_line (Interval (hd[LEFT] - hw,
108 int parity = abs(int (position_f ())) % 2;
110 for (int i=0; i < streepjes_i; i++)
113 s.translate_axis (-dir * inter_f * (i*2 + parity),
115 out->add_molecule (s);