From: hanwen Date: Sat, 17 Jan 2004 13:52:39 +0000 (+0000) Subject: * input/regression/balloon.ly: new file. X-Git-Tag: release/2.1.11~2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=77f985e43fb6a9f626b2090c375234167467927d;p=lilypond.git * input/regression/balloon.ly: new file. * lily/balloon.cc (brew_molecule): new file: draw boxes around objects, and make help texts. --- diff --git a/input/regression/balloon.ly b/input/regression/balloon.ly index cf06c5ab86..a3222a92b5 100644 --- a/input/regression/balloon.ly +++ b/input/regression/balloon.ly @@ -10,14 +10,21 @@ with lines and explanatory text added." \relative c' { + %% by hand: \once\property Voice.Stem \set #'molecule-callback = #Balloon_interface::brew_molecule - \once\property Voice.Stem \set #'original-callback = #Stem::brew_molecule + \once\property Voice.Stem \set #'balloon-original-callback = #Stem::brew_molecule \once\property Voice.Stem \set #'balloon-text = #"I'm a stem" \once\property Voice.Stem \set #'balloon-text-offset = #'(3 . 4) \once\property Voice.Stem \set #'balloon-text-props = #'((font-family . roman)) - + + %% use predefd function. + \context Voice \applyoutput #(add-balloon-text + 'NoteHead "heads, or tails?" + '(0 . -3)) + + c8 } } diff --git a/lily/balloon.cc b/lily/balloon.cc index 0604a81234..dfb4d86f2e 100644 --- a/lily/balloon.cc +++ b/lily/balloon.cc @@ -25,7 +25,7 @@ Balloon_interface::brew_molecule (SCM smob) { Grob *me= unsmob_grob (smob); - SCM cb = me->get_grob_property ("original-callback"); + SCM cb = me->get_grob_property ("balloon-original-callback"); SCM scm_mol = SCM_EOL; if (gh_procedure_p (cb)) diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index a040ceecfb..7689afa901 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -119,7 +119,7 @@ Paper_outputter::output_scope (SCM mod, String prefix) { output_String_def (prefix + s, ly_scm2string (v)); } - else if (scm_number_p (v) == SCM_BOOL_T && scm_exact_p (v) == SCM_BOOL_T) + else if (scm_integer_p (v) == SCM_BOOL_T && scm_exact_p (v) == SCM_BOOL_T) { output_int_def (prefix + s, gh_scm2int (v)); } diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 3a5452eb13..d5809adf65 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -98,7 +98,7 @@ for balloon text.") (grob-property-description 'balloon-text-offset number-pair? "Where to put text relative to balloon.") (grob-property-description 'balloon-padding ly:dimension? "Text to add to help balloon") -(grob-property-description 'original-callback procedure? "The +(grob-property-description 'balloon-original-callback procedure? "The original molecule drawer to draw the balloon around.") diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 071a5dc05d..5159d13b7a 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -750,3 +750,23 @@ Rest can contain a list of beat groupings (music-map apply-duration lyric-music)) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; + + +(define-public ((add-balloon-text object-name text off) grob orig-context cur-context) + "Usage: see input/regression/balloon.ly " + (let* + ((meta (ly:get-grob-property grob 'meta)) + (nm (if (pair? meta) (cdr (assoc 'name meta)) "nonexistant")) + (cb (ly:get-grob-property grob 'molecule-callback))) + + (if (equal? nm object-name) + (begin + (ly:set-grob-property! grob 'molecule-callback Balloon_interface::brew_molecule) + (ly:set-grob-property! grob 'balloon-original-callback cb) + (ly:set-grob-property! grob 'balloon-text text) + (ly:set-grob-property! grob 'balloon-text-offset off) + (ly:set-grob-property! grob 'balloon-text-props '((font-family . roman))) + + ))))