From e4f799c08fbedd90350c0393c6af3230753b69c9 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 30 Apr 2003 12:41:28 +0000 Subject: [PATCH] * lily/parser.yy (Simple_music): add \applyoutput, syntax \applyoutput PROCEDURE * lily/my-lily-lexer.cc: add \applyoutput. * scm/music-types.scm (music-descriptions): add ApplyOutputEvent. * lily/text-item.cc: clean text-interface description --- ChangeLog | 11 ++++++ Documentation/header.html.in | 2 +- Documentation/index.texi | 8 ++-- Documentation/user/refman.itely | 28 +++++++++++++- input/GNUmakefile | 2 +- lily/item.cc | 29 ++++++++++---- lily/my-lily-lexer.cc | 1 + lily/output-property-engraver.cc | 52 ++++++++++++++------------ lily/output-property-music-iterator.cc | 7 ++++ lily/parser.yy | 10 ++++- lily/text-item.cc | 4 +- ly/engraver-init.ly | 1 + scm/grob-property-description.scm | 31 +++------------ scm/music-types.scm | 34 +++++++++++++++-- scm/new-markup.scm | 9 ++--- 15 files changed, 155 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2ff44a34a8..beb7fbec23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-04-30 Han-Wen Nienhuys + + * lily/parser.yy (Simple_music): add \applyoutput, syntax + \applyoutput PROCEDURE + + * lily/my-lily-lexer.cc: add \applyoutput. + + * scm/music-types.scm (music-descriptions): add ApplyOutputEvent. + + * lily/text-item.cc: clean text-interface description + 2003-04-27 Han-Wen Nienhuys * input/{regression,test}/: use postfix for slur endings and beam diff --git a/Documentation/header.html.in b/Documentation/header.html.in index c6b60da408..991ff6c3b7 100644 --- a/Documentation/header.html.in +++ b/Documentation/header.html.in @@ -43,7 +43,7 @@ which substitutes some @AT_VARIABLES@ as well. Home
Examples
- Templates
+ Templates
Download diff --git a/Documentation/index.texi b/Documentation/index.texi index 958d270196..dab705f4ae 100644 --- a/Documentation/index.texi +++ b/Documentation/index.texi @@ -63,7 +63,7 @@ Windows}. (Or just @uref{http://cygwin.com/setup.exe, Install Lily Now}). @itemize @bullet @item @uref{../user/out-www/lilypond/Tutorial.html,Learn} how to use LilyPond. @item - @uref{../../input/template/out-www/template.html, Templates}, for + @uref{../../input/template/out-www/collated-files.html, Templates}, for different music styles. Add notes, and done! @end itemize @@ -100,10 +100,10 @@ you want to fine-tune output, you need the information in this document. @item - @uref{../../input/template/out-www/template.html, Templates}, for + @uref{../../input/template/out-www/collated-files.html, Templates}, for different music styles. Add notes, and done! -@item All of the @uref{../../input/test/out-www/test.html,tips-and-tricks} +@item All of the @uref{../../input/test/out-www/collated-files.html,tips-and-tricks} input snippets, with the corresponding output shown. Also available in @uref{../../input/test/out-www/test.ps.gz,PostScript} and @@ -124,7 +124,7 @@ output shown. Also available in @itemize @bullet @item The @uref{ChangeLog.html, ChangeLog} lists things recently done. @item The -@uref{../../input/regression/out-www/regression.html,Regression Tests} +@uref{../../input/regression/out-www/collated-files.html,Regression Tests} are lot of snippets that test all basic features. Also available in @uref{../../input/regression/out-www/regression.ps.gz,PostScript} and @uref{../../input/regression/out-www/regression.pdf,PDF} formats. diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 35428488f8..4cb40bcb33 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -4604,6 +4604,7 @@ object, and set a object property in that object. @menu * Tuning objects :: +* Applyoutput:: * Outputproperty:: * Font selection:: * Text markup:: @@ -4755,12 +4756,37 @@ The backend is not very strict in type-checking object properties. If you LilyPond may crash. +@node Applyoutput +@subsection Applyoutput + +The most versatile way of tuning object is @code{\applyoutput}. Its +syntax is +@example +\applyoutput @var{proc} +@end example +where @var{proc} is a Scheme function, taking four arguments. + +When interpreted, the function @var{proc} is called for every grob found +in the context, with the following arguments: +@itemize @bullet +@item the grob itself +@item the context where the grob was created +@item the context where @code{\applyoutput} is processed. +@end itemize + +The cause of the grob, i.e. the music expression or object that was +responsible for creating the object, is in the object property +@code{cause}. For example, for a note head, this is a +@internalsref{NoteHead} event, and for a @internalsref{Stem} object, +this is a @internalsref{NoteHead} object. + + @node Outputproperty @subsection Outputproperty @cindex \outputproperty -A second way of tuning objects is the more arcane @code{\outputproperty} +Another way of tuning objects is the more arcane @code{\outputproperty} feature. The syntax is as follows: @example \outputproperty @var{predicate} @var{symbol} = @var{value} diff --git a/input/GNUmakefile b/input/GNUmakefile index c682f4ae0b..73e0931e91 100644 --- a/input/GNUmakefile +++ b/input/GNUmakefile @@ -3,7 +3,7 @@ depth = .. SUBDIRS=test regression tutorial no-notation ascii-art template mutopia # nereides is tweaked a lot, can't do (read webpage) -examples= size13 size26 +examples= # size13 size26 #examples+=size11 size13 size16 size20 size23 size26 LOCALSTEPMAKE_TEMPLATES=ly mutopia diff --git a/lily/item.cc b/lily/item.cc index c3e8c38569..236885dc32 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -193,12 +193,25 @@ unsmob_item (SCM s ) ADD_INTERFACE(Item, "item-interface", - " - -Grobs can be distinguished in their role in the horizontal spacing. -Many grobs define constraints on the spacing by their sizes. For -example, note heads, clefs, stems, and all other symbols with a fixed -shape. These grobs form a subtype called @code{Item}. - -", + "\n" + "\n" + "Grobs can be distinguished in their role in the horizontal spacing.\n" + "Many grobs define constraints on the spacing by their sizes. For\n" + "example, note heads, clefs, stems, and all other symbols with a fixed\n" + "shape. These grobs form a subtype called @code{Item}.\n" + "\n" + "\n" + "Some items need special treatment for line breaking. For example, a\n" + "clef is normally only printed at the start of a line (i.e. after a\n" + "line break). To model this, `breakable' items (clef, key signature,\n" + "bar lines, etc.) are copied twice. Then we have three versions of each\n" + "breakable item: one version if there is no line break, one version\n" + "that is printed before the line break (at the end of a system), one\n" + "version that is printed after the line break.\n" + "\n" + "Whether these versions are visible and take up space, is determined by\n" + "the outcome of the @code{break-visibility}. This grob property is a\n" + "function taking a direction (-1, 0 or 1) as argument. It returns a\n" + "cons of booleans, signifying whether this grob should be transparent\n" + "and have no extent.\n", "no-spacing-rods break-visibility breakable") diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 2463a121e7..684cacc8d8 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -29,6 +29,7 @@ static Keyword_ent the_key_tab[]={ {"alias", ALIAS}, {"apply", APPLY}, {"applycontext", APPLYCONTEXT}, + {"applyoutput", APPLYOUTPUT}, {"autochange", AUTOCHANGE}, {"simultaneous", SIMULTANEOUS}, {"sequential", SEQUENTIAL}, diff --git a/lily/output-property-engraver.cc b/lily/output-property-engraver.cc index 9b8edbc527..4f7c3a0e20 100644 --- a/lily/output-property-engraver.cc +++ b/lily/output-property-engraver.cc @@ -10,24 +10,12 @@ #include "engraver.hh" #include "grob.hh" #include "output-property-music-iterator.hh" +#include "translator-group.hh" class Output_property_engraver : public Engraver { TRANSLATOR_DECLARATIONS(Output_property_engraver); protected: - - /* - should do this with \once and \push ? - - - \property Voice.outputProperties \push #pred = #modifier - - where both MODIFIER and PRED are functions taking a - grob. - - */ - - Link_array props_; virtual void stop_translation_timestep (); @@ -54,17 +42,35 @@ Output_property_engraver::acknowledge_grob (Grob_info inf) { Music * o = props_[i]; SCM pred = o->get_mus_property ("predicate"); - - /* - should typecheck pred. - */ - SCM result=gh_apply (pred, - scm_list_n (inf.grob_->self_scm (), SCM_UNDEFINED)); - if (to_boolean (result)) + + + + if (gh_procedure_p (pred)) { - SCM sym = o->get_mus_property ("grob-property"); - SCM val = o->get_mus_property ("grob-value"); - inf.grob_->internal_set_grob_property (sym, val); + /* + should typecheck pred. + */ + SCM result=scm_call_1 (pred, inf.grob_->self_scm ()); + if (to_boolean (result)) + { + SCM sym = o->get_mus_property ("grob-property"); + SCM val = o->get_mus_property ("grob-value"); + inf.grob_->internal_set_grob_property (sym, val); + } + } + else + { + Translator_group * d = + dynamic_cast (inf.origin_trans_); + + if (!d) + d = dynamic_cast (inf.origin_trans_->daddy_trans_); + + SCM proc = o->get_mus_property ("procedure"); + scm_call_3 (proc, + inf.grob_->self_scm(), + d->self_scm(), + daddy_trans_->self_scm()); } } } diff --git a/lily/output-property-music-iterator.cc b/lily/output-property-music-iterator.cc index fff33c8fc4..e1cd1618a6 100644 --- a/lily/output-property-music-iterator.cc +++ b/lily/output-property-music-iterator.cc @@ -10,6 +10,13 @@ #include "music-list.hh" #include "output-property-music-iterator.hh" + +/* + Huh. + + Why do we need this? + + */ void Output_property_music_iterator::process (Moment m) { diff --git a/lily/parser.yy b/lily/parser.yy index 26dee0f653..e9025b65c2 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -204,7 +204,8 @@ yylex (YYSTYPE *s, void * v) /* tokens which are not keywords */ %token AUTOCHANGE %token ALIAS -%token APPLYCONTEXT +%token APPLYCONTEXT +%token APPLYOUTPUT %token APPLY %token ACCEPTS %token ALTERNATIVE @@ -828,6 +829,13 @@ Simultaneous_music: Simple_music: event_chord { $$ = $1; } + | APPLYOUTPUT embedded_scm { + if (!gh_procedure_p ($2)) + THIS->parser_error (_ ("\applycontext takes function argument")); + $$ = MY_MAKE_MUSIC ("ApplyOutputEvent"); + $$->set_mus_property ("procedure", $2); + $$->set_spot (THIS->here_input()); + } | APPLYCONTEXT embedded_scm { if (!gh_procedure_p ($2)) THIS->parser_error (_ ("\applycontext takes function argument")); diff --git a/lily/text-item.cc b/lily/text-item.cc index b3b1061952..098ef17402 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -249,8 +249,8 @@ Text_item::brew_molecule (SCM smob) ADD_INTERFACE (Text_item,"text-interface", - "A scheme markup text", - "text axis baseline-skip extent lookup raise kern word-space"); + "A scheme markup text, see @ref{Markup functions}.", + "text baseline-skip word-space"); /* diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 2fb368af1f..1c85c4c44b 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -460,6 +460,7 @@ ScoreContext = \translator { OrchestralScoreContext= \translator { \ScoreContext } + EasyNotation = \translator { \ScoreContext NoteHead \override #'molecule-callback = #Note_head::brew_ez_molecule diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index e5e853885b..ada78a1793 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -65,7 +65,6 @@ the grob to the nearest open space. (grob-property-description 'adjust-if-on-staffline boolean? "If this grob is on a staff line, adjust its appearance, so that it better fits into the staff. E.g., if set true on stem grobs, flares of mensural flags will always be aligned with the staff lines, regardless if the associated note head is printed on a staff line or inbetween.") (grob-property-description 'after-line-breaking-callback procedure? "Procedure taking a grob as argument. This procedure is called (using dependency resolution) after line breaking. Return value is ignored.") -(grob-property-description 'axis number? "the alignment of the text, 0 is horizontal, 1 is vertical.") (grob-property-description 'align-dir ly:dir? "Which side to align? -1: left side, 0: around center of width, 1: right side.") (grob-property-description 'alignment-done boolean? "boolean to administrate whether we've done the alignment already (to ensure that the process is done only once).") (grob-property-description 'all-elements grob-list? "list of all grobs in this line. Needed for protecting grobs from GC.") @@ -183,7 +182,6 @@ mean centre distance weighted per note (grob-property-description 'expand-limit integer? "maximum number of measures expanded in church rests.") (grob-property-description 'extra-X-extent number-pair? "enlarge in X dimension by this much, measured in staff space.") (grob-property-description 'extra-Y-extent number-pair? "see @code{extra-Y-extent}.") -(grob-property-description 'extent number-pair? "the extent of the text: (WIDTH . HEIGHT)") (grob-property-description 'X-extent number-pair? "Store extent. internal use only. ") (grob-property-description 'Y-extent number-pair? "Store extent. internal use only. ") (grob-property-description 'extra-offset number-pair? "pair of reals @@ -277,11 +275,8 @@ name of character within font.") (grob-property-description 'inversion list? " musical-pitch, optional.") (grob-property-description 'items-worth-living grob-list? "list of interesting items. If empty in a particular system, clear that system.") (grob-property-description 'join-heads boolean? "Whether to join the noteheads of an ambitus grob with a vertical line.") -(grob-property-description 'kern ly:dimension? "amount of extra white space to add. - -For text, this is `relative'(?) to the current alignment. - -For barline, space after a thick line.") +(grob-property-description 'kern ly:dimension? "amount of extra white +space to add. For barline, space after a thick line.") (grob-property-description 'knee boolean? "Is this beam a knee?") (grob-property-description 'knee-spacing-correction number? "optical correction amount for knees. 0: no correction; 1: full correction.") (grob-property-description 'layer number? "The output layer [0..2]. The default is 1.") @@ -303,7 +298,6 @@ use @code{\outputproperty}. @code{\property .. \override} will not work: @code{\override} is processed after the StaffSymbol is created, and will have no effect. ") -(grob-property-description 'lookup symbol? "lookup method: 'value for plain text, 'name for character-name.") (grob-property-description 'maximum-length ly:dimension? "don't make Grob longer than this") (grob-property-description 'maximum-rest-count integer? "kill off rests so we don't more than this number left.") (grob-property-description 'measure-length ly:moment? "Length of a @@ -378,8 +372,6 @@ as a real penalty.") (grob-property-description 'quilisma boolean? "is this neume a quilisma?.") (grob-property-description 'positions pair? "cons of staff positions (LEFT . RIGHT") (grob-property-description 'prefix-set number? "DOCME") - -(grob-property-description 'raise ly:dimension? "height for text to be raised (a negative value lowers the text.") (grob-property-description 'ratio number? "Slur parameter. See height-limit.") (grob-property-description 'right-padding ly:dimension? "space right of accs.") (grob-property-description 'right-trim-amount ly:dimension? "shortening of the lyric extender on the right.") @@ -466,21 +458,10 @@ Like @code{bracket-visibility}, but for the number.") ") -(grob-property-description 'break-visibility procedure? "a function that takes the break direction and returns a cons of booleans containing (TRANSPARENT . EMPTY). - -Some items need special treatment for line breaking. For example, a -clef is normally only printed at the start of a line (i.e. after a -line break). To model this, `breakable' items (clef, key signature, -bar lines, etc.) are copied twice. Then we have three versions of each -breakable item: one version if there is no line break, one version -that is printed before the line break (at the end of a system), one -version that is printed after the line break. - -Whether these versions are visible and take up space, is determined by -the outcome of the @code{break-visibility}. This grob property is a -function taking a direction (-1, 0 or 1) as argument. It returns a -cons of booleans, signifying whether this grob should be transparent -and have no extent.") +(grob-property-description 'break-visibility procedure? "a function +that takes the break direction and returns a cons of booleans +containing (TRANSPARENT . EMPTY). +") (grob-property-description 'virga boolean? "is this neume a virga?.") (grob-property-description 'when ly:moment? "when does this column happen?.") diff --git a/scm/music-types.scm b/scm/music-types.scm index 9ec34ae051..6f97df349e 100644 --- a/scm/music-types.scm +++ b/scm/music-types.scm @@ -22,6 +22,23 @@ where x is one of \@\{\\ppp, \\pp, \\p, \\mp, \\mf, \\f, \\ff, \\fff.\@\}") (types . (general-music apply-context)) (iterator-ctor . ,Apply_context_iterator::constructor) )) + (ApplyOutputEvent + . ( + (description . " +Call the argument with all current grobs during interpreting phase. + +SYNTAX + +\applyoutput FUNC + +arguments to func are 1. the grob, 2. the originating context, +3. context where FUNC is called. + +") + (internal-class-name . "Event") + (iterator-ctor . ,Output_property_music_iterator::constructor) + (types . (general-music layout-instruction)) + )) (ArpeggioEvent . ( (description . "Make an arpeggio on this note. Syntax: @@ -181,7 +198,8 @@ c8-[ c c-] c8") (internal-class-name . "Key_change_ev") (types . (general-music key-change-event event)) - )) + )) + (LigatureEvent . ( (description . "(docme).") @@ -257,7 +275,13 @@ e.g. @code{\\mark \"A\"}.") (OverrideProperty . ( - (description . "Extend the definition of a graphical object") + (description . "Extend the definition of a graphical object. + +SYNTAX + +@code{\\propery Foo.Bar \\override} @var{SYMBOL} = @var{VALUE} + +") (internal-class-name . "Music") (types . (general-music layout-instruction)) @@ -355,7 +379,11 @@ to group start-mmrest, skip, stop-mmrest sequence. Syntax @code{R2.*5} for 5 mea (SimultaneousMusic . ( - (description . "Music playing together. Syntax: \\simultaneous @{ .. @} or < .. >.") + (description . "Music playing together. + +SYNTAX + +@code{ \\simultaneous @{ .. @}} or < .. >.") (internal-class-name . "Simultaneous_music") (iterator-ctor . ,Simultaneous_music_iterator::constructor) diff --git a/scm/new-markup.scm b/scm/new-markup.scm index cafc755904..1f5f31a620 100644 --- a/scm/new-markup.scm +++ b/scm/new-markup.scm @@ -285,11 +285,10 @@ for the reader. (fs (cdr (chain-assoc 'font-relative-size props))) (entry (cons 'font-relative-size (- fs 1))) ) - (interpret-markup - grob (cons (list entry) props) - (car rest)) - - )) + (interpret-markup + grob (cons (list entry) props) + (car rest)) + )) (define-public (bigger-markup grob props . rest) "Syntax: \\bigger MARKUP" -- 2.39.5