]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/paper-outputter.cc (output_expr):
authorJan Nieuwenhuizen <janneke@gnu.org>
Mon, 8 Mar 2004 22:12:26 +0000 (22:12 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 8 Mar 2004 22:12:26 +0000 (22:12 +0000)
(output_header):
(output_line): New method.

* lily/system.cc (get_line):
(get_lines): New method.
(output_scheme):
(output_line): Remove.

* scm/lily.scm (make-title): New function.

* lily/paper-book.cc:
* lily/include/paper-book.hh: New file.

* lily/include/ly-module.hh: New file, matching ly-module.cc (WAS:
ly-modules.hh).

* lily/ly-module.cc (ly_modules_lookup): New function.

* lily/main.cc (main_with_guile): Move memory leak debug code back.

* scm/output-ps.scm (make-title): Remove.
(output-scopes): Junk header-title test.

26 files changed:
ChangeLog
input/test/title-markup.ly
lily/break-substitution.cc
lily/include/lily-proto.hh
lily/include/ly-module.hh [new file with mode: 0644]
lily/include/ly-modules.hh [deleted file]
lily/include/main.hh
lily/include/paper-book.hh [new file with mode: 0644]
lily/include/paper-outputter.hh
lily/include/paper-score.hh
lily/include/system.hh
lily/input-file-results.cc
lily/ly-module.cc
lily/main.cc
lily/music-output-def.cc
lily/my-lily-lexer.cc
lily/paper-book.cc [new file with mode: 0644]
lily/paper-def.cc
lily/paper-outputter.cc
lily/paper-score.cc
lily/parser.yy
lily/score.cc
lily/system.cc
scm/lily.scm
scm/output-ps.scm
scm/output-tex.scm

index 062dc929a705bbc2e087ab36d15ab49d5fe74d94..011cb40c54dcba6bad38955da76ec10bb79e424e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,37 @@
+2004-03-08  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * lily/paper-outputter.cc (output_expr):
+       (output_header):
+       (output_line): New method.
+
+       * lily/system.cc (get_line):
+       (get_lines): New method.
+       (output_scheme):
+       (output_line): Remove.
+
+       * scm/lily.scm (make-title): New function.
+
+       * lily/paper-book.cc: 
+       * lily/include/paper-book.hh: New file.
+
+       * lily/include/ly-module.hh: New file, matching ly-module.cc (WAS:
+       ly-modules.hh).
+
+       * lily/ly-module.cc (ly_modules_lookup): New function.
+
+       * lily/main.cc (main_with_guile): Move memory leak debug code back.
+
+       * scm/output-ps.scm (make-title): Remove.
+       (output-scopes): Junk header-title test.
+
 2004-03-08  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
        * mf/feta-schrift.mf: thicker dot for portato.
-       
 
        * lily/accidental-placement.cc (position_accidentals): bugfix in
        offset, this fixes right-padding of AccidentalPlacement.
 
-       * lily/[h-z]*.cc:  () formatting.
+       * lily/[h-z]*.cc: () formatting.
 
        * Documentation/user/tutorial.itely (An orchestral part): more
        fixes for the tutorial.
index 12bdc0c943655d1ee35aaff943cfb553d609346a..e5a86c004c8759a0e5dd6f0b88f7c973dab32c9e 100644 (file)
@@ -1,11 +1,10 @@
 \version "2.1.29"
 %{
-   \markup in titles is WIP, only available in direct PostScript output
-   process and view this file doing:
+   \markup in titles is WIP.
+
+   only available when compiled with PAGE_LAYOUT is #define'd
+   see include/paper-book.hh
 
-     lilypond-bin -fps title-markup.ly
-     export GS_LIB=$(pwd)/mf/out:/usr/share/texmf/fonts/type1/bluesky/cm
-     gs title-markup.ps
 %}
 
 sizeTest = \markup {
@@ -63,7 +62,7 @@ spaceTest = \markup { "two space chars" }
         >
     }
 %}
-    makeTitle = \markup {
+    bookTitle = \markup {
        \column <
            %\fill-line #linewidth < \huge \bigger \bold \title >
             \override #'(baseline-skip . 4) \column <
@@ -100,7 +99,18 @@ spaceTest = \markup { "two space chars" }
 
 \score {
     \context Staff \notes \relative c' {
-       c2-\sizeTest c2-\spaceTest \break
-       c2 c2
+       c2-\sizeTest c2-\spaceTest
+       % \break c2 c2
+    }
+}
+
+\header {
+    scoreTitle = \markup { "Tweetje" }
+}
+
+\score {
+    \context Staff \notes \relative c' {
+       c2-\sizeTest c2-\spaceTest
+       % \break c2 c2
     }
 }
index 59664579f757521a4408267a7cafc2bcb78eff18..bd524417f55f9b73a0842c54f0d53bbbe274ad0c 100644 (file)
@@ -90,18 +90,16 @@ do_break_substitution (SCM src)
  again:
  
   if (unsmob_grob (src))
-    {
-      return substitute_grob (unsmob_grob (src));
-    }
+    return substitute_grob (unsmob_grob (src));
   else if (gh_vector_p (src))
     {
-      int  l = SCM_VECTOR_LENGTH (src);
-      SCM nv = scm_c_make_vector (l, SCM_UNDEFINED);
-
-      for (int i  =0 ; i< l ; i++)
+      int len = SCM_VECTOR_LENGTH (src);
+      SCM nv = scm_c_make_vector (len, SCM_UNDEFINED);
+      for (int i = 0; i < len; i++)
        {
          SCM si = scm_int2num (i);
-         scm_vector_set_x (nv, si, do_break_substitution (scm_vector_ref (src, si))); 
+         scm_vector_set_x (nv, si,
+                           do_break_substitution (scm_vector_ref (src, si))); 
        }
     }
   else if (ly_pair_p (src)) 
index 57863cdb80789e52c0e8d4f8014551166bcd4713..493b5ef46d56dfe319a722e62cf2de0b4a2ce157 100644 (file)
@@ -109,6 +109,7 @@ class Pitch;
 class My_lily_lexer;
 class Note_performer;
 class Output_property;
+class Paper_book;
 class Paper_column;
 class Paper_def;
 class Paper_outputter;
@@ -162,4 +163,5 @@ class Translator_group;
 class Transposed_music;
 class Type_swallow_translator;
 class yyFlexLexer;
-#endif // LILY_PROTO_HH;
+
+#endif /* LILY_PROTO_HH */
diff --git a/lily/include/ly-module.hh b/lily/include/ly-module.hh
new file mode 100644 (file)
index 0000000..c486a4e
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+  ly-module.hh -- declare  module related helper functions 
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#ifndef LY_MODULE_HH
+#define LY_MODULE_HH
+
+#include "lily-guile.hh"
+
+SCM ly_make_anonymous_module ();
+void ly_copy_module_variables (SCM dest, SCM src);
+SCM ly_module_to_alist (SCM mod);
+SCM ly_module_lookup (SCM module, SCM sym);
+SCM ly_modules_lookup (SCM modules, SCM sym);
+SCM ly_module_symbols (SCM mod);
+void  ly_reexport_module (SCM mod);
+inline bool ly_module_p (SCM x) { return SCM_MODULEP(x); }
+void ly_clear_anonymous_modules ();
+
+#endif /* LY_MODULE_HH */
+
diff --git a/lily/include/ly-modules.hh b/lily/include/ly-modules.hh
deleted file mode 100644 (file)
index 6a05cf9..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-  ly-modules.hh -- declare  module related helper functions 
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef LY_MODULES_HH
-#define LY_MODULES_HH
-
-#include "lily-guile.hh"
-
-SCM ly_make_anonymous_module ();
-void ly_copy_module_variables (SCM dest, SCM src);
-SCM ly_module_to_alist (SCM mod);
-SCM ly_module_lookup (SCM module, SCM sym);
-SCM ly_module_symbols (SCM mod);
-void  ly_reexport_module (SCM mod);
-inline bool ly_module_p (SCM x) { return SCM_MODULEP(x); }
-void ly_clear_anonymous_modules ();
-
-#endif /* LY_MODULES_HH */
-
index 978e3f86d13548ef25b999e77a0dc5c8ada096a0..5c5ed19e8c942d854323c7004c9d2fab6d457c44 100644 (file)
@@ -46,4 +46,6 @@ extern int exit_status_global;
 extern File_path global_path;
 extern int score_count_global;
 
+extern Paper_book *paper_book;
+
 #endif /* MAIN_HH */
diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh
new file mode 100644 (file)
index 0000000..9fd93ff
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+  paper-book.hh -- declare Paper_book
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2004  Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#ifndef PAPER_BOOK_HH
+#define PAPER_BOOK_HH
+
+// #define PAGE_LAYOUT 1
+
+#include "parray.hh"
+class Page;
+
+class Paper_book
+{
+public:
+  Link_array<Paper_score> paper_scores_;
+  Paper_book ();
+
+  Link_array<Page> *get_pages ();
+  void output ();
+};
+
+#endif /* PAPER_BOOK_HH */
+
index 82c359452244cd7d35342b5bbf09f533228c400b..58c23e2464367efa74c6afe42252f584abbaf296 100644 (file)
@@ -41,6 +41,9 @@ public:
   void output_metadata (SCM, Paper_def*);
   void output_music_output_def (Music_output_def* odef);
   void output_scheme (SCM scm);
+  void output_expr (SCM expr, Offset o);
+  void output_header (Paper_def*);
+  void output_line (SCM, bool);
 };
 
-#endif // PAPER_OUTPUTTER_HH
+#endif /* PAPER_OUTPUTTER_HH */
index 6aeec1ce3ae9fb3d3c64f75bff57ddd2686b7d03..6ef31f47964a3af63ee19b2b258845a76bd6f8d5 100644 (file)
@@ -27,9 +27,14 @@ class Paper_score : public Music_output
 public:
   Paper_def *paper_;
 
+  /* Vector with lines of stencils.  */
+  Protected_scm lines_;
+  Stencil *book_title_;
+  Stencil *score_title_;
+
   Paper_outputter *outputter_;  
   System *system_;
-  
+
   Paper_score ();
 
   /**
@@ -39,7 +44,8 @@ public:
 
   Link_array<Item> broken_col_range (Item const*,Item const*) const;
   void typeset_line (System*);
-    
+  void output ();
+
 protected:
     /* MAIN ROUTINES */
   virtual void process (String);
index a9b24b6f2c4497cb3d6672bb4de615d294f28665..911aa0b792fac365016dbf9388c7929c98bab6ca 100644 (file)
@@ -23,15 +23,15 @@ class System : public Spanner
 {
 public:
   int rank_;
-  void post_processing (bool);
+  void post_processing ();
+  SCM get_line ();
+  SCM get_lines ();
 
   System (SCM);
   int element_count () const;
   int spanner_count () const;
 
-
   void break_into_pieces (Array<Column_x_positions> const&);
-  void output_lines ();
   static bool has_interface (Grob*);
   
   Link_array<Item> broken_col_range (Item const*, Item const*) const;
@@ -39,8 +39,6 @@ public:
   
   void add_column (Paper_column*);
   void typeset_grob (Grob*);
-  void output_stencil (SCM, Offset);
-  void output_scheme (SCM);
   void pre_processing ();
 
 protected:
index c10086445330ee197d5cbc7f2e3b1aebbef956a9..a70ed99376b465f6b0e868335015de8fab3aed19 100644 (file)
@@ -30,7 +30,9 @@
 #include "source.hh"
 #include "lily-version.hh"
 #include "scm-hash.hh"
-#include "ly-modules.hh"
+#include "ly-module.hh"
+
+#include "paper-book.hh"
 
 bool store_locations_global_b;
 
@@ -210,17 +212,7 @@ do_one_file (char const *file)
   
   String in_file = inpath.to_string ();
   String out_file = outpath.to_string ();
-  
-#if 0
-  /* Code to debug memory leaks.  Cannot call from within .ly
-     since then we get the protects from the parser state too. */
-  static SCM proc ;
-  if (!proc)
-       proc = scm_c_eval_string ("dump-gc-protects");
-  scm_gc ();
-  scm_call_0 (proc);
-#endif
-      
+
   if (init.length () && global_path.find (init).is_empty ())
     {
       warning (_f ("can't find file: `%s'", init));
@@ -238,5 +230,12 @@ do_one_file (char const *file)
   if (!proc)
     proc = scm_c_eval_string ("dump-gc-protects");
 
+#ifdef PAGE_LAYOUT
+  Paper_book book;
+  paper_book = &book;
+#endif
   Input_file_results inp_file (init, in_file, out_file);
+#ifdef PAGE_LAYOUT
+  book.output ();
+#endif
 }
index 4f4aecb8738d170b66970c381ea2690607cb7fe1..dd204fa938dce606c8ca5ccf55d243de72bccf16 100644 (file)
@@ -1,15 +1,15 @@
-/*   
-ly-module.cc --  implement guile module stuff.
-
-source file of the GNU LilyPond music typesetter
-
-(c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+/*
+  ly-module.cc --  implement guile module stuff.
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
- */
+*/
 
 #include "string.hh"
 #include "lily-guile.hh"
-#include "ly-modules.hh"
+#include "ly-module.hh"
 #include "protected-scm.hh"
 
 #define FUNC_NAME __FUNCTION__
@@ -42,11 +42,9 @@ ly_clear_anonymous_modules ()
   for (; gh_pair_p (s) ; s = gh_cdr (s))
     {
       SCM tab= scm_c_make_hash_table (2);
-      /*
-       UGH.
-      */
-      
-      SCM_STRUCT_DATA (gh_car (s))[scm_module_index_obarray] = (long unsigned int) tab;
+      /* UGH. */
+      SCM_STRUCT_DATA (gh_car (s))[scm_module_index_obarray]
+       = (long unsigned int) tab;
     }
 }
 
@@ -60,9 +58,7 @@ define_one_var (void * closure, SCM key, SCM val, SCM result)
   return SCM_EOL;
 }
 
-/*
-  Ugh signature of scm_internal_hash_fold () is inaccurate.
- */
+/* Ugh signature of scm_internal_hash_fold () is inaccurate.  */
 typedef SCM (*Hash_cl_func)();
 
 void
@@ -86,7 +82,8 @@ ly_module_symbols (SCM mod)
   SCM_VALIDATE_MODULE (1, mod);
   
   SCM obarr= SCM_MODULE_OBARRAY (mod);
-  return scm_internal_hash_fold ((Hash_cl_func) &accumulate_symbol, NULL, SCM_EOL, obarr); 
+  return scm_internal_hash_fold ((Hash_cl_func) &accumulate_symbol,
+                                NULL, SCM_EOL, obarr); 
 }
 
 SCM
@@ -106,9 +103,7 @@ ly_module_to_alist (SCM mod)
   return scm_internal_hash_fold ((Hash_cl_func) &entry_to_alist, NULL, SCM_EOL, obarr); 
 }
 
-/*
-  Lookup SYM, but don't give error when it is not defined.
- */
+/* Lookup SYM, but don't give error when it is not defined.  */
 SCM
 ly_module_lookup (SCM module, SCM sym)
 {
@@ -119,18 +114,28 @@ ly_module_lookup (SCM module, SCM sym)
 #undef FUNC_NAME
 }
 
+SCM
+ly_modules_lookup (SCM modules, SCM sym)
+{
+  for (SCM s = gh_car (modules); SCM_MODULEP (s); s = ly_cdr (s))
+    {
+      SCM v = scm_sym2var (sym, scm_module_lookup_closure (s), SCM_UNDEFINED);
+      if (v != SCM_UNDEFINED)
+       return v;
+    }
+  return SCM_UNDEFINED;
+}
+
+
 SCM export_function;
 
 void
 ly_export (SCM module, SCM namelist)
 {
   if (!export_function)
-    {
-      export_function = scm_permanent_object (scm_c_lookup ("module-export!"));
-    }
+    export_function = scm_permanent_object (scm_c_lookup ("module-export!"));
   
-  scm_call_2 (SCM_VARIABLE_REF (export_function),
-             module, namelist);
+  scm_call_2 (SCM_VARIABLE_REF (export_function), module, namelist);
 }
 
 void
index 337918b3f21d9cb7c6ab85f5696e395d676015df..08b483c4dec70dd69cca63544002af72c0d0d7b7 100644 (file)
@@ -278,17 +278,33 @@ main_with_guile (void *, int, char **)
 
   init_scheme_code_string += ")";
   gh_eval_str ((char*) init_scheme_code_string.to_str0 ());
-  
+
+  /* We accept multiple independent music files on the command line to
+     reduce compile time when processing lots of small files.
+     Starting the GUILE engine is very time consuming.  */
   bool first = true;
   while (char const *arg = option_parser->get_next_arg ())
     {
+  
+#if 0
+      /* Code to debug memory leaks.  Cannot call from within .ly
+        since then we get the protects from the parser state too.  */
+      static SCM proc;
+      if (!proc)
+       proc = scm_c_eval_string ("dump-gc-protects");
+      scm_gc ();
+      scm_call_0 (proc);
+#endif
+      
       do_one_file (arg);
       first = false;
     }
   delete option_parser;
   option_parser = 0;
 
-  /* No FILE arguments is now a usage error */
+  /* No FILE arguments is now a usage error to help newbies.  If you
+     want a filter, you're not a newbie and should know to use file
+     argument `-'.  */
   if (first)
     {
       usage ();
index 9ead9e7d8c4e0480fab7643145e26ddd031a569f..b690c9450d50d884eb0f4badc9f065daf7ce0350 100644 (file)
@@ -15,7 +15,7 @@
 #include "main.hh"
 #include "file-path.hh"
 #include "lily-guile.hh"
-#include "ly-modules.hh"
+#include "ly-module.hh"
 
 #include "ly-smobs.icc"
 
index 30b4afd7dde561361f83513d2dc91e8e642fead7..a0a276ccf7ff33d8fcad1a42a0b153c1f59dcf00 100644 (file)
@@ -22,7 +22,7 @@
 #include "main.hh"
 #include "input.hh"
 #include "moment.hh"
-#include "ly-modules.hh"
+#include "ly-module.hh"
 
 
 static Keyword_ent the_key_tab[]={
diff --git a/lily/paper-book.cc b/lily/paper-book.cc
new file mode 100644 (file)
index 0000000..3e43a14
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+  paper-book.cc -- implement Paper_book
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "main.hh"
+#include "paper-book.hh"
+#include "paper-score.hh"
+#include "paper-def.hh"
+#include "stencil.hh"
+#include "paper-outputter.hh"
+
+// WIP -- simplistic page interface
+// Do we need this at all?  SCM, smob?
+class Page
+{
+public:
+  Paper_def *paper_;
+
+  SCM lines_;
+  Real hsize_;
+  Real vsize_;
+
+  Page (Paper_def*);
+  void output (Paper_outputter*, bool);
+};
+
+Page::Page (Paper_def *paper)
+{
+  paper_ = paper;
+  hsize_ = paper->get_realvar (ly_symbol2scm ("hsize"));
+  vsize_ = paper->get_realvar (ly_symbol2scm ("vsize"));
+}
+
+void
+Page::output (Paper_outputter *out, bool is_last)
+{
+  int line_count = SCM_VECTOR_LENGTH ((SCM) lines_);
+  for (int i = 0; i < line_count; i++)
+    out->output_line (scm_vector_ref (lines_, scm_int2num (i)),
+                     is_last && i == line_count - 1);
+}
+
+
+Paper_book *paper_book;
+
+Paper_book::Paper_book ()
+{
+}
+
+void
+Paper_book::output ()
+{
+  Paper_outputter *out = paper_scores_[0]->outputter_;
+  
+  Paper_def *paper = paper_scores_[0]->paper_;
+  out->output_header (paper);
+  
+  if (paper_scores_[0]->book_title_)
+    out->output_expr (paper_scores_[0]->book_title_->get_expr (),
+                     Offset (0, 0));
+
+  Link_array<Page> *pages = get_pages ();
+  int page_count = pages->size ();
+  for (int i = 0; i < page_count; i++)
+    (*pages)[i]->output (out, i + 1 == page_count);
+
+  out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
+  progress_indication ("\n");
+}
+
+/*
+  WIP -- this simply adds one Page per \score
+  TODO:
+     * get dimensions
+     * title: bookTitle vs scoreTitle
+     * header / footer (generate per Page, with page#)
+     * start-page / stop-page in output-* interface
+     * some page breaking algorithm
+*/
+Link_array<Page>*
+Paper_book::get_pages ()
+{
+  Link_array<Page> *pages = new Link_array<Page>;
+  Paper_def *paper = paper_scores_[0]->paper_;
+  int score_count = paper_scores_.size ();
+  for (int i = 0; i < score_count; i++)
+    {
+      Page *page = new Page (paper);
+      page->lines_ = paper_scores_[i]->lines_;
+      pages->push (page);
+    }
+
+  //if (paper_scores_[0]->book_title_)
+  //  title = paper_scores_[0]->book_title_->extent (Y_AXIS).length ();
+
+  return pages;
+}
index 0e7ab2254e62c056b5add19021359e24eb291aee..3d325428682c1446c1e9e2fea54cb4c4cfcfaabe 100644 (file)
@@ -20,7 +20,7 @@
 #include "scm-hash.hh"
 #include "input-file-results.hh" // urg? header_global
 #include "paper-outputter.hh"
-#include "ly-modules.hh"
+#include "ly-module.hh"
 
 /*
   This is an almost empty thing. The only substantial thing this class
index 2fe344130750340af8529ca03ea905946250a9ea..51135a7e9c493153c6efe6278d9cf53c8bce3c11 100644 (file)
 #include "lily-version.hh"
 #include "paper-def.hh"
 #include "input-file-results.hh"
-#include "ly-modules.hh"
+#include "ly-module.hh"
+
+
+#include "input-smob.hh"  // output_expr
 
 
 Paper_outputter::Paper_outputter (String name)
@@ -62,9 +65,9 @@ Paper_outputter::output_metadata (SCM scopes, Paper_def *paper)
 {
   SCM fields = SCM_EOL;
   for (int i = dump_header_fieldnames_global.size (); i--; )
-    fields = gh_cons (ly_symbol2scm (dump_header_fieldnames_global[i].to_str0 ()),
-                                    fields);
-  
+    fields
+      = gh_cons (ly_symbol2scm (dump_header_fieldnames_global[i].to_str0 ()),
+                fields);
   output_scheme (scm_list_n (ly_symbol2scm ("output-scopes"),
                             paper->self_scm (),
                             scm_list_n (ly_symbol2scm ("quote"),
@@ -75,6 +78,42 @@ Paper_outputter::output_metadata (SCM scopes, Paper_def *paper)
                             SCM_UNDEFINED));
 }
 
+void
+Paper_outputter::output_header (Paper_def *paper)
+{
+  output_music_output_def (paper);
+  output_scheme (scm_list_1 (ly_symbol2scm ("header-end")));
+  output_scheme (scm_list_2 (ly_symbol2scm ("define-fonts"),
+                            ly_quote_scm (paper->font_descriptions ())));
+}
+
+void
+Paper_outputter::output_line (SCM line, bool is_last)
+{
+  Offset dim = ly_scm2offset (ly_car (line));
+  Real width = dim[X_AXIS];
+  Real height = dim[Y_AXIS];
+      
+  if (height > 50 CM)
+    {
+      programming_error ("Improbable system height.");
+      height = 50 CM;
+    }
+
+  output_scheme (scm_list_3 (ly_symbol2scm ("start-system"),
+                            gh_double2scm (width), gh_double2scm (height)));
+
+  for (SCM s = ly_cdr (line); gh_pair_p (s); s = ly_cdr (s))
+    {
+      Stencil *stil = unsmob_stencil (ly_cdar (s));
+      output_expr (stil->get_expr (), ly_scm2offset (ly_caar (s)));
+    }
+
+  if (is_last)
+    output_scheme (scm_list_1 (ly_symbol2scm ("stop-last-system")));
+  else
+    output_scheme (scm_list_1 (ly_symbol2scm ("stop-system")));
+}
 
 void
 Paper_outputter::output_music_output_def (Music_output_def* odef)
@@ -82,3 +121,52 @@ Paper_outputter::output_music_output_def (Music_output_def* odef)
   output_scheme (scm_list_n (ly_symbol2scm ("output-paper-def"),
                             odef->self_scm (), SCM_UNDEFINED));
 }
+
+/* TODO: replaceme/rewriteme, see output-ps.scm: output-stencil  */
+void
+Paper_outputter::output_expr (SCM expr, Offset o)
+{
+  while (1)
+    {
+      if (!gh_pair_p (expr))
+       return;
+  
+      SCM head =ly_car (expr);
+      if (unsmob_input (head))
+       {
+         Input * ip = unsmob_input (head);
+      
+         output_scheme (scm_list_n (ly_symbol2scm ("define-origin"),
+                                    scm_makfrom0str (ip->file_string ().to_str0 ()),
+                                    gh_int2scm (ip->line_number ()),
+                                    gh_int2scm (ip->column_number ()),
+                                    SCM_UNDEFINED));
+         expr = ly_cadr (expr);
+       }
+      else  if (head ==  ly_symbol2scm ("no-origin"))
+       {
+         output_scheme (scm_list_n (head, SCM_UNDEFINED));
+         expr = ly_cadr (expr);
+       }
+      else if (head == ly_symbol2scm ("translate-stencil"))
+       {
+         o += ly_scm2offset (ly_cadr (expr));
+         expr = ly_caddr (expr);
+       }
+      else if (head == ly_symbol2scm ("combine-stencil"))
+       {
+         output_expr (ly_cadr (expr), o);
+         expr = ly_caddr (expr);
+       }
+      else
+       {
+         output_scheme (scm_list_n (ly_symbol2scm ("placebox"),
+                                    gh_double2scm (o[X_AXIS]),
+                                    gh_double2scm (o[Y_AXIS]),
+                                    expr,
+                                    SCM_UNDEFINED));
+         return;
+       }
+    }
+}
+
index f392455a898d9eeff2a2a528b6b76a3c3fd75cf7..9202095e17aceae65fa377aa146431265b84c86f 100644 (file)
 #include "misc.hh"
 #include "all-font-metrics.hh"
 
+#include "stencil.hh"
+#include "paper-book.hh"
+#include "ly-module.hh"
+
 Paper_score::Paper_score ()
 {
-  paper_ =0;
-  outputter_ =0;
+  paper_ = 0;
+  outputter_ = 0;
   system_ = 0;
   main_smob_ = SCM_EOL;
+  lines_ = SCM_EOL;
+  book_title_ = 0;
+  score_title_ = 0;
 }
 
-void
-Paper_score::typeset_line (System *l)
+Paper_score::Paper_score (Paper_score const &s)
+  : Music_output (s)
 {
-  if (!system_)
-    {
-      system_ = l;             // ugh.
-    }
-
-  main_smob_ = gh_cons (l->self_scm (), main_smob_);
-  l->pscore_ = this;
-
-  scm_gc_unprotect_object (l->self_scm ());
+  assert (false);
 }
 
 
-Paper_score::Paper_score (Paper_score const &s)
-  : Music_output (s)
+void
+Paper_score::typeset_line (System *line)
 {
-  assert (false);
+  if (!system_)
+    /* ugh. */
+    system_ = line;
+
+  main_smob_ = gh_cons (line->self_scm (), main_smob_);
+  line->pscore_ = this;
+
+  scm_gc_unprotect_object (line->self_scm ());
 }
 
 Array<Column_x_positions>
@@ -66,9 +72,6 @@ Paper_score::calc_breaking ()
   return sol;
 }
 
-/*
-  urg. clean me
- */
 void
 Paper_score::process (String outname)
 {
@@ -77,52 +80,79 @@ Paper_score::process (String outname)
                             system_->element_count (),
                             system_->spanner_count ()));
 
-  
   progress_indication (_ ("Preprocessing graphical objects...") + " ");
 
-  /*
-    Check out why we need this - removing gives assertion failures
-    down the road.
-   */
-  { /* doubly, also done in Score_engraver */
-    Link_array<Grob> pc (system_->columns ());
-  
-    pc[0]->set_property ("breakable", SCM_BOOL_T);
-    pc.top ()->set_property ("breakable", SCM_BOOL_T);
-  }
-
+  /* FIXME: Check out why we need this - removing gives assertion failures
+     down the road.
+     
+     doubly, also done in Score_engraver */
+  Link_array<Grob> pc (system_->columns ());
+  pc[0]->set_property ("breakable", SCM_BOOL_T);
+  pc.top ()->set_property ("breakable", SCM_BOOL_T);
+    
   system_->pre_processing ();
  
   Array<Column_x_positions> breaking = calc_breaking ();
   system_->break_into_pieces (breaking);
-  
+  lines_ = system_->get_lines ();
+
+  // FIXME: ...
   outputter_ = paper_->get_paper_outputter (outname);
 
   progress_indication ("\n");
 
   SCM scopes = SCM_EOL;
-
   if (header_)
     scopes = scm_cons (header_, scopes);
   if (global_input_file->header_ && global_input_file->header_ != header_)
     scopes = scm_cons (global_input_file->header_, scopes);
   
   outputter_->output_metadata (scopes, paper_);
-  outputter_->output_music_output_def (paper_);
-  outputter_->output_scheme (scm_list_1 (ly_symbol2scm ("header-end")));
 
-  outputter_
-    ->output_scheme (scm_list_2 (ly_symbol2scm ("define-fonts"),
-                                ly_quote_scm (paper_->font_descriptions ())));
+#ifdef PAGE_LAYOUT
+  SCM make_title = scm_primitive_eval (ly_symbol2scm ("make-title"));
+  SCM b = ly_modules_lookup (scopes, ly_symbol2scm ("bookTitle"));
+  if (b != SCM_UNDEFINED && scm_variable_bound_p (b) == SCM_BOOL_T)
+    book_title_
+      = unsmob_stencil (gh_call2 (make_title, paper_->self_scm (),
+                                 scm_variable_ref (b)));
+  
+  SCM s = ly_modules_lookup (scopes, ly_symbol2scm ("scoreTitle"));
+  if (s != SCM_UNDEFINED && scm_variable_bound_p (s) == SCM_BOOL_T)
+    score_title_
+      = unsmob_stencil (gh_call2 (make_title, paper_->self_scm (),
+                                 scm_variable_ref (s)));
+  
+#if 0
+  // FIXME: 
+  delete system_;
+  system_ = 0;
+#endif
+  
+  /* Ugh: caller (Score) should do this, but does not know our flavor
+     (paper or midi).  */
+  paper_book->paper_scores_.push (this);
+#else
+  output ();
+#endif  
+}
 
-  outputter_->output_scheme (scm_list_2 (ly_symbol2scm ("make-title"),
-                                        ly_quote_scm (outputter_->file_)));
-  system_->output_lines ();
+void
+Paper_score::output ()
+{
+  outputter_->output_header (paper_);
+  
+  int line_count = SCM_VECTOR_LENGTH ((SCM) lines_);
+  for (int i = 0; i < line_count; i++)
+    outputter_->output_line (scm_vector_ref (lines_, scm_int2num (i)),
+                            i == line_count - 1);
+  
   outputter_->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
-
   progress_indication ("\n");
 
+#if 0  
   // huh?
   delete outputter_;
   outputter_ = 0;
+#endif  
 }
index d1b40819d9e75fedae04c90e456d6eb6802cdaa9..3723bf4347c6a687bb9d605184e3b81926820854 100644 (file)
@@ -74,12 +74,13 @@ TODO:
 #include "input.hh"
 #include "lilypond-input-version.hh"
 #include "scm-hash.hh"
-#include "ly-modules.hh"
+#include "ly-module.hh"
 #include "music-sequence.hh"
 #include "input-smob.hh"
 #include "event.hh"
 #include "text-item.hh"
 #include "music-list.hh"
+#include "paper-book.hh"
 
 #define MY_MAKE_MUSIC(x)  make_music_by_name (ly_symbol2scm (x))
 
@@ -455,7 +456,9 @@ toplevel_expression:
                                                
                   scm_gc_unprotect_object (id->self_scm ());
                }
+#ifndef PAGE_LAYOUT
                scm_gc_unprotect_object (sc->self_scm ());
+#endif
        }
        | output_def {
                SCM id = SCM_EOL;
index 4350d8854a0bc531b0cd9ab58ca054dcf7a078b4..0f3c924df13da985fffc0e4f1ea670147ce4ff27 100644 (file)
@@ -21,8 +21,9 @@
 #include "cpu-timer.hh"
 #include "main.hh"
 #include "paper-def.hh"
-#include "ly-modules.hh"
+#include "ly-module.hh"
 
+#include "paper-book.hh"
 
 
 /*
@@ -88,7 +89,7 @@ Score::Score (Score const &s)
   music_ =  m?m->clone ()->self_scm () : SCM_EOL;
   scm_gc_unprotect_object (music_);
   
-  for (int i=0; i < s.defs_.size (); i++)
+  for (int i = 0; i < s.defs_.size (); i++)
     defs_.push (s.defs_[i]->clone ());
 
   header_ = ly_make_anonymous_module ();
@@ -96,17 +97,15 @@ Score::Score (Score const &s)
     ly_copy_module_variables (header_, s.header_);
 }
 
-
-
 LY_DEFINE (ly_run_translator, "ly:run-translator", 
-         2, 0, 0,
-         (SCM mus, SCM output_def),
-         "Process @var{mus} according to @var{output_def}. A interpretation "
-"context is set up, and @var{mus} is interpreted with it. The  "
-"context is returned in its final state." )
+         2, 0, 0, (SCM mus, SCM output_def),
+          "Process @var{mus} according to @var{output_def}. "
+          "An interpretation context is set up, "
+          "and @var{mus} is interpreted with it.  "
+          "The context is returned in its final state.")
 {
   Music_output_def *odef = unsmob_music_output_def (output_def);
-  Music * music = unsmob_music (mus);
+  Music *music = unsmob_music (mus);
 
   SCM_ASSERT_TYPE (music, mus, SCM_ARG1, __FUNCTION__, "Music");
   SCM_ASSERT_TYPE (odef, output_def, SCM_ARG2, __FUNCTION__, "Output definition");
@@ -123,7 +122,7 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
   progress_indication (_ ("Interpreting music..."));
   
   trans->final_mom_ = music->get_length ();
-  SCM protected_iter =  Music_iterator::get_static_get_iterator (music);
+  SCM protected_iter = Music_iterator::get_static_get_iterator (music);
   Music_iterator * iter = unsmob_iterator (protected_iter);
   iter->init_translator (music, trans);
 
@@ -149,31 +148,27 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
 
 
 LY_DEFINE (ly_render_output, "ly:render-output",
-         3,0,0,
-         (SCM context, SCM header, SCM out_filename),
-         "Given a Score context in its final state, calculate the output, "
-         "and  dump the result to @var{out-filename}, using "
-         "@var{header} for the bibliographic information.")
+          3, 0, 0, (SCM context, SCM header, SCM out_filename),
+          "Given a Score context in its final state, calculate the output, "
+          "and  dump the result to @var{out-filename}, using "
+          "@var{header} for the bibliographic information.")
 {
   Global_context * gt = dynamic_cast<Global_context *> (unsmob_context (context));
   
-  SCM_ASSERT_TYPE (gt, context, SCM_ARG1, __FUNCTION__,
-                 "Global context");
-  SCM_ASSERT_TYPE (ly_module_p (header), header, SCM_ARG2, __FUNCTION__,
-                 "module");
-  SCM_ASSERT_TYPE (gh_string_p (out_filename), out_filename, SCM_ARG3, __FUNCTION__,
-                 "output filename");
-
-  Music_output * output = gt->get_output ();
+  SCM_ASSERT_TYPE (gt, context, SCM_ARG1, __FUNCTION__, "Global context");
+  SCM_ASSERT_TYPE (ly_module_p (header), header, SCM_ARG2, __FUNCTION__, "module");
+  SCM_ASSERT_TYPE (gh_string_p (out_filename), out_filename, SCM_ARG3, __FUNCTION__, "output filename");
 
+  Music_output *output = gt->get_output ();
   output->header_ = header;
-  
   progress_indication ("\n");
   output->process (ly_scm2string (out_filename));
-  
-  delete output ;
 
-  return SCM_UNDEFINED ;
+#ifndef PAGE_LAYOUT
+  delete output;
+#endif
+
+  return SCM_UNDEFINED;
 }
 
 void
@@ -184,4 +179,3 @@ default_rendering (SCM mus, SCM outdef, SCM head, SCM outname)
   if (unsmob_context (context))
     ly_render_output (context,  head, outname);
 }
-
index 61ab2ebbecd69b90bbe3dbc9b6d40b95701bf072..2c221eefbf1e03784fc4c66893c953be3ae5c19f 100644 (file)
@@ -6,7 +6,6 @@
   (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "input-smob.hh"
 #include "axis-group-interface.hh"
 #include "warn.hh"
 #include "system.hh"
 #include "paper-score.hh"
 #include "string.hh"
 #include "warn.hh"
-#include "dimensions.hh"
 #include "stencil.hh"
 #include "all-font-metrics.hh"
 #include "spacing-interface.hh"
 #include "staff-symbol-referencer.hh"
-
-// todo: use map.
-void
-fixup_refpoints (SCM s)
-{
-  for (; gh_pair_p (s); s = ly_cdr (s))
-    {
-      Grob::fixup_refpoint (ly_car (s));
-    }
-}
-
+#include "paper-book.hh"
 
 System::System (SCM s)
   : Spanner (s)
@@ -118,13 +106,22 @@ System::typeset_grob (Grob * elem)
   scm_gc_unprotect_object (elem->self_scm ());
 }
 
-void
-System::output_lines ()
+// todo: use map.
+static void
+fixup_refpoints (SCM s)
 {
-  for (SCM s = get_property ("all-elements");
-       gh_pair_p (s); s = ly_cdr (s))
+  for (; gh_pair_p (s); s = ly_cdr (s))
     {
-      Grob * g = unsmob_grob (ly_car (s));
+      Grob::fixup_refpoint (ly_car (s));
+    }
+}
+
+SCM
+System::get_lines ()
+{
+  for (SCM s = get_property ("all-elements"); gh_pair_p (s); s = ly_cdr (s))
+    {
+      Grob *g = unsmob_grob (ly_car (s));
       if (g->internal_has_interface (ly_symbol2scm ("only-prebreak-interface")))
        {
          /*
@@ -151,9 +148,7 @@ System::output_lines ()
       Grob *se = broken_intos_[i];
       SCM all = se->get_property ("all-elements");
       for (SCM s = all; gh_pair_p (s); s = ly_cdr (s))
-       {
-         fixup_refpoint (ly_car (s));
-       }
+       fixup_refpoint (ly_car (s));
       count += scm_ilength (all);
     }
   
@@ -162,42 +157,41 @@ System::output_lines ()
    */
   fixup_refpoints (get_property ("all-elements"));
 
-  
-  for (SCM s = get_property ("all-elements");
-       gh_pair_p (s); s = ly_cdr (s))
-    {
-      unsmob_grob (ly_car (s))->handle_broken_dependencies ();
-    }
+  for (SCM s = get_property ("all-elements"); gh_pair_p (s); s = ly_cdr (s))
+    unsmob_grob (ly_car (s))->handle_broken_dependencies ();
   handle_broken_dependencies ();
 
-  /*
-    Because the this->get_property (all-elements) contains items
-    in 3 versions, handle_broken_dependencies () will leave duplicated
-    items in all-elements. Strictly speaking this is harmless, but it
-    leads to duplicated symbols in the output. uniquify_list () makes
-    sure that no duplicates are in the list.
-   */
-  for (int i=0; i < broken_intos_.size (); i++)
+#if 0  /* don't do this: strange side effects.  */
+  
+  /* Because the this->get_property (all-elements) contains items in 3
+     versions, handle_broken_dependencies () will leave duplicated
+     items in all-elements.  Strictly speaking this is harmless, but
+     it leads to duplicated symbols in the output.  uniquify_list ()
+     makes sure that no duplicates are in the list.  */
+  for (int i = 0; i < line_count; i++)
     {
-      /*
-       don't do this: strange side effects.
-       */
-      //    SCM al = broken_intos_[i]->get_property ("all-elements");
-      //      al  = uniquify_list (al); 
+      SCM all = broken_intos_[i]->get_property ("all-elements");
+      all = uniquify_list (all); 
     }
+#endif
   
   if (verbose_global_b)
     progress_indication (_f ("Element count %d.",  count + element_count ()));
 
+  int line_count = broken_intos_.size ();
+  SCM lines = scm_c_make_vector (line_count, SCM_UNDEFINED);
   
-  for (int i=0; i < broken_intos_.size (); i++)
+   for (int i = 0; i < line_count; i++)
     {
       System *system = dynamic_cast<System*> (broken_intos_[i]);
 
       if (verbose_global_b)
        progress_indication ("[");
-      bool last = i+1 == broken_intos_.size ();
-      system->post_processing (last);
+      
+      // bool last = (i + 1 == line_count);
+
+      system->post_processing ();
+      scm_vector_set_x (lines, scm_int2num (i), system->get_line ());
 
       if (verbose_global_b)
        {
@@ -205,7 +199,8 @@ System::output_lines ()
          progress_indication ("]");
        }
 
-      if (i < broken_intos_.size () - 1)
+#ifndef PAGE_LAYOUT
+      if (i < line_count - 1)
        {
          SCM lastcol =  ly_car (system->get_property ("columns"));
          Grob*  e = unsmob_grob (lastcol);
@@ -219,7 +214,9 @@ System::output_lines ()
                                             inter, SCM_UNDEFINED));          
            }
        }
+#endif                 
     }
+   return lines;
 }
 
 
@@ -335,61 +332,6 @@ System::break_into_pieces (Array<Column_x_positions> const &breaking)
     }
 }
 
-void
-System::output_stencil (SCM expr, Offset o)
-{
-  while (1)
-    {
-      if (!gh_pair_p (expr))
-       return;
-  
-      SCM head =ly_car (expr);
-      if (unsmob_input (head))
-       {
-         Input * ip = unsmob_input (head);
-      
-         pscore_->outputter_->output_scheme (scm_list_n (ly_symbol2scm ("define-origin"),
-                                                          scm_makfrom0str (ip->file_string ().to_str0 ()),
-                                                          gh_int2scm (ip->line_number ()),
-                                                          gh_int2scm (ip->column_number ()),
-                                                          SCM_UNDEFINED));
-         expr = ly_cadr (expr);
-       }
-      else  if (head ==  ly_symbol2scm ("no-origin"))
-       {
-         pscore_->outputter_->output_scheme (scm_list_n (head, SCM_UNDEFINED));
-         expr = ly_cadr (expr);
-       }
-      else if (head == ly_symbol2scm ("translate-stencil"))
-       {
-         o += ly_scm2offset (ly_cadr (expr));
-         expr = ly_caddr (expr);
-       }
-      else if (head == ly_symbol2scm ("combine-stencil"))
-       {
-         output_stencil (ly_cadr (expr), o);
-         expr = ly_caddr (expr);
-       }
-      else
-       {
-         pscore_->outputter_->
-           output_scheme (scm_list_n (ly_symbol2scm ("placebox"),
-                                   gh_double2scm (o[X_AXIS]),
-                                   gh_double2scm (o[Y_AXIS]),
-                                   expr,
-                                   SCM_UNDEFINED));
-
-         return;
-       }
-    }
-}
-
-void
-System::output_scheme (SCM s)
-{
-  pscore_->outputter_->output_scheme (s);
-}
-
 void
 System::add_column (Paper_column*p)
 {
@@ -435,123 +377,77 @@ System::pre_processing ()
     }
 }
 
-
-  const int LAYER_COUNT= 3;
-
-
-
 void
-System::post_processing (bool last_line)
+System::post_processing ()
 {
-  for (SCM s = get_property ("all-elements");
-       gh_pair_p (s); s = ly_cdr (s))
+  for (SCM s = get_property ("all-elements"); gh_pair_p (s); s = ly_cdr (s))
     {
-      Grob* sc = unsmob_grob (ly_car (s));
-      sc->calculate_dependencies (POSTCALCED, POSTCALCING,
-                                 ly_symbol2scm ("after-line-breaking-callback"));
+      Grob *g = unsmob_grob (ly_car (s));
+      g->calculate_dependencies (POSTCALCED, POSTCALCING,
+          ly_symbol2scm ("after-line-breaking-callback"));
     }
 
-  Interval i (extent (this, Y_AXIS));
-  if (i.is_empty ())
-    programming_error ("Huh?  Empty System?");
+  Interval iv (extent (this, Y_AXIS));
+  if (iv.is_empty ())
+    programming_error ("System with zero extent.");
   else
-    translate_axis (- i[MAX], Y_AXIS);
+    translate_axis (-iv[MAX], Y_AXIS);
 
-  Real height = i.length ();
-  if (height > 50 CM)
-    {
-      programming_error ("Improbable system height");
-      height = 50 CM;
-    }
-
-  /*
-    generate all stencils  to trigger all font loads.
-  */
+  /* Generate all stencils to trigger font loads.
+     This might seem inefficient, but Stencils are cached per grob
+     anyway. */
   SCM all = get_property ("all-elements")  ;
   all = uniquify_list (all);
 
-  /*
-    trigger font loads first.
-
-    This might seem inefficient, but Stencils are cached per grob
-    anyway.
-    */
   this->get_stencil ();
   for (SCM s = all; gh_pair_p (s); s = ly_cdr (s))
     {
-      Grob * g = unsmob_grob (ly_car (s));
+      Grob *g = unsmob_grob (ly_car (s));
       g->get_stencil ();
     }
-  
-  /*
-    font defs;
-   */
-  SCM font_names = ly_quote_scm (get_paper ()->font_descriptions ());  
-  output_scheme (scm_list_n (ly_symbol2scm ("define-fonts"),
-                            font_names,
-                            SCM_UNDEFINED));
+}
 
-  /*
-    line preamble.
-   */
-  Interval j (extent (this, X_AXIS));
-  Real length = j[RIGHT];
-    
-  output_scheme (scm_list_n (ly_symbol2scm ("start-system"),
-                         gh_double2scm (length),
-                         gh_double2scm (height),
-                         SCM_UNDEFINED));
-  
-  /* Output elements in three layers, 0, 1, 2.
-     The default layer is 1. */
-  {
-    Stencil *m = this->get_stencil ();
-    if (m)
-      output_stencil (m->get_expr (), Offset (0,0));
-  }
-  
-  for (int i = 0; i < 3; i++)
-    for (SCM s = get_property ("all-elements"); gh_pair_p (s);
-        s = ly_cdr (s))
+/* Return line:
+   ((HEIGHT . WIDTH) LINE)
+   LINE: list of ((OFFSET-X . OFFSET-Y) . STENCIL)
+   Maybe make clas/smob?  */
+SCM
+System::get_line ()
+{  
+  static int const LAYER_COUNT = 3;
+  SCM line = SCM_EOL;
+  if (Stencil *me = get_stencil ())
+    line = scm_cons (scm_cons (ly_offset2scm (Offset (0, 0)),
+                              me->smobbed_copy ()), line);
+
+  /* Output stencils in three layers: 0, 1, 2.  The default layer is
+     1.  */
+  for (int i = 0; i < LAYER_COUNT; i++)
+    for (SCM s = get_property ("all-elements"); gh_pair_p (s); s = ly_cdr (s))
       {
-       Grob *sc = unsmob_grob (ly_car (s));
-       Stencil *m = sc->get_stencil ();
-       if (!m)
-         continue;
-       
-       SCM s = sc->get_property ("layer");
-       int layer = gh_number_p (s) ? gh_scm2int (s) : 1;
-       if (layer != i)
+       Grob *g = unsmob_grob (ly_car (s));
+       Stencil *stil = g->get_stencil ();
+
+       /* Skip empty stencils and grobs that are not in this layer.  */
+       if (!stil
+           || robust_scm2int (g->get_property ("layer"), 1) != i)
          continue;
        
-       Offset o (sc->relative_coordinate (this, X_AXIS),
-                 sc->relative_coordinate (this, Y_AXIS));
+       Offset o (g->relative_coordinate (this, X_AXIS),
+                 g->relative_coordinate (this, Y_AXIS));
        
-       SCM e = sc->get_property ("extra-offset");
-       if (gh_pair_p (e))
-         {
-           Offset z = ly_scm2offset (e);
-           z *= Staff_symbol_referencer::staff_space (sc);
-           
-           o += z;
-         }
-       
-       output_stencil (m->get_expr (), o);
+       Offset extra = robust_scm2offset (g->get_property ("extra-offset"),
+                                         Offset (0, 0))
+         * Staff_symbol_referencer::staff_space (g);
+       line = scm_cons (scm_cons (ly_offset2scm (o + extra),
+                                  stil->smobbed_copy ()), line);
       }
 
-  
-  
-  if (last_line)
-    {
-      output_scheme (scm_list_n (ly_symbol2scm ("stop-last-system"), SCM_UNDEFINED));
-    }
-  else
-    {
-      output_scheme (scm_list_n (ly_symbol2scm ("stop-system"), SCM_UNDEFINED));
-    }
+  Interval x (extent (this, X_AXIS));
+  Interval y (extent (this, Y_AXIS));
+  return scm_cons (ly_offset2scm (Offset (x.length (), y.length ())), line);
 }
 
-
 Link_array<Item> 
 System::broken_col_range (Item const*l, Item const*r) const
 {
@@ -605,12 +501,8 @@ System::columns ()const
     }
   return acs;
 }
-  
-
-
 
 ADD_INTERFACE (System,"system-interface",
               "This is the toplevel object: each object in a score "
-              "ultimately has a System object as its X and Y parent. "
-              ,
-              "between-system-string all-elements columns");
+              "ultimately has a System object as its X and Y parent. ",
+              "between-system-string all-elements columns")
index 161e8932fdec2c88f8869d8984a1b24c46bd89b4..c2a0430bc51f694b311467444a6c877b0a7402fc 100644 (file)
@@ -388,13 +388,22 @@ L1 is copied, L2 not.
    ))
 
 (define-public (find-dumper format )
-  (let*
-      ((d (assoc format output-alist)))
+  (let* ((d (assoc format output-alist)))
     
     (if (pair? d)
        (caddr d)
-       (scm-error "Could not find dumper for format ~s" format))
-    ))
+       (scm-error "Could not find dumper for format ~s" format))))
+
+
+(define-public (make-title paper markup)
+  (if (markup? markup)
+      (let ((BASELINE-SKIP 2)
+            (props (list (append `((linewidth . ,(ly:paper-get-number
+                                                 paper 'linewidth))
+                                   (font-family . roman))
+                                 (ly:paper-lookup paper 'font-defaults)))))
+       (stack-lines DOWN 0 BASELINE-SKIP
+                    (list (interpret-markup paper props markup))))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; other files.
index 6be76dbeced637f6eafff4bc1bc09b722e6f7a2b..24b259d369f82e67bdb34f04bb9813bfa5f173c7 100644 (file)
 ;; alist containing fontname -> fontcommand assoc (both strings)
 (define font-name-alist '())
 
-;; WIP -- stencils from markup? values of output-scopes
-(define header-stencil #f)
-
-(define BASELINE-SKIP 3)
-
 ;; /lilypondpaperoutputscale 1.75729901757299 def
 ;;/lily-output-units 2.83464  def  %% milimeter
 ;;/output-scale lilypondpaperoutputscale lily-output-units mul def
        (string-append "/" key " {" val "} bind def\n")
        (string-append "/" key " (" val ") def\n"))))
 
-(define (make-title port)
-  (if header-stencil
-      (let ((x-ext (ly:stencil-get-extent header-stencil Y))
-           (y-ext (ly:stencil-get-extent header-stencil X)))
-       (display (start-system
-                 (/ (interval-length x-ext) OUTPUT-SCALE)
-                 (/ (interval-length y-ext) OUTPUT-SCALE))
-                port)
-       (output-stencil port (ly:stencil-get-expr header-stencil) '(0 . 0))
-       (display (stop-system) port)))
-  "")
-
 (define (no-origin) "")
 
 ;; FIXME: duplictates output-scopes, duplicated in other backends
 ;; FIXME: duplicated in other output backends
 ;; FIXME: silly interface name
 (define (output-scopes paper scopes fields basename)
-  (let* ((props (list (append
-                      `((linewidth . ,(ly:paper-get-number paper 'linewidth))
-                        (font-family . roman))
-                      (ly:paper-lookup paper 'font-defaults))))
-       (prefix "lilypond")
-       (stencils '()))
+  (let ((prefix "lilypond"))
 
     ;; FIXME: duplicates output-paper's scope-entry->string, mostly
     (define (scope-entry->string key var)
        (if (memq key fields)
            (header-to-file basename key val))
        (cond
-        ;; define strings, for /make-lilypond-title to pick up
         ((string? val) (ps-string-def prefix key val))
         ((number? val) (ps-number-def prefix key val))
-        ((markup? val) (set! stencils
-                             (append
-                              stencils
-                              (list
-                               (interpret-markup paper props val))))
-         "")
-        (else ""))))
+       (else ""))))
     
     (define (output-scope scope)
       (apply string-append (module-map scope-entry->string scope)))
 
-    (let ((s (string-append (apply string-append (map output-scope scopes)))))
-      (set! header-stencil (stack-lines DOWN 0 BASELINE-SKIP stencils))
-
-      ;; match systems, which are also aligned to center
-      (ly:stencil-align-to! header-stencil Y CENTER)
-      
-      ;; trigger font load
-      (ly:stencil-get-expr header-stencil)
-      s)))
+    (string-append (apply string-append (map output-scope scopes)))))
 
 ;; hmm, looks like recursing call is always last statement, does guile
 ;; think so too?
index 4698e8ee4108abce3490acea5594ca6dd9b5f392..0ef9f4727a2af36870ec2b521cb6d20f60253d59 100644 (file)
@@ -99,6 +99,7 @@
      (module-map
      (lambda (sym var)
        (let ((val (variable-ref var))
+            ;;(val (if (variable-bound? var) (variable-ref var) '""))
             (tex-key (symbol->string sym)))
         
         (if (memq sym fields)
 
 (define-public (tex-output-expression expr port)
   (display (eval expr this-module) port ))
-
-(define (make-title port) "")