]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/system.cc (get_line): Return Paper_line. Change all users.
authorJan Nieuwenhuizen <janneke@gnu.org>
Mon, 15 Mar 2004 21:33:58 +0000 (21:33 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 15 Mar 2004 21:33:58 +0000 (21:33 +0000)
* lily/include/paper-line.hh:
* lily/include/paper-line.cc: New file.

ChangeLog
lily/include/lily-proto.hh
lily/include/paper-line.hh [new file with mode: 0644]
lily/include/stencil.hh
lily/paper-book.cc
lily/paper-line.cc [new file with mode: 0644]
lily/paper-outputter.cc
lily/stencil.cc
lily/system.cc

index 5cc8eb100bc48fd76046118c4ac16b9b06b532c3..ed90e8fb304d51c39f4019467946e5f02db9c991 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-03-15  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * lily/system.cc (get_line): Return Paper_line.  Change all users.
+
+       * lily/include/paper-line.hh:
+       * lily/include/paper-line.cc: New file.
+
 2004-03-15  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
        * GNUmakefile.in: remove stray make out=www
index b537a981a99099be69cf288ef38ceaa59a61b5ab..7b1ce3da0571eb16ae4400c660d5ab4695e6b2e7 100644 (file)
@@ -110,6 +110,7 @@ class Output_property;
 class Paper_book;
 class Paper_column;
 class Paper_def;
+class Paper_line;
 class Paper_outputter;
 class Paper_score;
 class Paper_stream;
diff --git a/lily/include/paper-line.hh b/lily/include/paper-line.hh
new file mode 100644 (file)
index 0000000..6dd51fa
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+  paper-line.hh -- declare Paper_line
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+#ifndef PAPER_LINE_HH
+#define PAPER_LINE_HH
+
+#include "lily-proto.hh"
+#include "smobs.hh"
+#include "offset.hh"
+
+class Paper_line
+{
+  SCM stencils_;
+  Offset dim_;
+  bool is_title_;
+  DECLARE_SIMPLE_SMOBS (Paper_line,);
+  
+public:
+  Paper_line (Offset, SCM, bool = true);
+
+  Offset dim () const;
+  SCM smobbed_copy () const;
+  SCM stencils () const;
+  bool is_title () const;
+};
+
+DECLARE_UNSMOB (Paper_line, paper_line);
+
+#endif /* PAPER_LINE_HH */
index 234681b7a798258b7da343540cd96ba19a4364a1..8f10fd6ba3627e3055a2513848dd35da9515d20a 100644 (file)
@@ -71,13 +71,8 @@ public:
   
   Interval extent (Axis) const;
   Box extent_box () const;
-  /**
-     codify THIS into a Scheme expression.
-   */
-  SCM create_scheme () const;
   bool is_empty () const;
 
-
   static SCM ly_get_stencil_extent (SCM mol, SCM axis);
   static SCM ly_set_stencil_extent_x (SCM,SCM,SCM);
   static SCM ly_stencil_combined_at_edge (SCM,SCM,SCM,SCM,SCM);
index 09c6253b8d1bbdfc6f9c6c8dd4231728e83b089b..9810f2159984136850cd6a23a0826333c10913f2 100644 (file)
@@ -14,6 +14,7 @@
 #include "paper-book.hh"
 #include "paper-def.hh"
 #include "paper-outputter.hh"
+#include "paper-line.hh"
 #include "paper-score.hh"
 #include "stencil.hh"
 
@@ -21,23 +22,15 @@ static Real const MIN_COVERAGE = 0.66;
 static Real const MAX_CRAMP = 0.05;
 
 static SCM
-stencil2line (Stencil* stil)
+stencil2line (Stencil* stil, bool is_title = false)
 {
   static SCM z;
   if (!z)
     z = scm_permanent_object (ly_offset2scm (Offset (0, 0)));
   Offset dim = Offset (stil->extent (X_AXIS).length (),
                       stil->extent (Y_AXIS).length ());
-  return scm_cons (ly_offset2scm (dim),
-                  scm_list_1 (scm_cons (z, stil->smobbed_copy ())));
-}
-
-static SCM
-title2line (Stencil* stil)
-{
-  SCM s = stencil2line (stil);
-  /* whugh, add marker recognise titles.  */
-  return scm_cons (scm_cons (ly_symbol2scm ("title"), ly_car (s)), ly_cdr (s));
+  Paper_line pl (dim, stil->smobbed_copy (), is_title);
+  return pl.smobbed_copy ();
 }
 
 /* Simplistic page interface */
@@ -143,20 +136,13 @@ Page::output (Paper_outputter *out, bool is_last)
   for (SCM s = lines_; gh_pair_p (s); s = ly_cdr (s))
     {
       SCM line = ly_car (s);
-      SCM offset = ly_car (line);
-      if (ly_car (offset) == ly_symbol2scm ("title"))
-       line = scm_cons (ly_cdr (offset), ly_cdr (line));
       out->output_line (line, &o,
                        is_last && gh_pair_p (ly_cdr (s)) && !get_copyright ()
                        && !get_tagline () && !get_footer ());
-      if (gh_pair_p (ly_cdr (s)) && ly_car (offset) != ly_symbol2scm ("title"))
+      if (gh_pair_p (ly_cdr (s)) && unsmob_paper_line (line)->is_title ())
        o[Y_AXIS] += vfill; 
     }
 
-#if 0
-  if (get_copyright () || get_tagline () || get_footer ())
-    o[Y_AXIS] += foot_sep_;
-#else
   o[Y_AXIS] = vsize_ - bottom_margin_;
   if (get_copyright ())
     o[Y_AXIS] -= get_copyright ()->extent (Y_AXIS).length ();
@@ -164,7 +150,6 @@ Page::output (Paper_outputter *out, bool is_last)
     o[Y_AXIS] -= get_tagline ()->extent (Y_AXIS).length ();
   if (get_footer ())
     o[Y_AXIS] -= get_footer ()->extent (Y_AXIS).length ();
-#endif
 
   if (get_copyright ())
     out->output_line (stencil2line (get_copyright ()), &o,
@@ -290,8 +275,8 @@ Paper_book::init ()
       int line_count = SCM_VECTOR_LENGTH ((SCM) scores_[i]);
       for (int j = 0; j < line_count; j++)
        {
-         SCM line = scm_vector_ref ((SCM) scores_[i], scm_int2num (j));
-         height_ += ly_scm2offset (ly_car (line))[Y_AXIS];
+         SCM s = scm_vector_ref ((SCM) scores_[i], scm_int2num (j));
+         height_ += unsmob_paper_line (s)->dim ()[Y_AXIS];
        }
     }
 
@@ -409,7 +394,7 @@ Paper_book::fill_pages (Page *page, int page_count, Real fudge)
       for (int j = 0; j < line_count; j++)
        {
          SCM line = scm_vector_ref ((SCM) scores_[i], scm_int2num (j));
-         h += ly_scm2offset (ly_car (line))[Y_AXIS];
+         h += unsmob_paper_line (line)->dim ()[Y_AXIS];
          Real fill = (page->height_ - text_height) / text_height;
          // Real fill_h = (page->height_ + h - text_height) / text_height;
          Real fudged_fill = (page->height_ - (text_height + fudge))
@@ -429,7 +414,7 @@ Paper_book::fill_pages (Page *page, int page_count, Real fudge)
              text_height = page->text_height ();
            }
          if (j == 0 && title)
-           page->lines_ = ly_snoc (title2line (title), page->lines_);
+           page->lines_ = ly_snoc (stencil2line (title, true), page->lines_);
          page->lines_ = ly_snoc (line, page->lines_);
          page->line_count_++;
          page->height_ += h;
diff --git a/lily/paper-line.cc b/lily/paper-line.cc
new file mode 100644 (file)
index 0000000..e4da3cb
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+  paper-line.cc -- implement Paper_line
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "paper-line.hh"
+#include "ly-smobs.icc"
+
+Paper_line::Paper_line (Offset o, SCM stencils, bool is_title)
+{
+  dim_ = o;
+  stencils_ = stencils;
+  is_title_ = is_title;
+}
+
+Offset
+Paper_line::dim () const
+{
+  return dim_;
+}
+
+bool
+Paper_line::is_title () const
+{
+  return is_title_;
+}
+
+SCM
+Paper_line::stencils () const
+{
+  return stencils_;
+}
+
+SCM
+Paper_line::mark_smob (SCM s)
+{
+  Paper_line *line = (Paper_line*) ly_cdr (s);
+  return line->stencils_;
+}
+
+int
+Paper_line::print_smob (SCM, SCM port, scm_print_state*)
+{
+  scm_puts ("#<Paper_line ", port);
+  scm_puts (" >", port);
+  return 1;
+}
+
+SCM
+Paper_line::smobbed_copy () const
+{
+  Paper_line *line = new Paper_line (*this);
+  return line->smobbed_self ();
+}
+
+IMPLEMENT_SIMPLE_SMOBS (Paper_line);
+IMPLEMENT_TYPE_P (Paper_line, "ly:paper-line?");
+IMPLEMENT_DEFAULT_EQUAL_P (Paper_line);
index 0f88314df8c90aef8c00fa86f40289818a967381..7e5fc947c9f81e9e6060f14d00a9a8e887c48ef3 100644 (file)
@@ -25,6 +25,7 @@
 #include "input-file-results.hh"
 #include "ly-module.hh"
 #include "paper-book.hh"
+#include "paper-line.hh"
 #include "input-smob.hh"  // output_expr
 
 
@@ -164,7 +165,8 @@ Paper_outputter::output_header (Paper_def *paper, SCM scopes, int page_count)
 void
 Paper_outputter::output_line (SCM line, Offset *origin, bool is_last)
 {
-  Offset dim = ly_scm2offset (ly_car (line));
+  Paper_line *pl = unsmob_paper_line (line);
+  Offset dim = pl->dim ();
   if (dim[Y_AXIS] > 50 CM)
     {
       programming_error ("Improbable system height.");
@@ -184,19 +186,14 @@ Paper_outputter::output_line (SCM line, Offset *origin, bool is_last)
     }
 
   SCM between = SCM_EOL;
-  for (SCM s = ly_cdr (line); gh_pair_p (s); s = ly_cdr (s))
+  for (SCM s = pl->stencils (); gh_pair_p (s); s = ly_cdr (s))
     {
-      Stencil *stil = unsmob_stencil (ly_cdar (s));
-      SCM head = ly_caar (s);
-      
-      if (head == ly_symbol2scm ("between-system-string"))
-       {
-         between = stil->get_expr ();
-         continue;
-       }
-
+      Stencil *stil = unsmob_stencil (ly_car (s));
       if (stil)
-       output_expr (stil->get_expr (), ly_scm2offset (head));
+       output_expr (stil->get_expr (), stil->origin ());
+      /* Only if !PAGE_LAYOUT */
+      else if (ly_caar (s) == ly_symbol2scm ("between-system-string"))
+       between = ly_cdar (s);
     }
 
   if (is_last)
index 9acbc8dc0a03ecbacfc9bf5f97eba35d5468ef58..1a6f21e104071939c049219c50db32a98dc26574 100644 (file)
@@ -65,8 +65,8 @@ Stencil::translate (Offset o)
     }
 
   expr_ = scm_list_n (ly_symbol2scm ("translate-stencil"),
-                  ly_offset2scm (o),
-                  expr_, SCM_UNDEFINED);
+                     ly_offset2scm (o),
+                     expr_, SCM_UNDEFINED);
   if (!is_empty ())
     dim_.translate (o);
   origin_ += o;
index 36a2bac602c1b0131368c69b2c78878b1b775ec1..0434a75fcda25d21efa64f347d6243a53b45b7e4 100644 (file)
@@ -21,6 +21,7 @@
 #include "spacing-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "paper-book.hh"
+#include "paper-line.hh"
 
 System::System (SCM s)
   : Spanner (s)
@@ -384,22 +385,13 @@ System::post_processing ()
     }
 }
 
-/* Return line:
-   ((HEIGHT . WIDTH) . LINE)
-   LINE: list of ((OFFSET-X . OFFSET-Y) . STENCIL)
-
-   or (!PAGE_LAYOUT):
-     ('between-system-string . STENCIL)
-   
-   Maybe make clas/smob?  */
 SCM
 System::get_line ()
 {  
   static int const LAYER_COUNT = 3;
-  SCM line = SCM_EOL;
+  SCM stencils = SCM_EOL;
   if (Stencil *me = get_stencil ())
-    line = scm_cons (scm_cons (ly_offset2scm (Offset (0, 0)),
-                              me->smobbed_copy ()), line);
+    stencils = scm_cons (me->smobbed_copy (), stencils);
 
   /* Output stencils in three layers: 0, 1, 2.  The default layer is
      1.  */
@@ -413,15 +405,16 @@ System::get_line ()
        if (!stil
            || robust_scm2int (g->get_property ("layer"), 1) != i)
          continue;
-       
+
        Offset o (g->relative_coordinate (this, X_AXIS),
                  g->relative_coordinate (this, Y_AXIS));
-       
+
        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);
+       /* FIXME: 0.5 */
+       stil->translate ((o + extra) * 0.5);
+       stencils = scm_cons (stil->smobbed_copy (), stencils);
       }
 
   if (output_format_global != PAGE_LAYOUT)
@@ -432,15 +425,13 @@ System::get_line ()
       SCM between = ly_symbol2scm ("between-system-string");
       SCM inter = g->internal_get_property (between);
       if (gh_string_p (inter))
-       {
-         Stencil *stil = new Stencil (Box (), scm_list_2 (between, inter));
-         line = scm_cons (scm_cons (between, stil->smobbed_copy ()), line);
-       }
+       stencils = scm_cons (scm_cons (between, inter), stencils);
     }
 
   Interval x (extent (this, X_AXIS));
   Interval y (extent (this, Y_AXIS));
-  return scm_cons (ly_offset2scm (Offset (x.length (), y.length ())), line);
+  Paper_line pl (Offset (x.length (), y.length ()), stencils);
+  return pl.smobbed_copy ();
 }
 
 Link_array<Item> 
@@ -454,10 +445,10 @@ System::broken_col_range (Item const*l, Item const*r) const
 
   while (gh_pair_p (s) && ly_car (s) != r->self_scm ())
     s = ly_cdr (s);
-    
+
   if (gh_pair_p (s))
     s = ly_cdr (s);
-  
+
   while (gh_pair_p (s) && ly_car (s) != l->self_scm ())
     {
       Paper_column*c = dynamic_cast<Paper_column*> (unsmob_grob (ly_car (s)));