- int l = Rhythmic_head::balltype_i (me);
-
- int b = (l >= 2);
- SCM at = scm_list_n (ly_symbol2scm ("ez-ball"),
- me->get_grob_property ("note-character"),
- gh_int2scm (b),
- gh_int2scm (1-b),
- SCM_UNDEFINED);
- Box bx (Interval (0, 1.0), Interval (-0.5, 0.5));
- Molecule m (bx, at);
- int p = (int) rint (Staff_symbol_referencer::position_f (me));
-
- int sz = Staff_symbol_referencer::line_count (me)-1;
- int streepjes_i = abs (p) < sz
- ? 0
- : (abs (p) - sz) /2;
-
- if (streepjes_i)
- {
- Direction dir = (Direction)sign (p);
- Interval hd = m.extent (X_AXIS);
- Real hw = hd.length ()/4;
- m.add_molecule (ledger_lines (me, false, streepjes_i, dir,
- Interval (hd[LEFT] - hw,
- hd[RIGHT] + hw)));
+ Grob *staff = Staff_symbol_referencer::get_staff_symbol (me);
+
+ if (staff)
+ {
+ Real ss = Staff_symbol::staff_space (staff);
+ Interval lines = Staff_symbol::line_span (staff) * (ss / 2.0);
+ Real my_pos = Staff_symbol_referencer::get_position (me) * ss / 2.0;
+ Interval my_ext = me->extent (me, Y_AXIS) + my_pos;
+
+ // The +1 and -1 come from the fact that we only want to add
+ // the interval between the note and the first ledger line, not
+ // the whole interval between the note and the staff.
+ Interval iv (min (0.0, lines[UP] - my_ext[DOWN] + 1),
+ max (0.0, lines[DOWN] - my_ext[UP] - 1));
+ return ly_interval2scm (iv);