From: Jan Nieuwenhuizen Date: Mon, 15 Mar 2004 21:33:58 +0000 (+0000) Subject: * lily/system.cc (get_line): Return Paper_line. Change all users. X-Git-Tag: release/2.1.32~35 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=174a03a6569e73ee4962c184d2ff2e3a3a370496;p=lilypond.git * lily/system.cc (get_line): Return Paper_line. Change all users. * lily/include/paper-line.hh: * lily/include/paper-line.cc: New file. --- diff --git a/ChangeLog b/ChangeLog index 5cc8eb100b..ed90e8fb30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-03-15 Jan Nieuwenhuizen + + * 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 * GNUmakefile.in: remove stray make out=www diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index b537a981a9..7b1ce3da05 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -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 index 0000000000..6dd51fa630 --- /dev/null +++ b/lily/include/paper-line.hh @@ -0,0 +1,33 @@ +/* + paper-line.hh -- declare Paper_line + + source file of the GNU LilyPond music typesetter + + (c) 1997--2004 Han-Wen Nienhuys +*/ +#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 */ diff --git a/lily/include/stencil.hh b/lily/include/stencil.hh index 234681b7a7..8f10fd6ba3 100644 --- a/lily/include/stencil.hh +++ b/lily/include/stencil.hh @@ -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); diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 09c6253b8d..9810f21599 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -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 index 0000000000..e4da3cb548 --- /dev/null +++ b/lily/paper-line.cc @@ -0,0 +1,61 @@ +/* + paper-line.cc -- implement Paper_line + + source file of the GNU LilyPond music typesetter + + (c) 2004 Jan Nieuwenhuizen +*/ + +#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 ("#", 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); diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 0f88314df8..7e5fc947c9 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -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) diff --git a/lily/stencil.cc b/lily/stencil.cc index 9acbc8dc0a..1a6f21e104 100644 --- a/lily/stencil.cc +++ b/lily/stencil.cc @@ -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; diff --git a/lily/system.cc b/lily/system.cc index 36a2bac602..0434a75fcd 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -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 @@ -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 (unsmob_grob (ly_car (s)));