shouldShowBracket method
Whether this group prints a bracket, under Behind Bars p.201.
Behaviour change (2.7.2), and it moves ink. An UN-CONFIGURED tuplet no
longer always gets a bracket. It gets a bracket unless its notes are
joined by a beam — a beamed group is already delimited by its own beam,
so Gould has it print the numeral ALONE, which is what Sibelius, Finale
and MuseScore all print. Measured on a 3:2 triplet of three beamed
eighths at staffSpace = 12: 1960 dark pixels before, 1832 after — the
128 px the bracket and its two hooks were adding over a beam that already
said the same thing.
The old behaviour was not a decision, it was the absence of one. This
getter was a getter and had ZERO callers in lib/, example/ and
test/; TupletRenderer gated on the deprecated showBracket instead,
which defaults to true, so every tuplet ever drawn by this package was
bracketed and bracketConfig was inert too — measured, a triplet built
with bracketConfig: TupletBracket(show: false) rasterised to the same
1960 px as the default. The rule existed, was fixed twice, and was never
asked.
The author still wins, in this order:
- the deprecated showBracket
= falsesuppresses unconditionally; - bracketConfig decides —
show: falseoff,alwaysShow: trueor BracketSide.notehead on; - otherwise the automatic rule, evaluated against a default TupletBracket.
Note that showBracket: true is NOT read as "force on". It cannot be:
it is the constructor's default, so true carries no evidence that anyone
asked for it — parser_support.dart passes a literal true for every
tuplet it builds, and honouring that would disable the rule for every
parsed score. Force-on is spelled bracketConfig: TupletBracket( alwaysShow: true).
beamOf is the beam decision, taken by whoever HAS it — pass
LayoutEngine.beamOf, or TupletRenderer's own draw-pass map. core/
cannot see the layout and must not: the dependency runs the other way.
Taking the answer as a plain BeamType? Function(Note) keeps this class
free of layout types (BeamType is core's own), which is why the
parameter lives here rather than the whole method being moved into the
layout — see the ADR-005 note on TupletBracket.shouldShow. With no
beamOf the rule falls back to the author's own Note.beam hint, which
on an automatically beamed score is null everywhere and yields the
conservative answer (draw the bracket).
This was a getter through 2.7.1. It is now a method so it can take that
argument; call sites add (). There were none to update.
Implementation
bool shouldShowBracket({BeamType? Function(Note note)? beamOf}) {
// The deprecated flag is only evidence when it is `false` (see above).
// ignore: deprecated_member_use_from_same_package
if (!showBracket) return false;
final config = bracketConfig ?? const TupletBracket();
return config.shouldShow(elements, beamOf: beamOf);
}