Werner LEMBERG schrieb: >> If there are any objections or anyone would like further changes, >> please tell me so. > > Just two things regarding your coding style: > > . Please use tabs consistently; it sees that some lines use 8 > spaces, other lines a tab. > > . Stay within the 80 character limit per line if possible.
Thanks for your opinion and your comments. You are of course right. I don't know where the mixed spaces/tabs came from (maybe they are due to some copying & pasting, although I wonder why I didn't notice the mixture), and exceeding the 80 character limit certainly was an inattention of mine. To avoid unnecessary hassle for the developers I have attached a corrected version of the patch. Hope this helps. Thanks again, Max
>From e7168eccc2bbadd8db6cd97b21a51c77c214b058 Mon Sep 17 00:00:00 2001 From: Maximilian Albert <[EMAIL PROTECTED]> Date: Wed, 11 Apr 2007 12:22:23 +0200 Subject: [PATCH] New notehead (accent-shaped with centered stem) + corresponding doc update --- input/manual/note-head-style.ly | 4 + input/regression/note-head-style.ly | 4 + lily/include/note-head.hh | 1 + lily/note-head.cc | 29 ++++++++ mf/feta-bolletjes.mf | 126 +++++++++++++++++++++++++++++++++++ scm/define-grobs.scm | 2 +- scm/output-lib.scm | 1 + 7 files changed, 166 insertions(+), 1 deletions(-) diff --git a/input/manual/note-head-style.ly b/input/manual/note-head-style.ly index c561eec..0759927 100644 --- a/input/manual/note-head-style.ly +++ b/input/manual/note-head-style.ly @@ -91,6 +91,10 @@ pattern = << \break + \override Staff.NoteHead #'style = #'accent + s1*0^\markup { "accent" } + \pattern + \override Staff.NoteHead #'style = #'slash s1*0^\markup { "slash" } \pattern diff --git a/input/regression/note-head-style.ly b/input/regression/note-head-style.ly index c561eec..0759927 100644 --- a/input/regression/note-head-style.ly +++ b/input/regression/note-head-style.ly @@ -91,6 +91,10 @@ pattern = << \break + \override Staff.NoteHead #'style = #'accent + s1*0^\markup { "accent" } + \pattern + \override Staff.NoteHead #'style = #'slash s1*0^\markup { "slash" } \pattern diff --git a/lily/include/note-head.hh b/lily/include/note-head.hh index 2edeb1b..e15be8a 100644 --- a/lily/include/note-head.hh +++ b/lily/include/note-head.hh @@ -18,6 +18,7 @@ public: DECLARE_SCHEME_CALLBACK (brew_ez_stencil, (SCM)); DECLARE_SCHEME_CALLBACK (stem_x_shift, (SCM)); DECLARE_SCHEME_CALLBACK (calc_stem_attachment, (SCM)); + DECLARE_SCHEME_CALLBACK (y_offset_callback, (SCM)); DECLARE_GROB_INTERFACE(); static Real stem_attachment_coordinate (Grob *, Axis a); diff --git a/lily/note-head.cc b/lily/note-head.cc index c711f87..a8384b8 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -15,6 +15,7 @@ using namespace std; #include "directional-element-interface.hh" +#include "staff-symbol-referencer.hh" #include "font-interface.hh" #include "international.hh" #include "warn.hh" @@ -141,6 +142,34 @@ Note_head::calc_stem_attachment (SCM smob) return ly_offset2scm (get_stem_attachment (fm, key)); } +MAKE_SCHEME_CALLBACK (Note_head, y_offset_callback, 1); +SCM +Note_head::y_offset_callback (SCM smob) +{ + Grob *me = unsmob_grob (smob); + SCM style_scm = me->get_property ("style"); + double offset = scm_to_double (Staff_symbol_referencer::callback (smob)); + + if (!scm_is_symbol (style_scm)) + return scm_from_double (offset); + + string style = string (ly_symbol2string (style_scm)); + if (style != "accent") + return scm_from_double (offset); + + double extra_offset; + if (scm_to_int (me->get_property ("staff-position")) % 2 == 0) { + Real linethickness = Staff_symbol_referencer::line_thickness (me); + // The precise value of the following factor depends + // on the parameters in mf/feta-bolletjes.mf + extra_offset = - 127.0/60 * linethickness; + + } else { + extra_offset = 0.0; + } + + return scm_from_double (offset + extra_offset); +} ADD_INTERFACE (Note_head, "Note head", diff --git a/mf/feta-bolletjes.mf b/mf/feta-bolletjes.mf index b45222e..c1a011f 100644 --- a/mf/feta-bolletjes.mf +++ b/mf/feta-bolletjes.mf @@ -967,6 +967,132 @@ fi; %%%%%%%% % +% Accent-shaped notehead +% + +def draw_accent_notehead (expr width_factor, clearing_factor, + ratio, upper_th, thick_factor, upstem) = +begingroup; + save upper_thickness, lower_thickness, clearing; + save ww, hh; + save roundness, thinning_start, thinning_factor; + save se, ne, up_dist, down_dist; + pair se, ne, up_dist, down_dist; + save se_new, up_dist_new; + pair se_new, up_dist_new; + + hh# := staff_space# + stafflinethickness# * upper_th; + ww# := hh# * width_factor; + set_char_box (0, ww#, hh#, 0); + define_pixels (ww, hh); + + upper_thickness = stafflinethickness * upper_th; + lower_thickness = stafflinethickness * upper_th * thick_factor; + clearing = stafflinethickness * clearing_factor; + roundness = stafflinethickness * 0.5; + thinning_start = 0.6; + + + pickup pencircle scaled roundness; + + lft x1 = lft x3 = lft x4 = lft x6 = 0; + rt x2 = ww; + bot y1 = 0; + top y6 - bot y1 = lower_thickness; + top y3 - bot y4 = upper_thickness; + y2 - bot y1 = ratio * (top y3 - bot y1); + + bot y4 - clearing = staff_space; + + z5 - z4 = whatever * (z2 - z3); + z5 - z6 = whatever * (z2 - z1); + + se = unitvector (z2 - z3); + ne = unitvector (z2 - z1); + + up_dist = (se rotated 90) * 0.5 roundness; + down_dist = (ne rotated (-90)) * 0.5 roundness; + + z5a = whatever[z4 - up_dist, z5 - up_dist] + = whatever[z6 - down_dist, z5 - down_dist]; + + thinning_factor = (x5 - x5a) / (x2 - x5a); + z5b = z5a shifted (2.00 * thinning_factor * (x2 - x5a), + 0.75 * thinning_factor * (y2 - y5a)); + + z9 = thinning_start[z4, z5]; + z10 = thinning_start[z6, z5]; + penpos9 (roundness, angle (z5 - z4) - 90); + penpos10 (roundness, angle (z5 - z6) - 90); + + z2b - z3 = whatever * (z5b - z9r); + x2b = x2; + + z2c = 0.3[z2, z2b]; + se_new = unitvector (z2c - z3); + up_dist_new = (se_new rotated 90) * 0.5 roundness; + + fill lft z1{down} + .. (z1 + down_dist){ne} + -- (z2 + down_dist){ne} + .. (z2c + up_dist_new){-se_new} + -- (z3 + up_dist_new){-se_new} + .. lft z3{down} + -- lft z4{down} + .. (z4 - up_dist){se} + -- z9r + -- z5b + -- z10l + -- (z6 - down_dist){-ne} + .. lft z6{down} + --cycle; + + + % stem attachment adjustments + if upstem: + z7 = 0.5[z2,z3]; + z7a = whatever[z4,z5]; + z7a = (x7 - stemthickness/2, whatever); + z7b = z7a shifted (stemthickness, 0); + % the shift in the following line is to account + % for the assignment to currentpicture below + z8 = z7b shifted (0, -(staff_space - stafflinethickness)/2); + else: + z7 = 0.5[z2,z1]; + z7a = whatever[z6,z5]; + z7a = (x7 - stemthickness/2, whatever); + % the shift in the following line is to account + % for the assignment to currentpicture below + z8 = (ww,0) + - (z7a shifted (0, -(staff_space - stafflinethickness)/2)); + fi; + currentpicture := currentpicture + shifted (0, -(staff_space - stafflinethickness)/2); + charwx := x8/hppp; + charwy := y8/hppp; + + labels (range 1 thru 6, 5a, 5b); + labels (7a, 7b, 8); + labels (9, 9r, 10, 10l); +endgroup; +enddef; + + +% N.B.: When changing the parameters in the following function calls, +% please adapt the factor in Note_head::y_offset_callback accordingly +% so that accents are centered on stafflines. + +fet_beginchar("Accent-shaped notehead", "u0accent"); + draw_accent_notehead(1.0, 0.4, 0.5, 1.7, 5/3, true); +fet_endchar; + +fet_beginchar("Accent-shaped notehead", "d0accent"); + draw_accent_notehead(1.0, 0.4, 0.5, 1.7, 5/3, false); +fet_endchar; + + +%%%%%%%% +% % SOLFA SHAPED NOTES % diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 82d377c..c56fffa 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1147,7 +1147,7 @@ (duration-log . ,note-head::calc-duration-log) (stem-attachment . ,ly:note-head::calc-stem-attachment) (glyph-name . ,note-head::calc-glyph-name) - (Y-offset . ,ly:staff-symbol-referencer::callback) + (Y-offset . ,ly:note-head::y-offset-callback) (X-offset . ,ly:note-head::stem-x-shift) (meta . ((class . Item) (interfaces . (rhythmic-grob-interface diff --git a/scm/output-lib.scm b/scm/output-lib.scm index eea7614..0fbc649 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -154,6 +154,7 @@ ;; Therefore, style "default" does not appear in this case ;; statement. -- jr ((xcircle) "2xcircle") + ((accent) "0accent") ((harmonic) "0harmonic") ((harmonic-black) "2harmonic") ((harmonic-mixed) (if (<= log 1) "0harmonic" -- 1.4.4.4
_______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel