]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/parser.yy (Simple_music): add \applyoutput, syntax
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 30 Apr 2003 12:41:28 +0000 (12:41 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 30 Apr 2003 12:41:28 +0000 (12:41 +0000)
\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

15 files changed:
ChangeLog
Documentation/header.html.in
Documentation/index.texi
Documentation/user/refman.itely
input/GNUmakefile
lily/item.cc
lily/my-lily-lexer.cc
lily/output-property-engraver.cc
lily/output-property-music-iterator.cc
lily/parser.yy
lily/text-item.cc
ly/engraver-init.ly
scm/grob-property-description.scm
scm/music-types.scm
scm/new-markup.scm

index 2ff44a34a8b8c0d3ab34f43e9c58ce4ec4496fb1..beb7fbec2379003a6611b3c928c596d0ac0c854f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2003-04-30  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * 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  <hanwen@cs.uu.nl>
 
        * input/{regression,test}/: use postfix for slur endings and beam
index c6b60da408bc83778b27dcd2808ea8b322613d51..991ff6c3b7949867846a10a34b454c730fcbf902 100644 (file)
@@ -43,7 +43,7 @@ which substitutes some @AT_VARIABLES@ as well.
       <tr><td><font size="-1">
        <a href="@TOP@index.html">Home</a><br>
        <a href="@TOP@examples.html">Examples</a><br>
-       <a href="@TOP@input/template/out-www/template.html">Templates</a><br>
+       <a href="@TOP@input/template/out-www/collated-files.html">Templates</a><br>
       </font></td></tr>
       <tr><td bgcolor="#e8e8ff">
        <b>Download </b>
index 958d270196c5e46d50fe05b0ed16b8d96647e95b..dab705f4aec83859584a791843815eb4cbfc217f 100644 (file)
@@ -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.
index 35428488f81724b1aba43480fbb625e1a551372f..4cb40bcb3337cc2ba838663ce5fc5e262c2053ac 100644 (file)
@@ -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}
index c682f4ae0b0aeae0391630031cd9f6e023a8af5c..73e0931e91b5afa58d02eedddbba0c7c1da5a8dd 100644 (file)
@@ -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
index c3e8c38569187870043919a3aa1242eed2de241f..236885dc328f8db57e8999cad82c8cfdfc42910f 100644 (file)
@@ -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")
index 2463a121e75b14dce307198767b490dd892bf849..684cacc8d82efec0e263e5a3003c7ad4cbf4d7a1 100644 (file)
@@ -29,6 +29,7 @@ static Keyword_ent the_key_tab[]={
   {"alias", ALIAS},
   {"apply", APPLY},
   {"applycontext", APPLYCONTEXT},
+  {"applyoutput", APPLYOUTPUT},
   {"autochange", AUTOCHANGE},
   {"simultaneous", SIMULTANEOUS},
   {"sequential", SEQUENTIAL},
index 9b8edbc52766d5c6d460d05ef4676ccde4d51b50..4f7c3a0e2018cb9e311fc5e6231c93aaee62f4f2 100644 (file)
 #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<Music> 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<Translator_group*> (inf.origin_trans_);
+
+         if (!d)
+           d = dynamic_cast<Translator_group*> (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());
        }
     }
 }
index fff33c8fc465407175b84413fe85b8afe9103a2f..e1cd1618a6d804b48ff89031560d8d5ab4590427 100644 (file)
 #include "music-list.hh"
 #include "output-property-music-iterator.hh"
 
+
+/*
+  Huh.
+
+  Why do we need this?
+  
+ */
 void
 Output_property_music_iterator::process (Moment m)
 {
index 26dee0f653f0a4c91e4a255c722c823d9140d892..e9025b65c224fb00ad1cfdbfad95240901d4af97 100644 (file)
@@ -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"));
index b3b10619525262971513c8e811361c56e63b72cb..098ef17402e5cad7cba87197374826aee0c61181 100644 (file)
@@ -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");
 
 
 /*
index 2fb368af1f462c85b04904e3fda8807d2c0f4426..1c85c4c44b0bfa7822ad250147b7ccf9d0c3c0d4 100644 (file)
@@ -460,6 +460,7 @@ ScoreContext = \translator {
 OrchestralScoreContext= \translator {
        \ScoreContext
 }
+
 EasyNotation =  \translator {
        \ScoreContext
        NoteHead \override #'molecule-callback = #Note_head::brew_ez_molecule
index e5e853885be27fe6dc425062ee898eb30c021b41..ada78a17936b48d2f8b6d755957d5830987c64c2 100644 (file)
@@ -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?.")
index 9ec34ae051bb4a637a0acdf8ea9c6d1d37a2b204..6f97df349e13758eeab1caa27caaf349fdccf741 100644 (file)
@@ -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)
index cafc7559043728ca93c2b5feb245d9694dbf9031..1f5f31a6202d26908cbca44d23de1c3cb0c312a6 100644 (file)
@@ -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"