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"
#include "dimension-cache.hh"
+#include "staff-symbol-referencer.hh"
-void
-Note_head::flip_around_stem (Direction d)
-{
- Real l= make_molecule ().dim_[X_AXIS].length ();
- translate_axis (l * d, X_AXIS);
-}
-Interval
-Note_head::dim_callback (Dimension_cache const * c)
-{
- Note_head* n = dynamic_cast<Note_head*> (c->element_l ());
- return n->make_molecule ().dim_[X_AXIS];
-}
-Note_head::Note_head ()
+/*
+ build a ledger line for small pieces.
+ */
+Molecule
+Note_head::ledger_line (Interval xwid) const
{
- dim_cache_[X_AXIS]->callback_l_ = dim_callback;
+ Drul_array<Molecule> endings;
+ endings[LEFT] = lookup_l()->afm_find ("noteheads-ledgerending");
+ Molecule * e = &endings[LEFT];
+ endings[RIGHT] = *e;
+
+ Real thick = e->dim_[Y_AXIS].length();
+ Real len = e->dim_[X_AXIS].length () - thick;
+
+ Molecule total;
+ Direction d = LEFT;
+ do {
+ endings[d].translate_axis (xwid[d] - endings[d].dim_[X_AXIS][d], X_AXIS);
+ total.add_molecule (endings[d]);
+ } while ((flip(&d)) != LEFT);
+
+ Real xpos = xwid [LEFT] + len;
+
+ while (xpos + len + thick /2 <= xwid[RIGHT])
+ {
+ e->translate_axis (len, X_AXIS);
+ total.add_molecule (*e);
+ xpos += len;
+ }
+
+ return total;
}
+
void
Note_head::do_pre_processing ()
{
- Rhythmic_head::do_pre_processing ();
-
// 8 ball looks the same as 4 ball:
String type;
SCM style = get_elt_property ("style");
- if (style != SCM_UNDEFINED)
+ if (gh_string_p (style))
{
type = ly_scm2string (style);
}
- if (balltype_i_ > 2 || type == "harmonic" || type == "cross")
- balltype_i_ = 2;
-
- if (dots_l ()) // move into Rhythmic_head?
- dots_l ()->set_position(int (position_f ()));
+ if (balltype_i () > 2 || type == "harmonic" || type == "cross")
+ set_elt_property ("duration-log", gh_int2scm (2));
-
+ if (Dots *d = dots_l ())
+ { // move into Rhythmic_head?
+ Staff_symbol_referencer_interface si (d);
+ Staff_symbol_referencer_interface me (this);
+
+ si.set_position(int (me.position_f ()));
+ }
}
-int
-Note_head::compare (Note_head *const &a, Note_head * const &b)
-{
- return sign(a->position_f () - b->position_f ());
-}
-
-
-Molecule
-Note_head::make_molecule () const
+Molecule*
+Note_head::do_brew_molecule_p() const
{
- String type;
+ Staff_symbol_referencer_interface si (this);
+
+ Real inter_f = si.staff_space ()/2;
+ int sz = si.line_count ()-1;
+ Real p = si.position_f ();
+ int streepjes_i = abs (p) < sz
+ ? 0
+ : (abs((int)p) - sz) /2;
+
+ String type;
SCM style = get_elt_property ("style");
- if (style != SCM_UNDEFINED)
+ if (gh_string_p (style))
{
type = ly_scm2string (style);
}
- return lookup_l()->afm_find (String ("noteheads-")
- + to_str (balltype_i_) + type);
-}
-
-Molecule*
-Note_head::do_brew_molecule_p() const
-{
- Real inter_f = staff_line_leading_f ()/2;
- int sz = lines_i ()-1;
-
- int streepjes_i = abs (position_f ()) < sz
- ? 0
- : (abs((int)position_f ()) - sz) /2;
-
- Molecule* out = new Molecule (make_molecule ());
+ Molecule* out =
+ new Molecule (lookup_l()->afm_find (String ("noteheads-") + to_str (balltype_i ()) + type));
- Box b = out->dim_;
+ Box ledgerless = out->dim_;
if (streepjes_i)
{
- Direction dir = (Direction)sign (position_f ());
+ Direction dir = (Direction)sign (p);
Interval hd = out->dim_[X_AXIS];
Real hw = hd.length ()/4;
- Molecule ledger
- = lookup_l ()->ledger_line (Interval (hd[LEFT] - hw,
- hd[RIGHT] + hw));
+ Molecule ledger (ledger_line (Interval (hd[LEFT] - hw,
+ hd[RIGHT] + hw)));
- int parity = abs(int (position_f ())) % 2;
+ int parity = abs(int (p)) % 2;
for (int i=0; i < streepjes_i; i++)
{
}
}
- out->dim_ = b;
+ out->dim_ = ledgerless;
return out;
}