for different \score blocks separately.
(post-process-pages): put write-page-layout into paper block.
* lily/output-def.cc (get_parser): new file.
* lily/output-def-scheme.cc (LY_DEFINE): ly:output-def-parser, new
file.
* lily/include/output-def.hh (class Output_def): add parser_ member.
* input/regression/page-layout-twopass.ly (Module): new file.
* scm/lily.scm: remove cpp hack.
2006-01-25 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * scm/layout-page-layout.scm (write-page-breaks): record tweaks
+ for different \score blocks separately.
+ (post-process-pages): put write-page-layout into paper block.
+
+ * lily/output-def.cc (get_parser): new file.
+
+ * lily/output-def-scheme.cc (LY_DEFINE): ly:output-def-parser, new
+ file.
+
+ * lily/include/output-def.hh (class Output_def): add parser_ member.
+
+ * input/regression/page-layout-twopass.ly (Module): new file.
+
+ * scm/lily.scm: remove cpp hack.
+
* lily/lyric-engraver.cc (get_voice_to_lyrics): use NPOS everywhere.
2006-01-25 Jan Nieuwenhuizen <janneke@gnu.org>
* flower/interval.cc:
* flower/include/interval.hh:
-
+
* flower/string-convert.cc:
* flower/include/string-convert.hh: Use std::string [interface].
Update callers.
--- /dev/null
+blabla = {
+\break
+\pageBreak
+\spacingTweaks #'((system-Y-extent -11.050006 . 0.0)
+ (system-refpoint-Y-extent -4.0 . -4.0)
+ (system-index . 0)
+ (page-system-count . 3)
+ (page-printable-height . 148.438777952756)
+ (page-space-left . -47.1596563937008))
+
+
+\skip 1*2/1\grace { \skip 1*1/16 }
+\break
+\spacingTweaks #'((system-Y-extent -11.050006 . 0.347445669291338)
+ (system-refpoint-Y-extent -4.0 . -4.0)
+ (system-index . 1)
+ (page-system-count . 3)
+ (page-printable-height . 148.438777952756)
+ (page-space-left . -47.1596563937008))
+
+
+\skip 1*1/1
+\break
+\spacingTweaks #'((system-Y-extent -8.0 . 0.313302362204724)
+ (system-refpoint-Y-extent -4.0 . -4.0)
+ (system-index . 2)
+ (page-system-count . 3)
+ (page-printable-height . 148.438777952756)
+ (page-space-left . -47.1596563937008))
+
+
+}
\ No newline at end of file
scores_ = scm_cons (s, scores_);
}
+
/* Concatenate all score outputs into a Paper_book
*/
Paper_book *
if (!use_object_keys)
return 0;
+ return create_grob_key (name);
+}
+
+/*
+ We want to have a key for some objects anyway, so we can invent a
+ unique identifier for each (book,score) tuple.
+*/
+Object_key const *
+Context::create_grob_key (String name)
+{
int disambiguation_count = 0;
if (grob_counts_.find (name) != grob_counts_.end ())
disambiguation_count = grob_counts_[name];
"An interpretation context is set up,\n"
"and @var{mus} is interpreted with it. \n"
"The context is returned in its final state.\n"
-
- "\n\nOptionally, this routine takes an Object-key to\n"
+ "\n\n"
+ "Optionally, this routine takes an Object-key to\n"
"to uniquely identify the Score block containing it.\n")
{
Output_def *odef = unsmob_output_def (output_def);
Cpu_timer timer;
- Global_context *trans = new Global_context (odef, music->get_length (), unsmob_key (key));
+ Global_context *trans = new Global_context (odef, music->get_length (),
+ unsmob_key (key));
if (!trans)
{
programming_error ("no toplevel translator");
SCM protected_iter = Music_iterator::get_static_get_iterator (music);
Music_iterator *iter = unsmob_iterator (protected_iter);
iter->init_translator (music, trans);
-
iter->construct_children ();
if (!iter->ok ())
#include "output-def.hh"
#include "system.hh"
#include "font-interface.hh"
-
+#include "paper-score.hh"
LY_DEFINE (ly_grob_property_data, "ly:grob-property-data",
{
Grob *me = unsmob_grob (grob);
SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "Grob");
- return me->key ()->self_scm ();
+
+ return me->key () ? me->key ()->self_scm () : SCM_EOL;
}
LY_DEFINE (ly_grob_default_font, "ly:grob-default-font",
#include "warn.hh"
#include "pointer-group-interface.hh"
#include "misc.hh"
-#include "paper-score.hh"
#include "stencil.hh"
#include "warn.hh"
#include "system.hh"
#include "misc.hh"
#include "music.hh"
#include "item.hh"
-#include "paper-score.hh"
#include "ly-smobs.icc"
#include "output-def.hh"
-
-
-
-
Grob *
Grob::clone (int count) const
{
public:
Object_key const *key () const { return key_; }
+
+ Object_key const *create_grob_key (String);
Object_key const *get_grob_key (String);
Object_key const *get_context_key (String, String);
class Ligature_bracket_engraver;
class Ligature_engraver;
class Lily_lexer;
+class Lily_parser;
class Lilypond_context_key;
class Lilypond_grob_key;
class Line_group_engraver_group;
virtual void derived_mark () const;
virtual int get_type () const;
virtual int do_compare (Object_key const *other) const;
- virtual SCM as_scheme () const;
public:
+ virtual SCM as_scheme () const;
static Object_key *from_scheme (SCM);
static Object_key *undump (SCM);
int compare (Object_key const *other) const;
*/
class Output_def
{
+
public:
VIRTUAL_COPY_CONSTRUCTOR (Output_def, Output_def);
DECLARE_SMOBS (Output_def, );
public:
SCM scope_;
- Output_def * parent_;
+ Output_def *parent_;
+
Input input_origin_;
String user_key_;
+ Lily_parser *parser_;
+ Lily_parser *get_parser () const;
+
Output_def (Output_def const&);
Output_def ();
-
+
/*
variables.
*/
System *system_;
SCM systems_;
SCM paper_systems_;
-
public:
Paper_score (Output_def *);
-
+
DECLARE_CLASSNAME(Paper_score);
Output_def *layout () const;
SCM music_;
public:
- String user_key_;
Link_array<Output_def> defs_;
+ String user_key_;
SCM header_;
bool error_found_;
Score ();
Score (Score const &);
+
SCM get_music () const;
+ void add_output_def (Output_def *def);
void set_music (SCM music);
SCM book_rendering (Output_def *, Output_def *, Object_key *);
};
Paper_score *pscore_; // ugh.
public:
+ Paper_score *paper_score () const;
int get_rank () const;
void post_processing ();
SCM get_paper_system ();
return scm_makfrom0str (p->output_basename_.c_str ());
}
+
Output_def *layout = unsmob_output_def (id);
layout = layout ? layout->clone () : new Output_def;
layout->set_variable (ly_symbol2scm ("is-layout"), SCM_BOOL_T);
-
+ layout->parser_ = parser;
+
return layout;
}
Output_def *layout = unsmob_output_def (id);
layout = layout ? layout->clone () : new Output_def;
layout->set_variable (ly_symbol2scm ("is-midi"), SCM_BOOL_T);
+ layout->parser_ = parser;
return layout;
}
layout = layout ? dynamic_cast<Output_def *> (layout->clone ()) : new Output_def;
layout->set_variable (ly_symbol2scm ("is-paper"), SCM_BOOL_T);
+ layout->parser_ = parser;
return layout;
}
void
Lilypond_grob_key::derived_mark () const
{
- scm_gc_mark (context_->self_scm ());
+ if (context_)
+ scm_gc_mark (context_->self_scm ());
}
// todo: reverse order of comparison for efficiency reasons.
if (Object_key const *sub_key = unsmob_key (scm_car (s)))
scm_set_car_x (s, dump_key (sub_key));
else if (Moment *mom = unsmob_moment (scm_car (s)))
- {
- scm_set_car_x (s,
- scm_list_2 (ly_symbol2scm ("unquote"),
- mom->as_scheme ()));
- }
+ scm_set_car_x (s,
+ scm_list_2 (ly_symbol2scm ("unquote"),
+ mom->as_scheme ()));
}
file_contents_ = scm_cons (scm_list_3 (ly_symbol2scm ("define-key"),
SCM
Copied_key::as_scheme () const
{
- return scm_list_2 (original_ ? original_->self_scm () : SCM_BOOL_F, scm_from_int (copy_count_));
+ return scm_list_2 (original_
+ ? original_->self_scm ()
+ : SCM_BOOL_F, scm_from_int (copy_count_));
}
Object_key *
return new Copied_key (unsmob_key (scm_car (a)),
scm_to_int (scm_list_ref (a, scm_from_int (1))));
}
+
#include "output-def.hh"
#include "ly-module.hh"
#include "context-def.hh"
+#include "lily-parser.hh"
LY_DEFINE (ly_layout_lookup, "ly:output-def-lookup",
2, 1, 0, (SCM pap, SCM sym, SCM def),
Output_def *id = unsmob_output_def (output_def);
SCM al = ly_module2alist (id->scope_);
-
SCM ell = SCM_EOL;
for (SCM s = al; scm_is_pair (s); s = scm_cdr (s))
{
return scm_from_double (output_scale (b));
}
+/*
+ Cannot put in scope, but need a separate function, since we don't
+ want to allow this in --safe.
+ */
+LY_DEFINE (ly_output_def_parser, "ly:output-def-parser",
+ 1, 0, 0, (SCM odef),
+ "Return the parser where @var{odef} is coming from.")
+{
+ Output_def *b = unsmob_output_def (odef);
+ SCM_ASSERT_TYPE (b, odef, SCM_ARG1, __FUNCTION__, "paper");
+
+ return b->get_parser()->self_scm ();
+}
+
+
LY_DEFINE (ly_make_output_def, "ly:make-output-def",
0, 0, 0, (),
"Make a output def.")
Output_def::Output_def ()
{
scope_ = SCM_EOL;
+ parser_ = 0;
parent_ = 0;
- smobify_self ();
+ smobify_self ();
+
scope_ = ly_make_anonymous_module (false);
}
{
scope_ = SCM_EOL;
parent_ = 0;
+ parser_ = s.parser_;
smobify_self ();
input_origin_ = s.input_origin_;
IMPLEMENT_SMOBS (Output_def);
IMPLEMENT_DEFAULT_EQUAL_P (Output_def);
+Lily_parser *
+Output_def::get_parser () const
+{
+ return parent_ ? parent_->get_parser () : parser_;
+}
+
SCM
Output_def::mark_smob (SCM m)
{
#include <cmath>
#include <ctime>
+
using namespace std;
#include "dimensions.hh"
*/
#include "paper-score.hh"
-
+#include "book.hh"
#include "all-font-metrics.hh"
#include "gourlay-breaking.hh"
#include "main.hh"
}
else
{
- $$->defs_.push ($2);
+ $$->add_output_def ($2);
}
$2->unprotect ();
}
Object_key const *sys_key = context ()->get_grob_key ("System");
pscore_->typeset_system (new System (props, sys_key));
+
system_ = pscore_->root_system ();
context ()->set_property ("rootSystem", system_->self_scm ());
#include "score.hh"
#include <cstdio>
+
using namespace std;
#include "book.hh"
#include "paper-book.hh"
#include "paper-score.hh"
#include "warn.hh"
-
#include "music.hh"
+
#include "ly-smobs.icc"
Score::Score ()
}
SCM context = ly_run_translator (music, scaled_def, key);
-
+
SCM output_as_scm = ly_format_output (context);
Music_output *output = unsmob_music_output (output_as_scm);
{
return music_;
}
+
+void
+Score::add_output_def (Output_def *def)
+{
+ defs_.push (def);
+}
scm_cons (ly_symbol2scm ("combine-stencil"),
exprs));
-
-
Grob *left_bound = this->get_bound (LEFT);
SCM prop_init = left_bound->get_property ("line-break-system-details");
Prob *pl = make_paper_system (prop_init);
return columns;
}
+Paper_score*
+System::paper_score () const
+{
+ return pscore_;
+}
+
int
System::get_rank () const
{
return dynamic_cast<System*> (system_grob);
}
+
+
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. ",
(postprocess-output book framework-ps-module
(format "~a.preview.eps" basename)
(cons "png" (ly:output-formats)))))
+
(if #f
(define-public (output-preview-framework basename book scopes fields)
(scm page)
)
+
(define (write-page-breaks pages)
"Dump page breaks"
-
- (define tweaks '())
+ (define tweaks (make-hash-table 23))
+
+ (define (record what property-pairs)
+ (let*
+ ((key (ly:output-def-lookup (ly:grob-layout what)
+ 'tweak-key
+ "tweaks"
+ ))
+ (when (ly:grob-property what 'when))
+ )
+
+ (if (not (hash-ref tweaks key))
+ (hash-set! tweaks key '()))
+
+ (hash-set! tweaks key
+ (acons when property-pairs
+ (hash-ref tweaks key)))
+
+ ))
- (define (record when property-pairs)
- (set! tweaks
- (acons when property-pairs
- tweaks)))
(define (graceless-moment mom)
(ly:make-moment
(ly:moment-main-numerator mom)
(ly:moment-main-denominator mom)
0 0))
-
+
(define (moment->skip mom)
(let*
((main (if (> (ly:moment-main-numerator mom) 0)
(format out-port "~a\n~a\n" skip base)
(dump-tweaks out-port (cdr tweak-list) (graceless-moment now))
)))
-
+
+ (define (dump-all-tweaks)
+ (let*
+ ((paper (ly:paper-book-paper (page-property (car pages) 'paper-book)))
+ (parser (ly:output-def-parser paper))
+ (name (format "~a-page-layout.ly"
+ (ly:parser-output-name parser)))
+ (out-port (open-output-file name)))
+
+ (ly:progress "Writing page layout to ~a" name)
+ (hash-for-each
+ (lambda (key val)
+ (format out-port "~a = {" key)
+ (dump-tweaks out-port (reverse val) (ly:make-moment 0 1))
+ (display "}" out-port))
+ tweaks)
+ ))
+
(define (handle-page page)
(define index 0)
(define (handle-system sys)
(set! props (cons '(page-break . #t)
props)))
(if (not (ly:prob-property? sys 'is-title))
- (record (ly:grob-property (ly:spanner-bound (ly:prob-property sys 'system-grob) LEFT) 'when)
- props))
+ (record (ly:spanner-bound (ly:prob-property sys 'system-grob) LEFT)
+ props))
(set! index (1+ index))
))
(for-each handle-page pages)
-
- (let*
- ((out-port (open-output-file "breaks.ly")))
-
- (display "{" out-port)
- (dump-tweaks out-port (reverse tweaks) (ly:make-moment 0 1))
- (display "}" out-port)
- ))
+ (dump-all-tweaks))
(define (post-process-pages layout pages)
- (if (ly:get-option 'write-page-layout)
+ (if (ly:output-def-lookup layout 'write-page-layout)
(write-page-breaks pages)))
(verbose ,(ly:command-line-verbose?) "value for the --verbose flag")
(ttf-verbosity 0
"how much verbosity for TTF font embedding?")
- (write-page-layout #f
- "dump page layout settings.")
(debug-gc #f
- "dump GC protection info"))))
+ "dump GC protection info"))
+ ))
;; FIXME: stray statement
(define-scheme-options)
-;; cpp hack to get useful error message
-(define ifdef "First run this through cpp.")
-(define ifndef "First run this through cpp.")
;; gettext wrapper for guile < 1.7.2
(if (defined? 'gettext)