+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
class Paper_book;
class Paper_column;
class Paper_def;
+class Paper_line;
class Paper_outputter;
class Paper_score;
class Paper_stream;
--- /dev/null
+/*
+ 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 */
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);
#include "paper-book.hh"
#include "paper-def.hh"
#include "paper-outputter.hh"
+#include "paper-line.hh"
#include "paper-score.hh"
#include "stencil.hh"
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 */
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 ();
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,
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];
}
}
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))
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;
--- /dev/null
+/*
+ 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);
#include "input-file-results.hh"
#include "ly-module.hh"
#include "paper-book.hh"
+#include "paper-line.hh"
#include "input-smob.hh" // output_expr
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.");
}
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)
}
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;
#include "spacing-interface.hh"
#include "staff-symbol-referencer.hh"
#include "paper-book.hh"
+#include "paper-line.hh"
System::System (SCM s)
: Spanner (s)
}
}
-/* 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. */
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)
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>
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)));