]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-book.cc
* lily/main.cc (main_with_guile): call lilypond-main
[lilypond.git] / lily / paper-book.cc
index af4eaf1d613035cbfeb26b31c8faefcb8ed5ebdf..8620970ab161ab3436df0fb05196ffcca7a8bca5 100644 (file)
@@ -29,7 +29,8 @@ stencil2line (Stencil* stil, bool is_title = false)
   Offset dim = Offset (stil->extent (X_AXIS).length (),
                       stil->extent (Y_AXIS).length ());
   Paper_line *pl = new Paper_line (dim, scm_cons (stil->smobbed_copy (),
-                                                 SCM_EOL), is_title);
+                                                 SCM_EOL),
+                                  -10001 * is_title, is_title);
 
   return scm_gc_unprotect_object (pl->self_scm ());
 }
@@ -167,7 +168,7 @@ Page::output (Paper_outputter *out, bool is_last)
   if (get_footer ())
     out->output_line (stencil2line (get_footer ()), &o, is_last);
   out->output_scheme (scm_list_2 (ly_symbol2scm ("stop-page"),
-                                 gh_bool2scm (is_last && !get_footer ())));
+                                 ly_bool2scm (is_last && !get_footer ())));
   progress_indication ("]");
 }
 
@@ -190,10 +191,6 @@ Page::text_height ()
 
 /****************************************************************/
 
-/* Current global paper book.  Gives default_rendering access from
-   input-file-results.  */
-Paper_book *paper_book;
-
 Paper_book::Paper_book ()
 {
   copyright_ = SCM_EOL;
@@ -254,7 +251,7 @@ Paper_book::output (String outname)
 
   Paper_def *paper = papers_[0];
   Paper_outputter *out = paper->get_paper_outputter (outname);
-  out->output_header (paper, scopes (0), pages->size ());
+  out->output_header (paper, scopes (0), pages->size (), false);
 
   int page_count = pages->size ();
   for (int i = 0; i < page_count; i++)
@@ -262,13 +259,10 @@ Paper_book::output (String outname)
 
   out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
 
-  /*
-    Ugh
-   */
-  for (int i =pages->size (); i--;)
-    delete pages->elem(i);
+  /* Ugh.  */
+  for (int i = pages->size (); i--;)
+    delete pages->elem (i);
   delete pages;
-
   
   progress_indication ("\n");
 }
@@ -279,7 +273,8 @@ Paper_book::scopes (int i)
   SCM scopes = SCM_EOL;
   if (headers_[i])
     scopes = scm_cons (headers_[i], scopes);
-  if (global_headers_[i] && global_headers_[i] != headers_[i])
+  if (global_headers_.size ()
+      && global_headers_[i] && global_headers_[i] != headers_[i])
     scopes = scm_cons (global_headers_[i], scopes);
   return scopes;
 }
@@ -288,8 +283,8 @@ Stencil*
 Paper_book::title (int i)
 {
   SCM user_title = ly_scheme_function ("user-title");
-    SCM book_title = ly_scheme_function ("book-title");
-    SCM score_title = ly_scheme_function ("score-title");
+  SCM book_title = ly_scheme_function ("book-title");
+  SCM score_title = ly_scheme_function ("score-title");
   SCM field = (i == 0 ? ly_symbol2scm ("bookTitle")
               : ly_symbol2scm ("scoreTitle"));
 
@@ -315,12 +310,15 @@ Paper_book::classic_output (String outname)
 {
   int count = scores_.size ();
   Paper_outputter *out = papers_.top ()->get_paper_outputter (outname);
-  out->output_header (papers_.top (), scopes (count - 1), 0);
+  out->output_header (papers_.top (), scopes (count - 1), 0, true);
 
+  Paper_line *first = unsmob_paper_line (scm_vector_ref (scores_.top (),
+                                                        scm_int2num (0)));
+  Offset o (0, -0.5 * first->dim ()[Y_AXIS]);
   int line_count = SCM_VECTOR_LENGTH ((SCM) scores_.top ());
   for (int i = 0; i < line_count; i++)
     out->output_line (scm_vector_ref ((SCM) scores_.top (), scm_int2num (i)),
-                     0, i == line_count - 1);
+                     &o, i == line_count - 1);
   
   out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
   progress_indication ("\n");
@@ -406,11 +404,11 @@ Paper_book::pages ()
 
   SCM all = lines ();
   SCM proc = paper->get_scmvar ("page-breaking");
-  SCM breaks = scm_apply_0 (proc, scm_list_n (all, gh_double2scm (height_),
-                                           gh_double2scm (text_height),
-                                           gh_double2scm (-copy_height),
-                                           gh_double2scm (-tag_height),
-                                           SCM_UNDEFINED));
+  SCM breaks = scm_apply_0 (proc, scm_list_n (all, scm_make_real (height_),
+                                             scm_make_real (text_height),
+                                             scm_make_real (-copy_height),
+                                             scm_make_real (-tag_height),
+                                             SCM_UNDEFINED));
 
   /* Copyright on first page.  */
   if (unsmob_stencil (copyright_))
@@ -424,7 +422,7 @@ Paper_book::pages ()
       if (i)
        page = new Page (paper, i+1);
       int next = i + 1 < page_count
-       ? gh_scm2int (scm_vector_ref (breaks, gh_int2scm (i))) : 0;
+       ? ly_scm2int (scm_vector_ref (breaks, scm_int2num (i))) : 0;
       while ((!next && all != SCM_EOL) || line <= next)
        {
          SCM s = ly_car (all);
@@ -462,13 +460,13 @@ c_ragged_page_breaks (SCM lines, Real book_height, Real text_height,
       h += pl->dim ()[Y_AXIS];
       if (!pl->is_title () && h > page_height)
        {
-         breaks = ly_snoc (gh_int2scm (number), breaks);
+         breaks = ly_snoc (scm_int2num (number), breaks);
          page_number++;
          page_height = text_height + (page_number == page_count) * last;
          h = 0;
        }
       if (ly_cdr (s) == SCM_EOL)
-       breaks = ly_snoc (gh_int2scm (pl->number_), breaks);
+       breaks = ly_snoc (scm_int2num (pl->number_), breaks);
     }
 
   return scm_vector (breaks);
@@ -479,12 +477,12 @@ LY_DEFINE (ly_ragged_page_breaks, "ly:ragged-page-breaks",
           "Return a vector with line numbers of page breaks.")
 {
   SCM_ASSERT_TYPE (scm_pair_p (lines), lines, SCM_ARG1, __FUNCTION__, "list");
-  SCM_ASSERT_TYPE (gh_number_p (book), book, SCM_ARG2, __FUNCTION__, "real");
-  SCM_ASSERT_TYPE (gh_number_p (text), text, SCM_ARG2, __FUNCTION__, "real");
-  SCM_ASSERT_TYPE (gh_number_p (first), first, SCM_ARG2, __FUNCTION__, "real");
-  SCM_ASSERT_TYPE (gh_number_p (last), last, SCM_ARG2, __FUNCTION__, "real");
+  SCM_ASSERT_TYPE (is_number (book), book, SCM_ARG2, __FUNCTION__, "real");
+  SCM_ASSERT_TYPE (is_number (text), text, SCM_ARG2, __FUNCTION__, "real");
+  SCM_ASSERT_TYPE (is_number (first), first, SCM_ARG2, __FUNCTION__, "real");
+  SCM_ASSERT_TYPE (is_number (last), last, SCM_ARG2, __FUNCTION__, "real");
 
   return c_ragged_page_breaks (lines,
-                              gh_scm2double (book), gh_scm2double (text),
-                              gh_scm2double (first), gh_scm2double (last));
+                              ly_scm2double (book), ly_scm2double (text),
+                              ly_scm2double (first), ly_scm2double (last));
 }