--- /dev/null
+\version "2.11.52"
+\header {
+ texidoc = "Ledger lines should appear at every other location
+for a variety of staves using both @code{line-count} and
+@code{line-positions}."
+}
+
+notes = \relative c' {
+ \time 3/4
+ c2. | d | e | f
+ g2. | a | b | c
+ d2. | e | f | g
+ a2.
+}
+
+\new Staff {
+ % upper and lower lines both odd
+ #(define mylines '(-1 0 1))
+ \override Staff.StaffSymbol #'line-count = #(length mylines)
+ \override Staff.StaffSymbol #'line-positions = #mylines
+ \notes
+}
+
+\new Staff {
+ % upper and lower lines both even
+ #(define mylines '(-2 0 2))
+ \override Staff.StaffSymbol #'line-positions = #mylines
+
+ \override Staff.StaffSymbol #'line-count = #(length mylines)
+ \notes
+}
+
+\new Staff {
+ % lower line odd, upper line even
+ #(define mylines '(-1 0 2))
+ \override Staff.StaffSymbol #'line-positions = #mylines
+ \override Staff.StaffSymbol #'line-count = #(length mylines)
+ \notes
+}
+
+\new Staff {
+ % odd line count
+ \override Staff.StaffSymbol #'line-count = #5
+ \notes
+}
+
+\new Staff {
+ % even line count
+ \override Staff.StaffSymbol #'line-count = #4
+ \notes
+}
static int get_steps (Grob *);
static int line_count (Grob *);
+ static bool on_line (Grob *me, int pos);
DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (height, (SCM));
DECLARE_GROB_INTERFACE();
bool
Staff_symbol_referencer::on_line (Grob *me, int pos)
{
- int sz = line_count (me) - 1;
- return ((pos + sz) % 2) == 0;
+ return Staff_symbol::on_line (me, pos);
}
bool
return ly_interval2scm (y_ext);
}
+bool
+Staff_symbol::on_line (Grob *me, int pos)
+{
+ SCM line_positions = me->get_property ("line-positions");
+ if (scm_is_pair (line_positions))
+ {
+ Real min_line = HUGE_VAL;
+ Real max_line = -HUGE_VAL;
+ for (SCM s = line_positions; scm_is_pair (s); s = scm_cdr (s))
+ {
+ Real current_line = scm_to_double (scm_car (s));
+ if (pos == current_line)
+ return true;
+ if (current_line > max_line)
+ max_line = current_line;
+ if (current_line < min_line)
+ min_line = current_line;
+
+ }
+ if (pos < min_line)
+ return (( (int) (rint (pos - min_line)) % 2) == 0);
+ if (pos > max_line)
+ return (( (int) (rint (pos - max_line)) % 2) == 0);
-
+ return false;
+ }
+ else
+ return ((abs (pos + line_count (me)) % 2) == 1);
+}
ADD_INTERFACE (Staff_symbol,
"This spanner draws the lines of a staff. A staff symbol"