]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/stencil-scheme.cc (ly:stencil-expr): Rename (was:
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 28 Apr 2004 12:55:37 +0000 (12:55 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 28 Apr 2004 12:55:37 +0000 (12:55 +0000)
ly:stencil-get-expr).  Update callers.
(ly:stencil-align-to!):  Return stencil too.

* lily/paper-outputter.cc (output_page): Bugfix.  Use page
stencil.  Remove looped line-based page output.
(output_line): Use line stencil.  Remove looped stencil-based line
output.

* lily/page.cc (ly:page-paper-lines): New function.

* input/test/markup-score.ly: New file.

* lily/book.cc (to_stencil): New method.

* lily/parser.yy (markup): Use it to grok \score.

ChangeLog
input/test/markup-score.ly
lily/book.cc
lily/page.cc
lily/paper-line.cc
lily/paper-outputter.cc
lily/parser.yy
lily/stencil-scheme.cc
ly/declarations-init.ly
scm/lily.scm

index 8f332321744eeeb66efc7fffd353abc7c6244c36..7ad5d7fb8b59e28ca7023946bd10c0383b4d6d06 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2004-04-28  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * lily/stencil-scheme.cc (ly:stencil-expr): Rename (was:
+       ly:stencil-get-expr).  Update callers.
+       (ly:stencil-align-to!):  Return stencil too.
+
+       * lily/paper-outputter.cc (output_page): Bugfix.  Use page
+       stencil.  Remove looped line-based page output.
+       (output_line): Use line stencil.  Remove looped stencil-based line
+       output.
+
+       * lily/page.cc (ly:page-paper-lines): New function.
+
        * input/test/markup-score.ly: New file.
 
        * scm/define-markup-commands.scm (stencil): New markup.
index 8e1966ff7e0571d7542e8e4be5916065916143b8..81b32a54ef84827730a5769d519abf14389542d5 100644 (file)
@@ -1,41 +1,58 @@
-
 \header {
     %% WIP
     texidoc = "Use \\score block as markup command."
-    
 }
 
 \version "2.3.1"
 
+%%;; Hmm - why is stencil so tall?
+#(define (page-stack-lines page)
+  (stack-stencils Y 1 0
+   (map ly:paper-line-stencil (ly:page-paper-lines page))))
+       
+#(define (page-stack-lines page)
+  (let* ((urg-stencil (ly:stencil-align-to! (stack-stencils Y DOWN 0
+                       (map ly:paper-line-stencil (ly:page-paper-lines page)))
+                      Y DOWN))
+        (expr (ly:stencil-expr urg-stencil))
+        (xext (ly:stencil-extent urg-stencil X))
+        (yext (ly:stencil-extent urg-stencil Y)))
+   (ly:stencil-align-to!
+    ;; urgr
+    (ly:make-stencil expr xext (cons (* -0.25 (cdr yext)) 0))
+    Y CENTER)))
 
-\paper {
+inBed = \paper {
     raggedright = ##t
-    vsize = 30 \mm
-    linewidth = 30\mm
+    linewidth = 40\mm
     indent = 0 \mm
-    hsize = 40\mm
+
+    %% #(define page-to-stencil page-stack-lines)
+    #(define (page-to-stencil page)
+      (box-stencil (page-stack-lines page) 0.1 0.5))
+
+    \context {
+       \StaffContext
+       minimumVerticalExtent = ##f
+    }
 }
+
 \header {
     title = "title"
     subtitle = \markup { \fill-line <
        "subtitle with score: "
-       \score { \relative \notes { a'^"Hi" b c } }
+       \score { \relative \notes { a'^"Hi" b c } \paper { \inBed } }
        "woo!"
     > }
     subsubtitle = "subsubtitle"
 }
 
-\paper {
-    raggedright = ##f
-    linewidth = 150\mm
-    indent = 15\mm
-    vsize = 298\mm
-    hsize = 210 \mm
-}
-
 \relative {
     a' b c d \break
     a b c d \break
+    %% interesting bug:
+    %%a b^\markup { \score{ \notes\relative{ <b'1 dis fis> } \paper{ \inBed }}} c d
+    a b c d \break
     a b c d \break
 }
 
index 7400270e7b6ef154a6052f3c0d0005d69b7cd67d..477c25087891e00fea24a2eb7509d92c28023d19 100644 (file)
@@ -108,7 +108,8 @@ Book::to_stencil (Music_output_def *default_def, SCM header)
   for (int i = 0; i < score_count; i++)
     {
       Paper_def *paper = 0;
-      SCM systems = scores_[i]->book_rendering ("", default_def, &paper);
+      SCM systems = scores_[i]->book_rendering ("<markup>", default_def,
+                                               &paper);
       if (systems != SCM_UNDEFINED)
        {
          if (paper)
@@ -121,6 +122,9 @@ Book::to_stencil (Music_output_def *default_def, SCM header)
   SCM pages = paper_book->pages ();
   scm_gc_unprotect_object (paper_book->self_scm ());
   if (pages != SCM_EOL)
-    return unsmob_page (ly_car (pages))->to_stencil ();
+    {
+      progress_indication (_f ("paper output to `%s'...", "<markup>"));
+      return unsmob_page (ly_car (pages))->to_stencil ();
+    }
   return SCM_EOL;
 }
index a25d2a78f9510c52387989b98e620e71a43c7129..801e9c9c50af7cc07ac3c7681505d3f556c1b3f4 100644 (file)
@@ -112,7 +112,7 @@ stack_stencils (Stencil &a, Stencil *b, Offset *origin)
 SCM
 Page::to_stencil () const
 {
-  SCM proc = ly_scheme_function ("page-to-stencil");
+  SCM proc = paper_->lookup_variable (ly_symbol2scm ("page-to-stencil"));
   return scm_call_1 (proc, self_scm ());
 }
 
@@ -141,20 +141,11 @@ LY_DEFINE (ly_page_header_lines_footer_stencil, "ly:page-header-lines-footer-ste
       stack_stencils (stencil, s, &o);
       o[Y_AXIS] += p->head_sep_;
     }
+
   for (SCM s = p->lines_; s != SCM_EOL; s = ly_cdr (s))
     {
       Paper_line *p = unsmob_paper_line (ly_car (s));
-#if 0 // ugh, parse error?
-      Stencil line (Box (Interval (0, p->dim ()[X_AXIS]),
-                        Interval (0, p->dim ()[Y_AXIS])), SCM_EOL);
-#else
-      Box x (Interval (0, p->dim ()[X_AXIS]),
-            Interval (0, p->dim ()[Y_AXIS]));
-      Stencil line (x, SCM_EOL);
-#endif
-      line.add_stencil (*unsmob_stencil (p->to_stencil ()));
-      stack_stencils (stencil, &line, &o);
-      
+      stack_stencils (stencil, unsmob_stencil (p->to_stencil ()), &o);
       /* Do not put vfill between title and its music, */
       if (ly_cdr (s) != SCM_EOL
          && (!p->is_title () || vfill < 0))
@@ -200,3 +191,11 @@ Page::text_height () const
   return h;
 }
 
+LY_DEFINE (ly_page_paper_lines, "ly:page-paper-lines",
+          1, 0, 0, (SCM page),
+          "Return paper-lines from PAGE.")
+{
+  Page *p = unsmob_page (page);
+  SCM_ASSERT_TYPE (p, page, SCM_ARG1, __FUNCTION__, "page");
+  return p->lines_;
+}
index 746b4aca46052047179ab6f9a114faaa1cbcb479..ee258154475cf8ee27b58463187a5f8ded1e309b 100644 (file)
@@ -81,6 +81,9 @@ Paper_line::to_stencil () const
   Stencil stencil;
   for (SCM s = stencils_; ly_c_pair_p (s); s = ly_cdr (s))
     stencil.add_stencil (*unsmob_stencil (ly_car (s)));
+  Offset o = dim ();
+  Box x (Interval (0, o[X_AXIS]), Interval (0, o[Y_AXIS]));
+  stencil = Stencil (x, stencil.expr ());
   return stencil.smobbed_copy ();
 }
 
@@ -110,3 +113,13 @@ LY_DEFINE (ly_paper_line_break_score, "ly:paper-line-break-score",
   SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
   return scm_int2num (int (pl->penalty ()));
 }
+
+LY_DEFINE (ly_paper_line_stencil, "ly:paper-line-stencil",
+          1, 0, 0, (SCM line),
+          "Return the height of @var{line}.")
+{
+  Paper_line *pl = unsmob_paper_line (line);
+  SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
+  return pl->to_stencil ();
+}
+
index 7999da4e749beb459aacbbf1a2616f5d791b2330..8de4a29e167e20525238a5edc7ae5abfa3ceb3bf 100644 (file)
@@ -183,12 +183,7 @@ Paper_outputter::output_line (SCM line, Offset *origin, bool is_last)
                             ly_quote_scm (ly_offset2scm (*origin)),
                             ly_quote_scm (ly_offset2scm (dim))));
 
-#if 1 /* FIXME: how stupid is this memorywise?  */
   output_stencil (unsmob_stencil (p->to_stencil ()));
-#else
-  for (SCM s = p->stencils (); ly_c_pair_p (s); s = ly_cdr (s))
-    output_expr (unsmob_stencil (ly_car (s))->expr (), Offset (0, 0));
-#endif
 
   (*origin)[Y_AXIS] += dim[Y_AXIS];
   output_scheme (scm_list_2 (ly_symbol2scm ("stop-system"),
@@ -200,8 +195,6 @@ Paper_outputter::output_page (Page *p, bool is_last)
 {
   output_scheme (scm_list_1 (ly_symbol2scm ("start-page")));
 
-#if 0 /* FIXME: how stupid is this, memorywise?  */
-  
   output_scheme (scm_list_3 (ly_symbol2scm ("start-system"),
                             ly_quote_scm (ly_offset2scm (Offset (0, 0))),
                             ly_quote_scm (ly_offset2scm (Offset (0, 0)))));
@@ -209,63 +202,6 @@ Paper_outputter::output_page (Page *p, bool is_last)
   output_stencil (unsmob_stencil (p->to_stencil ()));
 
   output_scheme (scm_list_2 (ly_symbol2scm ("stop-system"), SCM_BOOL_T));
-#else
-  Offset o (p->left_margin_, p->top_margin_);
-  Real vfill = (p->line_count_ > 1
-               ? (p->text_height () - p->height_) / (p->line_count_ - 1)
-               : 0);
-
-  Real coverage = p->height_ / p->text_height ();
-  if (coverage < p->MIN_COVERAGE_)
-    /* Do not space out a badly filled page.  This is too simplistic
-       (ie broken), because this should not vary too much between
-       (subsequent?) pages in a book.  */
-    vfill = 0;
-
-  if (unsmob_stencil (p->header_))
-    {
-      output_line (stencil2line (unsmob_stencil (p->header_)), &o, false);
-      o[Y_AXIS] += p->head_sep_;
-    }
-  for (SCM s = p->lines_; s != SCM_EOL; s = ly_cdr (s))
-    {
-      SCM line = ly_car (s);
-      output_line (line, &o,
-                  is_last && ly_cdr (s) != SCM_EOL
-                  && !unsmob_stencil (p->copyright_)
-                  && !unsmob_stencil (p->tagline_)
-                  && !unsmob_stencil (p->footer_));
-      
-      /* Do not put vfill between title and its music, */
-      if (scm_pair_p (ly_cdr (s))
-         && (!unsmob_paper_line (line)->is_title () || vfill < 0))
-       o[Y_AXIS] += vfill;
-      /* rather put extra just before the title.  */
-      if (ly_cdr (s) != SCM_EOL
-         && (unsmob_paper_line (ly_cadr (s))->is_title () && vfill > 0))
-       o[Y_AXIS] += vfill;
-    }
-
-  o[Y_AXIS] = p->vsize_ - p->bottom_margin_;
-  if (unsmob_stencil (p->copyright_))
-    o[Y_AXIS] -= unsmob_stencil (p->copyright_)->extent (Y_AXIS).length ();
-  if (unsmob_stencil (p->tagline_))
-    o[Y_AXIS] -= unsmob_stencil (p->tagline_)->extent (Y_AXIS).length ();
-  if (unsmob_stencil (p->footer_))
-    o[Y_AXIS] -= unsmob_stencil (p->footer_)->extent (Y_AXIS).length ();
-
-  if (unsmob_stencil (p->copyright_))
-    output_line (stencil2line (unsmob_stencil (p->copyright_)), &o,
-                is_last
-                && !unsmob_stencil (p->tagline_)
-                && !unsmob_stencil (p->footer_));
-  if (unsmob_stencil (p->tagline_))
-    output_line (stencil2line (unsmob_stencil (p->tagline_)), &o,
-                     is_last && !unsmob_stencil (p->footer_));
-  if (unsmob_stencil (p->footer_))
-    output_line (stencil2line (unsmob_stencil (p->footer_)), &o, is_last);
-#endif
-  
   output_scheme (scm_list_2 (ly_symbol2scm ("stop-page"),
                             ly_bool2scm (is_last
                                          && !unsmob_stencil (p->footer_))));
index 5914531b8593a285443d246e059af301bb982374..842244079cf22cffe26fb2821e70e98a24b1194e 100644 (file)
@@ -315,6 +315,11 @@ or
 %token WITH
 
 /* escaped */
+/* FIXME: this sucks.  The user will get to see these names:
+    syntax error, unexpected E_CHAR:
+               \
+                 %%
+  */
 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
 %token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
 %token E_BACKSLASH
@@ -2455,6 +2460,7 @@ markup:
                SCM s = book->to_stencil (paper, THIS->header_);
                $$ = scm_list_2 (ly_scheme_function ("stencil-markup"), s);
                scm_gc_unprotect_object (score->self_scm ());
+               scm_gc_unprotect_object (book->self_scm ());
        }
        ;
 
index af6904f5c25656752e0130bbb19c1549077b4b04..7971229f074f3968b10e2e81c05980851ec44c4e 100644 (file)
@@ -66,7 +66,7 @@ LY_DEFINE (ly_translate_stencil, "ly:stencil-translate",
   return new_s;
 }
 
-LY_DEFINE (ly_stencil_expr, "ly:stencil-get-expr",
+LY_DEFINE (ly_stencil_expr, "ly:stencil-expr",
           1, 0, 0, (SCM stil),
           "Return the expression of @var{stil}.")
 {
@@ -223,5 +223,5 @@ LY_DEFINE (ly_align_to_x, "ly:stencil-align-to!",
 
   unsmob_stencil (stil)->align_to ((Axis)ly_scm2int (axis),
                                   ly_scm2double (dir));
-  return SCM_UNDEFINED;
+  return stil;
 }
index 671b97470c6e95e5ad07418bfdbae49c33d92586..48e17441cedec4216022272ef401b56abceeab46 100644 (file)
@@ -74,6 +74,8 @@ melismaEnd = #(make-span-event 'ManualMelismaEvent STOP)
     #(define page-breaking ly:ragged-page-breaks)
     %%#(define page-breaking ly:optimal-page-breaks)
 
+    #(define page-to-stencil ly:page-header-lines-footer-stencil)
+
     \include "engraver-init.ly"
 }
 
@@ -149,3 +151,5 @@ unusedEntry = \notes { c4 }
 #(define toplevel-book-handler default-toplevel-book-handler)
 #(define toplevel-music-handler default-toplevel-music-handler)
 #(define toplevel-score-handler default-toplevel-score-handler)
+
+#(define toplevel-score-handler default-toplevel-score-handler)
index d192d70af0794f7c0ef57f0927c952df80566caf..e22e5a5acd686a1f28c9980e5de4a95151f9f775 100644 (file)
@@ -98,9 +98,6 @@
 
 (define-public safe-mode? #f)
 
-;; Hmm
-(define-public page-to-stencil ly:page-header-lines-footer-stencil)
-
 ;; parser stuff.
 (define-public (print-music-as-book parser music)
   (let* ((score (ly:music-scorify music))