From f7d159a1db04e3847ecee715578f2b17ccfc7fde Mon Sep 17 00:00:00 2001
From: David Nalesnik
Date: Wed, 1 Mar 2017 10:48:54 -0600
Subject: [PATCH] Hide brackets on single-note ottavas
This patch introduces the property "no-bracket-for-singleton," which
when set to #t prints an ottava text without bracket for single notes.
The ottava text is centered on the note-column. (This is not the case
when hiding the bracket by setting OttavaBracket.style to 'none, which
preserves the bracketed position.)
When an ottava is broken, all "singletons" will be bracketed except one
ending the spanner.
---
lily/ottava-bracket.cc | 14 ++++++++++++++
scm/define-grob-properties.scm | 2 ++
2 files changed, 16 insertions(+)
diff --git a/lily/ottava-bracket.cc b/lily/ottava-bracket.cc
index 63a9d3e..2125ffc 100644
--- a/lily/ottava-bracket.cc
+++ b/lily/ottava-bracket.cc
@@ -84,6 +84,19 @@ Ottava_bracket::print (SCM smob)
Drul_array shorten = robust_scm2interval (me->get_property ("shorten-pair"),
Interval (0, 0));
+ extract_grob_set (me, "side-support-elements", sse);
+
+ if (to_boolean (me->get_property ("no-bracket-for-singleton")) &&
+ sse.size () == 1 && !broken[RIGHT]) {
+ Grob *elt = sse[0];
+ Interval elt_ext = elt->extent (common, X_AXIS);
+ text.align_to (X_AXIS, CENTER);
+ text.align_to (Y_AXIS, CENTER);
+ text.translate_axis (elt_ext.center (), X_AXIS);
+ text.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
+ return text.smobbed_copy ();
+ }
+
/*
TODO: we should check if there are ledgers, and modify length of
the spanner to that.
@@ -191,6 +204,7 @@ ADD_INTERFACE (Ottava_bracket,
/* properties */
"edge-height "
"bracket-flare "
+ "no-bracket-for-singleton "
"shorten-pair "
"minimum-length "
);
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index e950d53..e126cc4 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -671,6 +671,8 @@ syllable following an extender).")
(no-alignment ,boolean? "If set, don't place this grob in a
@code{VerticalAlignment}; rather, place it using its own
@code{Y-offset} callback.")
+ (no-bracket-for-singleton ,boolean? "Do not print a bracket for
+ottavas spanning a single note.")
(no-ledgers ,boolean? "If set, don't draw ledger lines on this
object.")
(no-stem-extend ,boolean? "If set, notes with ledger lines do not
--
2.1.4