Change flag creation to use the 'flag prop (function returning the stencil)
-) Added the 'flag grob property to the stem: It's a function taking the
stem grob and returning a stencil for the whole flag (including a possible
grace slash). It uses the 'flag-style property with the exact same values
as previously, so any existing score should still be working.
The default is ly:stem::calc-flag (implemented in C++), but
I also implemented the default styles (no-flag, normal-flag and
mensural-flag) in Scheme, where the function default-flag also uses
the 'flag-style grob property. Both (the flag creation in C++ and in
Scheme) show practically the same performance[*], so we might get rid of
one of them in the future. Flag creation using scheme can thus be enabled
by
\override Stem #'flag = #default-flag
flag creation in C++ can be explicitly enabled by
\override Stem #'flag = #ly:stem::calc-flag
-) Implemented the default flag styles as scheme-functions, so that one can
re-use them in one's own flag style functions. The default flags functions
are implemented in a modular way, so one can easily create styles that
adjust only some aspects of the default flags. An example style implemented
in the regression test is to use mirrored flags (i.e. flags always pointing
to the left). This can be implemented by creating the flag for the opposite
stem direction and rotating it by 180 degrees ;-)
-) Added regression tests to check that the default flag styles all keep
working.
-) In the regression tests, I also added some custom styles: weighted-flag,
where the flags are shown as one big black box and the "number" of flags
is indicated by the height of the box. The other example is the
mirrored-normal-flag style mentioned above (useful for tutorials about music
notation to show that flags should *NOT* be printed to the left!)
The real motivation for this feature, namely straight flags (either
old-style with a large slant or modern-style with a much smaller slant),
is not yet implemented, but should not be too hard, using the
ly:round-filled-polygon function.
[*] We now have two ways to generate flags: One C++ implementation
(ly:stem::calc-flag) and one pure-Scheme implementation (default-flag).
Both require the same amount of memory and there is hardly any difference
in their runtime. For example, a file consisting of 10,000 eighth notes
(nothing else) needs ~1.5GB RAM and runs for a bit over 3 minutes here,
with the C++ implementation beating the Scheme implementation by mere
5 seconds:
In C++:
real 3m9.133s
user 3m4.896s