From cce6142535a66c88811f7f9f28eba89b8fc3b9a3 Mon Sep 17 00:00:00 2001 From: Paul Morris Date: Tue, 19 Apr 2016 15:46:08 -0400 Subject: [PATCH] Issue 4828/1: Allow override of NoteHead.ledger-positions Typical use case is: \once \override NoteHead.ledger-positions = #'(...) where the user specifies a list of ledger positions. --- lily/include/staff-symbol.hh | 2 +- lily/ledger-line-spanner.cc | 3 +-- lily/note-head.cc | 1 + lily/staff-symbol.cc | 10 +++++++++- scm/define-grob-properties.scm | 6 ++++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lily/include/staff-symbol.hh b/lily/include/staff-symbol.hh index 9454ebe7f4..28b30244c7 100644 --- a/lily/include/staff-symbol.hh +++ b/lily/include/staff-symbol.hh @@ -34,7 +34,7 @@ public: static Real get_ledger_line_thickness (Grob *); static vector line_positions (Grob *); - static vector ledger_positions (Grob *me, int pos); + static vector ledger_positions (Grob *me, int pos, Item const *head = 0); static int line_count (Grob *); static bool on_line (Grob *me, int pos, bool allow_ledger = true); static Interval line_span (Grob *); diff --git a/lily/ledger-line-spanner.cc b/lily/ledger-line-spanner.cc index 42d32b496a..2fe2d7d9c3 100644 --- a/lily/ledger-line-spanner.cc +++ b/lily/ledger-line-spanner.cc @@ -211,10 +211,9 @@ Ledger_line_spanner::print (SCM smob) for (vsize i = heads.size (); i--;) { Item *h = dynamic_cast (heads[i]); - int pos = Staff_symbol_referencer::get_rounded_position (h); vector ledger_positions = - Staff_symbol::ledger_positions (staff, pos); + Staff_symbol::ledger_positions (staff, pos, h); // We work with all notes that produce ledgers and any notes that // fall outside the staff that do not produce ledgers, such as diff --git a/lily/note-head.cc b/lily/note-head.cc index 33bbf339ca..73a2255d90 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -211,5 +211,6 @@ ADD_INTERFACE (Note_head, "glyph-name " "stem-attachment " "style " + "ledger-positions " ); diff --git a/lily/staff-symbol.cc b/lily/staff-symbol.cc index 256a9bdd0d..527a5c7baf 100644 --- a/lily/staff-symbol.cc +++ b/lily/staff-symbol.cc @@ -135,8 +135,16 @@ Staff_symbol::line_positions (Grob *me) } vector -Staff_symbol::ledger_positions (Grob *me, int pos) +Staff_symbol::ledger_positions (Grob *me, int pos, Item const *head) { + // allow the option to override ledger positions via note head grob + if (head) + { + SCM posns = head->get_property ("ledger-positions"); + if (scm_is_pair (posns)) + return ly_scm2floatvector (posns); + } + SCM ledger_positions = me->get_property ("ledger-positions"); Real ledger_extra = robust_scm2double (me->get_property ("ledger-extra"), 0); vector line_positions = Staff_symbol::line_positions (me); diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index e54bdaf183..dcf9705998 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -575,8 +575,10 @@ lines for.") lines. It is the sum of 2@tie{}numbers: The first is the factor for line thickness, and the second for staff space. Both contributions are added.") - (ledger-positions ,list? "Repeating pattern for the vertical positions -of ledger lines. Bracketed groups are always shown together.") + (ledger-positions ,list? "Vertical positions of ledger lines. +When set on a @code{StaffSymbol} grob it defines a repeating +pattern of ledger lines and any parenthesized groups will always be +shown together.") (left-bound-info ,list? "An alist of properties for determining attachments of spanners to edges.") (left-padding ,ly:dimension? "The amount of space that is put -- 2.39.2