\header {
texidoc="Transposition symbols should be correctly positioned
-close to the parent clef."
+close to the parent clef. Horizontal alignment is fine-tuned
+for standard C, G and F clefs: for example, downwards transposition
+of a G clef should be centered exactly under the middle of clef hook.
+For clefs that don't have fine-tuned alignment the transposition
+number should be centered."
}
+
+% use huge staff-size to see the tiny differencies better.
+#(set-global-staff-size 35)
+
+clefVariations =
+#(define-music-function (parser location type)(string?)
+ #{
+ \once \omit Staff.Clef s4
+ \override Staff.Clef.full-size-change = ##t
+ \clef #(string-append type "8") s4
+ \clef #(string-append type "15") s4
+ \clef #(string-append type "(8)") s4
+ \clef #(string-append type "(141)") s4
+ % change clefs are omitted - too similar to regular ones
+ \cueClef #(string-append type "8") s4
+ \cueClef #(string-append type "15") s4
+ \cueClef #(string-append type "(8)") s4
+ \cueClef #(string-append type "(141)") s4
+ #})
+
+\markup "Even the smallest positioning changes may indicate a problem!"
\score {
<<
- \new Staff { \clef "G^8" g''1 }
- \new Staff { \clef "F^8" c'1 }
- \new Staff { \clef "C^8" c''1 }
- \new Staff { \clef "G_8" g1 }
- \new Staff { \clef "F_8" c,1 }
- \new Staff { \clef "C_8" c1 }
+ \new Staff { \clefVariations "C_" }
+ \new Staff { \clefVariations "C^" }
+ \new Staff { \clefVariations "G_" }
+ \new Staff { \clefVariations "G^" }
+ \new Staff { \clefVariations "F_" }
+ \new Staff { \clefVariations "F^" }
>>
}
+
+\layout {
+ \context {
+ \Staff
+ \remove Time_signature_engraver
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ This file is part of LilyPond, the GNU music typesetter.
+
+ Copyright (C) 2014--2014 Janek Warchoł <lemniskata.bernoullego@gmail.com>
+
+ LilyPond is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ LilyPond is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "item.hh"
+
+struct Clef_modifier
+{
+ DECLARE_SCHEME_CALLBACK (calc_parent_alignment, (SCM));
+ DECLARE_GROB_INTERFACE ();
+};
+
+MAKE_SCHEME_CALLBACK (Clef_modifier, calc_parent_alignment, 1)
+SCM
+Clef_modifier::calc_parent_alignment (SCM smob)
+{
+ Grob *me = Grob::unsmob (smob);
+ Grob *clef = me->get_parent (X_AXIS);
+ string full_clef_name = ly_scm2string (clef->get_property ("glyph"));
+
+ int separator_position = full_clef_name.find ('.');
+ string clef_type = full_clef_name.substr (separator_position + 1,
+ separator_position + 2);
+
+ // find entry with keyname clef_type in clef-alignments
+ SCM alist_entry = scm_assq (ly_symbol2scm (clef_type.c_str ()),
+ me->get_property ("clef-alignments"));
+
+ if (scm_is_pair (alist_entry))
+ {
+ SCM entry_value = scm_cdr (alist_entry);
+ // the value should be a pair of numbers - first is the alignment
+ // for modifiers below the clef, second for those above.
+ if (scm_is_pair (entry_value))
+ if (robust_scm2dir (me->get_property ("direction"), DOWN) == DOWN)
+ return scm_car (entry_value);
+ else
+ return scm_cdr (entry_value);
+
+ else // default alignment = centered
+ return scm_from_double (0);
+ }
+ else // default alignment = centered
+ return scm_from_double (0);
+}
+
+ADD_INTERFACE (Clef_modifier,
+ "The number describing transposition of the clef, placed below\n"
+ "or above clef sign. Usually this is 8 (octave transposition)\n"
+ "or 15 (two octaves), but LilyPond allows any integer here.",
+
+ /* properties */
+ "clef-alignments "
+ );
+
"The number describing transposition of the clef, placed below
or above clef sign. Usually this is 8 (octave transposition)
or 15 (two octaves), but LilyPond allows any integer here."
- '())
+ '(clef-alignments))
(ly:add-interface
'dynamic-interface
@code{chord-dots-limit} staff-positions.")
(circled-tip ,boolean? "Put a circle at start/@/end of
hairpins (al/@/del niente).")
+ (clef-alignments ,list? "An alist of parent-alignments
+that should be used for clef modifiers with various clefs")
(clip-edges ,boolean? "Allow outward pointing beamlets at the
edges of beams?")
(collapse-height ,ly:dimension? "Minimum height of system start
. (
(break-visibility . ,(grob::inherit-parent-property
X 'break-visibility))
+ (clef-alignments . ((G . (-0.2 . 0.1))
+ (F . (-0.3 . -0.2))
+ (C . (0 . 0))))
(color . ,(grob::inherit-parent-property
X 'color))
(font-shape . italic)
(font-size . -4)
- (parent-alignment-X . ,CENTER)
+ (parent-alignment-X . ,ly:clef-modifier::calc-parent-alignment)
(self-alignment-X . ,CENTER)
(staff-padding . 0.7)
(stencil . ,ly:text-interface::print)