+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.
\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 {
>
}
%}
- makeTitle = \markup {
+ bookTitle = \markup {
\column <
%\fill-line #linewidth < \huge \bigger \bold \title >
\override #'(baseline-skip . 4) \column <
\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
}
}
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))
class My_lily_lexer;
class Note_performer;
class Output_property;
+class Paper_book;
class Paper_column;
class Paper_def;
class Paper_outputter;
class Transposed_music;
class Type_swallow_translator;
class yyFlexLexer;
-#endif // LILY_PROTO_HH;
+
+#endif /* LILY_PROTO_HH */
--- /dev/null
+/*
+ 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 */
+
+++ /dev/null
-/*
- 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 */
-
extern File_path global_path;
extern int score_count_global;
+extern Paper_book *paper_book;
+
#endif /* MAIN_HH */
--- /dev/null
+/*
+ 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 */
+
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 */
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 ();
/**
Link_array<Item> broken_col_range (Item const*,Item const*) const;
void typeset_line (System*);
-
+ void output ();
+
protected:
/* MAIN ROUTINES */
virtual void process (String);
{
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;
void add_column (Paper_column*);
void typeset_grob (Grob*);
- void output_stencil (SCM, Offset);
- void output_scheme (SCM);
void pre_processing ();
protected:
#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;
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));
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
}
-/*
-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__
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;
}
}
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
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
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)
{
#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
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 ();
#include "main.hh"
#include "file-path.hh"
#include "lily-guile.hh"
-#include "ly-modules.hh"
+#include "ly-module.hh"
#include "ly-smobs.icc"
#include "main.hh"
#include "input.hh"
#include "moment.hh"
-#include "ly-modules.hh"
+#include "ly-module.hh"
static Keyword_ent the_key_tab[]={
--- /dev/null
+/*
+ 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;
+}
#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
#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)
{
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"),
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)
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;
+ }
+ }
+}
+
#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>
return sol;
}
-/*
- urg. clean me
- */
void
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
}
#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))
scm_gc_unprotect_object (id->self_scm ());
}
+#ifndef PAGE_LAYOUT
scm_gc_unprotect_object (sc->self_scm ());
+#endif
}
| output_def {
SCM id = SCM_EOL;
#include "cpu-timer.hh"
#include "main.hh"
#include "paper-def.hh"
-#include "ly-modules.hh"
+#include "ly-module.hh"
+#include "paper-book.hh"
/*
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 ();
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");
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);
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
if (unsmob_context (context))
ly_render_output (context, head, outname);
}
-
(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)
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")))
{
/*
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);
}
*/
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)
{
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);
inter, SCM_UNDEFINED));
}
}
+#endif
}
+ return lines;
}
}
}
-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)
{
}
}
-
- 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
{
}
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")
))
(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.
;; 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?
(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) "")