source file of the GNU LilyPond music typesetter
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "misc.hh"
#include "molecule.hh"
#include "musical-request.hh"
-void
-Note_head::flip_around_stem (Direction d)
-{
- translate_axis (do_width ().length () * d, X_AXIS);
-}
+#include "staff-symbol-referencer.hh"
-Note_head::Note_head ()
+/*
+ build a ledger line for small pieces.
+ */
+Molecule
+Note_head::ledger_line (Interval xwid, Score_element *me)
{
- position_i_ = 0;
-}
+ Drul_array<Molecule> endings;
+ endings[LEFT] = me->lookup_l()->afm_find ("noteheads-ledgerending");
+ Molecule *e = &endings[LEFT];
+ endings[RIGHT] = *e;
+
+ Real thick = e->extent (Y_AXIS).length();
+ Real len = e->extent (X_AXIS).length () - thick;
-void
-Note_head::do_pre_processing ()
-{
- // 8 ball looks the same as 4 ball:
- if (balltype_i_ > 2)
- balltype_i_ = 2;
- if (dots_l_) // move into Rhythmic_head?
- dots_l_->position_i_ = position_i_;
-}
+ Molecule total;
+ Direction d = LEFT;
+ do {
+ endings[d].translate_axis (xwid[d] - endings[d].extent (X_AXIS)[d], X_AXIS);
+ total.add_molecule (endings[d]);
+ } while ((flip(&d)) != LEFT);
-int
-Note_head::compare (Note_head *const &a, Note_head * const &b)
-{
- return a->position_i_ - b->position_i_;
-}
+ Real xpos = xwid [LEFT] + len;
-/**
- Don't account for ledgerlines in the width.
- */
-Interval
-Note_head::do_width () const
-{
- Molecule a = lookup_l ()->notehead (balltype_i_, ""); // UGH
- Interval i = a.dim_[X_AXIS];
- return i;
+ while (xpos + len + thick /2 <= xwid[RIGHT])
+ {
+ e->translate_axis (len, X_AXIS);
+ total.add_molecule (*e);
+ xpos += len;
+ }
+
+ return total;
}
-Molecule*
-Note_head::do_brew_molecule_p() const
+
+MAKE_SCHEME_CALLBACK(Note_head,brew_molecule);
+
+SCM
+Note_head::brew_molecule (SCM smob)
{
- Molecule*out = 0;
- Real inter_f = staff_line_leading_f ()/2;
- int sz = lines_i ()-1;
+ Score_element *me = unsmob_element (smob);
- int streepjes_i = abs (position_i_) < sz
+
+ Real inter_f = Staff_symbol_referencer::staff_space (me)/2;
+ int sz = Staff_symbol_referencer::line_count (me)-1;
+ Real p = Staff_symbol_referencer::position_f (me);
+ int streepjes_i = abs (p) < sz
? 0
- : (abs(position_i_) - sz) /2;
-
+ : (abs((int)p) - sz) /2;
- String type;
- SCM style =get_elt_property (style_scm_sym);
- if (style != SCM_BOOL_F)
+ SCM style = me->get_elt_property ("style");
+ if (!gh_symbol_p (style))
{
- type = ly_scm2string (SCM_CDR(style));
+ style = ly_symbol2scm("default");
}
- Molecule head (lookup_l()->notehead (balltype_i_, type));
-
- out = new Molecule (Molecule (head));
+ // ugh: use gh_call ()
+ Molecule out = me->lookup_l()->afm_find (String ("noteheads-") +
+ ly_scm2string (scm_eval (gh_list (ly_symbol2scm("find-notehead-symbol"),
+ me->get_elt_property ("duration-log"),
+ ly_quote_scm(style),
+ SCM_UNDEFINED))));
if (streepjes_i)
{
- Direction dir = sign (position_i_);
- Interval hd = head.dim_[X_AXIS];
+ Direction dir = (Direction)sign (p);
+ Interval hd = out.extent (X_AXIS);
Real hw = hd.length ()/4;
+ Molecule ledger (ledger_line (Interval (hd[LEFT] - hw,
+ hd[RIGHT] + hw), me));
- Molecule ledger
- = lookup_l ()->ledger_line (Interval (hd[LEFT] - hw,
- hd[RIGHT] + hw));
-
- int parity = abs(position_i_) % 2;
+
+ ledger.set_empty (true);
+ int parity = abs(int (p)) % 2;
for (int i=0; i < streepjes_i; i++)
{
Molecule s (ledger);
s.translate_axis (-dir * inter_f * (i*2 + parity),
Y_AXIS);
- out->add_molecule (s);
+ out.add_molecule (s);
}
}
-
- out->translate_axis (inter_f*position_i_, Y_AXIS);
- return out;
+ return out.create_scheme();
+}
+
+bool
+Note_head::has_interface (Score_element*m)
+{
+ return m&& m->has_interface (ly_symbol2scm ("note-head-interface"));
}