#include "spanner.hh"
#include "group-interface.hh"
#include "paper-column.hh"
-#include "ambitus.hh"
struct Ledger_line_spanner
{
{
Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (smob));
Link_array<Grob> heads (Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-heads"));
- Link_array<Grob> ambituses (Pointer_group_interface__extract_grobs (me, (Grob*)0, "ambituses"));
- if (heads.is_empty () && ambituses.is_empty ())
+ if (heads.is_empty ())
return SCM_EOL;
+
+ // find size of note heads.
+ Grob * staff = Staff_symbol_referencer::get_staff_symbol (me);
+ if (!staff)
+ return SCM_EOL;
+
Stencil ledgers;
Stencil default_ledger;
{
Axis a = Axis (i);
common[a] = common_refpoint_of_array (heads, me, a);
- common[a] = common_refpoint_of_array (ambituses, common[a], a);
for (int i = heads.size (); i--; )
if (Grob * g = unsmob_grob (me->get_property ("accidental-grob")))
common[a] = common[a]->common_refpoint (g, a);
}
- // find size of note heads.
- Grob * staff = Staff_symbol_referencer::get_staff_symbol (me);
int interspaces = Staff_symbol::line_count (staff)-1;
Ledger_requests reqs;
Real length_fraction = 0.25;
Item *h = dynamic_cast<Item*> (heads[i]);
int pos = Staff_symbol_referencer::get_rounded_position (h);
- if (abs (pos) > interspaces)
+ if (pos
+ && abs (pos) > interspaces)
{
Interval head_extent = h->extent (common[X_AXIS], X_AXIS);
Interval ledger_extent = head_extent;
- head_extent.widen (length_fraction * head_extent.length ());
+ ledger_extent.widen (length_fraction * head_extent.length ());
Direction vdir = Direction (sign (pos));
int rank = Paper_column::get_rank (h->get_column ());
}
}
- /* create ledgers for ambitus.
-
- TODO: split off separate function
- */
- for (int i = ambituses.size (); i--; )
- {
- Item *a = dynamic_cast<Item*> (ambituses[i]);
- Interval x_ext = ambituses[i]->extent (common[X_AXIS], X_AXIS);
- x_ext.widen (length_fraction * x_ext.length ());
-
- Slice ps (Ambitus::get_positions (a));
- Direction d = DOWN;
- do
- {
- if (abs (ps[d]) > interspaces + 1)
- ledgers.add_stencil (brew_ledger_lines (staff, ps[d], interspaces,
- halfspace,
- ledgerlinethickness,
- x_ext, 0.0));
- }
- while (flip (&d) != DOWN);
- }
-
ledgers.translate_axis (-me->relative_coordinate (common[X_AXIS], X_AXIS),
X_AXIS);
ADD_INTERFACE (Ledger_line_spanner,
"ledger-line-interface",
- "This spanner draws the ledger lines of a staff on note heads. ",
+ "This spanner draws the ledger lines of a staff, for note heads that stick out. ",
"note-heads thickness gap length minimum-length")