summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Morris <paulwmorris@gmail.com>2016-04-23 16:04:56 -0400
committerPaul Morris <paulwmorris@gmail.com>2016-05-01 12:22:23 -0400
commitd1ca9346d8e86b873c3cf5511105b0252e6c54ad (patch)
treec98a696b81ad94d09531d726c37bfdce18ad3230
parentcce6142535a66c88811f7f9f28eba89b8fc3b9a3 (diff)
Issue 4828/2: Add StaffSymbol.ledger-positions-function
Lets the user provide a (quoted) function that is used to determine the list of ledger positions for a given note head position.
-rw-r--r--lily/staff-symbol.cc16
-rw-r--r--scm/define-grob-properties.scm3
2 files changed, 17 insertions, 2 deletions
diff --git a/lily/staff-symbol.cc b/lily/staff-symbol.cc
index 527a5c7baf..0697085e11 100644
--- a/lily/staff-symbol.cc
+++ b/lily/staff-symbol.cc
@@ -137,7 +137,7 @@ Staff_symbol::line_positions (Grob *me)
vector<Real>
Staff_symbol::ledger_positions (Grob *me, int pos, Item const *head)
{
- // allow the option to override ledger positions via note head grob
+ // allow override of ledger positions via note head grob...
if (head)
{
SCM posns = head->get_property ("ledger-positions");
@@ -145,6 +145,17 @@ Staff_symbol::ledger_positions (Grob *me, int pos, Item const *head)
return ly_scm2floatvector (posns);
}
+ // ...or via custom ledger positions function
+ SCM lp_function = me->get_property ("ledger-positions-function");
+ if (scm_is_pair (lp_function))
+ {
+ SCM func = scm_eval (lp_function, scm_interaction_environment ());
+ if (ly_is_procedure (func))
+ return ly_scm2floatvector (scm_call_2 (func,
+ me->self_scm (),
+ scm_from_int (pos)));
+ }
+
SCM ledger_positions = me->get_property ("ledger-positions");
Real ledger_extra = robust_scm2double (me->get_property ("ledger-extra"), 0);
vector<Real> line_positions = Staff_symbol::line_positions (me);
@@ -174,7 +185,7 @@ Staff_symbol::ledger_positions (Grob *me, int pos, Item const *head)
Direction dir = (Direction)sign (pos - nearest_line);
if (scm_is_pair (ledger_positions))
- // custom ledger line positions
+ // custom ledger positions via StaffSymbol.ledger-positions
{
Real min_pos = HUGE_VAL;
Real max_pos = -HUGE_VAL;
@@ -410,6 +421,7 @@ ADD_INTERFACE (Staff_symbol,
"ledger-extra "
"ledger-line-thickness "
"ledger-positions "
+ "ledger-positions-function "
"line-count "
"line-positions "
"staff-space "
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index dcf9705998..60b9d5b000 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -579,6 +579,9 @@ are added.")
When set on a @code{StaffSymbol} grob it defines a repeating
pattern of ledger lines and any parenthesized groups will always be
shown together.")
+ (ledger-positions-function ,scheme? "A quoted Scheme procedure that
+takes a @code{StaffSymbol} grob and the vertical position of a note head
+as arguments and returns a list of ledger line positions.")
(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