From: Neil Puttock Date: Wed, 19 Aug 2009 18:50:44 +0000 (+0100) Subject: Move `easy notation' print callback to scheme. X-Git-Tag: release/2.13.4-1~180^2~12 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=58df801a58c823d49a008e227d87d7e04c21ce5f;p=lilypond.git Move `easy notation' print callback to scheme. * remove easy-notation.cc * add exported function ly:staff-symbol-staff-space to make accessing 'staff-space more convenient * add scheme implementation of ly:note-head::brew-ez-stencil to output-lib.scm * add convert-rule --- diff --git a/lily/easy-notation.cc b/lily/easy-notation.cc deleted file mode 100644 index 8838efee2d..0000000000 --- a/lily/easy-notation.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* - easy-notation.cc -- implement easy notation heads - - source file of the GNU LilyPond music typesetter - - (c) 2005--2009 Han-Wen Nienhuys -*/ - -#include "note-head.hh" - -#include -using namespace std; - -#include "font-interface.hh" -#include "grob.hh" -#include "music.hh" -#include "output-def.hh" -#include "staff-symbol-referencer.hh" -#include "stem.hh" -#include "stream-event.hh" -#include "text-interface.hh" -#include "rhythmic-head.hh" - -/* - -TODO: move to scheme - -*/ -MAKE_SCHEME_CALLBACK (Note_head, brew_ez_stencil, 1); -SCM -Note_head::brew_ez_stencil (SCM smob) -{ - Grob *me = unsmob_grob (smob); - int log = Rhythmic_head::duration_log (me); - - SCM cause = me->get_property ("cause"); - SCM spitch = unsmob_stream_event (cause)->get_property ("pitch"); - Pitch *pit = unsmob_pitch (spitch); - - SCM idx = scm_from_int (pit->get_notename ()); - SCM names = me->get_property ("note-names"); - SCM charstr = SCM_EOL; - if (scm_is_vector (names)) - charstr = scm_vector_ref (names, idx); - else - { - char s[2] = "a"; - s[0] = char ((pit->get_notename () + 2) % 7 + 'a'); - s[0] = char (toupper (s[0])); - charstr = scm_from_locale_string (s); - } - - SCM letter - = Text_interface::interpret_string (me->layout ()->self_scm (), - Font_interface::text_font_alist_chain (me), - charstr); - - Stencil l (*unsmob_stencil (letter)); - l.align_to (X_AXIS, CENTER); - l.align_to (Y_AXIS, CENTER); - - l = Stencil (Box (), l.expr ()); - Real ss = Staff_symbol_referencer::staff_space (me); - Real lt = Staff_symbol_referencer::line_thickness (me); - - Real radius = (ss + lt) / 2.0; - Real stem_thick = 1.3 * lt; - if (Grob *stem = unsmob_grob (me->get_object ("stem"))) - stem_thick = Stem::thickness (stem); - - int black = (log >= 2); - - Stencil head; - Box extent (Interval (-radius, radius), - Interval (-radius, radius)); - - Stencil black_head (extent, - scm_list_4 (ly_symbol2scm ("circle"), - scm_from_double (radius), - scm_from_double (0.0), - SCM_BOOL_T)); - Stencil white_head; - if (black) - l = l.in_color (1, 1, 1); - else - { - white_head = Stencil (extent, - scm_list_4 (ly_symbol2scm ("circle"), - scm_from_double (radius - stem_thick), - scm_from_double (0.0), - SCM_BOOL_T)); - - white_head = white_head.in_color (1, 1, 1); - } - - Stencil total; - total.add_stencil (l); - total.add_stencil (white_head); - total.add_stencil (black_head); - total.translate_axis (radius, X_AXIS); - - return total.smobbed_copy (); -} - diff --git a/lily/staff-symbol-referencer-scheme.cc b/lily/staff-symbol-referencer-scheme.cc index ebf2686777..74dd8c2e3a 100644 --- a/lily/staff-symbol-referencer-scheme.cc +++ b/lily/staff-symbol-referencer-scheme.cc @@ -7,13 +7,13 @@ */ #include "grob.hh" -#include "staff-symbol-referencer.hh" -#include "staff-symbol.hh" #include "libc-extension.hh" +#include "staff-symbol.hh" +#include "staff-symbol-referencer.hh" LY_DEFINE (ly_grob_staff_position, "ly:grob-staff-position", - 1, 0, 0, (SCM sg), - "Return the Y-position of @var{sg} relative to the staff.") + 1, 0, 0, (SCM sg), + "Return the Y-position of @var{sg} relative to the staff.") { LY_ASSERT_SMOB (Grob, sg, 1); Grob *g = unsmob_grob (sg); @@ -27,7 +27,8 @@ LY_DEFINE (ly_grob_staff_position, "ly:grob-staff-position", LY_DEFINE (ly_position_on_line_p, "ly:position-on-line?", 2, 0, 0, (SCM sg, SCM spos), - "Return whether @var{pos} is on a line of the staff associated with the the grob @var{sg} (even on an extender line).") + "Return whether @var{spos} is on a line of the staff associated" + " with the the grob @var{sg} (even on an extender line).") { LY_ASSERT_SMOB (Grob, sg, 1); LY_ASSERT_TYPE (scm_is_number, spos, 2); @@ -40,10 +41,22 @@ LY_DEFINE (ly_position_on_line_p, "ly:position-on-line?", LY_DEFINE (ly_staff_symbol_line_thickness, "ly:staff-symbol-line-thickness", 1, 0, 0, (SCM grob), - "Returns the line-thickness of the staff associated with @var{grob}.") + "Returns the @code{line-thickness} of the staff associated" + " with @var{grob}.") { LY_ASSERT_SMOB (Grob, grob, 1); Grob *g = unsmob_grob (grob); Real thickness = Staff_symbol_referencer::line_thickness (g); return scm_from_double (thickness); } + +LY_DEFINE (ly_staff_symbol_staff_space, "ly:staff-symbol-staff-space", + 1, 0, 0, (SCM grob), + "Returns the @code{staff-space} of the staff associated" + " with @var{grob}.") +{ + LY_ASSERT_SMOB (Grob, grob, 1); + Grob *g = unsmob_grob (grob); + Real staff_space = Staff_symbol_referencer::staff_space (g); + return scm_from_double (staff_space); +} diff --git a/ly/property-init.ly b/ly/property-init.ly index 3063f39807..49ff7dc560 100644 --- a/ly/property-init.ly +++ b/ly/property-init.ly @@ -117,8 +117,8 @@ tieSolid = { } easyHeadsOn = { - \override NoteHead #'stencil = #ly:note-head::brew-ez-stencil - \override NoteHead #'font-size = #-7 + \override NoteHead #'stencil = #note-head::brew-ez-stencil + \override NoteHead #'font-size = #-8 \override NoteHead #'font-family = #'sans \override NoteHead #'font-series = #'bold } diff --git a/python/convertrules.py b/python/convertrules.py index 71298e2698..e0d118f11a 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -2913,7 +2913,8 @@ revert-auto-beam-setting have been eliminated. \\overrideBeamSettings has been\ added. BeatGrouping has been eliminated.\n\ Different settings for vertical layout.\n\ ly:system-start-text::print -> system-start-text::print\n\ -Beam #'thickness -> Beam #'beam-thickness")) +Beam #'thickness -> Beam #'beam-thickness\n\ +ly:note-head::brew-ez-stencil -> note-head::brew-ez-stencil")) def conv(str): if re.search("override-auto-beam-setting", str): stderr_write ("\n") @@ -2936,7 +2937,8 @@ def conv(str): stderr_write(NOT_SMART % _("alignment-offsets has been changed to alignment-distances: \ you must now specify the distances between staves rather than the offset of staves.\n")) stderr_write(UPDATE_MANUALLY) - str = re.sub ('ly:system-start-text::print', 'system-start-text::print', str) + str = re.sub ('ly:(system-start-text::print|note-head::brew-ez-stencil)', + '\\1', str) str = re.sub ('(\\bBeam\\s+#\')(?=thickness\\b)', '\\1beam-', str) return str diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 152f35c7cf..142a2d0341 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -157,6 +157,41 @@ (string-append (number->string (max 0 log)) (symbol->string style))))))) +(define-public (note-head::brew-ez-stencil grob) + (let* ((log (ly:grob-property grob 'duration-log)) + (pitch (ly:event-property (event-cause grob) 'pitch)) + (pitch-index (ly:pitch-notename pitch)) + (note-names (ly:grob-property grob 'note-names)) + (pitch-string (if (vector? note-names) + (vector-ref note-names pitch-index) + (string + (integer->char + (+ (modulo (+ pitch-index 2) 7) + (char->integer #\A)))))) + (staff-space (ly:staff-symbol-staff-space grob)) + (line-thickness (ly:staff-symbol-line-thickness grob)) + (stem (ly:grob-object grob 'stem)) + (stem-thickness (* (if (ly:grob? stem) + (ly:grob-property stem 'thickness) + 1.3) + line-thickness)) + (radius (/ (+ staff-space line-thickness) 2)) + (letter (markup #:center-align #:vcenter pitch-string)) + (filled-circle (markup #:draw-circle radius 0 #t))) + + (grob-interpret-markup + grob + (if (>= log 2) + (make-combine-markup + filled-circle + (make-with-color-markup white letter)) + (make-combine-markup + (make-combine-markup + filled-circle + (make-with-color-markup white (make-draw-circle-markup + (- radius stem-thickness) 0 #t))) + letter))))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; bar numbers @@ -164,7 +199,8 @@ (define-public ((every-nth-bar-number-visible n) barnum) (= 0 (modulo barnum n))) -(define-public ((modulo-bar-number-visible n m) barnum) (and (> barnum 1) (= m (modulo barnum n)))) +(define-public ((modulo-bar-number-visible n m) barnum) + (and (> barnum 1) (= m (modulo barnum n)))) (define-public ((set-bar-number-visibility n) tr) (let ((bn (ly:context-property tr 'currentBarNumber))) diff --git a/scm/safe-lily.scm b/scm/safe-lily.scm index a4625c1e92..1793003de2 100644 --- a/scm/safe-lily.scm +++ b/scm/safe-lily.scm @@ -170,7 +170,6 @@ ly:multi-measure-rest::print ly:multi-measure-rest::set-spacing-rods ly:note-head::print -;; ly:note-head::brew-ez-stencil ly:ottava-bracket::print ly:paper-column::print ly:percent-repeat-item-interface::beat-slash