]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/paper-system.cc (read_left_bound): new function. Read
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 26 Sep 2005 23:25:59 +0000 (23:25 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 26 Sep 2005 23:25:59 +0000 (23:25 +0000)
line-break-system-details from left bound to determine extents.

* Documentation/user/programming-interface.itely (Using LilyPond
syntax inside Scheme): change applyxxx -> applyXxx.

* ly/music-functions-init.ly: add outputProperty music function.

* lily/parser.yy (Generic_prefix_music_scm): add scm-scm-scm signature.

* lily/grob-scheme.cc (LY_DEFINE): add ! to ly:grob-suicide! name.

* python/convertrules.py (conv): rule

* ly/music-functions-init.ly: applyxxx -> applyXxx

* ly/engraver-init.ly (AncientRemoveEmptyStaffContext): alias
TabVoice to Voice.

20 files changed:
ChangeLog
Documentation/user/advanced-notation.itely
Documentation/user/invoking.itely
Documentation/user/programming-interface.itely
lily/grob-scheme.cc
lily/include/paper-system.hh
lily/lexer.ll
lily/paper-book.cc
lily/paper-column-engraver.cc
lily/paper-column.cc
lily/paper-system-scheme.cc
lily/paper-system.cc
lily/parser.yy
lily/score-engraver.cc
lily/system.cc
ly/engraver-init.ly
ly/music-functions-init.ly
python/convertrules.py
scm/define-grob-properties.scm
scm/safe-lily.scm

index 94c266c6f2aaa8890fed964fa80de073511a7e43..c899dfbf3c98937f5eb6a9299487fea275a6b0a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2005-09-27  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * lily/paper-system.cc (read_left_bound): new function. Read
+       line-break-system-details from left bound to determine extents.
+       * Documentation/user/programming-interface.itely (Using LilyPond
+       syntax inside Scheme): change applyxxx -> applyXxx.
+
+       * ly/music-functions-init.ly: add outputProperty music function.
+
+       * lily/parser.yy (Generic_prefix_music_scm): add scm-scm-scm signature.
+
+       * lily/grob-scheme.cc (LY_DEFINE): add ! to ly:grob-suicide! name.
+
+       * python/convertrules.py (conv): rule
+
+       * ly/music-functions-init.ly: applyxxx -> applyXxx
+
+       * ly/engraver-init.ly (AncientRemoveEmptyStaffContext): alias
+       TabVoice to Voice.
+
 2005-09-26  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
        * flower/include/real.hh: include <math.h> iso. <cmath>
index 9d4a2e62f42320641e0a463c612ff4b98cb9a345..0b0a8fb977c7cf1a9faf7269c0e66f5fa3ac442a 100644 (file)
@@ -1899,7 +1899,7 @@ The following example demonstrates its use.
 
 @lilypond[quote,verbatim,fragment,raggedright,relative=2]
 \context Voice {
-  \applyoutput
+  \applyOutput
     #(add-balloon-text 'NoteHead "heads, or tails?"
     '(1 . -3))
   c8
@@ -2321,7 +2321,7 @@ problematic notes.
 @cindex automatic beams, tuning
 @cindex tuning automatic beaming
 
-@c [TODO: use \applycontext]
+@c [TODO: use \applyContext]
 
 In normal time signatures, automatic beams can start on any note but can
 only end in a few positions within the measure: beams can end on a beat,
index fed9a894f210bda7ef1981b45d6e88305bbc4374..e698d13a3aefdab83d3db4c540c0eb928530ff4d 100644 (file)
@@ -488,7 +488,7 @@ here for reference.
  \magnify isn't changed to \fontsize.
     - \magnify #m => \fontsize #f, where f = 6ln(m)/ln(2)
  remove-tag isn't changed.
-    - \applymusic #(remove-tag '. . .) => \keepWithTag #'. . .
+    - \applyMusic #(remove-tag '. . .) => \keepWithTag #'. . .
  firstpagenumber isn't changed.
     - firstpagenumber no => printfirstpagenumber = ##f
  Line breaks in header strings aren't converted.
index da209bcfd8852323712c2cff5df08205819e8dbd..b5058b609b70ac633aeeaffe7f9a5b1112b32cd4 100644 (file)
@@ -161,11 +161,11 @@ The syntax of composite music expressions, like @code{\repeat},
 
 Such syntax can also be defined as user code.  To do this, it is
 necessary to create a @emph{music function}.  This is a specially marked
-Scheme function.  For example, the music function @code{\applymusic} applies
+Scheme function.  For example, the music function @code{\applyMusic} applies
 a user-defined function to a music expression.  Its syntax is
 
 @example
-\applymusic #@var{func} @var{music}
+\applyMusic #@var{func} @var{music}
 @end example
 
 A music function is created with @code{ly:make-music-function},
@@ -174,7 +174,7 @@ A music function is created with @code{ly:make-music-function},
 (ly:make-music-function
 @end example
 
-@code{\applymusic} takes a Scheme function and a Music expression as
+@code{\applyMusic} takes a Scheme function and a Music expression as
 arguments.  This is encoded in its parameter list,
 
 @example
@@ -192,10 +192,10 @@ and line numbers.  The definition is the second argument of
 @end example
 
 The above Scheme code only defines the functionality.  The tag
-@code{\applymusic} is selected by defining
+@code{\applyMusic} is selected by defining
 
 @example
-applymusic = #(ly:make-music-function
+applyMusic = #(ly:make-music-function
                 (list procedure? ly:music?)
                 (lambda (parser location func music)
                   (func music)))
@@ -206,12 +206,12 @@ A @code{def-music-function} macro is introduced on top of
 functions:
 
 @example
-applymusic = #(def-music-function (parser location func music)
+applyMusic = #(def-music-function (parser location func music)
                 (procedure? ly:music?)
                 (func music))
 @end example
 
-Examples of the use of @code{\applymusic} are in the next section.
+Examples of the use of @code{\applyMusic} are in the next section.
 
 @seealso
 @file{ly/@/music@/-functions@/-init@/.ly}.
@@ -220,10 +220,10 @@ Examples of the use of @code{\applymusic} are in the next section.
 @subsection Manipulating music expressions
 
 Music objects and their properties can be accessed and manipulated
-directly, through the @code{\applymusic} mechanism.
-The syntax for @code{\applymusic} is
+directly, through the @code{\applyMusic} mechanism.
+The syntax for @code{\applyMusic} is
 @example
-\applymusic #@var{func} @var{music}
+\applyMusic #@var{func} @var{music}
 @end example
 
 @noindent
@@ -241,7 +241,7 @@ its argument,
     (reverse (ly:music-property m 'elements)))
   m)
 
-\applymusic #rev-music-1 { c'4 d'4 } 
+\applyMusic #rev-music-1 { c'4 d'4 } 
 @end lilypond
 
 The use of such a function is very limited.  The effect of this
@@ -249,13 +249,13 @@ function is void when applied to an argument that does not have
 multiple children.  The following function application has no effect
 
 @example
-\applymusic #rev-music-1 \grace @{ c4 d4 @}
+\applyMusic #rev-music-1 \grace @{ c4 d4 @}
 @end example
 
 @noindent
 In this case, @code{\grace} is stored as @internalsref{GraceMusic}, which
 has no @code{elements}, only a single @code{element}.  Every generally
-applicable function for @code{\applymusic} must -- like music expressions
+applicable function for @code{\applyMusic} must -- like music expressions
 themselves -- be recursive.
 
 The following example is such a recursive function: It first extracts
@@ -295,7 +295,7 @@ above by the internal equivalent of
    \context Voice = "2" @{ \voiceTwo b @} >>
 @end example
 
-Other applications of @code{\applymusic} are writing out repeats
+Other applications of @code{\applyMusic} are writing out repeats
 automatically (@inputfileref{input/@/test,unfold@/-all@/-repeats@/.ly}),
 saving keystrokes (@inputfileref{input/@/test,music@/-box@/.ly}) and
 exporting LilyPond input to other formats
@@ -402,7 +402,7 @@ example:
 
 {
   c'^"1"
-  \applymusic #(with-padding 3) { c'^"2" c'^"3" }
+  \applyMusic #(with-padding 3) { c'^"2" c'^"3" }
   c'^"4"
 }
 @end lilypond
@@ -720,12 +720,12 @@ to the @code{interpret-markup} function, with the @code{layout} and
 @subsection Context evaluation
 
 @cindex calling code during interpreting
-@cindex @code{\applycontext}
+@cindex @code{\applyContext}
 
 Contexts can be modified during interpretation with Scheme code.  The
 syntax for this is
 @example
-\applycontext @var{function}
+\applyContext @var{function}
 @end example
 
 @var{function} should be a Scheme function taking a single argument,
@@ -733,7 +733,7 @@ being the context to apply it to.  The following code will print the
 current bar number on the standard output during the compile:
 
 @example
-\applycontext
+\applyContext
   #(lambda (x)
     (format #t "\nWe were called in barnumber ~a.\n"
      (ly:context-property x 'currentBarNumber)))
index 4480d4f990b209200c72e8a20677ec00e639793b..972fd0bfc70b086557751ac8aef227467e9f58ca 100644 (file)
@@ -186,7 +186,7 @@ LY_DEFINE (ly_spanner_broken_into, "ly:spanner-broken-into",
   return s;
 }
 
-LY_DEFINE (ly_grob_suicide, "ly:grob-suicide",
+LY_DEFINE (ly_grob_suicide_x, "ly:grob-suicide!",
           1, 0, 0, (SCM g),
           "Kill @var{g}.")
 {
index 3c9168993e519430e2a661b1245fab98afd1ecc9..c292d9641319f96ab03ec7fd4ba00bc9f364b2d5 100644 (file)
@@ -29,11 +29,12 @@ public:
   int number_;
 
   Paper_system (Stencil, bool);
-
+  void read_left_bound (Item*);
   Stencil to_stencil () const;
   SCM stencils () const;
   bool is_title () const;
   Real break_before_penalty () const;
+  Interval staff_refpoints () const;
 };
 
 DECLARE_UNSMOB (Paper_system, paper_system);
index a5fbdb6a94473bfb6ef976912a13973844e6a807..d12fea593637160d72a44bd34371c6b6d9cdecdc 100644 (file)
@@ -518,7 +518,7 @@ BOM_UTF8    \357\273\277
                        else if (tag == ly_symbol2scm ("scheme0-scheme1-scheme2"))
                                return MARKUP_HEAD_SCM0_SCM1_SCM2;
                        else {
-                               programming_error ("no parser tag defined for this signature"); 
+                               programming_error ("no parser tag defined for this markup signature"); 
                                ly_display_scm (s);
                                assert(false);
                        }
@@ -920,6 +920,10 @@ music_function_type (SCM func)
        {
                return MUSIC_FUNCTION_SCM_SCM_MUSIC;
        }
+       else if (type == ly_symbol2scm ("scm-scm-scm"))
+       {
+               return MUSIC_FUNCTION_SCM_SCM_SCM;
+       }
        else if (type == ly_symbol2scm ("markup"))
        {
                return MUSIC_FUNCTION_MARKUP;
index 77ac4fff8a07e145a870916a412113dd268518d3..2294a0aef80dd89a0235b7cbcb731d890f6834f2 100644 (file)
@@ -321,6 +321,7 @@ Paper_book::systems ()
          Paper_system *ps = new Paper_system (*unsmob_stencil (t), true);
          systems_ = scm_cons (ps->self_scm (), systems_);
          ps->unprotect ();
+         
          // FIXME: figure out penalty.
          //set_system_penalty (ps, scores_[i].header_);
        }
index 256aa430b995caf973e4953b3513e36b8e96236a..efc9226d83acbea45e9bd09a36d0e36f89094f1f 100644 (file)
@@ -214,7 +214,13 @@ ADD_TRANSLATOR (Paper_column_engraver,
                "Score_engraver::forbid_breaks to stop linebreaks.  In practice, this "
                "means that you can make a breakpoint by creating a barline (assuming "
                "that there are no beams or notes that prevent a breakpoint.) ",
-               /* create */ "PaperColumn NonMusicalPaperColumn",
+               
+               /* create */
+               "PaperColumn "
+               "NonMusicalPaperColumn",
+               
                /* accept */ "break-event",
                /* read */ "",
-               /* write */ "currentCommandColumn currentMusicalColumn");
+               /* write */
+               "currentCommandColumn "
+               "currentMusicalColumn");
index ce29a2011a1ce3539f9ec8360087ff8e777c3e23..13407f61e0051938b5b7fa0698f1a66620281ef5 100644 (file)
@@ -26,29 +26,6 @@ Paper_column::clone (int count) const
   return new Paper_column (*this, count);
 }
 
-ADD_INTERFACE (Paper_column, "paper-column-interface",
-              "@code{Paper_column} objects form the top-most X-parents for items."
-              "  The are two types of columns: musical columns, where are attached to, and "
-              "  non-musical columns, where bar-lines, clefs etc. are attached to. "
-              "  The spacing engine determines the X-positions of these objects."
-              
-              "\n\n"
-              "They are\n"
-              "  numbered, the first (leftmost) is column 0. Numbering happens before\n"
-              "  line-breaking, and columns are not renumbered after line breaking.\n"
-              "  Since many columns go unused, you should only use the rank field to\n"
-              "  get ordering information.  Two adjacent columns may have\n"
-              "  non-adjacent numbers.\n",
-              
-              
-              "between-cols "
-              "bounded-by-me "
-              "page-penalty "
-              "shortest-playing-duration "
-              "shortest-starter-duration "
-              "used "
-              "when ");
-
 void
 Paper_column::do_break_processing ()
 {
@@ -194,3 +171,32 @@ Paper_column::before_line_breaking (SCM grob)
 
   return SCM_UNSPECIFIED;
 }
+
+
+ADD_INTERFACE (Paper_column,
+
+              "paper-column-interface",
+              "@code{Paper_column} objects form the top-most X-parents for items."
+              "  The are two types of columns: musical columns, where are attached to, and "
+              "  non-musical columns, where bar-lines, clefs etc. are attached to. "
+              "  The spacing engine determines the X-positions of these objects."
+              
+              "\n\n"
+              "They are\n"
+              "  numbered, the first (leftmost) is column 0. Numbering happens before\n"
+              "  line-breaking, and columns are not renumbered after line breaking.\n"
+              "  Since many columns go unused, you should only use the rank field to\n"
+              "  get ordering information.  Two adjacent columns may have\n"
+              "  non-adjacent numbers.\n",
+              
+
+              /* properties */
+              "between-cols "
+              "bounded-by-me "
+              "line-break-system-details "
+              "page-penalty "
+              "shortest-playing-duration "
+              "shortest-starter-duration "
+              "used "
+              "when ");
+
index 760999b3ebfc2082e61b45365cfa7e35d247471c..97bb947afe32cd10fc5d9cb6508a108df7fd78dc 100644 (file)
@@ -61,6 +61,6 @@ LY_DEFINE (ly_paper_system_staff_extent, "ly:paper-system-staff-extents",
 {
   Paper_system *ps = unsmob_paper_system (system);
   SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
-  return ly_interval2scm (ps->staff_refpoints_);
+  return ly_interval2scm (ps->staff_refpoints ());
 }
 
index e78a1e9be90722987e9d077997efd09ce66203aa..5f5e1702c965bfb425953d49cd5334a3c1aa3cab 100644 (file)
@@ -7,8 +7,7 @@
 */
 
 #include "paper-system.hh"
-
-#include "virtual-methods.hh"
+#include "item.hh"
 
 #include "ly-smobs.icc"
 
@@ -70,3 +69,40 @@ Paper_system::to_stencil () const
 {
   return stencil_;
 }
+
+void
+Paper_system::read_left_bound (Item *left)
+{
+  break_before_penalty_
+    = robust_scm2double (left->get_property ("page-penalty"), 0.0);
+
+  SCM details
+    = left->get_property ("line-break-system-details");
+
+  SCM yext
+    = scm_assoc (ly_symbol2scm ("Y-extent"), details);
+  
+  SCM staff_ext
+    = scm_assoc (ly_symbol2scm ("refpoint-Y-extent"), details);
+
+  if (scm_is_pair (yext)
+      && is_number_pair (scm_cdr (yext)))
+    {
+      Box b = stencil_.extent_box();
+      b[Y_AXIS] = ly_scm2interval (scm_cdr (yext));
+      
+      stencil_ = Stencil (b, stencil_.expr ());
+    }
+
+  if (scm_is_pair (staff_ext)
+      && is_number_pair (scm_cdr (staff_ext)))
+    {
+      staff_refpoints_ = ly_scm2interval (scm_cdr (staff_ext));
+    }
+}
+
+Interval
+Paper_system::staff_refpoints () const
+{
+  return staff_refpoints_;
+}
index 475e556acea80761653b541511bd110aaf4d2321..0b71a7f5dbe5fb01f84d4e085abce3af49a20254 100644 (file)
@@ -407,6 +407,7 @@ parser.yy:352.8-24: warning: symbol `"\\<"' used more than once as a literal str
 %token <scm> MUSIC_FUNCTION_SCM_MUSIC_MUSIC 
 %token <scm> MUSIC_FUNCTION_SCM_SCM 
 %token <scm> MUSIC_FUNCTION_SCM_SCM_MUSIC 
+%token <scm> MUSIC_FUNCTION_SCM_SCM_SCM 
 %token <scm> MUSIC_IDENTIFIER
 %token <scm> NOTENAME_PITCH
 %token <scm> NUMBER_IDENTIFIER
@@ -1116,6 +1117,9 @@ Generic_prefix_music_scm:
        | MUSIC_FUNCTION_SCM_SCM embedded_scm embedded_scm {
                $$ = scm_list_4 ($1, make_input (@$), $2, $3);
        }
+       | MUSIC_FUNCTION_SCM_SCM_SCM embedded_scm embedded_scm embedded_scm {
+               $$ = scm_list_5 ($1, make_input (@$), $2, $3, $4);
+       }
        | MUSIC_FUNCTION_SCM_SCM_MUSIC embedded_scm embedded_scm Music {
                $$ = scm_list_5 ($1, make_input (@$), $2, $3, $4->self_scm ());
        }
index 44e7a9e42718224b67f2d21b3c7a85ebd49fbe48..281416068c6bbdb46ee55bebc0b66c33451f51db 100644 (file)
@@ -169,7 +169,14 @@ ADD_TRANSLATOR_GROUP (Score_engraver,
                      "Score_engraver::forbid_breaks to stop linebreaks.  In practice, this "
                      "means that you can make a breakpoint by creating a barline (assuming "
                      "that there are no beams or notes that prevent a breakpoint.) ",
-                     /* create */ "System PaperColumn NonMusicalPaperColumn",
-                     /* accept */ "break-event",
-                     /* read */ "currentMusicalColumn currentCommandColumn verticallySpacedContexts",
-                     /* write */ "");
+                     /* create */
+                     "System ",
+
+                     /* accept */
+                     "break-event",
+                     /* read */
+                     "currentMusicalColumn "
+                     "currentCommandColumn "
+                     "verticallySpacedContexts",
+                     /* write */
+                     "");
index 6e597b1bf363fb49b4713caa8f101f8582c1842f..7df79c196c9489ef0256ed9bae95a7064ca2c9b9 100644 (file)
@@ -385,10 +385,8 @@ System::get_paper_system ()
 
   Paper_system *pl = new Paper_system (sys_stencil, false);
   pl->staff_refpoints_ = staff_refpoints;
-  Item *break_point = this->get_bound (LEFT);
-  pl->break_before_penalty_
-    = robust_scm2double (break_point->get_property ("page-penalty"), 0.0);
-
+  pl->read_left_bound (this->get_bound (LEFT));
+  
   return pl->unprotect ();
 }
 
index 5d8ba62dc292d337849163124c4e03b21f96d69f..eca683aeba6db4256045f4b23991349a62a52e3a 100644 (file)
@@ -616,6 +616,7 @@ AncientRemoveEmptyStaffContext = \context {
 \context {
   \Voice
   \name "TabVoice"
+  \alias "Voice"
   \consists "Tab_note_heads_engraver"
   \remove "Note_heads_engraver"
   \remove "Fingering_engraver"
index 18297e98aba6bbdb9015543d78ebeda8d0257b21..d32a540f761d622a8a2b9ba65c1d8199420c7002 100644 (file)
@@ -6,7 +6,7 @@
 
 #(use-modules (srfi srfi-1))  
 
-applymusic =
+applyMusic =
 #(def-music-function (parser location func music) (procedure? ly:music?)
                (func music))
 
@@ -33,7 +33,7 @@ autochange =
 #(def-music-function (parser location music) (ly:music?)
                (make-autochange-music music))
 
-applycontext =
+applyContext =
 #(def-music-function (parser location proc) (procedure?)
                  (make-music 'ApplyContext 
                    'origin location
@@ -58,12 +58,29 @@ displayLilyMusic =
    (display-lily-music music)
    music)
 
-applyoutput =
+applyOutput =
 #(def-music-function (parser location proc) (procedure?)
                 (make-music 'ApplyOutputEvent 
                   'origin location
                   'procedure proc))
 
+outputProperty =
+#(def-music-function (parser location name prop value)
+   (symbol? symbol? scheme?)
+
+
+   "Set @var{prop} to @var{value} in all grobs named @var{name} "
+
+   (make-music 'ApplyOutputEvent
+              'origin location
+              'procedure
+              (lambda (grob orig-context context)
+                (if (equal?
+                     (cdr (assoc 'name (ly:grob-property grob 'meta)))
+                     name)
+                    (set! (ly:grob-property grob prop) value)
+                ))))
+
 breathe =
 #(def-music-function (parser location) ()
             (make-music 'EventChord 
index 6f99647b16ccd9740c71e80871eddd9d7a47a2c4..471a4927b40697326c5ff8191ed52b33b49be8ce 100644 (file)
@@ -2555,3 +2555,14 @@ conversions.append (((2, 7, 6), conv,
                     '''Performer_group_performer -> Performer_group, Engraver_group_engraver -> Engraver_group
 inside-slur -> avoid-slur'''))
 
+
+
+def conv (str):
+       str = re.sub(r'\\applyoutput', '\\applyOutput', str)
+       str = re.sub(r'\\applycontext', '\\applyContext', str)
+       str = re.sub(r'\\applymusic', '\\applyMusic', str)
+       str = re.sub(r'ly:grob-suicide', 'ly:grob-suicide!', str)
+       return str
+
+conversions.append (((2, 7, 10), conv,
+                    '''\\applyxxx -> \\applyXxx'''))
index 7628772368cf01725f7738553da79e5833b0aa5b..f71ee578c73721f7ec859a097ae308ea7cae2ac9 100644 (file)
@@ -306,6 +306,10 @@ unbeamed stems.")
      (length-fraction ,number? "Length of ledger line as fraction of note head size.")
      (lengths ,list? "Default stem lengths. The list gives a length
 for each flag-count.")
+     (line-break-system-details ,list?
+                               "Alist of properties to use when this
+column is the start of a system.")
+     
      (line-count ,integer? "The number of staff lines.")
      (measure-length ,ly:moment? "Length of a
 measure. Used in some spacing situations.")
index e9310f6aed0fdef4236fdd70bcc5a8ffdcaa6787..9300f8b248a365efbf98a2afa89651be3d98ab59 100644 (file)
@@ -56,7 +56,7 @@
    ly:grob-script-priority-less
    ly:grob-set-property!
    ly:grob-staff-position
-   ly:grob-suicide
+   ly:grob-suicide!
    ly:grob-system
    ly:grob-translate-axis!
    ly:grob?